blob: 046d59b4aa3aab6867a961e63459dd79ebc00264 [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 Silvermana29ebf92014-04-23 13:08:49 -050031 ], ['PLATFORM=="linux-arm-gcc"', {
Brian Silverman79723eb2014-04-21 22:05:11 -070032 'make_global_settings': [
Brian Silvermand3fac732014-05-03 16:03:46 -070033 ['CC', '<(ccache)<!(which arm-linux-gnueabihf-gcc-4.7)'],
34 ['CXX', '<(ccache)<!(which arm-linux-gnueabihf-g++-4.7)'],
Brian Silverman79723eb2014-04-21 22:05:11 -070035 ],
36 },
Brian Silvermana29ebf92014-04-23 13:08:49 -050037 ], ['PLATFORM=="linux-arm-clang"', {
Brian Silvermana8c04522014-04-27 20:03:08 -070038 'variables': {
39 'arm-clang-symlinks': '<!(realpath -s <(AOS)/build/arm-clang-symlinks)',
40 'arm-clang-sysroot': '<(arm-clang-symlinks)/sysroot',
Brian Silvermane6bada62014-05-04 16:16:54 -070041# Flags that should be passed to all compile/link/etc commands.
Brian Silvermana8c04522014-04-27 20:03:08 -070042 'platflags': [
43 '-target', 'armv7a-linux-gnueabihf',
44 '-mfloat-abi=hard',
Brian Silvermana8c04522014-04-27 20:03:08 -070045 '--sysroot=<(arm-clang-sysroot)',
46
Brian Silvermane6bada62014-05-04 16:16:54 -070047 # TODO(brians): See if it will run with this enabled.
Brian Silvermana8c04522014-04-27 20:03:08 -070048 #-mhwdiv=arm,thumb
49 ],
50 },
51 'make_global_settings': [
Brian Silvermand3fac732014-05-03 16:03:46 -070052 ['CC', '<(ccache)<(arm-clang-symlinks)/bin/clang'],
53 ['CXX', '<(ccache)<(arm-clang-symlinks)/bin/clang++'],
Brian Silvermana8c04522014-04-27 20:03:08 -070054 ],
55 'target_defaults': {
56 'cflags': [
Brian Silvermana8c04522014-04-27 20:03:08 -070057 '<@(platflags)',
58 ],
Brian Silverman34d25f22014-05-01 13:30:56 -070059 'cflags_cc': [
60 '-isystem', '<(arm-clang-sysroot)/usr/include/c++/4.7.2',
61 '-isystem', '<(arm-clang-sysroot)/usr/include/c++/4.7.2/arm-linux-gnueabihf',
62 ],
Brian Silvermana8c04522014-04-27 20:03:08 -070063 'ldflags': [
64 '<@(platflags)',
65 ],
66 },
Brian Silverman79723eb2014-04-21 22:05:11 -070067 },
68 ], ['PLATFORM=="linux-amd64-clang"', {
69 'make_global_settings': [
Brian Silvermand3fac732014-05-03 16:03:46 -070070 ['CC', '<(ccache)/opt/clang-3.5/bin/clang'],
71 ['CXX', '<(ccache)/opt/clang-3.5/bin/clang++'],
Brian Silverman79723eb2014-04-21 22:05:11 -070072 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -070073 },
74 ], ['PLATFORM=="linux-amd64-gcc"', {
Brian Silvermand3fac732014-05-03 16:03:46 -070075 'make_global_settings': [
Brian Silverman9b7a6842014-05-05 16:19:11 -070076 ['CC', '<(ccache)<!(which gcc-4.7)'],
77 ['CXX', '<(ccache)<!(which g++-4.7)'],
Brian Silvermand3fac732014-05-03 16:03:46 -070078 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -070079 },
Brian Silverman47cd6f62014-05-03 10:35:52 -070080 ], ['PLATFORM=="linux-amd64-gcc_4.8"', {
81 'make_global_settings': [
Brian Silvermand3fac732014-05-03 16:03:46 -070082 ['CC', '<(ccache)/opt/clang-3.5/bin/gcc'],
83 ['CXX', '<(ccache)/opt/clang-3.5/bin/g++'],
Brian Silverman47cd6f62014-05-03 10:35:52 -070084 ],
85 },
Brian Silvermanf0d3c782014-05-02 23:56:32 -070086 ], ['SANITIZER!="none"', {
Brian Silvermana4aff562014-05-02 17:43:50 -070087 'target_defaults': {
88 'cflags': [
Brian Silvermanf0d3c782014-05-02 23:56:32 -070089 '-fsanitize=<(SANITIZER)',
Brian Silvermana4aff562014-05-02 17:43:50 -070090 ],
91 'ldflags': [
Brian Silvermanf0d3c782014-05-02 23:56:32 -070092 '-fsanitize=<(SANITIZER)',
Brian Silvermana4aff562014-05-02 17:43:50 -070093 ],
Brian Silverman889f85e2014-09-05 11:39:09 -040094 'defines': [
95# GCC doesn't have __has_feature, so we have to use this instead.
96 'AOS_SANITIZER_<(SANITIZER)',
97 ],
Brian Silvermana4aff562014-05-02 17:43:50 -070098 },
Brian Silverman79723eb2014-04-21 22:05:11 -070099 },
Brian Silverman1294c082014-05-20 17:02:29 -0700100 ], ['SANITIZER!="none" and COMPILER!="gcc"', {
101 'target_defaults': {
102 'cflags': [
103 '-fno-sanitize-recover',
104 '-fno-sanitize=<!(echo <(disable_sanitizers) | sed "s/ /,/g")',
105 ],
106 },
107 },
Brian Silverman99895b92014-09-14 01:01:15 -0400108 ], ['EXTERNALS_EXTRA=="-fPIE"', {
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700109 'target_defaults': {
110 'cflags': [
Brian Silverman47cd6f62014-05-03 10:35:52 -0700111 '-fPIE',
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700112 ],
113 'ldflags': [
Brian Silverman47cd6f62014-05-03 10:35:52 -0700114 '-fPIE',
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700115 ],
Brian Silverman47cd6f62014-05-03 10:35:52 -0700116 'link_settings': {
117 'ldflags': [
118 '-pie',
119 ],
120 },
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700121 },
122 },
123 ], ['SANITIZER=="memory"', {
124 'target_defaults': {
125 'cflags': [
126 '-fsanitize-memory-track-origins',
127 ],
128 'ldflags': [
129 '-fsanitize-memory-track-origins',
130 ],
131 },
Brian Silverman79723eb2014-04-21 22:05:11 -0700132 },
brians343bc112013-02-10 01:53:46 +0000133 ],
134 ],
135 'target_defaults': {
136 'defines': [
137 '__STDC_FORMAT_MACROS',
Brian Silverman6137a502013-04-22 15:41:36 -0700138 '__STDC_CONSTANT_MACROS',
139 '__STDC_LIMIT_MACROS',
brians343bc112013-02-10 01:53:46 +0000140 ],
141 'ldflags': [
142 '-pipe',
143 ],
144 'cflags': [
145 '-pipe',
146
147 '-Wall',
148 '-Wextra',
149 '-Wswitch-enum',
150 '-Wpointer-arith',
151 '-Wstrict-aliasing=2',
152 '-Wcast-qual',
153 '-Wcast-align',
154 '-Wwrite-strings',
155 '-Wtype-limits',
156 '-Wsign-compare',
157 '-Wformat=2',
158 '-Werror',
Brian Silverman9ba2bc42013-03-17 14:18:33 -0700159
160 '-ggdb3',
brians343bc112013-02-10 01:53:46 +0000161 ],
162 'cflags_c': [
163 '-std=gnu99',
164 ],
brians343bc112013-02-10 01:53:46 +0000165 'include_dirs': [
166 '<(DEPTH)',
167 ],
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700168 # These have to be here because apparently gyp evaluates target_conditions
169 # even if the target is never used.
170 'variables': {
171 # Set this to 1 to disable rsyncing the file to the target.
172 'no_rsync%': 0,
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700173 # Set this to 1 if this file is a test that should not be run by
Brian Silvermanb3d50542014-04-23 14:28:55 -0500174 # `build.py tests`.
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700175 'is_special_test%': 0,
176 },
brians343bc112013-02-10 01:53:46 +0000177 'conditions': [
178 ['DEBUG=="yes"', {
Brian Silvermanaac705c2014-05-01 18:55:34 -0700179 'defines': [
180 'AOS_DEBUG=1',
181 ],
Brian Silverman266811f2014-05-03 22:48:04 -0700182 'conditions': [['SANITIZER=="none"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700183 'cflags': [
184 '-O0',
185 ],
186 }, {
187 'cflags': [
188 '-O1',
189 ],
190 }
191 ]],
192 }, { # 'DEBUG=="no"'
Brian Silvermanaac705c2014-05-01 18:55:34 -0700193 'defines': [
194 'AOS_DEBUG=0',
Brian Silverman3b6d3202014-09-14 01:01:54 -0400195 '_FORTIFY_SOURCE=2',
Brian Silvermanaac705c2014-05-01 18:55:34 -0700196 ],
brians343bc112013-02-10 01:53:46 +0000197 'cflags': [
198 '-O3',
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700199 '-fomit-frame-pointer',
brians343bc112013-02-10 01:53:46 +0000200 ],
Brian Silvermanefb993f2013-08-30 19:52:57 -0700201 'ldflags': [
202 '-O3',
203 ],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500204 'conditions': [['PLATFORM=="crio"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700205# Copied from stuff that I think started with the supplied Makefiles.
brians343bc112013-02-10 01:53:46 +0000206 'cflags': [
207 '-fstrength-reduce',
208 '-fno-builtin',
209 '-fno-strict-aliasing',
210 ],
Brian Silverman41abe012014-02-08 18:25:02 -0800211 }],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500212 ['ARCHITECTURE=="amd64"', {
Brian Silverman41abe012014-02-08 18:25:02 -0800213 'cflags': [
Brian Silverman41abe012014-02-08 18:25:02 -0800214 '-fstack-protector-all',
215 ],
216 }],
217 ]
brians343bc112013-02-10 01:53:46 +0000218 }
219 ],
Brian Silverman47cd6f62014-05-03 10:35:52 -0700220 ['OS=="linux" and ARCHITECTURE=="arm" and COMPILER=="gcc" and DEBUG=="yes"', {
Brian Silverman134e5222014-04-27 20:10:05 -0700221 'cflags': [
222 # GCC doesn't like letting us use r7 (which is also the frame
223 # pointer) to pass the syscall number to the kernel even when
224 # it's marked as clobbered.
225 # See <https://bugzilla.mozilla.org/show_bug.cgi?id=633436> for
226 # some more discussion.
227 '-fomit-frame-pointer',
228 ],
229 }
230 ],
Brian Silverman10b8a2b2014-09-14 01:04:25 -0400231 ['ARCHITECTURE=="arm"', {
232 'cflags': [
233 '-mcpu=cortex-a8',
234 '-mfpu=neon',
235 ],
236 'ldflags': [
237 '-mcpu=cortex-a8',
238 '-mfpu=neon',
239 ],
240 }],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500241 ['PLATFORM=="crio"', {
brians343bc112013-02-10 01:53:46 +0000242 'target_conditions': [
243 ['_type=="shared_library"', {
244 'ldflags': [
245 '-r',
246 '-nostdlib',
247 '-Wl,-X',
248 ],
249 }
250 ],
251 ],
252 'ldflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700253 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000254 '-mstrict-align',
255 '-mlongcall',
256 ],
257 'cflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700258 # The Freescale MPC5200B (cRIO-FRC) and MPC5125 (cRIO-FRC II) both
259 # have MPC603e cores according to Freescale docs.
260 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000261 '-mstrict-align',
262 '-mlongcall',
Brian Silverman823f3242013-11-17 13:20:22 -0800263 '-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/',
264 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/vxworks-6.3/target/h/',
265 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/gnu/3.4.4-vxworks-6.3/x86-win32/include/c++/3.4.4/',
266 '-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 +0000267 '-isystem', '<(WIND_BASE)/target/h',
268 '-isystem', '<(WIND_BASE)/target/h/wrn/coreip',
269 ],
Brian Silverman6e206682013-08-31 11:43:35 -0700270 'cflags_cc': [
271 '-std=gnu++0x',
272 ],
brians343bc112013-02-10 01:53:46 +0000273 'defines': [
274 'CPU=PPC603',
275 'TOOL_FAMILY=gnu',
276 'TOOL=gnu',
277 '_WRS_KERNEL',
278 '__PPC__',
Brian Silvermane6bada62014-05-04 16:16:54 -0700279# Prevent the vxworks system headers from being dumb and #defining min and max.
brians343bc112013-02-10 01:53:46 +0000280 'NOMINMAX',
281 ],
Brian Silvermane6bada62014-05-04 16:16:54 -0700282 }, { # 'PLATFORM!="crio"'
brians343bc112013-02-10 01:53:46 +0000283 'target_conditions': [
Brian Silvermane6bada62014-05-04 16:16:54 -0700284# Default to putting outputs into rsync_dir.
brians343bc112013-02-10 01:53:46 +0000285 ['no_rsync==0 and _type!="static_library"', {
286 'product_dir': '<(rsync_dir)',
287 },
288 ],
brians343bc112013-02-10 01:53:46 +0000289 ],
290 'ldflags': [
291 '-pthread',
brians343bc112013-02-10 01:53:46 +0000292 ],
brians343bc112013-02-10 01:53:46 +0000293 'cflags': [
294 '-pthread',
Brian Silverman6e206682013-08-31 11:43:35 -0700295 ],
296 'cflags_cc': [
297 '-std=gnu++11',
brians343bc112013-02-10 01:53:46 +0000298 ],
299 'defines': [
Brian Silvermanefb993f2013-08-30 19:52:57 -0700300 '_FILE_OFFSET_BITS=64',
brians343bc112013-02-10 01:53:46 +0000301 ],
302 'libraries': [
303 '-lm',
304 '-lrt',
305 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700306 'conditions': [
Brian Silvermana29ebf92014-04-23 13:08:49 -0500307 ['COMPILER=="gcc"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700308 'cflags': [
309 '-Wunused-local-typedefs',
310 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700311 'defines': [
312 '__has_feature(n)=0'
313 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700314 },
Brian Silvermana29ebf92014-04-23 13:08:49 -0500315 ], ['COMPILER=="clang"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700316 'cflags': [
317 '-fcolor-diagnostics',
Brian Silvermane6bada62014-05-04 16:16:54 -0700318 '-fmessage-length=80',
Brian Silvermanad09fd72014-08-14 23:38:36 -0700319 '-fmacro-backtrace-limit=0',
Brian Silverman79723eb2014-04-21 22:05:11 -0700320 ],
321 'defines': [
Brian Silverman79723eb2014-04-21 22:05:11 -0700322 # This tells clang's optimizer the same thing.
Brian Silvermanbbeed502014-08-14 23:19:15 -0700323 '__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 -0700324 ],
325 },
326 ],
327 ],
brians343bc112013-02-10 01:53:46 +0000328 }
329 ]
330 ],
331 },
332}