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