blob: 0f6394d7ecd4046f1d1a6bec91417c05021f97b5 [file] [log] [blame]
John Park7eb90422018-01-27 12:04:57 -08001import edu.wpi.first.nativeutils.*
2import org.gradle.internal.os.OperatingSystem
3
4def windowsCompilerArgs = ['/EHsc', '/DNOMINMAX', '/Zi', '/FS', '/Zc:inline', '/MT']
5def windowsReleaseCompilerArgs = ['/O2']
6def windowsLinkerArgs = [ '/DEBUG:FULL' ]
7def windowsReleaseLinkerArgs = [ '/OPT:REF', '/OPT:ICF' ]
8
9def linuxCompilerArgs = ['-std=c++11', '-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
10 '-Wno-unused-parameter', '-fPIC', '-rdynamic', '-Wno-error=deprecated-declarations', '-pthread']
11def linuxLinkerArgs = ['-rdynamic', '-pthread']
12def linuxReleaseCompilerArgs = ['-Og']
13def linuxDebugCompilerArgs = ['-O0']
14def linux32BitArg = '-m32'
15
16def macCompilerArgs = ['-std=c++11', '-Wall', '-Wextra', '-Werror', '-pedantic-errors', '-fPIC', '-g',
17 '-Wno-unused-parameter', '-Wno-missing-field-initializers', '-Wno-unused-private-field',
18 '-Wno-unused-const-variable', '-pthread']
19def macReleaseCompilerArgs = ['-O2']
20def macDebugCompilerArgs = ['-O0']
21def mac32BitArg = '-m32'
22
23def buildAll = project.hasProperty('buildAll')
24
25def windows64PlatformDetect = {
26 def arch = System.getProperty("os.arch")
27 def isWin = OperatingSystem.current().isWindows()
28 if (buildAll) {
29 return isWin
30 } else {
31 return isWin && arch == 'amd64'
32 }
33}
34
35def windows32PlatformDetect = {
36 def arch = System.getProperty("os.arch")
37 def isWin = OperatingSystem.current().isWindows()
38 if (buildAll) {
39 return isWin
40 } else {
41 return isWin && arch == 'x86'
42 }
43}
44
45def linux32IntelPlatformDetect = {
46 def arch = System.getProperty("os.arch")
47 def isLinux = OperatingSystem.current().isLinux()
48 def isIntel = (arch == 'amd64' || arch == 'i386')
49 if (buildAll) {
50 return isLinux && isIntel
51 } else {
52 return isLinux && arch == 'i386'
53 }
54}
55
56def linux64IntelPlatformDetect = {
57 def arch = System.getProperty("os.arch")
58 def isLinux = OperatingSystem.current().isLinux()
59 def isIntel = (arch == 'amd64' || arch == 'i386')
60 if (buildAll) {
61 return isLinux && isIntel
62 } else {
63 return isLinux && arch == 'amd64'
64 }
65}
66
67def linuxArmPlatformDetect = {
68 def arch = System.getProperty("os.arch")
69 def isIntel = (arch == 'amd64' || arch == 'i386')
70 return OperatingSystem.current().isLinux() && !isIntel
71}
72
73def mac64PlatformDetect = {
74 def arch = System.getProperty("os.arch")
75 def isMac = OperatingSystem.current().isMacOsX()
76 if (buildAll) {
77 return isMac
78 } else {
79 return isMac && arch == 'x86_64'
80 }
81}
82
83def mac32PlatformDetect = {
84 def arch = System.getProperty("os.arch")
85 def isMac = OperatingSystem.current().isMacOsX()
86 if (buildAll) {
87 return isMac
88 } else {
89 return isMac && arch == 'x86'
90 }
91}
92
93if (!project.hasProperty('skipAthena')) {
94 model {
95 buildConfigs {
96 roboRio(CrossBuildConfig) {
97 architecture = 'athena'
98 operatingSystem = 'linux'
99 toolChainPrefix = 'arm-frc-linux-gnueabi-'
100 compilerArgs = linuxCompilerArgs
101 linkerArgs = linuxLinkerArgs
102 debugCompilerArgs = linuxDebugCompilerArgs
103 releaseCompilerArgs = linuxReleaseCompilerArgs
104 releaseStripBinaries = true
105 compilerFamily = 'Gcc'
106 exclude << 'halSim'
107 exclude << 'halSimStaticDeps'
108 exclude << 'halSimTestingBase'
109 exclude << 'wpilibcTestingBase'
110 }
111 }
112 }
113}
114
115if (!project.hasProperty('onlyAthena')) {
116 model {
117 buildConfigs {
118 winX86(BuildConfig) {
119 architecture = 'x86'
120 operatingSystem = 'windows'
121 compilerArgs = windowsCompilerArgs
122 linkerArgs = windowsLinkerArgs
123 releaseCompilerArgs = windowsReleaseCompilerArgs
124 releaseLinkerArgs = windowsReleaseLinkerArgs
125 compilerFamily = 'VisualCpp'
126 detectPlatform = windows32PlatformDetect
127 exclude << 'halAthena'
128 }
129 winX64(BuildConfig) {
130 architecture = 'x86-64'
131 operatingSystem = 'windows'
132 compilerArgs = windowsCompilerArgs
133 linkerArgs = windowsLinkerArgs
134 releaseCompilerArgs = windowsReleaseCompilerArgs
135 releaseLinkerArgs = windowsReleaseLinkerArgs
136 compilerFamily = 'VisualCpp'
137 detectPlatform = windows64PlatformDetect
138 exclude << 'halAthena'
139 }
140 /* Disable 32 bit linux until we can figure out jenkins
141 linuxX86(BuildConfig) {
142 architecture = 'x86'
143 operatingSystem = 'linux'
144 compilerArgs = linuxCompilerArgs
145 compilerArgs << linux32BitArg
146 linkerArgs = linuxLinkerArgs
147 linkerArgs << linux32BitArg
148 debugCompilerArgs = linuxDebugCompilerArgs
149 releaseCompilerArgs = linuxReleaseCompilerArgs
150 releaseStripBinaries = true
151 compilerFamily = 'Gcc'
152 detectPlatform = linux32IntelPlatformDetect
153 exclude << 'halAthena'
154 }
155 */
156 linuxX64(BuildConfig) {
157 architecture = 'x86-64'
158 operatingSystem = 'linux'
159 compilerArgs = linuxCompilerArgs
160 linkerArgs = linuxLinkerArgs
161 debugCompilerArgs = linuxDebugCompilerArgs
162 releaseCompilerArgs = linuxReleaseCompilerArgs
163 releaseStripBinaries = true
164 compilerFamily = 'Gcc'
165 detectPlatform = linux64IntelPlatformDetect
166 exclude << 'halAthena'
167 }
168 /* 32 bit Mac OS X not supported by OpenCV.
169 * If support is ever added, will add this back in
170 macX86(BuildConfig) {
171 architecture = 'x86'
172 operatingSystem = 'osx'
173 compilerArgs = macCompilerArgs
174 compilerArgs << mac32BitArg
175 linkerArgs << mac32BitArg
176 debugCompilerArgs = macDebugCompilerArgs
177 releaseCompilerArgs = macReleaseCompilerArgs
178 releaseStripBinaries = true
179 compilerFamily = 'Clang'
180 detectPlatform = mac32PlatformDetect
181 exclude << 'halAthena'
182 }
183 */
184 macX64(BuildConfig) {
185 architecture = 'x86-64'
186 operatingSystem = 'osx'
187 compilerArgs = macCompilerArgs
188 debugCompilerArgs = macDebugCompilerArgs
189 releaseCompilerArgs = macReleaseCompilerArgs
190 releaseStripBinaries = true
191 compilerFamily = 'Clang'
192 detectPlatform = mac64PlatformDetect
193 exclude << 'halAthena'
194 }
195 }
196 }
197}
198
199if (project.hasProperty('linuxCross')) {
200 model {
201 buildConfigs {
202 linuxArm(CrossBuildConfig) {
203 architecture = 'nativearm'
204 operatingSystem = 'linux'
205 toolChainPrefix = 'PLEASE_PROVIDE_A_COMPILER_NAME'
206 compilerArgs = linuxCompilerArgs
207 linkerArgs = linuxLinkerArgs
208 debugCompilerArgs = linuxDebugCompilerArgs
209 releaseCompilerArgs = linuxReleaseCompilerArgs
210 releaseStripBinaries = true
211 skipByDefault = true
212 compilerFamily = 'Gcc'
213 exclude << 'gmock'
214 exclude << 'halAthena'
215 }
216 }
217 }
218} else {
219 model {
220 buildConfigs {
221 linuxArm(BuildConfig) {
222 architecture = 'nativearm'
223 operatingSystem = 'linux'
224 compilerArgs = linuxCompilerArgs
225 linkerArgs = linuxLinkerArgs
226 debugCompilerArgs = linuxDebugCompilerArgs
227 releaseCompilerArgs = linuxReleaseCompilerArgs
228 releaseStripBinaries = true
229 compilerFamily = 'Gcc'
230 detectPlatform = linuxArmPlatformDetect
231 exclude << 'halAthena'
232 }
233 }
234 }
235}