blob: cb2ca338e1fc003bf4e2c098080648f8b2e8f998 [file] [log] [blame]
brians343bc112013-02-10 01:53:46 +00001# This file gets passed to gyp with -I so that it gets included everywhere.
2{
3 'variables': {
4 'AOS': '<(DEPTH)/aos',
5# A directory with everything in it ignored from source control.
6 'TMPDIR': '<(DEPTH)/aos/build/temp',
7 'aos_abs': '<!(readlink -f <(DEPTH)/aos)', # for use in non-path contexts
Brian Silvermane6bada62014-05-04 16:16:54 -07008# The .gyp file that has targets for the various external libraries.
brians343bc112013-02-10 01:53:46 +00009 'EXTERNALS': '<(AOS)/build/externals.gyp',
Brian Silvermane6bada62014-05-04 16:16:54 -070010# The directory that gets rsynced to the target.
brians343bc112013-02-10 01:53:46 +000011 'rsync_dir': '<(PRODUCT_DIR)/outputs',
Brian Silvermane6bada62014-05-04 16:16:54 -070012# The directory that executables that depend on <(EXTERNALS):gtest get put into.
brians343bc112013-02-10 01:53:46 +000013 'test_dir': '<(PRODUCT_DIR)/tests',
Brian Silvermand3fac732014-05-03 16:03:46 -070014
Brian Silvermane6bada62014-05-04 16:16:54 -070015# Stuck into a variable (with a space on the end) to make disabling it easy.
Brian Silvermand3fac732014-05-03 16:03:46 -070016 'ccache': '<!(which ccache) ',
Brian Silverman1294c082014-05-20 17:02:29 -070017
18 'disable_sanitizers': [
19 # Bad alignment is just slow on x86 and traps on ARM, so we'll find
20 # it other ways, and some x86 code does it on purpose.
21 'alignment',
22 ],
brians343bc112013-02-10 01:53:46 +000023 },
24 'conditions': [
Brian Silvermanb3d50542014-04-23 14:28:55 -050025 ['PLATFORM=="crio"', {
brians343bc112013-02-10 01:53:46 +000026 'make_global_settings': [
Brian Silvermana67ecc72013-09-28 13:53:53 -070027 ['CC', '<!(readlink -f <(AOS)/build/crio_cc)'],
28 ['CXX', '<!(readlink -f <(AOS)/build/crio_cxx)'],
brians343bc112013-02-10 01:53:46 +000029 ],
brians343bc112013-02-10 01:53:46 +000030 }
Brian Silvermanbae86d62014-09-14 01:05:31 -040031 ], ['PLATFORM=="linux-arm-gcc_frc"', {
32 'make_global_settings': [
33 ['CC', '<(ccache)<!(which arm-frc-linux-gnueabi-gcc-4.9)'],
34 ['CXX', '<(ccache)<!(which arm-frc-linux-gnueabi-g++-4.9)'],
35 ],
36 },
Brian Silvermana29ebf92014-04-23 13:08:49 -050037 ], ['PLATFORM=="linux-arm-gcc"', {
Brian Silverman79723eb2014-04-21 22:05:11 -070038 'make_global_settings': [
Brian Silvermand3fac732014-05-03 16:03:46 -070039 ['CC', '<(ccache)<!(which arm-linux-gnueabihf-gcc-4.7)'],
40 ['CXX', '<(ccache)<!(which arm-linux-gnueabihf-g++-4.7)'],
Brian Silverman79723eb2014-04-21 22:05:11 -070041 ],
42 },
Brian Silvermana29ebf92014-04-23 13:08:49 -050043 ], ['PLATFORM=="linux-arm-clang"', {
Brian Silvermana8c04522014-04-27 20:03:08 -070044 'variables': {
45 'arm-clang-symlinks': '<!(realpath -s <(AOS)/build/arm-clang-symlinks)',
46 'arm-clang-sysroot': '<(arm-clang-symlinks)/sysroot',
Brian Silvermane6bada62014-05-04 16:16:54 -070047# Flags that should be passed to all compile/link/etc commands.
Brian Silvermana8c04522014-04-27 20:03:08 -070048 'platflags': [
49 '-target', 'armv7a-linux-gnueabihf',
50 '-mfloat-abi=hard',
Brian Silvermana8c04522014-04-27 20:03:08 -070051 '--sysroot=<(arm-clang-sysroot)',
52
Brian Silvermane6bada62014-05-04 16:16:54 -070053 # TODO(brians): See if it will run with this enabled.
Brian Silvermana8c04522014-04-27 20:03:08 -070054 #-mhwdiv=arm,thumb
55 ],
56 },
57 'make_global_settings': [
Brian Silvermand3fac732014-05-03 16:03:46 -070058 ['CC', '<(ccache)<(arm-clang-symlinks)/bin/clang'],
59 ['CXX', '<(ccache)<(arm-clang-symlinks)/bin/clang++'],
Brian Silvermana8c04522014-04-27 20:03:08 -070060 ],
61 'target_defaults': {
62 'cflags': [
Brian Silvermana8c04522014-04-27 20:03:08 -070063 '<@(platflags)',
64 ],
Brian Silverman34d25f22014-05-01 13:30:56 -070065 'cflags_cc': [
66 '-isystem', '<(arm-clang-sysroot)/usr/include/c++/4.7.2',
67 '-isystem', '<(arm-clang-sysroot)/usr/include/c++/4.7.2/arm-linux-gnueabihf',
68 ],
Brian Silvermana8c04522014-04-27 20:03:08 -070069 'ldflags': [
70 '<@(platflags)',
71 ],
72 },
Brian Silverman79723eb2014-04-21 22:05:11 -070073 },
74 ], ['PLATFORM=="linux-amd64-clang"', {
75 'make_global_settings': [
Brian Silvermand3fac732014-05-03 16:03:46 -070076 ['CC', '<(ccache)/opt/clang-3.5/bin/clang'],
77 ['CXX', '<(ccache)/opt/clang-3.5/bin/clang++'],
Brian Silverman79723eb2014-04-21 22:05:11 -070078 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -070079 },
80 ], ['PLATFORM=="linux-amd64-gcc"', {
Brian Silvermand3fac732014-05-03 16:03:46 -070081 'make_global_settings': [
Brian Silverman9b7a6842014-05-05 16:19:11 -070082 ['CC', '<(ccache)<!(which gcc-4.7)'],
83 ['CXX', '<(ccache)<!(which g++-4.7)'],
Brian Silvermand3fac732014-05-03 16:03:46 -070084 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -070085 },
Brian Silverman47cd6f62014-05-03 10:35:52 -070086 ], ['PLATFORM=="linux-amd64-gcc_4.8"', {
87 'make_global_settings': [
Brian Silvermand3fac732014-05-03 16:03:46 -070088 ['CC', '<(ccache)/opt/clang-3.5/bin/gcc'],
89 ['CXX', '<(ccache)/opt/clang-3.5/bin/g++'],
Brian Silverman47cd6f62014-05-03 10:35:52 -070090 ],
91 },
Brian Silvermanf0d3c782014-05-02 23:56:32 -070092 ], ['SANITIZER!="none"', {
Brian Silvermana4aff562014-05-02 17:43:50 -070093 'target_defaults': {
94 'cflags': [
Brian Silvermanf0d3c782014-05-02 23:56:32 -070095 '-fsanitize=<(SANITIZER)',
Brian Silvermana4aff562014-05-02 17:43:50 -070096 ],
97 'ldflags': [
Brian Silvermanf0d3c782014-05-02 23:56:32 -070098 '-fsanitize=<(SANITIZER)',
Brian Silvermana4aff562014-05-02 17:43:50 -070099 ],
Brian Silverman889f85e2014-09-05 11:39:09 -0400100 'defines': [
101# GCC doesn't have __has_feature, so we have to use this instead.
102 'AOS_SANITIZER_<(SANITIZER)',
103 ],
Brian Silvermana4aff562014-05-02 17:43:50 -0700104 },
Brian Silverman79723eb2014-04-21 22:05:11 -0700105 },
Brian Silverman1294c082014-05-20 17:02:29 -0700106 ], ['SANITIZER!="none" and COMPILER!="gcc"', {
107 'target_defaults': {
108 'cflags': [
109 '-fno-sanitize-recover',
110 '-fno-sanitize=<!(echo <(disable_sanitizers) | sed "s/ /,/g")',
111 ],
112 },
113 },
Brian Silverman99895b92014-09-14 01:01:15 -0400114 ], ['EXTERNALS_EXTRA=="-fPIE"', {
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700115 'target_defaults': {
116 'cflags': [
Brian Silverman47cd6f62014-05-03 10:35:52 -0700117 '-fPIE',
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700118 ],
119 'ldflags': [
Brian Silverman47cd6f62014-05-03 10:35:52 -0700120 '-fPIE',
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700121 ],
Brian Silverman47cd6f62014-05-03 10:35:52 -0700122 'link_settings': {
123 'ldflags': [
124 '-pie',
125 ],
126 },
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700127 },
128 },
129 ], ['SANITIZER=="memory"', {
130 'target_defaults': {
131 'cflags': [
132 '-fsanitize-memory-track-origins',
133 ],
134 'ldflags': [
135 '-fsanitize-memory-track-origins',
136 ],
137 },
Brian Silverman79723eb2014-04-21 22:05:11 -0700138 },
brians343bc112013-02-10 01:53:46 +0000139 ],
140 ],
141 'target_defaults': {
142 'defines': [
143 '__STDC_FORMAT_MACROS',
Brian Silverman6137a502013-04-22 15:41:36 -0700144 '__STDC_CONSTANT_MACROS',
145 '__STDC_LIMIT_MACROS',
Austin Schuhc9b0a9d2014-10-25 18:02:21 -0700146 'AOS_COMPILER_<!(echo <(FULL_COMPILER) | sed \'s/\./_/g\')',
brians343bc112013-02-10 01:53:46 +0000147 ],
148 'ldflags': [
149 '-pipe',
150 ],
151 'cflags': [
152 '-pipe',
153
154 '-Wall',
155 '-Wextra',
156 '-Wswitch-enum',
157 '-Wpointer-arith',
158 '-Wstrict-aliasing=2',
159 '-Wcast-qual',
160 '-Wcast-align',
161 '-Wwrite-strings',
162 '-Wtype-limits',
163 '-Wsign-compare',
164 '-Wformat=2',
165 '-Werror',
Brian Silverman9ba2bc42013-03-17 14:18:33 -0700166
167 '-ggdb3',
brians343bc112013-02-10 01:53:46 +0000168 ],
169 'cflags_c': [
170 '-std=gnu99',
171 ],
brians343bc112013-02-10 01:53:46 +0000172 'include_dirs': [
173 '<(DEPTH)',
174 ],
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700175 # These have to be here because apparently gyp evaluates target_conditions
176 # even if the target is never used.
177 'variables': {
178 # Set this to 1 to disable rsyncing the file to the target.
179 'no_rsync%': 0,
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700180 # Set this to 1 if this file is a test that should not be run by
Brian Silvermanb3d50542014-04-23 14:28:55 -0500181 # `build.py tests`.
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700182 'is_special_test%': 0,
183 },
brians343bc112013-02-10 01:53:46 +0000184 'conditions': [
185 ['DEBUG=="yes"', {
Brian Silvermanaac705c2014-05-01 18:55:34 -0700186 'defines': [
187 'AOS_DEBUG=1',
188 ],
Brian Silverman266811f2014-05-03 22:48:04 -0700189 'conditions': [['SANITIZER=="none"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700190 'cflags': [
191 '-O0',
192 ],
193 }, {
194 'cflags': [
195 '-O1',
196 ],
197 }
198 ]],
199 }, { # 'DEBUG=="no"'
Brian Silvermanaac705c2014-05-01 18:55:34 -0700200 'defines': [
201 'AOS_DEBUG=0',
Brian Silverman3b6d3202014-09-14 01:01:54 -0400202 '_FORTIFY_SOURCE=2',
Brian Silvermanaac705c2014-05-01 18:55:34 -0700203 ],
brians343bc112013-02-10 01:53:46 +0000204 'cflags': [
205 '-O3',
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700206 '-fomit-frame-pointer',
brians343bc112013-02-10 01:53:46 +0000207 ],
Brian Silvermanefb993f2013-08-30 19:52:57 -0700208 'ldflags': [
209 '-O3',
210 ],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500211 'conditions': [['PLATFORM=="crio"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700212# Copied from stuff that I think started with the supplied Makefiles.
brians343bc112013-02-10 01:53:46 +0000213 'cflags': [
214 '-fstrength-reduce',
215 '-fno-builtin',
216 '-fno-strict-aliasing',
217 ],
Brian Silverman41abe012014-02-08 18:25:02 -0800218 }],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500219 ['ARCHITECTURE=="amd64"', {
Brian Silverman41abe012014-02-08 18:25:02 -0800220 'cflags': [
Brian Silverman41abe012014-02-08 18:25:02 -0800221 '-fstack-protector-all',
222 ],
223 }],
224 ]
brians343bc112013-02-10 01:53:46 +0000225 }
226 ],
Brian Silverman47cd6f62014-05-03 10:35:52 -0700227 ['OS=="linux" and ARCHITECTURE=="arm" and COMPILER=="gcc" and DEBUG=="yes"', {
Brian Silverman134e5222014-04-27 20:10:05 -0700228 'cflags': [
229 # GCC doesn't like letting us use r7 (which is also the frame
230 # pointer) to pass the syscall number to the kernel even when
231 # it's marked as clobbered.
232 # See <https://bugzilla.mozilla.org/show_bug.cgi?id=633436> for
233 # some more discussion.
234 '-fomit-frame-pointer',
235 ],
236 }
237 ],
Brian Silvermanbae86d62014-09-14 01:05:31 -0400238 ['ARCHITECTURE=="arm" and FULL_COMPILER!="gcc_frc"', {
Brian Silverman10b8a2b2014-09-14 01:04:25 -0400239 'cflags': [
240 '-mcpu=cortex-a8',
241 '-mfpu=neon',
242 ],
243 'ldflags': [
244 '-mcpu=cortex-a8',
245 '-mfpu=neon',
246 ],
247 }],
Brian Silvermanbae86d62014-09-14 01:05:31 -0400248 ['ARCHITECTURE=="arm" and FULL_COMPILER=="gcc_frc"', {
249 'cflags': [
250 '-mcpu=cortex-a9',
251 '-mfpu=neon',
252 '-mfloat-abi=softfp',
253 ],
254 'ldflags': [
255 '-mcpu=cortex-a9',
256 '-mfpu=neon',
257 '-mfloat-abi=softfp',
258 ],
259 }],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500260 ['PLATFORM=="crio"', {
brians343bc112013-02-10 01:53:46 +0000261 'target_conditions': [
262 ['_type=="shared_library"', {
263 'ldflags': [
264 '-r',
265 '-nostdlib',
266 '-Wl,-X',
267 ],
268 }
269 ],
270 ],
271 'ldflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700272 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000273 '-mstrict-align',
274 '-mlongcall',
275 ],
276 'cflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700277 # The Freescale MPC5200B (cRIO-FRC) and MPC5125 (cRIO-FRC II) both
278 # have MPC603e cores according to Freescale docs.
279 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000280 '-mstrict-align',
281 '-mlongcall',
Brian Silverman823f3242013-11-17 13:20:22 -0800282 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/gnu/3.4.4-vxworks-6.3/x86-win32/lib/gcc/powerpc-wrs-vxworks/3.4.4/include/',
283 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/vxworks-6.3/target/h/',
284 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/gnu/3.4.4-vxworks-6.3/x86-win32/include/c++/3.4.4/',
285 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/gnu/3.4.4-vxworks-6.3/x86-win32/include/c++/3.4.4/powerpc-wrs-vxworks/',
brians343bc112013-02-10 01:53:46 +0000286 '-isystem', '<(WIND_BASE)/target/h',
287 '-isystem', '<(WIND_BASE)/target/h/wrn/coreip',
288 ],
Brian Silverman6e206682013-08-31 11:43:35 -0700289 'cflags_cc': [
290 '-std=gnu++0x',
291 ],
brians343bc112013-02-10 01:53:46 +0000292 'defines': [
293 'CPU=PPC603',
294 'TOOL_FAMILY=gnu',
295 'TOOL=gnu',
296 '_WRS_KERNEL',
297 '__PPC__',
Brian Silvermane6bada62014-05-04 16:16:54 -0700298# Prevent the vxworks system headers from being dumb and #defining min and max.
brians343bc112013-02-10 01:53:46 +0000299 'NOMINMAX',
300 ],
Brian Silvermane6bada62014-05-04 16:16:54 -0700301 }, { # 'PLATFORM!="crio"'
brians343bc112013-02-10 01:53:46 +0000302 'target_conditions': [
Brian Silvermane6bada62014-05-04 16:16:54 -0700303# Default to putting outputs into rsync_dir.
brians343bc112013-02-10 01:53:46 +0000304 ['no_rsync==0 and _type!="static_library"', {
305 'product_dir': '<(rsync_dir)',
306 },
307 ],
brians343bc112013-02-10 01:53:46 +0000308 ],
309 'ldflags': [
310 '-pthread',
brians343bc112013-02-10 01:53:46 +0000311 ],
brians343bc112013-02-10 01:53:46 +0000312 'cflags': [
313 '-pthread',
Brian Silverman6e206682013-08-31 11:43:35 -0700314 ],
315 'cflags_cc': [
316 '-std=gnu++11',
brians343bc112013-02-10 01:53:46 +0000317 ],
318 'defines': [
Brian Silvermanefb993f2013-08-30 19:52:57 -0700319 '_FILE_OFFSET_BITS=64',
brians343bc112013-02-10 01:53:46 +0000320 ],
321 'libraries': [
322 '-lm',
323 '-lrt',
324 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700325 'conditions': [
Brian Silvermana29ebf92014-04-23 13:08:49 -0500326 ['COMPILER=="gcc"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700327 'cflags': [
328 '-Wunused-local-typedefs',
329 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700330 'defines': [
331 '__has_feature(n)=0'
332 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700333 },
Brian Silvermana29ebf92014-04-23 13:08:49 -0500334 ], ['COMPILER=="clang"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700335 'cflags': [
336 '-fcolor-diagnostics',
Brian Silvermane6bada62014-05-04 16:16:54 -0700337 '-fmessage-length=80',
Brian Silvermanad09fd72014-08-14 23:38:36 -0700338 '-fmacro-backtrace-limit=0',
Brian Silverman79723eb2014-04-21 22:05:11 -0700339 ],
340 'defines': [
Brian Silverman79723eb2014-04-21 22:05:11 -0700341 # This tells clang's optimizer the same thing.
Brian Silvermanbbeed502014-08-14 23:19:15 -0700342 '__builtin_assume_aligned(p, a)=({ const typeof(p) my_p_ = (p); ((((uintptr_t)my_p_ % (a)) == 0u) ? my_p_ : (__builtin_unreachable(), (my_p_))); })',
Brian Silverman79723eb2014-04-21 22:05:11 -0700343 ],
344 },
345 ],
346 ],
brians343bc112013-02-10 01:53:46 +0000347 }
348 ]
349 ],
350 },
351}