blob: 3e70c4b55fcaec3274be8f89c3cb1245d32547cd [file] [log] [blame]
Austin Schuh1e69f942020-11-14 15:06:14 -08001import org.gradle.internal.os.OperatingSystem
2
James Kuszmaulb13e13f2023-11-22 20:44:04 -08003if (project.hasProperty('onlylinuxathena')) {
4 return;
5}
Austin Schuh1e69f942020-11-14 15:06:14 -08006
James Kuszmaulb13e13f2023-11-22 20:44:04 -08007apply plugin: 'cpp'
8if (OperatingSystem.current().isMacOsX()) {
9 apply plugin: 'objective-cpp'
10}
11apply plugin: 'visual-studio'
12apply plugin: 'edu.wpi.first.NativeUtils'
13
14ext {
15 nativeName = 'wpigui'
16}
17
18apply from: "${rootDir}/shared/config.gradle"
19apply from: "${rootDir}/shared/imgui.gradle"
20
21nativeUtils.exportsConfigs {
22 wpigui {
23 x64ExcludeSymbols = [
24 '_CT??_R0?AV_System_error',
25 '_CT??_R0?AVexception',
26 '_CT??_R0?AVfailure',
27 '_CT??_R0?AVruntime_error',
28 '_CT??_R0?AVsystem_error',
29 '_CTA5?AVfailure',
30 '_TI5?AVfailure',
31 '_CT??_R0?AVout_of_range',
32 '_CTA3?AVout_of_range',
33 '_TI3?AVout_of_range',
34 '_CT??_R0?AVbad_cast'
35 ]
Austin Schuh1e69f942020-11-14 15:06:14 -080036 }
James Kuszmaulb13e13f2023-11-22 20:44:04 -080037}
Austin Schuh1e69f942020-11-14 15:06:14 -080038
James Kuszmaulb13e13f2023-11-22 20:44:04 -080039model {
40 components {
41 "${nativeName}"(NativeLibrarySpec) {
42 sources.cpp {
43 source {
44 srcDirs "src/main/native/cpp"
45 include '*.cpp'
Austin Schuh1e69f942020-11-14 15:06:14 -080046 }
James Kuszmaulb13e13f2023-11-22 20:44:04 -080047 exportedHeaders {
48 srcDirs 'src/main/native/include'
Austin Schuh1e69f942020-11-14 15:06:14 -080049 }
50 }
James Kuszmaulb13e13f2023-11-22 20:44:04 -080051 binaries.all {
52 nativeUtils.useRequiredLibrary(it, 'imgui')
James Kuszmaulcf324122023-01-14 14:07:17 -080053 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()) {
James Kuszmaulb13e13f2023-11-22 20:44:04 -080058 it.sources {
59 wpiguiWindowsCpp(CppSourceSet) {
60 source {
61 srcDirs 'src/main/native/directx11'
62 include '*.cpp'
63 }
64 }
65 }
Austin Schuh1e69f942020-11-14 15:06:14 -080066 } else if (it.targetPlatform.operatingSystem.isMacOsX()) {
James Kuszmaulb13e13f2023-11-22 20:44:04 -080067 it.sources {
68 wpiguiMacObjectiveCpp(ObjectiveCppSourceSet) {
69 source {
70 srcDirs 'src/main/native/metal'
71 include '*.mm'
72 }
73 }
74 }
75 } 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 {
James Kuszmaulb13e13f2023-11-22 20:44:04 -080085 it.sources {
86 wpiguiUnixGl3Cpp(CppSourceSet) {
87 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'
James Kuszmaulcf324122023-01-14 14:07:17 -080097 }
Austin Schuh1e69f942020-11-14 15:06:14 -080098 }
99 }
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800100 }
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.cpp {
106 source {
107 srcDirs 'src/dev/native/cpp'
108 include '**/*.cpp'
109 }
110 exportedHeaders {
111 srcDirs 'src/dev/native/include'
112 }
113 }
114 binaries.all {
115 lib library: 'wpigui'
116 nativeUtils.useRequiredLibrary(it, 'imgui')
Austin Schuh1e69f942020-11-14 15:06:14 -0800117 }
118 }
119 }
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800120 binaries {
121 all {
122 if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
123 it.buildable = false
124 return
125 }
126 if (it.targetPlatform.operatingSystem.isWindows()) {
127 it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
128 } else if (it.targetPlatform.operatingSystem.isMacOsX()) {
129 it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
130 } else {
131 it.linker.args << '-lX11'
132 if (it.targetPlatform.name.startsWith('linuxarm')) {
133 it.linker.args << '-lGL'
134 }
135 }
136 }
137 withType(SharedLibraryBinarySpec) {
138 buildable = false
139 }
140 }
Austin Schuh1e69f942020-11-14 15:06:14 -0800141}
James Kuszmaulb13e13f2023-11-22 20:44:04 -0800142
143apply from: 'publish.gradle'