blob: 3ffe5c0176a1c28339c3041242987a32be14d8da [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 Silverman20141f92015-01-05 17:39:01 -080025 ['PLATFORM=="linux-arm-gcc_frc"', {
Brian Silvermanbae86d62014-09-14 01:05:31 -040026 'make_global_settings': [
27 ['CC', '<(ccache)<!(which arm-frc-linux-gnueabi-gcc-4.9)'],
28 ['CXX', '<(ccache)<!(which arm-frc-linux-gnueabi-g++-4.9)'],
29 ],
30 },
Brian Silverman20141f92015-01-05 17:39:01 -080031 ], ['PLATFORM=="linux-arm-clang_frc"', {
Brian Silvermana8c04522014-04-27 20:03:08 -070032 'variables': {
33 'arm-clang-symlinks': '<!(realpath -s <(AOS)/build/arm-clang-symlinks)',
34 'arm-clang-sysroot': '<(arm-clang-symlinks)/sysroot',
Brian Silvermane6bada62014-05-04 16:16:54 -070035# Flags that should be passed to all compile/link/etc commands.
Brian Silvermana8c04522014-04-27 20:03:08 -070036 'platflags': [
Brian Silverman20141f92015-01-05 17:39:01 -080037 '-target', 'armv7a-frc-linux-gnueabi',
38 '-mfloat-abi=softfp',
Brian Silvermana8c04522014-04-27 20:03:08 -070039 '--sysroot=<(arm-clang-sysroot)',
40
Brian Silvermane6bada62014-05-04 16:16:54 -070041 # TODO(brians): See if it will run with this enabled.
Brian Silvermana8c04522014-04-27 20:03:08 -070042 #-mhwdiv=arm,thumb
43 ],
44 },
45 'make_global_settings': [
Brian Silvermand3fac732014-05-03 16:03:46 -070046 ['CC', '<(ccache)<(arm-clang-symlinks)/bin/clang'],
47 ['CXX', '<(ccache)<(arm-clang-symlinks)/bin/clang++'],
Brian Silvermana8c04522014-04-27 20:03:08 -070048 ],
49 'target_defaults': {
50 'cflags': [
Brian Silvermana8c04522014-04-27 20:03:08 -070051 '<@(platflags)',
52 ],
Brian Silverman34d25f22014-05-01 13:30:56 -070053 'cflags_cc': [
Brian Silverman20141f92015-01-05 17:39:01 -080054 '-isystem', '<(arm-clang-sysroot)/include/c++/4.9.1',
55 '-isystem', '<(arm-clang-sysroot)/include/c++/4.9.1/arm-frc-linux-gnueabi',
Brian Silverman34d25f22014-05-01 13:30:56 -070056 ],
Brian Silvermana8c04522014-04-27 20:03:08 -070057 'ldflags': [
58 '<@(platflags)',
Brian Silverman20141f92015-01-05 17:39:01 -080059 '-L', '/usr/lib/x86_64-linux-gnu/gcc/arm-frc-linux-gnueabi/4.9.1',
60 #'-L', '<(arm-clang-sysroot)/other_lib/',
61 #'-nostartfiles',
Brian Silvermana8c04522014-04-27 20:03:08 -070062 ],
63 },
Brian Silverman79723eb2014-04-21 22:05:11 -070064 },
65 ], ['PLATFORM=="linux-amd64-clang"', {
66 'make_global_settings': [
Brian Silverman20141f92015-01-05 17:39:01 -080067 ['CC', '<(ccache)<!(which clang)'],
68 ['CXX', '<(ccache)<!(which clang++)'],
Brian Silverman79723eb2014-04-21 22:05:11 -070069 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -070070 },
71 ], ['PLATFORM=="linux-amd64-gcc"', {
Brian Silvermand3fac732014-05-03 16:03:46 -070072 'make_global_settings': [
Brian Silverman9b7a6842014-05-05 16:19:11 -070073 ['CC', '<(ccache)<!(which gcc-4.7)'],
74 ['CXX', '<(ccache)<!(which g++-4.7)'],
Brian Silvermand3fac732014-05-03 16:03:46 -070075 ],
Brian Silvermanf0d3c782014-05-02 23:56:32 -070076 },
Brian Silverman47cd6f62014-05-03 10:35:52 -070077 ], ['PLATFORM=="linux-amd64-gcc_4.8"', {
78 'make_global_settings': [
Brian Silvermand3fac732014-05-03 16:03:46 -070079 ['CC', '<(ccache)/opt/clang-3.5/bin/gcc'],
80 ['CXX', '<(ccache)/opt/clang-3.5/bin/g++'],
Brian Silverman47cd6f62014-05-03 10:35:52 -070081 ],
82 },
Brian Silvermanf0d3c782014-05-02 23:56:32 -070083 ], ['SANITIZER!="none"', {
Brian Silvermana4aff562014-05-02 17:43:50 -070084 'target_defaults': {
85 'cflags': [
Brian Silvermanf0d3c782014-05-02 23:56:32 -070086 '-fsanitize=<(SANITIZER)',
Brian Silvermana4aff562014-05-02 17:43:50 -070087 ],
88 'ldflags': [
Brian Silvermanf0d3c782014-05-02 23:56:32 -070089 '-fsanitize=<(SANITIZER)',
Brian Silvermana4aff562014-05-02 17:43:50 -070090 ],
Brian Silverman889f85e2014-09-05 11:39:09 -040091 'defines': [
92# GCC doesn't have __has_feature, so we have to use this instead.
93 'AOS_SANITIZER_<(SANITIZER)',
94 ],
Brian Silvermana4aff562014-05-02 17:43:50 -070095 },
Brian Silverman79723eb2014-04-21 22:05:11 -070096 },
Brian Silverman1294c082014-05-20 17:02:29 -070097 ], ['SANITIZER!="none" and COMPILER!="gcc"', {
98 'target_defaults': {
99 'cflags': [
100 '-fno-sanitize-recover',
101 '-fno-sanitize=<!(echo <(disable_sanitizers) | sed "s/ /,/g")',
102 ],
103 },
104 },
Brian Silvermanabe55a02014-12-29 21:36:17 -0800105 ], ['SANITIZER!="thread"', {
106 'libraries': [
107 '<!(readlink -f <(AOS)/../output/compiled-<(ARCHITECTURE)<(EXTERNALS_EXTRA)/gperftools-2.3-prefix/lib/libtcmalloc.a)',
108 '<!(readlink -f <(AOS)/../output/compiled-<(ARCHITECTURE)<(EXTERNALS_EXTRA)/libunwind-1.1-prefix/lib/libunwind.a)',
109 ],
Brian Silverman40486622014-12-30 17:38:55 -0800110 'defines': [
111 'TCMALLOC',
112 ],
Brian Silvermanabe55a02014-12-29 21:36:17 -0800113 },
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',
Austin Schuhc9b0a9d2014-10-25 18:02:21 -0700146 'AOS_COMPILER_<!(echo <(FULL_COMPILER) | sed \'s/\./_/g\')',
Brian Silverman20141f92015-01-05 17:39:01 -0800147 '_FILE_OFFSET_BITS=64',
brians343bc112013-02-10 01:53:46 +0000148 ],
149 'ldflags': [
150 '-pipe',
Brian Silverman20141f92015-01-05 17:39:01 -0800151 '-pthread',
152 ],
153 'libraries': [
154 '-lm',
155 '-lrt',
brians343bc112013-02-10 01:53:46 +0000156 ],
157 'cflags': [
158 '-pipe',
159
Brian Silverman20141f92015-01-05 17:39:01 -0800160 '-pthread',
161
brians343bc112013-02-10 01:53:46 +0000162 '-Wall',
163 '-Wextra',
164 '-Wswitch-enum',
165 '-Wpointer-arith',
166 '-Wstrict-aliasing=2',
167 '-Wcast-qual',
168 '-Wcast-align',
169 '-Wwrite-strings',
170 '-Wtype-limits',
171 '-Wsign-compare',
172 '-Wformat=2',
173 '-Werror',
Brian Silverman9ba2bc42013-03-17 14:18:33 -0700174
175 '-ggdb3',
brians343bc112013-02-10 01:53:46 +0000176 ],
177 'cflags_c': [
178 '-std=gnu99',
179 ],
Brian Silverman20141f92015-01-05 17:39:01 -0800180 'cflags_cc': [
181 '-std=gnu++11',
182 ],
brians343bc112013-02-10 01:53:46 +0000183 'include_dirs': [
184 '<(DEPTH)',
185 ],
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700186 # These have to be here because apparently gyp evaluates target_conditions
187 # even if the target is never used.
188 'variables': {
189 # Set this to 1 to disable rsyncing the file to the target.
190 'no_rsync%': 0,
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700191 # Set this to 1 if this file is a test that should not be run by
Brian Silvermanb3d50542014-04-23 14:28:55 -0500192 # `build.py tests`.
Brian Silvermand0a52dc2013-09-23 17:55:37 -0700193 'is_special_test%': 0,
194 },
brians343bc112013-02-10 01:53:46 +0000195 'conditions': [
196 ['DEBUG=="yes"', {
Brian Silvermanaac705c2014-05-01 18:55:34 -0700197 'defines': [
198 'AOS_DEBUG=1',
199 ],
Brian Silverman266811f2014-05-03 22:48:04 -0700200 'conditions': [['SANITIZER=="none"', {
Brian Silvermane6bada62014-05-04 16:16:54 -0700201 'cflags': [
202 '-O0',
203 ],
204 }, {
205 'cflags': [
206 '-O1',
207 ],
208 }
209 ]],
210 }, { # 'DEBUG=="no"'
Brian Silvermanaac705c2014-05-01 18:55:34 -0700211 'defines': [
212 'AOS_DEBUG=0',
Brian Silverman3b6d3202014-09-14 01:01:54 -0400213 '_FORTIFY_SOURCE=2',
Brian Silvermanaac705c2014-05-01 18:55:34 -0700214 ],
brians343bc112013-02-10 01:53:46 +0000215 'cflags': [
216 '-O3',
Brian Silverman2a36ddb2014-04-08 17:07:28 -0700217 '-fomit-frame-pointer',
brians343bc112013-02-10 01:53:46 +0000218 ],
Brian Silvermanefb993f2013-08-30 19:52:57 -0700219 'ldflags': [
220 '-O3',
221 ],
Brian Silverman20141f92015-01-05 17:39:01 -0800222 'conditions': [['ARCHITECTURE=="amd64"', {
Brian Silverman41abe012014-02-08 18:25:02 -0800223 'cflags': [
Brian Silverman41abe012014-02-08 18:25:02 -0800224 '-fstack-protector-all',
225 ],
226 }],
227 ]
brians343bc112013-02-10 01:53:46 +0000228 }
229 ],
Brian Silverman47cd6f62014-05-03 10:35:52 -0700230 ['OS=="linux" and ARCHITECTURE=="arm" and COMPILER=="gcc" and DEBUG=="yes"', {
Brian Silverman134e5222014-04-27 20:10:05 -0700231 'cflags': [
232 # GCC doesn't like letting us use r7 (which is also the frame
233 # pointer) to pass the syscall number to the kernel even when
234 # it's marked as clobbered.
235 # See <https://bugzilla.mozilla.org/show_bug.cgi?id=633436> for
236 # some more discussion.
237 '-fomit-frame-pointer',
238 ],
239 }
240 ],
Brian Silverman20141f92015-01-05 17:39:01 -0800241 ['ARCHITECTURE=="arm"', {
Brian Silvermanbae86d62014-09-14 01:05:31 -0400242 'cflags': [
243 '-mcpu=cortex-a9',
244 '-mfpu=neon',
245 '-mfloat-abi=softfp',
246 ],
247 'ldflags': [
248 '-mcpu=cortex-a9',
249 '-mfpu=neon',
250 '-mfloat-abi=softfp',
251 ],
252 }],
Brian Silverman20141f92015-01-05 17:39:01 -0800253 ['COMPILER=="gcc"', {
254 'cflags': [
255 '-Wunused-local-typedefs',
256 ],
257 'defines': [
258 '__has_feature(n)=0'
259 ],
260 }], ['COMPILER=="clang"', {
261 'cflags': [
262 '-fcolor-diagnostics',
263 '-fmessage-length=80',
264 '-fmacro-backtrace-limit=0',
265 ],
266 'defines': [
267 # This tells clang's optimizer the same thing.
268 '__builtin_assume_aligned(p, a)=({ const typeof(p) my_p_ = (p); ((((uintptr_t)my_p_ % (a)) == 0u) ? my_p_ : (__builtin_unreachable(), (my_p_))); })',
269 ],
270 }],
271 ],
272 'target_conditions': [
Brian Silvermane6bada62014-05-04 16:16:54 -0700273# Default to putting outputs into rsync_dir.
Brian Silverman20141f92015-01-05 17:39:01 -0800274 ['no_rsync==0 and _type!="static_library"', {
275 'product_dir': '<(rsync_dir)',
276 },
277 ],
brians343bc112013-02-10 01:53:46 +0000278 ],
279 },
280}