blob: bb4a4cad01ae7e7b88c4ff20e1e4ac6e0641d157 [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001import org.gradle.internal.os.OperatingSystem
2
James Kuszmaulcf324122023-01-14 14:07:17 -08003if (!project.hasProperty('onlylinuxathena')) {
Austin Schuh812d0d12021-11-04 20:16:48 -07004
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
James Kuszmaulcf324122023-01-14 14:07:17 -080027 apply from: "${rootDir}/shared/imgui.gradle"
28
Austin Schuh812d0d12021-11-04 20:16:48 -070029 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 {
90 source {
91 srcDirs 'src/main/native/win'
92 include '*.rc'
93 }
94 }
95 }
96 }
97 binaries.all {
James Kuszmaulcf324122023-01-14 14:07:17 -080098 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
Austin Schuh812d0d12021-11-04 20:16:48 -070099 it.buildable = false
100 return
101 }
102 lib project: ':glass', library: 'glassnt', linkage: 'static'
103 lib project: ':glass', library: 'glass', linkage: 'static'
James Kuszmaulcf324122023-01-14 14:07:17 -0800104 project(':ntcore').addNtcoreDependency(it, 'static')
105 lib project: ':wpinet', library: 'wpinet', linkage: 'static'
Austin Schuh812d0d12021-11-04 20:16:48 -0700106 lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
107 lib project: ':wpigui', library: 'wpigui', linkage: 'static'
James Kuszmaulcf324122023-01-14 14:07:17 -0800108 nativeUtils.useRequiredLibrary(it, 'imgui')
Austin Schuh812d0d12021-11-04 20:16:48 -0700109 if (it.targetPlatform.operatingSystem.isWindows()) {
110 it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
111 } else if (it.targetPlatform.operatingSystem.isMacOsX()) {
112 it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
113 } else {
114 it.linker.args << '-lX11'
James Kuszmaulcf324122023-01-14 14:07:17 -0800115 if (it.targetPlatform.name.startsWith('linuxarm')) {
116 it.linker.args << '-lGL'
117 }
Austin Schuh812d0d12021-11-04 20:16:48 -0700118 }
119 }
120 }
121 }
122 }
123
124 apply from: 'publish.gradle'
125}