blob: 9f9a22108c6316da9ed49dc2621febe8475ad06f [file] [log] [blame]
Brian Silverman8fce7482020-01-05 13:18:21 -08001import org.gradle.internal.os.OperatingSystem
2
Austin Schuh812d0d12021-11-04 20:16:48 -07003nativeUtils.skipInstallPdb = project.hasProperty('buildServer')
4
Brian Silverman8fce7482020-01-05 13:18:21 -08005nativeUtils.addWpiNativeUtils()
6nativeUtils.withRoboRIO()
7nativeUtils.withRaspbian()
8nativeUtils.withBionic()
9nativeUtils {
Austin Schuh812d0d12021-11-04 20:16:48 -070010 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 Silverman8fce7482020-01-05 13:18:21 -080019 }
Brian Silverman8fce7482020-01-05 13:18:21 -080020}
21
22nativeUtils.wpi.addWarnings()
23nativeUtils.wpi.addWarningsAsErrors()
Austin Schuh1e69f942020-11-14 15:06:14 -080024nativeUtils.wpi.addReleaseSymbolGeneration()
Brian Silverman8fce7482020-01-05 13:18:21 -080025
26nativeUtils.setSinglePrintPerPlatform()
Austin Schuh1e69f942020-11-14 15:06:14 -080027nativeUtils.enableSourceLink()
28
29nativeUtils.platformConfigs.each {
Austin Schuh812d0d12021-11-04 20:16:48 -070030 if (it.name.contains('windows')) {
31 return
32 }
Austin Schuh1e69f942020-11-14 15:06:14 -080033 it.linker.args << '-Wl,-rpath,\'$ORIGIN\''
34 if (it.name == 'osxx86-64') {
35 it.linker.args << "-headerpad_max_install_names"
36 }
37}
Brian Silverman8fce7482020-01-05 13:18:21 -080038
Austin Schuh812d0d12021-11-04 20:16:48 -070039nativeUtils.platformConfigs.linuxathena.linker.args.add("-Wl,--fatal-warnings")
40
Brian Silverman8fce7482020-01-05 13:18:21 -080041model {
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 Schuh812d0d12021-11-04 20:16:48 -070054apply plugin: DisableBuildingGTest
55
56if (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 Silverman8fce7482020-01-05 13:18:21 -080067ext.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
101ext.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 Schuh812d0d12021-11-04 20:16:48 -0700108 def target = nativeUtils.getPublishClassifier(it)
Brian Silverman8fce7482020-01-05 13:18:21 -0800109 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
146ext.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 Schuh1e69f942020-11-14 15:06:14 -0800171 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 Silverman8fce7482020-01-05 13:18:21 -0800179 }
180 }
181 }
182}