blob: 5a9119df1271f5fedae22363932d0bb6f359d62c [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',
brians343bc112013-02-10 01:53:46 +0000146 ],
147 'ldflags': [
148 '-pipe',
149 ],
150 'cflags': [
151 '-pipe',
152
153 '-Wall',
154 '-Wextra',
155 '-Wswitch-enum',
156 '-Wpointer-arith',
157 '-Wstrict-aliasing=2',
158 '-Wcast-qual',
159 '-Wcast-align',
160 '-Wwrite-strings',
161 '-Wtype-limits',
162 '-Wsign-compare',
163 '-Wformat=2',
164 '-Werror',
Brian Silverman9ba2bc42013-03-17 14:18:33 -0700165
166 '-ggdb3',
brians343bc112013-02-10 01:53:46 +0000167 ],
168 'cflags_c': [
169 '-std=gnu99',
170 ],
brians343bc112013-02-10 01:53:46 +0000171 'include_dirs': [
172 '<(DEPTH)',
173 ],
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700174 # These have to be here because apparently gyp evaluates target_conditions
175 # even if the target is never used.
176 'variables': {
177 # Set this to 1 to disable rsyncing the file to the target.
178 'no_rsync%': 0,
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700179 # Set this to 1 if this file is a test that should not be run by
Brian Silvermanb3d50542014-04-23 14:28:55 -0500180 # `build.py tests`.
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700181 'is_special_test%': 0,
182 },
brians343bc112013-02-10 01:53:46 +0000183 'conditions': [
184 ['DEBUG=="yes"', {
Brian Silvermanaac705c2014-05-01 18:55:34 -0700185 'defines': [
186 'AOS_DEBUG=1',
187 ],
Brian Silverman266811f2014-05-03 22:48:04 -0700188 'conditions': [['SANITIZER=="none"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700189 'cflags': [
190 '-O0',
191 ],
192 }, {
193 'cflags': [
194 '-O1',
195 ],
196 }
197 ]],
198 }, { # 'DEBUG=="no"'
Brian Silvermanaac705c2014-05-01 18:55:34 -0700199 'defines': [
200 'AOS_DEBUG=0',
Brian Silverman3b6d3202014-09-14 01:01:54 -0400201 '_FORTIFY_SOURCE=2',
Brian Silvermanaac705c2014-05-01 18:55:34 -0700202 ],
brians343bc112013-02-10 01:53:46 +0000203 'cflags': [
204 '-O3',
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700205 '-fomit-frame-pointer',
brians343bc112013-02-10 01:53:46 +0000206 ],
Brian Silvermanefb993f2013-08-30 19:52:57 -0700207 'ldflags': [
208 '-O3',
209 ],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500210 'conditions': [['PLATFORM=="crio"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700211# Copied from stuff that I think started with the supplied Makefiles.
brians343bc112013-02-10 01:53:46 +0000212 'cflags': [
213 '-fstrength-reduce',
214 '-fno-builtin',
215 '-fno-strict-aliasing',
216 ],
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 Silvermanbae86d62014-09-14 01:05:31 -0400237 ['ARCHITECTURE=="arm" and FULL_COMPILER!="gcc_frc"', {
Brian Silverman10b8a2b2014-09-14 01:04:25 -0400238 'cflags': [
239 '-mcpu=cortex-a8',
240 '-mfpu=neon',
241 ],
242 'ldflags': [
243 '-mcpu=cortex-a8',
244 '-mfpu=neon',
245 ],
246 }],
Brian Silvermanbae86d62014-09-14 01:05:31 -0400247 ['ARCHITECTURE=="arm" and FULL_COMPILER=="gcc_frc"', {
248 'cflags': [
249 '-mcpu=cortex-a9',
250 '-mfpu=neon',
251 '-mfloat-abi=softfp',
252 ],
253 'ldflags': [
254 '-mcpu=cortex-a9',
255 '-mfpu=neon',
256 '-mfloat-abi=softfp',
257 ],
258 }],
Brian Silvermanb3d50542014-04-23 14:28:55 -0500259 ['PLATFORM=="crio"', {
brians343bc112013-02-10 01:53:46 +0000260 'target_conditions': [
261 ['_type=="shared_library"', {
262 'ldflags': [
263 '-r',
264 '-nostdlib',
265 '-Wl,-X',
266 ],
267 }
268 ],
269 ],
270 'ldflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700271 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000272 '-mstrict-align',
273 '-mlongcall',
274 ],
275 'cflags': [
Brian Silverman1579fc12013-04-22 15:41:55 -0700276 # The Freescale MPC5200B (cRIO-FRC) and MPC5125 (cRIO-FRC II) both
277 # have MPC603e cores according to Freescale docs.
278 '-mcpu=603e',
brians343bc112013-02-10 01:53:46 +0000279 '-mstrict-align',
280 '-mlongcall',
Brian Silverman823f3242013-11-17 13:20:22 -0800281 '-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/',
282 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/vxworks-6.3/target/h/',
283 '-isystem', '<(aos_abs)/../output/downloaded/gccdist/WindRiver/gnu/3.4.4-vxworks-6.3/x86-win32/include/c++/3.4.4/',
284 '-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 +0000285 '-isystem', '<(WIND_BASE)/target/h',
286 '-isystem', '<(WIND_BASE)/target/h/wrn/coreip',
287 ],
Brian Silverman6e206682013-08-31 11:43:35 -0700288 'cflags_cc': [
289 '-std=gnu++0x',
290 ],
brians343bc112013-02-10 01:53:46 +0000291 'defines': [
292 'CPU=PPC603',
293 'TOOL_FAMILY=gnu',
294 'TOOL=gnu',
295 '_WRS_KERNEL',
296 '__PPC__',
Brian Silvermane6bada62014-05-04 16:16:54 -0700297# Prevent the vxworks system headers from being dumb and #defining min and max.
brians343bc112013-02-10 01:53:46 +0000298 'NOMINMAX',
299 ],
Brian Silvermane6bada62014-05-04 16:16:54 -0700300 }, { # 'PLATFORM!="crio"'
brians343bc112013-02-10 01:53:46 +0000301 'target_conditions': [
Brian Silvermane6bada62014-05-04 16:16:54 -0700302# Default to putting outputs into rsync_dir.
brians343bc112013-02-10 01:53:46 +0000303 ['no_rsync==0 and _type!="static_library"', {
304 'product_dir': '<(rsync_dir)',
305 },
306 ],
brians343bc112013-02-10 01:53:46 +0000307 ],
308 'ldflags': [
309 '-pthread',
brians343bc112013-02-10 01:53:46 +0000310 ],
brians343bc112013-02-10 01:53:46 +0000311 'cflags': [
312 '-pthread',
Brian Silverman6e206682013-08-31 11:43:35 -0700313 ],
314 'cflags_cc': [
315 '-std=gnu++11',
brians343bc112013-02-10 01:53:46 +0000316 ],
317 'defines': [
Brian Silvermanefb993f2013-08-30 19:52:57 -0700318 '_FILE_OFFSET_BITS=64',
brians343bc112013-02-10 01:53:46 +0000319 ],
320 'libraries': [
321 '-lm',
322 '-lrt',
323 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700324 'conditions': [
Brian Silvermana29ebf92014-04-23 13:08:49 -0500325 ['COMPILER=="gcc"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700326 'cflags': [
327 '-Wunused-local-typedefs',
328 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -0700329 'defines': [
330 '__has_feature(n)=0'
331 ],
Brian Silverman79723eb2014-04-21 22:05:11 -0700332 },
Brian Silvermana29ebf92014-04-23 13:08:49 -0500333 ], ['COMPILER=="clang"', {
Brian Silverman79723eb2014-04-21 22:05:11 -0700334 'cflags': [
335 '-fcolor-diagnostics',
Brian Silvermane6bada62014-05-04 16:16:54 -0700336 '-fmessage-length=80',
Brian Silvermanad09fd72014-08-14 23:38:36 -0700337 '-fmacro-backtrace-limit=0',
Brian Silverman79723eb2014-04-21 22:05:11 -0700338 ],
339 'defines': [
Brian Silverman79723eb2014-04-21 22:05:11 -0700340 # This tells clang's optimizer the same thing.
Brian Silvermanbbeed502014-08-14 23:19:15 -0700341 '__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 -0700342 ],
343 },
344 ],
345 ],
brians343bc112013-02-10 01:53:46 +0000346 }
347 ]
348 ],
349 },
350}