Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 1 | # Copyright 2012 the V8 project authors. All rights reserved. |
| 2 | # Redistribution and use in source and binary forms, with or without |
| 3 | # modification, are permitted provided that the following conditions are |
| 4 | # met: |
| 5 | # |
| 6 | # * Redistributions of source code must retain the above copyright |
| 7 | # notice, this list of conditions and the following disclaimer. |
| 8 | # * Redistributions in binary form must reproduce the above |
| 9 | # copyright notice, this list of conditions and the following |
| 10 | # disclaimer in the documentation and/or other materials provided |
| 11 | # with the distribution. |
| 12 | # * Neither the name of Google Inc. nor the names of its |
| 13 | # contributors may be used to endorse or promote products derived |
| 14 | # from this software without specific prior written permission. |
| 15 | # |
| 16 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | # Definitions for building standalone V8 binaries to run on Android. |
| 29 | # This is mostly excerpted from: |
| 30 | # http://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi |
| 31 | |
| 32 | { |
| 33 | 'variables': { |
| 34 | # Location of Android NDK. |
| 35 | 'variables': { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 36 | 'android_ndk_root%': '<!(/bin/echo -n $ANDROID_NDK_ROOT)', |
| 37 | 'android_toolchain%': '<!(/bin/echo -n $ANDROID_TOOLCHAIN)', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 38 | }, |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 39 | 'conditions': [ |
| 40 | ['android_ndk_root==""', { |
| 41 | 'variables': { |
| 42 | 'android_sysroot': '<(android_toolchain)/sysroot/', |
| 43 | 'android_stlport': '<(android_toolchain)/sources/cxx-stl/stlport/', |
| 44 | }, |
| 45 | 'android_include': '<(android_sysroot)/usr/include', |
| 46 | 'android_lib': '<(android_sysroot)/usr/lib', |
| 47 | 'android_stlport_include': '<(android_stlport)/stlport', |
| 48 | 'android_stlport_libs': '<(android_stlport)/libs', |
| 49 | }, { |
| 50 | 'variables': { |
| 51 | 'android_sysroot': '<(android_ndk_root)/platforms/android-<(android_target_platform)/arch-<(android_target_arch)', |
| 52 | 'android_stlport': '<(android_ndk_root)/sources/cxx-stl/stlport/', |
| 53 | }, |
| 54 | 'android_include': '<(android_sysroot)/usr/include', |
| 55 | 'android_lib': '<(android_sysroot)/usr/lib', |
| 56 | 'android_stlport_include': '<(android_stlport)/stlport', |
| 57 | 'android_stlport_libs': '<(android_stlport)/libs', |
| 58 | }], |
| 59 | ], |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 60 | # Enable to use the system stlport, otherwise statically |
| 61 | # link the NDK one? |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 62 | 'use_system_stlport%': '<(android_webview_build)', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 63 | 'android_stlport_library': 'stlport_static', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 64 | }, # variables |
| 65 | 'target_defaults': { |
| 66 | 'defines': [ |
| 67 | 'ANDROID', |
| 68 | 'V8_ANDROID_LOG_STDOUT', |
| 69 | ], |
| 70 | 'configurations': { |
| 71 | 'Release': { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 72 | 'cflags': [ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 73 | '-fomit-frame-pointer', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 74 | ], |
| 75 | }, # Release |
| 76 | }, # configurations |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 77 | 'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter'], |
| 78 | 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions', |
| 79 | # Note: Using -std=c++0x will define __STRICT_ANSI__, which |
| 80 | # in turn will leave out some template stuff for 'long |
| 81 | # long'. What we want is -std=c++11, but this is not |
| 82 | # supported by GCC 4.6 or Xcode 4.2 |
| 83 | '-std=gnu++0x' ], |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 84 | 'target_conditions': [ |
| 85 | ['_toolset=="target"', { |
| 86 | 'cflags!': [ |
| 87 | '-pthread', # Not supported by Android toolchain. |
| 88 | ], |
| 89 | 'cflags': [ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 90 | '-ffunction-sections', |
| 91 | '-funwind-tables', |
| 92 | '-fstack-protector', |
| 93 | '-fno-short-enums', |
| 94 | '-finline-limit=64', |
| 95 | '-Wa,--noexecstack', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 96 | # Note: This include is in cflags to ensure that it comes after |
| 97 | # all of the includes. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 98 | '-I<(android_include)', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 99 | ], |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 100 | 'cflags_cc': [ |
| 101 | '-Wno-error=non-virtual-dtor', # TODO(michaelbai): Fix warnings. |
| 102 | ], |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 103 | 'defines': [ |
| 104 | 'ANDROID', |
| 105 | #'__GNU_SOURCE=1', # Necessary for clone() |
| 106 | 'USE_STLPORT=1', |
| 107 | '_STLP_USE_PTR_SPECIALIZATIONS=1', |
| 108 | 'HAVE_OFF64_T', |
| 109 | 'HAVE_SYS_UIO_H', |
| 110 | 'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize. |
| 111 | ], |
| 112 | 'ldflags!': [ |
| 113 | '-pthread', # Not supported by Android toolchain. |
| 114 | ], |
| 115 | 'ldflags': [ |
| 116 | '-nostdlib', |
| 117 | '-Wl,--no-undefined', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 118 | ], |
| 119 | 'libraries!': [ |
| 120 | '-lrt', # librt is built into Bionic. |
| 121 | # Not supported by Android toolchain. |
| 122 | # Where do these come from? Can't find references in |
| 123 | # any Chromium gyp or gypi file. Maybe they come from |
| 124 | # gyp itself? |
| 125 | '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4', '-lnspr4', |
| 126 | ], |
| 127 | 'libraries': [ |
| 128 | '-l<(android_stlport_library)', |
| 129 | # Manually link the libgcc.a that the cross compiler uses. |
| 130 | '<!($CC -print-libgcc-file-name)', |
| 131 | '-lc', |
| 132 | '-ldl', |
| 133 | '-lstdc++', |
| 134 | '-lm', |
| 135 | ], |
| 136 | 'conditions': [ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 137 | ['android_webview_build==0', { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 138 | 'ldflags': [ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 139 | '-Wl,-rpath-link=<(android_lib)', |
| 140 | '-L<(android_lib)', |
| 141 | ], |
| 142 | }], |
| 143 | ['target_arch == "arm"', { |
| 144 | 'ldflags': [ |
| 145 | # Enable identical code folding to reduce size. |
| 146 | '-Wl,--icf=safe', |
| 147 | ], |
| 148 | }], |
| 149 | ['target_arch=="arm" and arm_version==7', { |
| 150 | 'cflags': [ |
| 151 | '-march=armv7-a', |
| 152 | '-mtune=cortex-a8', |
| 153 | '-mfpu=vfp3', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 154 | ], |
| 155 | }], |
| 156 | # NOTE: The stlport header include paths below are specified in |
| 157 | # cflags rather than include_dirs because they need to come |
| 158 | # after include_dirs. Think of them like system headers, but |
| 159 | # don't use '-isystem' because the arm-linux-androideabi-4.4.3 |
| 160 | # toolchain (circa Gingerbread) will exhibit strange errors. |
| 161 | # The include ordering here is important; change with caution. |
| 162 | ['use_system_stlport==0', { |
| 163 | 'cflags': [ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 164 | '-I<(android_stlport_include)', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 165 | ], |
| 166 | 'conditions': [ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 167 | ['target_arch=="arm" and arm_version==7', { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 168 | 'ldflags': [ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 169 | '-L<(android_stlport_libs)/armeabi-v7a', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 170 | ], |
| 171 | }], |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 172 | ['target_arch=="arm" and arm_version < 7', { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 173 | 'ldflags': [ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 174 | '-L<(android_stlport_libs)/armeabi', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 175 | ], |
| 176 | }], |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 177 | ['target_arch=="mipsel"', { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 178 | 'ldflags': [ |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 179 | '-L<(android_stlport_libs)/mips', |
| 180 | ], |
| 181 | }], |
| 182 | ['target_arch=="ia32" or target_arch=="x87"', { |
| 183 | 'ldflags': [ |
| 184 | '-L<(android_stlport_libs)/x86', |
| 185 | ], |
| 186 | }], |
| 187 | ['target_arch=="x64"', { |
| 188 | 'ldflags': [ |
| 189 | '-L<(android_stlport_libs)/x86_64', |
| 190 | ], |
| 191 | }], |
| 192 | ['target_arch=="arm64"', { |
| 193 | 'ldflags': [ |
| 194 | '-L<(android_stlport_libs)/arm64-v8a', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 195 | ], |
| 196 | }], |
| 197 | ], |
| 198 | }], |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 199 | ['target_arch=="ia32" or target_arch=="x87"', { |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 200 | # The x86 toolchain currently has problems with stack-protector. |
| 201 | 'cflags!': [ |
| 202 | '-fstack-protector', |
| 203 | ], |
| 204 | 'cflags': [ |
| 205 | '-fno-stack-protector', |
| 206 | ], |
| 207 | }], |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 208 | ['target_arch=="mipsel"', { |
| 209 | # The mips toolchain currently has problems with stack-protector. |
| 210 | 'cflags!': [ |
| 211 | '-fstack-protector', |
| 212 | '-U__linux__' |
| 213 | ], |
| 214 | 'cflags': [ |
| 215 | '-fno-stack-protector', |
| 216 | ], |
| 217 | }], |
Emily Bernier | d0a1eb7 | 2015-03-24 16:35:39 -0400 | [diff] [blame^] | 218 | ['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64") and component!="shared_library"', { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 219 | 'cflags': [ |
| 220 | '-fPIE', |
| 221 | ], |
| 222 | 'ldflags': [ |
| 223 | '-pie', |
| 224 | ], |
| 225 | }], |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 226 | ], |
| 227 | 'target_conditions': [ |
| 228 | ['_type=="executable"', { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 229 | 'conditions': [ |
| 230 | ['target_arch=="arm64"', { |
| 231 | 'ldflags': [ |
| 232 | '-Wl,-dynamic-linker,/system/bin/linker64', |
| 233 | ], |
| 234 | }, { |
| 235 | 'ldflags': [ |
| 236 | '-Wl,-dynamic-linker,/system/bin/linker', |
| 237 | ], |
| 238 | }] |
| 239 | ], |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 240 | 'ldflags': [ |
| 241 | '-Bdynamic', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 242 | '-Wl,-z,nocopyreloc', |
| 243 | # crtbegin_dynamic.o should be the last item in ldflags. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 244 | '<(android_lib)/crtbegin_dynamic.o', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 245 | ], |
| 246 | 'libraries': [ |
| 247 | # crtend_android.o needs to be the last item in libraries. |
| 248 | # Do not add any libraries after this! |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 249 | '<(android_lib)/crtend_android.o', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 250 | ], |
| 251 | }], |
| 252 | ['_type=="shared_library"', { |
| 253 | 'ldflags': [ |
| 254 | '-Wl,-shared,-Bsymbolic', |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 255 | '<(android_lib)/crtbegin_so.o', |
| 256 | ], |
| 257 | }], |
| 258 | ['_type=="static_library"', { |
| 259 | 'ldflags': [ |
| 260 | # Don't export symbols from statically linked libraries. |
| 261 | '-Wl,--exclude-libs=ALL', |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 262 | ], |
| 263 | }], |
| 264 | ], |
| 265 | }], # _toolset=="target" |
| 266 | # Settings for building host targets using the system toolchain. |
| 267 | ['_toolset=="host"', { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 268 | 'cflags': [ '-pthread' ], |
| 269 | 'ldflags': [ '-pthread' ], |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame] | 270 | 'ldflags!': [ |
| 271 | '-Wl,-z,noexecstack', |
| 272 | '-Wl,--gc-sections', |
| 273 | '-Wl,-O1', |
| 274 | '-Wl,--as-needed', |
| 275 | ], |
| 276 | }], |
| 277 | ], # target_conditions |
| 278 | }, # target_defaults |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 279 | } |