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