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
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.
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.
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
34 # Location of Android NDK.
36 'android_ndk_root%': '<!(/bin/echo -n $ANDROID_NDK_ROOT)',
37 'android_toolchain%': '<!(/bin/echo -n $ANDROID_TOOLCHAIN)',
40 ['android_ndk_root==""', {
42 'android_sysroot': '<(android_toolchain)/sysroot/',
43 'android_stlport': '<(android_toolchain)/sources/cxx-stl/stlport/',
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',
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/',
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',
60 # Enable to use the system stlport, otherwise statically
62 'use_system_stlport%': '<(android_webview_build)',
63 'android_stlport_library': 'stlport_static',
68 'V8_ANDROID_LOG_STDOUT',
73 '-fomit-frame-pointer',
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
84 'target_conditions': [
85 ['_toolset=="target"', {
87 '-pthread', # Not supported by Android toolchain.
90 '-ffunction-sections',
96 # Note: This include is in cflags to ensure that it comes after
97 # all of the includes.
98 '-I<(android_include)',
101 '-Wno-error=non-virtual-dtor', # TODO(michaelbai): Fix warnings.
105 #'__GNU_SOURCE=1', # Necessary for clone()
107 '_STLP_USE_PTR_SPECIALIZATIONS=1',
110 'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
113 '-pthread', # Not supported by Android toolchain.
117 '-Wl,--no-undefined',
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
125 '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4', '-lnspr4',
128 '-l<(android_stlport_library)',
129 # Manually link the libgcc.a that the cross compiler uses.
130 '<!($CC -print-libgcc-file-name)',
137 ['android_webview_build==0', {
139 '-Wl,-rpath-link=<(android_lib)',
143 ['target_arch == "arm"', {
145 # Enable identical code folding to reduce size.
149 ['target_arch=="arm" and arm_version==7', {
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', {
164 '-I<(android_stlport_include)',
167 ['target_arch=="arm" and arm_version==7', {
169 '-L<(android_stlport_libs)/armeabi-v7a',
172 ['target_arch=="arm" and arm_version < 7', {
174 '-L<(android_stlport_libs)/armeabi',
177 ['target_arch=="mipsel"', {
179 '-L<(android_stlport_libs)/mips',
182 ['target_arch=="ia32" or target_arch=="x87"', {
184 '-L<(android_stlport_libs)/x86',
187 ['target_arch=="x64"', {
189 '-L<(android_stlport_libs)/x86_64',
192 ['target_arch=="arm64"', {
194 '-L<(android_stlport_libs)/arm64-v8a',
199 ['target_arch=="ia32" or target_arch=="x87"', {
200 # The x86 toolchain currently has problems with stack-protector.
205 '-fno-stack-protector',
208 ['target_arch=="mipsel"', {
209 # The mips toolchain currently has problems with stack-protector.
215 '-fno-stack-protector',
218 ['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64") and component!="shared_library"', {
227 'target_conditions': [
228 ['_type=="executable"', {
230 ['target_arch=="arm64"', {
232 '-Wl,-dynamic-linker,/system/bin/linker64',
236 '-Wl,-dynamic-linker,/system/bin/linker',
242 '-Wl,-z,nocopyreloc',
243 # crtbegin_dynamic.o should be the last item in ldflags.
244 '<(android_lib)/crtbegin_dynamic.o',
247 # crtend_android.o needs to be the last item in libraries.
248 # Do not add any libraries after this!
249 '<(android_lib)/crtend_android.o',
252 ['_type=="shared_library"', {
254 '-Wl,-shared,-Bsymbolic',
255 '<(android_lib)/crtbegin_so.o',
258 ['_type=="static_library"', {
260 # Don't export symbols from statically linked libraries.
261 '-Wl,--exclude-libs=ALL',
265 }], # _toolset=="target"
266 # Settings for building host targets using the system toolchain.
267 ['_toolset=="host"', {
268 'cflags': [ '-pthread' ],
269 'ldflags': [ '-pthread' ],
271 '-Wl,-z,noexecstack',
277 ], # target_conditions