blob: f6fefd5c64e8c81d1434c305c6e90fde9a7aed01 [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 ],
94 },
Brian Silverman79723eb2014-04-21 22:05:11 -070095 },
Brian Silverman1294c082014-05-20 17:02:29 -070096 ], ['SANITIZER!="none" and COMPILER!="gcc"', {
97 'target_defaults': {
98 'cflags': [
99 '-fno-sanitize-recover',
100 '-fno-sanitize=<!(echo <(disable_sanitizers) | sed "s/ /,/g")',
101 ],
102 },
103 },
Brian Silvermana5301e32014-05-03 10:51:49 -0700104 ], ['SANITIZER_FPIE!=""', {
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700105 'target_defaults': {
106 'cflags': [
Brian Silverman47cd6f62014-05-03 10:35:52 -0700107 '-fPIE',
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700108 ],
109 'ldflags': [
Brian Silverman47cd6f62014-05-03 10:35:52 -0700110 '-fPIE',
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700111 ],
Brian Silverman47cd6f62014-05-03 10:35:52 -0700112 'link_settings': {
113 'ldflags': [
114 '-pie',
115 ],
116 },
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700117 },
118 },
119 ], ['SANITIZER=="memory"', {
120 'target_defaults': {
121 'cflags': [
122 '-fsanitize-memory-track-origins',
123 ],
124 'ldflags': [
125 '-fsanitize-memory-track-origins',
126 ],
127 },
Brian Silverman79723eb2014-04-21 22:05:11 -0700128 },
brians343bc112013-02-10 01:53:46 +0000129 ],
130 ],
131 'target_defaults': {
132 'defines': [
133 '__STDC_FORMAT_MACROS',
Brian Silverman6137a502013-04-22 15:41:36 -0700134 '__STDC_CONSTANT_MACROS',
135 '__STDC_LIMIT_MACROS',
Brian Silvermane6bada62014-05-04 16:16:54 -0700136 '_FORTIFY_SOURCE=2',
brians343bc112013-02-10 01:53:46 +0000137 ],
138 'ldflags': [
139 '-pipe',
140 ],
141 'cflags': [
142 '-pipe',
143
144 '-Wall',
145 '-Wextra',
146 '-Wswitch-enum',
147 '-Wpointer-arith',
148 '-Wstrict-aliasing=2',
149 '-Wcast-qual',
150 '-Wcast-align',
151 '-Wwrite-strings',
152 '-Wtype-limits',
153 '-Wsign-compare',
154 '-Wformat=2',
155 '-Werror',
Brian Silverman9ba2bc42013-03-17 14:18:33 -0700156
157 '-ggdb3',
brians343bc112013-02-10 01:53:46 +0000158 ],
159 'cflags_c': [
160 '-std=gnu99',
161 ],
brians343bc112013-02-10 01:53:46 +0000162 'include_dirs': [
163 '<(DEPTH)',
164 ],
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700165 # These have to be here because apparently gyp evaluates target_conditions
166 # even if the target is never used.
167 'variables': {
168 # Set this to 1 to disable rsyncing the file to the target.
169 'no_rsync%': 0,
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700170 # Set this to 1 if this file is a test that should not be run by
Brian Silvermanb3d50542014-04-23 14:28:55 -0500171 # `build.py tests`.
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700172 'is_special_test%': 0,
173 },
brians343bc112013-02-10 01:53:46 +0000174 'conditions': [
175 ['DEBUG=="yes"', {
Brian Silvermanaac705c2014-05-01 18:55:34 -0700176 'defines': [
177 'AOS_DEBUG=1',
178 ],
Brian Silverman266811f2014-05-03 22:48:04 -0700179 'conditions': [['SANITIZER=="none"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700180 'cflags': [
181 '-O0',
182 ],
183 }, {
184 'cflags': [
185 '-O1',
186 ],
187 }
188 ]],
189 }, { # 'DEBUG=="no"'
Brian Silvermanaac705c2014-05-01 18:55:34 -0700190 'defines': [
191 'AOS_DEBUG=0',
192 ],
brians343bc112013-02-10 01:53:46 +0000193 'cflags': [
194 '-O3',
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700195 '-fomit-frame-pointer',
brians343bc112013-02-10 01:53:46 +0000196 ],
Brian Silvermanefb993f2013-08-30 19:52:57 -0700197 'ldflags': [
198 '-O3',
199 ],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500200 'conditions': [['PLATFORM=="crio"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700201# Copied from stuff that I think started with the supplied Makefiles.
brians343bc112013-02-10 01:53:46 +0000202 'cflags': [
203 '-fstrength-reduce',
204 '-fno-builtin',
205 '-fno-strict-aliasing',
206 ],
Brian Silverman41abe012014-02-08 18:25:02 -0800207 }],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500208 ['ARCHITECTURE=="arm"', {
brians343bc112013-02-10 01:53:46 +0000209 'cflags': [
Brian Silvermanc4321322013-11-18 17:38:39 -0800210 '-mcpu=cortex-a8',
Brian Silverman46203612013-11-19 18:01:41 -0800211 '-mfpu=neon',
brians343bc112013-02-10 01:53:46 +0000212 ],
Brian Silverman41abe012014-02-08 18:25:02 -0800213 }],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500214 ['ARCHITECTURE=="amd64"', {
Brian Silverman41abe012014-02-08 18:25:02 -0800215 'cflags': [
Brian Silverman41abe012014-02-08 18:25:02 -0800216 '-fstack-protector-all',
217 ],
218 }],
219 ]
brians343bc112013-02-10 01:53:46 +0000220 }
221 ],
Brian Silverman47cd6f62014-05-03 10:35:52 -0700222 ['OS=="linux" and ARCHITECTURE=="arm" and COMPILER=="gcc" and DEBUG=="yes"', {
Brian Silverman134e5222014-04-27 20:10:05 -0700223 'cflags': [
224 # GCC doesn't like letting us use r7 (which is also the frame
225 # pointer) to pass the syscall number to the kernel even when
226 # it's marked as clobbered.
227 # See <https://bugzilla.mozilla.org/show_bug.cgi?id=633436> for
228 # some more discussion.
229 '-fomit-frame-pointer',
230 ],
231 }
232 ],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500233 ['PLATFORM=="crio"', {
brians343bc112013-02-10 01:53:46 +0000234 'target_conditions': [
235 ['_type=="shared_library"', {
236 'ldflags': [
237 '-r',
238 '-nostdlib',
239 '-Wl,-X',
240 ],
241 }
242 ],
243 ],
244 'ldflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700245 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000246 '-mstrict-align',
247 '-mlongcall',
248 ],
249 'cflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700250 # The Freescale MPC5200B (cRIO-FRC) and MPC5125 (cRIO-FRC II) both
251 # have MPC603e cores according to Freescale docs.
252 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000253 '-mstrict-align',
254 '-mlongcall',
Brian Silverman823f3242013-11-17 13:20:22 -0800255 '-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/',
256 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/vxworks-6.3/target/h/',
257 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/gnu/3.4.4-vxworks-6.3/x86-win32/include/c++/3.4.4/',
258 '-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 +0000259 '-isystem', '<(WIND_BASE)/target/h',
260 '-isystem', '<(WIND_BASE)/target/h/wrn/coreip',
261 ],
Brian Silverman6e206682013-08-31 11:43:35 -0700262 'cflags_cc': [
263 '-std=gnu++0x',
264 ],
brians343bc112013-02-10 01:53:46 +0000265 'defines': [
266 'CPU=PPC603',
267 'TOOL_FAMILY=gnu',
268 'TOOL=gnu',
269 '_WRS_KERNEL',
270 '__PPC__',
Brian Silvermane6bada62014-05-04 16:16:54 -0700271# Prevent the vxworks system headers from being dumb and #defining min and max.
brians343bc112013-02-10 01:53:46 +0000272 'NOMINMAX',
273 ],
Brian Silvermane6bada62014-05-04 16:16:54 -0700274 }, { # 'PLATFORM!="crio"'
brians343bc112013-02-10 01:53:46 +0000275 'target_conditions': [
Brian Silvermane6bada62014-05-04 16:16:54 -0700276# Default to putting outputs into rsync_dir.
brians343bc112013-02-10 01:53:46 +0000277 ['no_rsync==0 and _type!="static_library"', {
278 'product_dir': '<(rsync_dir)',
279 },
280 ],
brians343bc112013-02-10 01:53:46 +0000281 ],
282 'ldflags': [
283 '-pthread',
brians343bc112013-02-10 01:53:46 +0000284 ],
brians343bc112013-02-10 01:53:46 +0000285 'cflags': [
286 '-pthread',
Brian Silverman6e206682013-08-31 11:43:35 -0700287 ],
288 'cflags_cc': [
289 '-std=gnu++11',
brians343bc112013-02-10 01:53:46 +0000290 ],
291 'defines': [
Brian Silvermanefb993f2013-08-30 19:52:57 -0700292 '_FILE_OFFSET_BITS=64',
brians343bc112013-02-10 01:53:46 +0000293 ],
294 'libraries': [
295 '-lm',
296 '-lrt',
297 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700298 'conditions': [
Brian Silvermana29ebf92014-04-23 13:08:49 -0500299 ['COMPILER=="gcc"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700300 'cflags': [
301 '-Wunused-local-typedefs',
302 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700303 'defines': [
304 '__has_feature(n)=0'
305 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700306 },
Brian Silvermana29ebf92014-04-23 13:08:49 -0500307 ], ['COMPILER=="clang"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700308 'cflags': [
309 '-fcolor-diagnostics',
Brian Silvermane6bada62014-05-04 16:16:54 -0700310 '-fmessage-length=80',
Brian Silverman79723eb2014-04-21 22:05:11 -0700311 ],
312 'defines': [
Brian Silverman79723eb2014-04-21 22:05:11 -0700313 # This tells clang's optimizer the same thing.
Brian Silvermanbbeed502014-08-14 23:19:15 -0700314 '__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 -0700315 ],
316 },
317 ],
318 ],
brians343bc112013-02-10 01:53:46 +0000319 }
320 ]
321 ],
322 },
323}