Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 1 | import org.gradle.internal.os.OperatingSystem |
| 2 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 3 | nativeUtils.skipInstallPdb = project.hasProperty('buildServer') |
| 4 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 5 | nativeUtils.addWpiNativeUtils() |
| 6 | nativeUtils.withRoboRIO() |
| 7 | nativeUtils.withRaspbian() |
| 8 | nativeUtils.withBionic() |
| 9 | nativeUtils { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 10 | wpi { |
| 11 | configureDependencies { |
| 12 | wpiVersion = "-1" |
| 13 | niLibVersion = "2022.2.2" |
| 14 | opencvVersion = "4.5.2-1" |
| 15 | googleTestVersion = "1.9.0-5-437e100-1" |
| 16 | imguiVersion = "1.82-1" |
| 17 | wpimathVersion = "-1" |
| 18 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 19 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | nativeUtils.wpi.addWarnings() |
| 23 | nativeUtils.wpi.addWarningsAsErrors() |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 24 | nativeUtils.wpi.addReleaseSymbolGeneration() |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 25 | |
| 26 | nativeUtils.setSinglePrintPerPlatform() |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 27 | nativeUtils.enableSourceLink() |
| 28 | |
| 29 | nativeUtils.platformConfigs.each { |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 30 | if (it.name.contains('windows')) { |
| 31 | return |
| 32 | } |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 33 | it.linker.args << '-Wl,-rpath,\'$ORIGIN\'' |
| 34 | if (it.name == 'osxx86-64') { |
| 35 | it.linker.args << "-headerpad_max_install_names" |
| 36 | } |
| 37 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 38 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 39 | nativeUtils.platformConfigs.linuxathena.linker.args.add("-Wl,--fatal-warnings") |
| 40 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 41 | model { |
| 42 | components { |
| 43 | all { |
| 44 | nativeUtils.useAllPlatforms(it) |
| 45 | } |
| 46 | } |
| 47 | binaries { |
| 48 | withType(NativeBinarySpec).all { |
| 49 | nativeUtils.usePlatformArguments(it) |
| 50 | } |
| 51 | } |
| 52 | } |
| 53 | |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 54 | apply plugin: DisableBuildingGTest |
| 55 | |
| 56 | if (project.hasProperty('buildServer')) { |
| 57 | tasks.withType(org.gradle.nativeplatform.test.tasks.RunTestExecutable) { |
| 58 | def exeFile = file(it.executable) |
| 59 | def folder = exeFile.parentFile |
| 60 | |
| 61 | it.doLast { |
| 62 | folder.deleteDir() |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 67 | ext.appendDebugPathToBinaries = { binaries-> |
| 68 | binaries.withType(StaticLibraryBinarySpec) { |
| 69 | if (it.buildType.name.contains('debug')) { |
| 70 | def staticFileDir = it.staticLibraryFile.parentFile |
| 71 | def staticFileName = it.staticLibraryFile.name |
| 72 | def staticFileExtension = staticFileName.substring(staticFileName.lastIndexOf('.')) |
| 73 | staticFileName = staticFileName.substring(0, staticFileName.lastIndexOf('.')) |
| 74 | staticFileName = staticFileName + 'd' + staticFileExtension |
| 75 | def newStaticFile = new File(staticFileDir, staticFileName) |
| 76 | it.staticLibraryFile = newStaticFile |
| 77 | } |
| 78 | } |
| 79 | binaries.withType(SharedLibraryBinarySpec) { |
| 80 | if (it.buildType.name.contains('debug')) { |
| 81 | def sharedFileDir = it.sharedLibraryFile.parentFile |
| 82 | def sharedFileName = it.sharedLibraryFile.name |
| 83 | def sharedFileExtension = sharedFileName.substring(sharedFileName.lastIndexOf('.')) |
| 84 | sharedFileName = sharedFileName.substring(0, sharedFileName.lastIndexOf('.')) |
| 85 | sharedFileName = sharedFileName + 'd' + sharedFileExtension |
| 86 | def newSharedFile = new File(sharedFileDir, sharedFileName) |
| 87 | |
| 88 | def sharedLinkFileDir = it.sharedLibraryLinkFile.parentFile |
| 89 | def sharedLinkFileName = it.sharedLibraryLinkFile.name |
| 90 | def sharedLinkFileExtension = sharedLinkFileName.substring(sharedLinkFileName.lastIndexOf('.')) |
| 91 | sharedLinkFileName = sharedLinkFileName.substring(0, sharedLinkFileName.lastIndexOf('.')) |
| 92 | sharedLinkFileName = sharedLinkFileName + 'd' + sharedLinkFileExtension |
| 93 | def newLinkFile = new File(sharedLinkFileDir, sharedLinkFileName) |
| 94 | |
| 95 | it.sharedLibraryLinkFile = newLinkFile |
| 96 | it.sharedLibraryFile = newSharedFile |
| 97 | } |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | ext.createComponentZipTasks = { components, names, base, type, project, func -> |
| 102 | def stringNames = names.collect {it.toString()} |
| 103 | def configMap = [:] |
| 104 | components.each { |
| 105 | if (it in NativeLibrarySpec && stringNames.contains(it.name)) { |
| 106 | it.binaries.each { |
| 107 | if (!it.buildable) return |
Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame^] | 108 | def target = nativeUtils.getPublishClassifier(it) |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 109 | if (configMap.containsKey(target)) { |
| 110 | configMap.get(target).add(it) |
| 111 | } else { |
| 112 | configMap.put(target, []) |
| 113 | configMap.get(target).add(it) |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | def taskList = [] |
| 119 | def outputsFolder = file("$project.buildDir/outputs") |
| 120 | configMap.each { key, value -> |
| 121 | def task = project.tasks.create(base + "-${key}", type) { |
| 122 | description = 'Creates component archive for platform ' + key |
| 123 | destinationDirectory = outputsFolder |
| 124 | classifier = key |
| 125 | archiveBaseName = '_M_' + base |
| 126 | duplicatesStrategy = 'exclude' |
| 127 | |
| 128 | from(licenseFile) { |
| 129 | into '/' |
| 130 | } |
| 131 | |
| 132 | func(it, value) |
| 133 | } |
| 134 | taskList.add(task) |
| 135 | |
| 136 | project.build.dependsOn task |
| 137 | |
| 138 | project.artifacts { |
| 139 | task |
| 140 | } |
| 141 | addTaskToCopyAllOutputs(task) |
| 142 | } |
| 143 | return taskList |
| 144 | } |
| 145 | |
| 146 | ext.includeStandardZipFormat = { task, value -> |
| 147 | value.each { binary -> |
| 148 | if (binary.buildable) { |
| 149 | if (binary instanceof SharedLibraryBinarySpec) { |
| 150 | task.dependsOn binary.tasks.link |
| 151 | task.from(new File(binary.sharedLibraryFile.absolutePath + ".debug")) { |
| 152 | into nativeUtils.getPlatformPath(binary) + '/shared' |
| 153 | } |
| 154 | def sharedPath = binary.sharedLibraryFile.absolutePath |
| 155 | sharedPath = sharedPath.substring(0, sharedPath.length() - 4) |
| 156 | |
| 157 | task.from(new File(sharedPath + '.pdb')) { |
| 158 | into nativeUtils.getPlatformPath(binary) + '/shared' |
| 159 | } |
| 160 | task.from(binary.sharedLibraryFile) { |
| 161 | into nativeUtils.getPlatformPath(binary) + '/shared' |
| 162 | } |
| 163 | task.from(binary.sharedLibraryLinkFile) { |
| 164 | into nativeUtils.getPlatformPath(binary) + '/shared' |
| 165 | } |
| 166 | } else if (binary instanceof StaticLibraryBinarySpec) { |
| 167 | task.dependsOn binary.tasks.createStaticLib |
| 168 | task.from(binary.staticLibraryFile) { |
| 169 | into nativeUtils.getPlatformPath(binary) + '/static' |
| 170 | } |
Austin Schuh | 1e69f94 | 2020-11-14 15:06:14 -0800 | [diff] [blame] | 171 | def pdbDir = binary.staticLibraryFile.parentFile |
| 172 | task.from(pdbDir) { |
| 173 | include '*.pdb' |
| 174 | into nativeUtils.getPlatformPath(binary) + '/static' |
| 175 | } |
| 176 | task.from(new File(pdbDir, "SourceLink.json")) { |
| 177 | into nativeUtils.getPlatformPath(binary) + '/static' |
| 178 | } |
Brian Silverman | 8fce748 | 2020-01-05 13:18:21 -0800 | [diff] [blame] | 179 | } |
| 180 | } |
| 181 | } |
| 182 | } |