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',
47 ['target_arch=="x64"', {
48 'android_lib': '<(android_sysroot)/usr/lib64',
50 'android_lib': '<(android_sysroot)/usr/lib',
53 'android_stlport_include': '<(android_stlport)/stlport',
54 'android_stlport_libs': '<(android_stlport)/libs',
57 'android_sysroot': '<(android_ndk_root)/platforms/android-<(android_target_platform)/arch-<(android_target_arch)',
58 'android_stlport': '<(android_ndk_root)/sources/cxx-stl/stlport/',
60 'android_include': '<(android_sysroot)/usr/include',
62 ['target_arch=="x64"', {
63 'android_lib': '<(android_sysroot)/usr/lib64',
65 'android_lib': '<(android_sysroot)/usr/lib',
68 'android_stlport_include': '<(android_stlport)/stlport',
69 'android_stlport_libs': '<(android_stlport)/libs',
72 # Enable to use the system stlport, otherwise statically
74 'use_system_stlport%': '<(android_webview_build)',
75 'android_stlport_library': 'stlport_static',
80 'V8_ANDROID_LOG_STDOUT',
85 '-fomit-frame-pointer',
89 'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter'],
90 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions',
91 # Note: Using -std=c++0x will define __STRICT_ANSI__, which
92 # in turn will leave out some template stuff for 'long
93 # long'. What we want is -std=c++11, but this is not
94 # supported by GCC 4.6 or Xcode 4.2
96 'target_conditions': [
97 ['_toolset=="target"', {
99 '-pthread', # Not supported by Android toolchain.
102 '-ffunction-sections',
108 # Note: This include is in cflags to ensure that it comes after
109 # all of the includes.
110 '-I<(android_include)',
113 '-Wno-error=non-virtual-dtor', # TODO(michaelbai): Fix warnings.
117 #'__GNU_SOURCE=1', # Necessary for clone()
119 '_STLP_USE_PTR_SPECIALIZATIONS=1',
122 'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
125 '-pthread', # Not supported by Android toolchain.
129 '-Wl,--no-undefined',
132 '-lrt', # librt is built into Bionic.
133 # Not supported by Android toolchain.
134 # Where do these come from? Can't find references in
135 # any Chromium gyp or gypi file. Maybe they come from
137 '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4', '-lnspr4',
140 '-l<(android_stlport_library)',
141 # Manually link the libgcc.a that the cross compiler uses.
142 '<!($CC -print-libgcc-file-name)',
149 ['android_webview_build==0', {
151 '-Wl,-rpath-link=<(android_lib)',
155 ['target_arch == "arm"', {
157 # Enable identical code folding to reduce size.
161 ['target_arch=="arm" and arm_version==7', {
168 # NOTE: The stlport header include paths below are specified in
169 # cflags rather than include_dirs because they need to come
170 # after include_dirs. Think of them like system headers, but
171 # don't use '-isystem' because the arm-linux-androideabi-4.4.3
172 # toolchain (circa Gingerbread) will exhibit strange errors.
173 # The include ordering here is important; change with caution.
174 ['use_system_stlport==0', {
176 '-I<(android_stlport_include)',
179 ['target_arch=="arm" and arm_version==7', {
181 '-L<(android_stlport_libs)/armeabi-v7a',
184 ['target_arch=="arm" and arm_version < 7', {
186 '-L<(android_stlport_libs)/armeabi',
189 ['target_arch=="mipsel"', {
191 '-L<(android_stlport_libs)/mips',
194 ['target_arch=="ia32" or target_arch=="x87"', {
196 '-L<(android_stlport_libs)/x86',
199 ['target_arch=="x64"', {
201 '-L<(android_stlport_libs)/x86_64',
204 ['target_arch=="arm64"', {
206 '-L<(android_stlport_libs)/arm64-v8a',
211 ['target_arch=="ia32" or target_arch=="x87"', {
212 # The x86 toolchain currently has problems with stack-protector.
217 '-fno-stack-protector',
220 ['target_arch=="mipsel"', {
221 # The mips toolchain currently has problems with stack-protector.
227 '-fno-stack-protector',
230 ['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64") and component!="shared_library"', {
239 'target_conditions': [
240 ['_type=="executable"', {
242 ['target_arch=="arm64" or target_arch=="x64"', {
244 '-Wl,-dynamic-linker,/system/bin/linker64',
248 '-Wl,-dynamic-linker,/system/bin/linker',
254 '-Wl,-z,nocopyreloc',
255 # crtbegin_dynamic.o should be the last item in ldflags.
256 '<(android_lib)/crtbegin_dynamic.o',
259 # crtend_android.o needs to be the last item in libraries.
260 # Do not add any libraries after this!
261 '<(android_lib)/crtend_android.o',
264 ['_type=="shared_library"', {
266 '-Wl,-shared,-Bsymbolic',
267 '<(android_lib)/crtbegin_so.o',
270 ['_type=="static_library"', {
272 # Don't export symbols from statically linked libraries.
273 '-Wl,--exclude-libs=ALL',
277 }], # _toolset=="target"
278 # Settings for building host targets using the system toolchain.
279 ['_toolset=="host"', {
280 'cflags': [ '-pthread' ],
281 'ldflags': [ '-pthread' ],
283 '-Wl,-z,noexecstack',
289 ], # target_conditions