Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 1 | import org.gradle.internal.os.OperatingSystem |
| 2 | |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 3 | if (project.hasProperty('onlylinuxathena')) { |
| 4 | return; |
| 5 | } |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 6 | |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 7 | apply plugin: 'cpp' |
| 8 | if (OperatingSystem.current().isMacOsX()) { |
| 9 | apply plugin: 'objective-cpp' |
| 10 | } |
| 11 | apply plugin: 'visual-studio' |
| 12 | apply plugin: 'edu.wpi.first.NativeUtils' |
| 13 | |
| 14 | ext { |
| 15 | nativeName = 'wpigui' |
| 16 | } |
| 17 | |
| 18 | apply from: "${rootDir}/shared/config.gradle" |
| 19 | apply from: "${rootDir}/shared/imgui.gradle" |
| 20 | |
| 21 | nativeUtils.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 Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 36 | } |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 37 | } |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 38 | |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 39 | model { |
| 40 | components { |
| 41 | "${nativeName}"(NativeLibrarySpec) { |
| 42 | sources.cpp { |
| 43 | source { |
| 44 | srcDirs "src/main/native/cpp" |
| 45 | include '*.cpp' |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 46 | } |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 47 | exportedHeaders { |
| 48 | srcDirs 'src/main/native/include' |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 49 | } |
| 50 | } |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 51 | binaries.all { |
| 52 | nativeUtils.useRequiredLibrary(it, 'imgui') |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 53 | if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 54 | it.buildable = false |
| 55 | return |
| 56 | } |
| 57 | if (it.targetPlatform.operatingSystem.isWindows()) { |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 58 | it.sources { |
| 59 | wpiguiWindowsCpp(CppSourceSet) { |
| 60 | source { |
| 61 | srcDirs 'src/main/native/directx11' |
| 62 | include '*.cpp' |
| 63 | } |
| 64 | } |
| 65 | } |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 66 | } else if (it.targetPlatform.operatingSystem.isMacOsX()) { |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 67 | 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 Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 84 | } else { |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 85 | 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 Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame] | 97 | } |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 98 | } |
| 99 | } |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 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.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 Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | } |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 120 | 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 Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 141 | } |
James Kuszmaul | b13e13f | 2023-11-22 20:44:04 -0800 | [diff] [blame] | 142 | |
| 143 | apply from: 'publish.gradle' |