Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 1 | import org.gradle.internal.os.OperatingSystem |
| 2 | |
| 3 | if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) { |
| 4 | |
| 5 | description = "NetworkTables Viewer" |
| 6 | |
| 7 | apply plugin: 'cpp' |
| 8 | apply plugin: 'c' |
| 9 | apply plugin: 'google-test-test-suite' |
| 10 | apply plugin: 'visual-studio' |
| 11 | apply plugin: 'edu.wpi.first.NativeUtils' |
| 12 | |
| 13 | if (OperatingSystem.current().isWindows()) { |
| 14 | apply plugin: 'windows-resources' |
| 15 | } |
| 16 | |
| 17 | ext { |
| 18 | nativeName = 'outlineviewer' |
| 19 | } |
| 20 | |
| 21 | apply from: "${rootDir}/shared/resources.gradle" |
| 22 | apply from: "${rootDir}/shared/config.gradle" |
| 23 | |
| 24 | def wpilibVersionFileInput = file("src/main/generate/WPILibVersion.cpp.in") |
| 25 | def wpilibVersionFileOutput = file("$buildDir/generated/main/cpp/WPILibVersion.cpp") |
| 26 | |
| 27 | task generateCppVersion() { |
| 28 | description = 'Generates the wpilib version class' |
| 29 | group = 'WPILib' |
| 30 | |
| 31 | outputs.file wpilibVersionFileOutput |
| 32 | inputs.file wpilibVersionFileInput |
| 33 | |
| 34 | if (wpilibVersioning.releaseMode) { |
| 35 | outputs.upToDateWhen { false } |
| 36 | } |
| 37 | |
| 38 | // We follow a simple set of checks to determine whether we should generate a new version file: |
| 39 | // 1. If the release type is not development, we generate a new version file |
| 40 | // 2. If there is no generated version number, we generate a new version file |
| 41 | // 3. If there is a generated build number, and the release type is development, then we will |
| 42 | // only generate if the publish task is run. |
| 43 | doLast { |
| 44 | def version = wpilibVersioning.version.get() |
| 45 | println "Writing version ${version} to $wpilibVersionFileOutput" |
| 46 | |
| 47 | if (wpilibVersionFileOutput.exists()) { |
| 48 | wpilibVersionFileOutput.delete() |
| 49 | } |
| 50 | def read = wpilibVersionFileInput.text.replace('${wpilib_version}', version) |
| 51 | wpilibVersionFileOutput.write(read) |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | gradle.taskGraph.addTaskExecutionGraphListener { graph -> |
| 56 | def willPublish = graph.hasTask(publish) |
| 57 | if (willPublish) { |
| 58 | generateCppVersion.outputs.upToDateWhen { false } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | def generateTask = createGenerateResourcesTask('main', 'OV', 'ov', project) |
| 63 | |
| 64 | project(':').libraryBuild.dependsOn build |
| 65 | tasks.withType(CppCompile) { |
| 66 | dependsOn generateTask |
| 67 | dependsOn generateCppVersion |
| 68 | } |
| 69 | |
| 70 | model { |
| 71 | components { |
| 72 | // By default, a development executable will be generated. This is to help the case of |
| 73 | // testing specific functionality of the library. |
| 74 | "${nativeName}"(NativeExecutableSpec) { |
| 75 | baseName = 'outlineviewer' |
| 76 | sources { |
| 77 | cpp { |
| 78 | source { |
| 79 | srcDirs 'src/main/native/cpp', "$buildDir/generated/main/cpp" |
| 80 | include '**/*.cpp' |
| 81 | } |
| 82 | exportedHeaders { |
| 83 | srcDirs 'src/main/native/include' |
| 84 | } |
| 85 | } |
| 86 | if (OperatingSystem.current().isWindows()) { |
| 87 | rc { |
| 88 | source { |
| 89 | srcDirs 'src/main/native/win' |
| 90 | include '*.rc' |
| 91 | } |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | binaries.all { |
| 96 | if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) { |
| 97 | it.buildable = false |
| 98 | return |
| 99 | } |
| 100 | lib project: ':glass', library: 'glassnt', linkage: 'static' |
| 101 | lib project: ':glass', library: 'glass', linkage: 'static' |
| 102 | lib project: ':ntcore', library: 'ntcore', linkage: 'static' |
| 103 | lib project: ':wpiutil', library: 'wpiutil', linkage: 'static' |
| 104 | lib project: ':wpigui', library: 'wpigui', linkage: 'static' |
| 105 | nativeUtils.useRequiredLibrary(it, 'imgui_static') |
| 106 | if (it.targetPlatform.operatingSystem.isWindows()) { |
| 107 | it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib' |
| 108 | } else if (it.targetPlatform.operatingSystem.isMacOsX()) { |
| 109 | it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore' |
| 110 | } else { |
| 111 | it.linker.args << '-lX11' |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | apply from: 'publish.gradle' |
| 119 | } |