blob: 5959b67026d2b9749283ea1aad6ef0ae02cb7cef [file] [log] [blame]
Austin Schuh1e69f942020-11-14 15:06:14 -08001import org.gradle.internal.os.OperatingSystem
2
3if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
4
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"
17
18 nativeUtils.exportsConfigs {
19 wpigui {
Austin Schuh812d0d12021-11-04 20:16:48 -070020 x86ExcludeSymbols = [
21 '_CT??_R0?AV_System_error',
22 '_CT??_R0?AVexception',
23 '_CT??_R0?AVfailure',
24 '_CT??_R0?AVruntime_error',
25 '_CT??_R0?AVsystem_error',
26 '_CTA5?AVfailure',
27 '_TI5?AVfailure',
28 '_CT??_R0?AVout_of_range',
29 '_CTA3?AVout_of_range',
30 '_TI3?AVout_of_range',
31 '_CT??_R0?AVbad_cast'
32 ]
33 x64ExcludeSymbols = [
34 '_CT??_R0?AV_System_error',
35 '_CT??_R0?AVexception',
36 '_CT??_R0?AVfailure',
37 '_CT??_R0?AVruntime_error',
38 '_CT??_R0?AVsystem_error',
39 '_CTA5?AVfailure',
40 '_TI5?AVfailure',
41 '_CT??_R0?AVout_of_range',
42 '_CTA3?AVout_of_range',
43 '_TI3?AVout_of_range',
44 '_CT??_R0?AVbad_cast'
45 ]
Austin Schuh1e69f942020-11-14 15:06:14 -080046 }
47 }
48
49 model {
50 components {
51 "${nativeName}"(NativeLibrarySpec) {
52 sources {
53 cpp {
54 source {
55 srcDirs "src/main/native/cpp"
56 include '*.cpp'
57 }
58 exportedHeaders {
59 srcDirs 'src/main/native/include'
60 }
61 }
62 }
63 binaries.all {
64 nativeUtils.useRequiredLibrary(it, 'imgui_static')
65 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
66 it.buildable = false
67 return
68 }
69 if (it.targetPlatform.operatingSystem.isWindows()) {
70 it.sources {
71 wpiguiWindowsCpp(CppSourceSet) {
72 source {
73 srcDirs 'src/main/native/directx11'
74 include '*.cpp'
75 }
76 }
77 }
78 } else if (it.targetPlatform.operatingSystem.isMacOsX()) {
79 it.sources {
80 wpiguiMacObjectiveCpp(ObjectiveCppSourceSet) {
81 source {
82 srcDirs 'src/main/native/metal'
83 include '*.mm'
84 }
85 }
86 }
87 } else {
88 it.sources {
89 wpiguiUnixCpp(CppSourceSet) {
90 source {
91 srcDirs 'src/main/native/opengl3'
92 include '*.cpp'
93 }
94 }
95 }
96 }
97 it.sources.each {
98 it.exportedHeaders {
99 srcDirs 'src/main/native/include'
100 }
101 }
102 }
103 }
104 // By default, a development executable will be generated. This is to help the case of
105 // testing specific functionality of the library.
106 "${nativeName}Dev"(NativeExecutableSpec) {
107 targetBuildTypes 'debug'
108 sources {
109 cpp {
110 source {
111 srcDirs 'src/dev/native/cpp'
112 include '**/*.cpp'
113 }
114 exportedHeaders {
115 srcDirs 'src/dev/native/include'
116 }
117 }
118 }
119 binaries.all {
120 lib library: 'wpigui'
121 nativeUtils.useRequiredLibrary(it, 'imgui_static')
Austin Schuh1e69f942020-11-14 15:06:14 -0800122 }
123 }
124 }
125 binaries {
126 all {
127 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
128 it.buildable = false
129 return
130 }
131 if (it.targetPlatform.operatingSystem.isWindows()) {
132 it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
133 } else if (it.targetPlatform.operatingSystem.isMacOsX()) {
134 it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
135 } else {
136 it.linker.args << '-lX11'
137 }
138 }
139 withType(SharedLibraryBinarySpec) {
140 buildable = false
141 }
142 }
143 }
144
145 apply from: 'publish.gradle'
146}