blob: a061a662c4c6e7f053aa27af61ea6942c3ab0a8b [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=="arm"', {
brians343bc112013-02-10 01:53:46 +0000213 'cflags': [
Brian Silvermanc4321322013-11-18 17:38:39 -0800214 '-mcpu=cortex-a8',
Brian Silverman46203612013-11-19 18:01:41 -0800215 '-mfpu=neon',
brians343bc112013-02-10 01:53:46 +0000216 ],
Brian Silverman41abe012014-02-08 18:25:02 -0800217 }],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500218 ['ARCHITECTURE=="amd64"', {
Brian Silverman41abe012014-02-08 18:25:02 -0800219 'cflags': [
Brian Silverman41abe012014-02-08 18:25:02 -0800220 '-fstack-protector-all',
221 ],
222 }],
223 ]
brians343bc112013-02-10 01:53:46 +0000224 }
225 ],
Brian Silverman47cd6f62014-05-03 10:35:52 -0700226 ['OS=="linux" and ARCHITECTURE=="arm" and COMPILER=="gcc" and DEBUG=="yes"', {
Brian Silverman134e5222014-04-27 20:10:05 -0700227 'cflags': [
228 # GCC doesn't like letting us use r7 (which is also the frame
229 # pointer) to pass the syscall number to the kernel even when
230 # it's marked as clobbered.
231 # See <https://bugzilla.mozilla.org/show_bug.cgi?id=633436> for
232 # some more discussion.
233 '-fomit-frame-pointer',
234 ],
235 }
236 ],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500237 ['PLATFORM=="crio"', {
brians343bc112013-02-10 01:53:46 +0000238 'target_conditions': [
239 ['_type=="shared_library"', {
240 'ldflags': [
241 '-r',
242 '-nostdlib',
243 '-Wl,-X',
244 ],
245 }
246 ],
247 ],
248 'ldflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700249 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000250 '-mstrict-align',
251 '-mlongcall',
252 ],
253 'cflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700254 # The Freescale MPC5200B (cRIO-FRC) and MPC5125 (cRIO-FRC II) both
255 # have MPC603e cores according to Freescale docs.
256 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000257 '-mstrict-align',
258 '-mlongcall',
Brian Silverman823f3242013-11-17 13:20:22 -0800259 '-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/',
260 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/vxworks-6.3/target/h/',
261 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/gnu/3.4.4-vxworks-6.3/x86-win32/include/c++/3.4.4/',
262 '-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 +0000263 '-isystem', '<(WIND_BASE)/target/h',
264 '-isystem', '<(WIND_BASE)/target/h/wrn/coreip',
265 ],
Brian Silverman6e206682013-08-31 11:43:35 -0700266 'cflags_cc': [
267 '-std=gnu++0x',
268 ],
brians343bc112013-02-10 01:53:46 +0000269 'defines': [
270 'CPU=PPC603',
271 'TOOL_FAMILY=gnu',
272 'TOOL=gnu',
273 '_WRS_KERNEL',
274 '__PPC__',
Brian Silvermane6bada62014-05-04 16:16:54 -0700275# Prevent the vxworks system headers from being dumb and #defining min and max.
brians343bc112013-02-10 01:53:46 +0000276 'NOMINMAX',
277 ],
Brian Silvermane6bada62014-05-04 16:16:54 -0700278 }, { # 'PLATFORM!="crio"'
brians343bc112013-02-10 01:53:46 +0000279 'target_conditions': [
Brian Silvermane6bada62014-05-04 16:16:54 -0700280# Default to putting outputs into rsync_dir.
brians343bc112013-02-10 01:53:46 +0000281 ['no_rsync==0 and _type!="static_library"', {
282 'product_dir': '<(rsync_dir)',
283 },
284 ],
brians343bc112013-02-10 01:53:46 +0000285 ],
286 'ldflags': [
287 '-pthread',
brians343bc112013-02-10 01:53:46 +0000288 ],
brians343bc112013-02-10 01:53:46 +0000289 'cflags': [
290 '-pthread',
Brian Silverman6e206682013-08-31 11:43:35 -0700291 ],
292 'cflags_cc': [
293 '-std=gnu++11',
brians343bc112013-02-10 01:53:46 +0000294 ],
295 'defines': [
Brian Silvermanefb993f2013-08-30 19:52:57 -0700296 '_FILE_OFFSET_BITS=64',
brians343bc112013-02-10 01:53:46 +0000297 ],
298 'libraries': [
299 '-lm',
300 '-lrt',
301 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700302 'conditions': [
Brian Silvermana29ebf92014-04-23 13:08:49 -0500303 ['COMPILER=="gcc"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700304 'cflags': [
305 '-Wunused-local-typedefs',
306 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700307 'defines': [
308 '__has_feature(n)=0'
309 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700310 },
Brian Silvermana29ebf92014-04-23 13:08:49 -0500311 ], ['COMPILER=="clang"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700312 'cflags': [
313 '-fcolor-diagnostics',
Brian Silvermane6bada62014-05-04 16:16:54 -0700314 '-fmessage-length=80',
Brian Silvermanad09fd72014-08-14 23:38:36 -0700315 '-fmacro-backtrace-limit=0',
Brian Silverman79723eb2014-04-21 22:05:11 -0700316 ],
317 'defines': [
Brian Silverman79723eb2014-04-21 22:05:11 -0700318 # This tells clang's optimizer the same thing.
Brian Silvermanbbeed502014-08-14 23:19:15 -0700319 '__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 -0700320 ],
321 },
322 ],
323 ],
brians343bc112013-02-10 01:53:46 +0000324 }
325 ]
326 ],
327 },
328}