blob: 2051d63f792d29d5f25d7b87f04a0a48dda5a0d3 [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 Silvermanabe55a02014-12-29 21:36:17 -0800114 ], ['SANITIZER!="thread"', {
115 'libraries': [
116 '<!(readlink -f <(AOS)/../output/compiled-<(ARCHITECTURE)<(EXTERNALS_EXTRA)/gperftools-2.3-prefix/lib/libtcmalloc.a)',
117 '<!(readlink -f <(AOS)/../output/compiled-<(ARCHITECTURE)<(EXTERNALS_EXTRA)/libunwind-1.1-prefix/lib/libunwind.a)',
118 ],
119 },
Brian Silverman99895b92014-09-14 01:01:15 -0400120 ], ['EXTERNALS_EXTRA=="-fPIE"', {
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700121 'target_defaults': {
122 'cflags': [
Brian Silverman47cd6f62014-05-03 10:35:52 -0700123 '-fPIE',
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700124 ],
125 'ldflags': [
Brian Silverman47cd6f62014-05-03 10:35:52 -0700126 '-fPIE',
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700127 ],
Brian Silverman47cd6f62014-05-03 10:35:52 -0700128 'link_settings': {
129 'ldflags': [
130 '-pie',
131 ],
132 },
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700133 },
134 },
135 ], ['SANITIZER=="memory"', {
136 'target_defaults': {
137 'cflags': [
138 '-fsanitize-memory-track-origins',
139 ],
140 'ldflags': [
141 '-fsanitize-memory-track-origins',
142 ],
143 },
Brian Silverman79723eb2014-04-21 22:05:11 -0700144 },
brians343bc112013-02-10 01:53:46 +0000145 ],
146 ],
147 'target_defaults': {
148 'defines': [
149 '__STDC_FORMAT_MACROS',
Brian Silverman6137a502013-04-22 15:41:36 -0700150 '__STDC_CONSTANT_MACROS',
151 '__STDC_LIMIT_MACROS',
Austin Schuhc9b0a9d2014-10-25 18:02:21 -0700152 'AOS_COMPILER_<!(echo <(FULL_COMPILER) | sed \'s/\./_/g\')',
brians343bc112013-02-10 01:53:46 +0000153 ],
154 'ldflags': [
155 '-pipe',
156 ],
157 'cflags': [
158 '-pipe',
159
160 '-Wall',
161 '-Wextra',
162 '-Wswitch-enum',
163 '-Wpointer-arith',
164 '-Wstrict-aliasing=2',
165 '-Wcast-qual',
166 '-Wcast-align',
167 '-Wwrite-strings',
168 '-Wtype-limits',
169 '-Wsign-compare',
170 '-Wformat=2',
171 '-Werror',
Brian Silverman9ba2bc42013-03-17 14:18:33 -0700172
173 '-ggdb3',
brians343bc112013-02-10 01:53:46 +0000174 ],
175 'cflags_c': [
176 '-std=gnu99',
177 ],
brians343bc112013-02-10 01:53:46 +0000178 'include_dirs': [
179 '<(DEPTH)',
180 ],
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700181 # These have to be here because apparently gyp evaluates target_conditions
182 # even if the target is never used.
183 'variables': {
184 # Set this to 1 to disable rsyncing the file to the target.
185 'no_rsync%': 0,
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700186 # Set this to 1 if this file is a test that should not be run by
Brian Silvermanb3d50542014-04-23 14:28:55 -0500187 # `build.py tests`.
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700188 'is_special_test%': 0,
189 },
brians343bc112013-02-10 01:53:46 +0000190 'conditions': [
191 ['DEBUG=="yes"', {
Brian Silvermanaac705c2014-05-01 18:55:34 -0700192 'defines': [
193 'AOS_DEBUG=1',
194 ],
Brian Silverman266811f2014-05-03 22:48:04 -0700195 'conditions': [['SANITIZER=="none"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700196 'cflags': [
197 '-O0',
198 ],
199 }, {
200 'cflags': [
201 '-O1',
202 ],
203 }
204 ]],
205 }, { # 'DEBUG=="no"'
Brian Silvermanaac705c2014-05-01 18:55:34 -0700206 'defines': [
207 'AOS_DEBUG=0',
Brian Silverman3b6d3202014-09-14 01:01:54 -0400208 '_FORTIFY_SOURCE=2',
Brian Silvermanaac705c2014-05-01 18:55:34 -0700209 ],
brians343bc112013-02-10 01:53:46 +0000210 'cflags': [
211 '-O3',
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700212 '-fomit-frame-pointer',
brians343bc112013-02-10 01:53:46 +0000213 ],
Brian Silvermanefb993f2013-08-30 19:52:57 -0700214 'ldflags': [
215 '-O3',
216 ],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500217 'conditions': [['PLATFORM=="crio"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700218# Copied from stuff that I think started with the supplied Makefiles.
brians343bc112013-02-10 01:53:46 +0000219 'cflags': [
220 '-fstrength-reduce',
221 '-fno-builtin',
222 '-fno-strict-aliasing',
223 ],
Brian Silverman41abe012014-02-08 18:25:02 -0800224 }],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500225 ['ARCHITECTURE=="amd64"', {
Brian Silverman41abe012014-02-08 18:25:02 -0800226 'cflags': [
Brian Silverman41abe012014-02-08 18:25:02 -0800227 '-fstack-protector-all',
228 ],
229 }],
230 ]
brians343bc112013-02-10 01:53:46 +0000231 }
232 ],
Brian Silverman47cd6f62014-05-03 10:35:52 -0700233 ['OS=="linux" and ARCHITECTURE=="arm" and COMPILER=="gcc" and DEBUG=="yes"', {
Brian Silverman134e5222014-04-27 20:10:05 -0700234 'cflags': [
235 # GCC doesn't like letting us use r7 (which is also the frame
236 # pointer) to pass the syscall number to the kernel even when
237 # it's marked as clobbered.
238 # See <https://bugzilla.mozilla.org/show_bug.cgi?id=633436> for
239 # some more discussion.
240 '-fomit-frame-pointer',
241 ],
242 }
243 ],
Brian Silvermanbae86d62014-09-14 01:05:31 -0400244 ['ARCHITECTURE=="arm" and FULL_COMPILER!="gcc_frc"', {
Brian Silverman10b8a2b2014-09-14 01:04:25 -0400245 'cflags': [
246 '-mcpu=cortex-a8',
247 '-mfpu=neon',
248 ],
249 'ldflags': [
250 '-mcpu=cortex-a8',
251 '-mfpu=neon',
252 ],
253 }],
Brian Silvermanbae86d62014-09-14 01:05:31 -0400254 ['ARCHITECTURE=="arm" and FULL_COMPILER=="gcc_frc"', {
255 'cflags': [
256 '-mcpu=cortex-a9',
257 '-mfpu=neon',
258 '-mfloat-abi=softfp',
259 ],
260 'ldflags': [
261 '-mcpu=cortex-a9',
262 '-mfpu=neon',
263 '-mfloat-abi=softfp',
264 ],
265 }],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500266 ['PLATFORM=="crio"', {
brians343bc112013-02-10 01:53:46 +0000267 'target_conditions': [
268 ['_type=="shared_library"', {
269 'ldflags': [
270 '-r',
271 '-nostdlib',
272 '-Wl,-X',
273 ],
274 }
275 ],
276 ],
277 'ldflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700278 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000279 '-mstrict-align',
280 '-mlongcall',
281 ],
282 'cflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700283 # The Freescale MPC5200B (cRIO-FRC) and MPC5125 (cRIO-FRC II) both
284 # have MPC603e cores according to Freescale docs.
285 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000286 '-mstrict-align',
287 '-mlongcall',
Brian Silverman823f3242013-11-17 13:20:22 -0800288 '-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/',
289 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/vxworks-6.3/target/h/',
290 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/gnu/3.4.4-vxworks-6.3/x86-win32/include/c++/3.4.4/',
291 '-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 +0000292 '-isystem', '<(WIND_BASE)/target/h',
293 '-isystem', '<(WIND_BASE)/target/h/wrn/coreip',
294 ],
Brian Silverman6e206682013-08-31 11:43:35 -0700295 'cflags_cc': [
296 '-std=gnu++0x',
297 ],
brians343bc112013-02-10 01:53:46 +0000298 'defines': [
299 'CPU=PPC603',
300 'TOOL_FAMILY=gnu',
301 'TOOL=gnu',
302 '_WRS_KERNEL',
303 '__PPC__',
Brian Silvermane6bada62014-05-04 16:16:54 -0700304# Prevent the vxworks system headers from being dumb and #defining min and max.
brians343bc112013-02-10 01:53:46 +0000305 'NOMINMAX',
306 ],
Brian Silvermane6bada62014-05-04 16:16:54 -0700307 }, { # 'PLATFORM!="crio"'
brians343bc112013-02-10 01:53:46 +0000308 'target_conditions': [
Brian Silvermane6bada62014-05-04 16:16:54 -0700309# Default to putting outputs into rsync_dir.
brians343bc112013-02-10 01:53:46 +0000310 ['no_rsync==0 and _type!="static_library"', {
311 'product_dir': '<(rsync_dir)',
312 },
313 ],
brians343bc112013-02-10 01:53:46 +0000314 ],
315 'ldflags': [
316 '-pthread',
brians343bc112013-02-10 01:53:46 +0000317 ],
brians343bc112013-02-10 01:53:46 +0000318 'cflags': [
319 '-pthread',
Brian Silverman6e206682013-08-31 11:43:35 -0700320 ],
321 'cflags_cc': [
322 '-std=gnu++11',
brians343bc112013-02-10 01:53:46 +0000323 ],
324 'defines': [
Brian Silvermanefb993f2013-08-30 19:52:57 -0700325 '_FILE_OFFSET_BITS=64',
brians343bc112013-02-10 01:53:46 +0000326 ],
327 'libraries': [
328 '-lm',
329 '-lrt',
330 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700331 'conditions': [
Brian Silvermana29ebf92014-04-23 13:08:49 -0500332 ['COMPILER=="gcc"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700333 'cflags': [
334 '-Wunused-local-typedefs',
335 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700336 'defines': [
337 '__has_feature(n)=0'
338 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700339 },
Brian Silvermana29ebf92014-04-23 13:08:49 -0500340 ], ['COMPILER=="clang"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700341 'cflags': [
342 '-fcolor-diagnostics',
Brian Silvermane6bada62014-05-04 16:16:54 -0700343 '-fmessage-length=80',
Brian Silvermanad09fd72014-08-14 23:38:36 -0700344 '-fmacro-backtrace-limit=0',
Brian Silverman79723eb2014-04-21 22:05:11 -0700345 ],
346 'defines': [
Brian Silverman79723eb2014-04-21 22:05:11 -0700347 # This tells clang's optimizer the same thing.
Brian Silvermanbbeed502014-08-14 23:19:15 -0700348 '__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 -0700349 ],
350 },
351 ],
352 ],
brians343bc112013-02-10 01:53:46 +0000353 }
354 ]
355 ],
356 },
357}