Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 1 | import org.gradle.internal.os.OperatingSystem |
| 2 | |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 3 | if (!project.hasProperty('onlylinuxathena')) { |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 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" |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 17 | apply from: "${rootDir}/shared/imgui.gradle" |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 18 | |
| 19 | nativeUtils.exportsConfigs { |
| 20 | wpigui { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 21 | 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 Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 34 | } |
| 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 Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 52 | nativeUtils.useRequiredLibrary(it, 'imgui') |
| 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()) { |
| 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 Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 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 { |
| 85 | it.sources { |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 86 | wpiguiUnixGl3Cpp(CppSourceSet) { |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 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' |
| 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 Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 118 | nativeUtils.useRequiredLibrary(it, 'imgui') |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 119 | } |
| 120 | } |
| 121 | } |
| 122 | binaries { |
| 123 | all { |
James Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 124 | if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) { |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 125 | 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 Kuszmaul | cf32412 | 2023-01-14 14:07:17 -0800 | [diff] [blame^] | 134 | if (it.targetPlatform.name.startsWith('linuxarm')) { |
| 135 | it.linker.args << '-lGL' |
| 136 | } |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 137 | } |
| 138 | } |
| 139 | withType(SharedLibraryBinarySpec) { |
| 140 | buildable = false |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | apply from: 'publish.gradle' |
| 146 | } |