brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 1 | # 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 Silverman | e6bada6 | 2014-05-04 16:16:54 -0700 | [diff] [blame] | 8 | # The .gyp file that has targets for the various external libraries. |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 9 | 'EXTERNALS': '<(AOS)/build/externals.gyp', |
Brian Silverman | e6bada6 | 2014-05-04 16:16:54 -0700 | [diff] [blame] | 10 | # The directory that gets rsynced to the target. |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 11 | 'rsync_dir': '<(PRODUCT_DIR)/outputs', |
Brian Silverman | e6bada6 | 2014-05-04 16:16:54 -0700 | [diff] [blame] | 12 | # The directory that executables that depend on <(EXTERNALS):gtest get put into. |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 13 | 'test_dir': '<(PRODUCT_DIR)/tests', |
Brian Silverman | d3fac73 | 2014-05-03 16:03:46 -0700 | [diff] [blame] | 14 | |
Brian Silverman | e6bada6 | 2014-05-04 16:16:54 -0700 | [diff] [blame] | 15 | # Stuck into a variable (with a space on the end) to make disabling it easy. |
Brian Silverman | d3fac73 | 2014-05-03 16:03:46 -0700 | [diff] [blame] | 16 | 'ccache': '<!(which ccache) ', |
Brian Silverman | 1294c08 | 2014-05-20 17:02:29 -0700 | [diff] [blame] | 17 | |
| 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 | ], |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 23 | }, |
| 24 | 'conditions': [ |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 25 | ['PLATFORM=="linux-arm-gcc_frc"', { |
Brian Silverman | bae86d6 | 2014-09-14 01:05:31 -0400 | [diff] [blame] | 26 | '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 Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 31 | ], ['PLATFORM=="linux-arm-clang_frc"', { |
Brian Silverman | a8c0452 | 2014-04-27 20:03:08 -0700 | [diff] [blame] | 32 | 'variables': { |
| 33 | 'arm-clang-symlinks': '<!(realpath -s <(AOS)/build/arm-clang-symlinks)', |
| 34 | 'arm-clang-sysroot': '<(arm-clang-symlinks)/sysroot', |
Brian Silverman | e6bada6 | 2014-05-04 16:16:54 -0700 | [diff] [blame] | 35 | # Flags that should be passed to all compile/link/etc commands. |
Brian Silverman | a8c0452 | 2014-04-27 20:03:08 -0700 | [diff] [blame] | 36 | 'platflags': [ |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 37 | '-target', 'armv7a-frc-linux-gnueabi', |
| 38 | '-mfloat-abi=softfp', |
Brian Silverman | a8c0452 | 2014-04-27 20:03:08 -0700 | [diff] [blame] | 39 | '--sysroot=<(arm-clang-sysroot)', |
| 40 | |
Brian Silverman | e6bada6 | 2014-05-04 16:16:54 -0700 | [diff] [blame] | 41 | # TODO(brians): See if it will run with this enabled. |
Brian Silverman | a8c0452 | 2014-04-27 20:03:08 -0700 | [diff] [blame] | 42 | #-mhwdiv=arm,thumb |
| 43 | ], |
| 44 | }, |
| 45 | 'make_global_settings': [ |
Brian Silverman | d3fac73 | 2014-05-03 16:03:46 -0700 | [diff] [blame] | 46 | ['CC', '<(ccache)<(arm-clang-symlinks)/bin/clang'], |
| 47 | ['CXX', '<(ccache)<(arm-clang-symlinks)/bin/clang++'], |
Brian Silverman | a8c0452 | 2014-04-27 20:03:08 -0700 | [diff] [blame] | 48 | ], |
| 49 | 'target_defaults': { |
| 50 | 'cflags': [ |
Brian Silverman | a8c0452 | 2014-04-27 20:03:08 -0700 | [diff] [blame] | 51 | '<@(platflags)', |
| 52 | ], |
Brian Silverman | 34d25f2 | 2014-05-01 13:30:56 -0700 | [diff] [blame] | 53 | 'cflags_cc': [ |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 54 | '-isystem', '<(arm-clang-sysroot)/include/c++/4.9.1', |
| 55 | '-isystem', '<(arm-clang-sysroot)/include/c++/4.9.1/arm-frc-linux-gnueabi', |
Brian Silverman | 34d25f2 | 2014-05-01 13:30:56 -0700 | [diff] [blame] | 56 | ], |
Brian Silverman | a8c0452 | 2014-04-27 20:03:08 -0700 | [diff] [blame] | 57 | 'ldflags': [ |
| 58 | '<@(platflags)', |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 59 | '-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 Silverman | a8c0452 | 2014-04-27 20:03:08 -0700 | [diff] [blame] | 62 | ], |
| 63 | }, |
Brian Silverman | 79723eb | 2014-04-21 22:05:11 -0700 | [diff] [blame] | 64 | }, |
| 65 | ], ['PLATFORM=="linux-amd64-clang"', { |
| 66 | 'make_global_settings': [ |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 67 | ['CC', '<(ccache)<!(which clang)'], |
| 68 | ['CXX', '<(ccache)<!(which clang++)'], |
Brian Silverman | 79723eb | 2014-04-21 22:05:11 -0700 | [diff] [blame] | 69 | ], |
Brian Silverman | f0d3c78 | 2014-05-02 23:56:32 -0700 | [diff] [blame] | 70 | }, |
| 71 | ], ['PLATFORM=="linux-amd64-gcc"', { |
Brian Silverman | d3fac73 | 2014-05-03 16:03:46 -0700 | [diff] [blame] | 72 | 'make_global_settings': [ |
Brian Silverman | 9b7a684 | 2014-05-05 16:19:11 -0700 | [diff] [blame] | 73 | ['CC', '<(ccache)<!(which gcc-4.7)'], |
| 74 | ['CXX', '<(ccache)<!(which g++-4.7)'], |
Brian Silverman | d3fac73 | 2014-05-03 16:03:46 -0700 | [diff] [blame] | 75 | ], |
Brian Silverman | f0d3c78 | 2014-05-02 23:56:32 -0700 | [diff] [blame] | 76 | }, |
Brian Silverman | 47cd6f6 | 2014-05-03 10:35:52 -0700 | [diff] [blame] | 77 | ], ['PLATFORM=="linux-amd64-gcc_4.8"', { |
| 78 | 'make_global_settings': [ |
Brian Silverman | d3fac73 | 2014-05-03 16:03:46 -0700 | [diff] [blame] | 79 | ['CC', '<(ccache)/opt/clang-3.5/bin/gcc'], |
| 80 | ['CXX', '<(ccache)/opt/clang-3.5/bin/g++'], |
Brian Silverman | 47cd6f6 | 2014-05-03 10:35:52 -0700 | [diff] [blame] | 81 | ], |
| 82 | }, |
Brian Silverman | f0d3c78 | 2014-05-02 23:56:32 -0700 | [diff] [blame] | 83 | ], ['SANITIZER!="none"', { |
Brian Silverman | a4aff56 | 2014-05-02 17:43:50 -0700 | [diff] [blame] | 84 | 'target_defaults': { |
| 85 | 'cflags': [ |
Brian Silverman | f0d3c78 | 2014-05-02 23:56:32 -0700 | [diff] [blame] | 86 | '-fsanitize=<(SANITIZER)', |
Brian Silverman | a4aff56 | 2014-05-02 17:43:50 -0700 | [diff] [blame] | 87 | ], |
| 88 | 'ldflags': [ |
Brian Silverman | f0d3c78 | 2014-05-02 23:56:32 -0700 | [diff] [blame] | 89 | '-fsanitize=<(SANITIZER)', |
Brian Silverman | a4aff56 | 2014-05-02 17:43:50 -0700 | [diff] [blame] | 90 | ], |
Brian Silverman | 889f85e | 2014-09-05 11:39:09 -0400 | [diff] [blame] | 91 | 'defines': [ |
| 92 | # GCC doesn't have __has_feature, so we have to use this instead. |
| 93 | 'AOS_SANITIZER_<(SANITIZER)', |
| 94 | ], |
Brian Silverman | a4aff56 | 2014-05-02 17:43:50 -0700 | [diff] [blame] | 95 | }, |
Brian Silverman | 79723eb | 2014-04-21 22:05:11 -0700 | [diff] [blame] | 96 | }, |
Brian Silverman | 1294c08 | 2014-05-20 17:02:29 -0700 | [diff] [blame] | 97 | ], ['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 Silverman | abe55a0 | 2014-12-29 21:36:17 -0800 | [diff] [blame] | 105 | ], ['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 Silverman | 4048662 | 2014-12-30 17:38:55 -0800 | [diff] [blame] | 110 | 'defines': [ |
| 111 | 'TCMALLOC', |
| 112 | ], |
Brian Silverman | abe55a0 | 2014-12-29 21:36:17 -0800 | [diff] [blame] | 113 | }, |
Brian Silverman | 99895b9 | 2014-09-14 01:01:15 -0400 | [diff] [blame] | 114 | ], ['EXTERNALS_EXTRA=="-fPIE"', { |
Brian Silverman | f0d3c78 | 2014-05-02 23:56:32 -0700 | [diff] [blame] | 115 | 'target_defaults': { |
| 116 | 'cflags': [ |
Brian Silverman | 47cd6f6 | 2014-05-03 10:35:52 -0700 | [diff] [blame] | 117 | '-fPIE', |
Brian Silverman | f0d3c78 | 2014-05-02 23:56:32 -0700 | [diff] [blame] | 118 | ], |
| 119 | 'ldflags': [ |
Brian Silverman | 47cd6f6 | 2014-05-03 10:35:52 -0700 | [diff] [blame] | 120 | '-fPIE', |
Brian Silverman | f0d3c78 | 2014-05-02 23:56:32 -0700 | [diff] [blame] | 121 | ], |
Brian Silverman | 47cd6f6 | 2014-05-03 10:35:52 -0700 | [diff] [blame] | 122 | 'link_settings': { |
| 123 | 'ldflags': [ |
| 124 | '-pie', |
| 125 | ], |
| 126 | }, |
Brian Silverman | f0d3c78 | 2014-05-02 23:56:32 -0700 | [diff] [blame] | 127 | }, |
| 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 Silverman | 79723eb | 2014-04-21 22:05:11 -0700 | [diff] [blame] | 138 | }, |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 139 | ], |
| 140 | ], |
| 141 | 'target_defaults': { |
| 142 | 'defines': [ |
| 143 | '__STDC_FORMAT_MACROS', |
Brian Silverman | 6137a50 | 2013-04-22 15:41:36 -0700 | [diff] [blame] | 144 | '__STDC_CONSTANT_MACROS', |
| 145 | '__STDC_LIMIT_MACROS', |
Austin Schuh | c9b0a9d | 2014-10-25 18:02:21 -0700 | [diff] [blame] | 146 | 'AOS_COMPILER_<!(echo <(FULL_COMPILER) | sed \'s/\./_/g\')', |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 147 | '_FILE_OFFSET_BITS=64', |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 148 | ], |
| 149 | 'ldflags': [ |
| 150 | '-pipe', |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 151 | '-pthread', |
| 152 | ], |
| 153 | 'libraries': [ |
| 154 | '-lm', |
| 155 | '-lrt', |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 156 | ], |
| 157 | 'cflags': [ |
| 158 | '-pipe', |
| 159 | |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 160 | '-pthread', |
| 161 | |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 162 | '-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 Silverman | 9ba2bc4 | 2013-03-17 14:18:33 -0700 | [diff] [blame] | 174 | |
| 175 | '-ggdb3', |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 176 | ], |
| 177 | 'cflags_c': [ |
| 178 | '-std=gnu99', |
| 179 | ], |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 180 | 'cflags_cc': [ |
| 181 | '-std=gnu++11', |
| 182 | ], |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 183 | 'include_dirs': [ |
| 184 | '<(DEPTH)', |
| 185 | ], |
Brian Silverman | d0a52dc | 2013-09-23 17:55:37 -0700 | [diff] [blame] | 186 | # 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 Silverman | 2a36ddb | 2014-04-08 17:07:28 -0700 | [diff] [blame] | 191 | # Set this to 1 if this file is a test that should not be run by |
Brian Silverman | b3d5054 | 2014-04-23 14:28:55 -0500 | [diff] [blame] | 192 | # `build.py tests`. |
Brian Silverman | d0a52dc | 2013-09-23 17:55:37 -0700 | [diff] [blame] | 193 | 'is_special_test%': 0, |
| 194 | }, |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 195 | 'conditions': [ |
| 196 | ['DEBUG=="yes"', { |
Brian Silverman | aac705c | 2014-05-01 18:55:34 -0700 | [diff] [blame] | 197 | 'defines': [ |
| 198 | 'AOS_DEBUG=1', |
| 199 | ], |
Brian Silverman | 266811f | 2014-05-03 22:48:04 -0700 | [diff] [blame] | 200 | 'conditions': [['SANITIZER=="none"', { |
Brian Silverman | e6bada6 | 2014-05-04 16:16:54 -0700 | [diff] [blame] | 201 | 'cflags': [ |
| 202 | '-O0', |
| 203 | ], |
| 204 | }, { |
| 205 | 'cflags': [ |
| 206 | '-O1', |
| 207 | ], |
| 208 | } |
| 209 | ]], |
| 210 | }, { # 'DEBUG=="no"' |
Brian Silverman | aac705c | 2014-05-01 18:55:34 -0700 | [diff] [blame] | 211 | 'defines': [ |
| 212 | 'AOS_DEBUG=0', |
Brian Silverman | 3b6d320 | 2014-09-14 01:01:54 -0400 | [diff] [blame] | 213 | '_FORTIFY_SOURCE=2', |
Brian Silverman | aac705c | 2014-05-01 18:55:34 -0700 | [diff] [blame] | 214 | ], |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 215 | 'cflags': [ |
| 216 | '-O3', |
Brian Silverman | 2a36ddb | 2014-04-08 17:07:28 -0700 | [diff] [blame] | 217 | '-fomit-frame-pointer', |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 218 | ], |
Brian Silverman | efb993f | 2013-08-30 19:52:57 -0700 | [diff] [blame] | 219 | 'ldflags': [ |
| 220 | '-O3', |
| 221 | ], |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 222 | 'conditions': [['ARCHITECTURE=="amd64"', { |
Brian Silverman | 41abe01 | 2014-02-08 18:25:02 -0800 | [diff] [blame] | 223 | 'cflags': [ |
Brian Silverman | 41abe01 | 2014-02-08 18:25:02 -0800 | [diff] [blame] | 224 | '-fstack-protector-all', |
| 225 | ], |
| 226 | }], |
| 227 | ] |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 228 | } |
| 229 | ], |
Brian Silverman | 47cd6f6 | 2014-05-03 10:35:52 -0700 | [diff] [blame] | 230 | ['OS=="linux" and ARCHITECTURE=="arm" and COMPILER=="gcc" and DEBUG=="yes"', { |
Brian Silverman | 134e522 | 2014-04-27 20:10:05 -0700 | [diff] [blame] | 231 | '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 Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 241 | ['ARCHITECTURE=="arm"', { |
Brian Silverman | bae86d6 | 2014-09-14 01:05:31 -0400 | [diff] [blame] | 242 | '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 Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 253 | ['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 Silverman | e6bada6 | 2014-05-04 16:16:54 -0700 | [diff] [blame] | 273 | # Default to putting outputs into rsync_dir. |
Brian Silverman | 20141f9 | 2015-01-05 17:39:01 -0800 | [diff] [blame] | 274 | ['no_rsync==0 and _type!="static_library"', { |
| 275 | 'product_dir': '<(rsync_dir)', |
| 276 | }, |
| 277 | ], |
brians | 343bc11 | 2013-02-10 01:53:46 +0000 | [diff] [blame] | 278 | ], |
| 279 | }, |
| 280 | } |