blob: fb08198a8b0887f8d4304a983fad35caca05d635 [file] [log] [blame]
Austin Schuh1e69f942020-11-14 15:06:14 -08001import org.gradle.internal.os.OperatingSystem
2
James Kuszmaulcf324122023-01-14 14:07:17 -08003if (!project.hasProperty('onlylinuxathena')) {
Austin Schuh1e69f942020-11-14 15:06:14 -08004
5 apply plugin: 'cpp'
6 if (OperatingSystem.current().isMacOsX()) {
7 apply plugin: 'objective-cpp'
8 }
9 apply plugin: 'visual-studio'
10 apply plugin: 'edu.wpi.first.NativeUtils'
11
12 ext {
13 nativeName = 'wpigui'
14 }
15
16 apply from: "${rootDir}/shared/config.gradle"
James Kuszmaulcf324122023-01-14 14:07:17 -080017 apply from: "${rootDir}/shared/imgui.gradle"
Austin Schuh1e69f942020-11-14 15:06:14 -080018
19 nativeUtils.exportsConfigs {
20 wpigui {
Austin Schuh812d0d12021-11-04 20:16:48 -070021 x64ExcludeSymbols = [
22 '_CT??_R0?AV_System_error',
23 '_CT??_R0?AVexception',
24 '_CT??_R0?AVfailure',
25 '_CT??_R0?AVruntime_error',
26 '_CT??_R0?AVsystem_error',
27 '_CTA5?AVfailure',
28 '_TI5?AVfailure',
29 '_CT??_R0?AVout_of_range',
30 '_CTA3?AVout_of_range',
31 '_TI3?AVout_of_range',
32 '_CT??_R0?AVbad_cast'
33 ]
Austin Schuh1e69f942020-11-14 15:06:14 -080034 }
35 }
36
37 model {
38 components {
39 "${nativeName}"(NativeLibrarySpec) {
40 sources {
41 cpp {
42 source {
43 srcDirs "src/main/native/cpp"
44 include '*.cpp'
45 }
46 exportedHeaders {
47 srcDirs 'src/main/native/include'
48 }
49 }
50 }
51 binaries.all {
James Kuszmaulcf324122023-01-14 14:07:17 -080052 nativeUtils.useRequiredLibrary(it, 'imgui')
53 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
Austin Schuh1e69f942020-11-14 15:06:14 -080054 it.buildable = false
55 return
56 }
57 if (it.targetPlatform.operatingSystem.isWindows()) {
58 it.sources {
59 wpiguiWindowsCpp(CppSourceSet) {
60 source {
61 srcDirs 'src/main/native/directx11'
62 include '*.cpp'
63 }
64 }
65 }
66 } else if (it.targetPlatform.operatingSystem.isMacOsX()) {
67 it.sources {
68 wpiguiMacObjectiveCpp(ObjectiveCppSourceSet) {
69 source {
70 srcDirs 'src/main/native/metal'
71 include '*.mm'
72 }
73 }
74 }
James Kuszmaulcf324122023-01-14 14:07:17 -080075 } else if (it.targetPlatform.name.startsWith('linuxarm')) {
76 it.sources {
77 wpiguiUnixGl2Cpp(CppSourceSet) {
78 source {
79 srcDirs 'src/main/native/opengl2'
80 include '*.cpp'
81 }
82 }
83 }
Austin Schuh1e69f942020-11-14 15:06:14 -080084 } else {
85 it.sources {
James Kuszmaulcf324122023-01-14 14:07:17 -080086 wpiguiUnixGl3Cpp(CppSourceSet) {
Austin Schuh1e69f942020-11-14 15:06:14 -080087 source {
88 srcDirs 'src/main/native/opengl3'
89 include '*.cpp'
90 }
91 }
92 }
93 }
94 it.sources.each {
95 it.exportedHeaders {
96 srcDirs 'src/main/native/include'
97 }
98 }
99 }
100 }
101 // By default, a development executable will be generated. This is to help the case of
102 // testing specific functionality of the library.
103 "${nativeName}Dev"(NativeExecutableSpec) {
104 targetBuildTypes 'debug'
105 sources {
106 cpp {
107 source {
108 srcDirs 'src/dev/native/cpp'
109 include '**/*.cpp'
110 }
111 exportedHeaders {
112 srcDirs 'src/dev/native/include'
113 }
114 }
115 }
116 binaries.all {
117 lib library: 'wpigui'
James Kuszmaulcf324122023-01-14 14:07:17 -0800118 nativeUtils.useRequiredLibrary(it, 'imgui')
Austin Schuh1e69f942020-11-14 15:06:14 -0800119 }
120 }
121 }
122 binaries {
123 all {
James Kuszmaulcf324122023-01-14 14:07:17 -0800124 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
Austin Schuh1e69f942020-11-14 15:06:14 -0800125 it.buildable = false
126 return
127 }
128 if (it.targetPlatform.operatingSystem.isWindows()) {
129 it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
130 } else if (it.targetPlatform.operatingSystem.isMacOsX()) {
131 it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
132 } else {
133 it.linker.args << '-lX11'
James Kuszmaulcf324122023-01-14 14:07:17 -0800134 if (it.targetPlatform.name.startsWith('linuxarm')) {
135 it.linker.args << '-lGL'
136 }
Austin Schuh1e69f942020-11-14 15:06:14 -0800137 }
138 }
139 withType(SharedLibraryBinarySpec) {
140 buildable = false
141 }
142 }
143 }
144
145 apply from: 'publish.gradle'
146}