Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / native_client / build / android_settings.gypi
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 {
6   # This block was taken wholesale from chromium's build/common.gypi
7   # BEGIN CODE TAKEN FROM CHROME'S COMMON.GYPI
8   'variables': {
9     # Location of Android NDK.
10     'variables': {
11       'variables': {
12         # Unfortunately we have to use absolute paths to the SDK/NDK because
13         # they're passed to ant which uses a different relative path from
14         # gyp.
15         'android_ndk_root%': '<!(cd <(DEPTH) && pwd -P)/third_party/android_tools/ndk/',
16         'android_ndk_experimental_root%': '<!(cd <(DEPTH) && pwd -P)/third_party/android_tools/ndk_experimental/',
17         'android_sdk_root%': '<!(cd <(DEPTH) && pwd -P)/third_party/android_tools/sdk/',
18         'android_host_arch%': '<!(uname -m)',
19         # Android API-level of the SDK used for compilation.
20         'android_sdk_version%': '19',
21         'android_sdk_build_tools_version%': '19.0.0',
22         'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
23       },
24       # Copy conditionally-set variables out one scope.
25       'android_ndk_root%': '<(android_ndk_root)',
26       'android_sdk_root%': '<(android_sdk_root)',
27       'android_sdk_version%': '<(android_sdk_version)',
28       'android_stlport_root': '<(android_ndk_root)/sources/cxx-stl/stlport',
29       'host_os%': '<(host_os)',
30
31       'android_sdk%': '<(android_sdk_root)/platforms/android-<(android_sdk_version)',
32       # Android SDK build tools (e.g. dx, aapt, aidl)
33       'android_sdk_tools%': '<(android_sdk_root)/build-tools/<(android_sdk_build_tools_version)',
34
35       # Android API level 14 is ICS (Android 4.0) which is the minimum
36       # platform requirement for Chrome on Android, we use it for native
37       # code compilation.
38       'conditions': [
39         ['target_arch == "ia32"', {
40           'android_app_abi%': 'x86',
41           'android_gdbserver%': '<(android_ndk_root)/prebuilt/android-x86/gdbserver/gdbserver',
42           'android_ndk_sysroot%': '<(android_ndk_root)/platforms/android-14/arch-x86',
43           'android_ndk_lib_dir%': 'usr/lib',
44           'android_toolchain%': '<(android_ndk_root)/toolchains/x86-4.6/prebuilt/<(host_os)-<(android_host_arch)/bin',
45         }],
46         ['target_arch == "x64"', {
47           'android_app_abi%': 'x86_64',
48           'android_gdbserver%': '<(android_ndk_experimental_root)/prebuilt/android-x86_64/gdbserver/gdbserver',
49           'android_ndk_sysroot%': '<(android_ndk_experimental_root)/platforms/android-20/arch-x86_64',
50           'android_ndk_lib_dir%': 'usr/lib64',
51           'android_toolchain%': '<(android_ndk_experimental_root)/toolchains/x86_64-4.8/prebuilt/<(host_os)-<(android_host_arch)/bin',
52           'android_stlport_root': '<(android_ndk_experimental_root)/sources/cxx-stl/stlport',
53         }],
54         ['target_arch=="arm"', {
55           'conditions': [
56             ['arm_version<7', {
57               'android_app_abi%': 'armeabi',
58             }, {
59               'android_app_abi%': 'armeabi-v7a',
60             }],
61           ],
62           'android_gdbserver%': '<(android_ndk_root)/prebuilt/android-arm/gdbserver/gdbserver',
63           'android_ndk_sysroot%': '<(android_ndk_root)/platforms/android-14/arch-arm',
64           'android_ndk_lib_dir%': 'usr/lib',
65           'android_toolchain%': '<(android_ndk_root)/toolchains/arm-linux-androideabi-4.6/prebuilt/<(host_os)-<(android_host_arch)/bin',
66         }],
67         ['target_arch == "arm64"', {
68           'android_app_abi%': 'arm64-v8a',
69           'android_gdbserver%': '<(android_ndk_experimental_root)/prebuilt/android-arm64/gdbserver/gdbserver',
70           'android_ndk_sysroot%': '<(android_ndk_experimental_root)/platforms/android-20/arch-arm64',
71           'android_ndk_lib_dir%': 'usr/lib',
72           'android_toolchain%': '<(android_ndk_experimental_root)/toolchains/aarch64-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
73           'android_stlport_root': '<(android_ndk_experimental_root)/sources/cxx-stl/stlport',
74         }],
75         ['target_arch == "mipsel"', {
76           'android_app_abi%': 'mips',
77           'android_gdbserver%': '<(android_ndk_root)/prebuilt/android-mips/gdbserver/gdbserver',
78           'android_ndk_sysroot%': '<(android_ndk_root)/platforms/android-14/arch-mips',
79           'android_ndk_lib_dir%': 'usr/lib',
80           'android_toolchain%': '<(android_ndk_root)/toolchains/mipsel-linux-android-4.6/prebuilt/<(host_os)-<(android_host_arch)/bin',
81         }],
82       ],
83     },
84     # Copy conditionally-set variables out one scope.
85     'android_app_abi%': '<(android_app_abi)',
86     'android_gdbserver%': '<(android_gdbserver)',
87     'android_ndk_root%': '<(android_ndk_root)',
88     'android_ndk_sysroot%': '<(android_ndk_sysroot)',
89     'android_sdk_root%': '<(android_sdk_root)',
90     'android_sdk_version%': '<(android_sdk_version)',
91     'android_toolchain%': '<(android_toolchain)',
92
93     'android_ndk_include': '<(android_ndk_sysroot)/usr/include',
94     'android_ndk_lib': '<(android_ndk_sysroot)/<(android_ndk_lib_dir)',
95     'android_sdk_tools%': '<(android_sdk_tools)',
96     'android_sdk%': '<(android_sdk)',
97     'android_sdk_jar%': '<(android_sdk)/android.jar',
98
99     'android_stlport_root': '<(android_stlport_root)',
100     'android_stlport_include': '<(android_stlport_root)/stlport',
101     'android_stlport_libs_dir': '<(android_stlport_root)/libs/<(android_app_abi)',
102     'host_os%': '<(host_os)',
103
104     # Location of the "strip" binary, used by both gyp and scripts.
105     'android_strip%' : '<!(/bin/echo -n <(android_toolchain)/*-strip)',
106
107     # Location of the "readelf" binary.
108     'android_readelf%' : '<!(/bin/echo -n <(android_toolchain)/*-readelf)',
109
110     # Determines whether we should optimize JNI generation at the cost of
111     # breaking assumptions in the build system that when inputs have changed
112     # the outputs should always change as well.  This is meant purely for
113     # developer builds, to avoid spurious re-linking of native files.
114     'optimize_jni_generation%': 0,
115   },
116   # END CODE TAKEN FROM CHROME'S COMMON.GYPI
117   # Hardcode the compiler names in the Makefile so that
118   # it won't depend on the environment at make time.
119   'make_global_settings': [
120     ['CC', '<!(/bin/echo -n <(android_toolchain)/*-gcc)'],
121     ['CXX', '<!(/bin/echo -n <(android_toolchain)/*-g++)'],
122     ['CC.host', '<!(which gcc)'],
123     ['CXX.host', '<!(which g++)'],
124   ],
125   'target_defaults': {
126     'target_conditions': [
127       # Settings for building device targets using Android's toolchain.
128       # These are based on the setup.mk file from the Android NDK.
129       #
130       # The NDK Android executable link step looks as follows:
131       #  $LDFLAGS
132       #  $(TARGET_CRTBEGIN_DYNAMIC_O)  <-- crtbegin.o
133       #  $(PRIVATE_OBJECTS)            <-- The .o that we built
134       #  $(PRIVATE_STATIC_LIBRARIES)   <-- The .a that we built
135       #  $(TARGET_LIBGCC)              <-- libgcc.a
136       #  $(PRIVATE_SHARED_LIBRARIES)   <-- The .so that we built
137       #  $(PRIVATE_LDLIBS)             <-- System .so
138       #  $(TARGET_CRTEND_O)            <-- crtend.o
139       #
140       # For now the above are approximated for executables by adding
141       # crtbegin.o to the end of the ldflags and 'crtend.o' to the end
142       # of 'libraries'.
143       #
144       # The NDK Android shared library link step looks as follows:
145       #  $LDFLAGS
146       #  $(PRIVATE_OBJECTS)            <-- The .o that we built
147       #  -l,--whole-archive
148       #  $(PRIVATE_WHOLE_STATIC_LIBRARIES)
149       #  -l,--no-whole-archive
150       #  $(PRIVATE_STATIC_LIBRARIES)   <-- The .a that we built
151       #  $(TARGET_LIBGCC)              <-- libgcc.a
152       #  $(PRIVATE_SHARED_LIBRARIES)   <-- The .so that we built
153       #  $(PRIVATE_LDLIBS)             <-- System .so
154       #
155       # For now, assume that whole static libraries are not needed.
156       #
157       # For both executables and shared libraries, add the proper
158       # libgcc.a to the start of libraries which puts it in the
159       # proper spot after .o and .a files get linked in.
160       #
161       # TODO: The proper thing to do longer-tem would be proper gyp
162       # support for a custom link command line.
163       ['_toolset=="target"', {
164         # NOTE: The stlport header include paths below are specified in
165         # cflags rather than include_dirs because they need to come
166         # after include_dirs. This is because they notably contain stddef.h
167         # that define things incompatibly.
168         'cflags': [
169           '--sysroot=<(android_ndk_sysroot)',
170           '-I<(android_stlport_include)',
171           '-fPIE',
172           '-fvisibility=default',
173           '-ffunction-sections',
174           '-funwind-tables',
175           '-fstack-protector',
176           '-fno-short-enums',
177           '-finline-limit=64',
178           '-Wa,--noexecstack',
179         ],
180         'defines': [
181           'ANDROID',
182           '__GNU_SOURCE=1',  # Necessary for strerror_r()
183           'USE_STLPORT=1',
184           '_STLP_USE_PTR_SPECIALIZATIONS=1',
185         ],
186         'ldflags!': ['-pthread'],
187         'ldflags': [
188           '-Bdynamic',
189           '-Wl,--gc-sections',
190           '-Wl,-z,nocopyreloc',
191           '-pie',
192           '-rdynamic',
193           '--sysroot=<(android_ndk_sysroot)',
194           '-nostdlib',
195           '-Wl,--no-undefined',
196           '-L<(android_stlport_root)/libs/<(android_app_abi)',
197           # Don't export symbols from statically linked libraries.
198           '-Wl,--exclude-libs=ALL',
199           # crtbegin_dynamic.o should be the last item in ldflags.
200           '<(android_ndk_lib)/crtbegin_dynamic.o',
201         ],
202         'libraries': [
203           '-lstlport_shared',
204           # Manually link the libgcc.a that the cross compiler uses.
205           '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
206           '-lc',
207           '-ldl',
208           '-lm',
209           # crtend_android.o needs to be the last item in libraries.
210           # Do not add any libraries after this!
211           '<(android_ndk_lib)/crtend_android.o',
212         ],
213       }],
214     ],
215   }
216 }