OLD | NEW |
1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 # for details. All rights reserved. Use of this source code is governed by a | 2 # for details. All rights reserved. Use of this source code is governed by a |
3 # BSD-style license that can be found in the LICENSE file. | 3 # BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 # Definitions for building standalone Dart binaries to run on Android. | 5 # Definitions for building standalone Dart binaries to run on Android. |
6 # This is mostly excerpted from: | 6 # This is mostly excerpted from: |
7 # http://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi | 7 # http://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi |
8 | 8 |
9 { | 9 { |
10 'variables': { | 10 'variables': { |
11 # Location of Android NDK. | 11 'android_ndk_root': '<(PRODUCT_DIR)/../../third_party/android_tools/ndk', |
12 'variables': { | |
13 'variables': { | |
14 'android_ndk_root%': '<!(/bin/echo -n $ANDROID_NDK_ROOT)', | |
15 | |
16 # Switch between different build types, currently only '0' is | |
17 # supported. | |
18 'android_build_type%': 0, | |
19 }, | |
20 'android_ndk_root%': '<(android_ndk_root)', | |
21 'android_ndk_sysroot': '<(android_ndk_root)/platforms/android-9/arch-<(and
roid_target_arch)', | |
22 'android_build_type%': '<(android_build_type)', | |
23 }, | |
24 'android_ndk_root%': '<(android_ndk_root)', | |
25 'android_ndk_sysroot': '<(android_ndk_sysroot)', | |
26 'android_ndk_include': '<(android_ndk_sysroot)/usr/include', | |
27 'android_ndk_lib': '<(android_ndk_sysroot)/usr/lib', | |
28 # Enable to use the system stlport, otherwise statically | |
29 # link the NDK one? | |
30 'use_system_stlport%': '<(android_build_type)', | |
31 'android_stlport_library': 'stlport_static', | |
32 # Copy it out one scope. | |
33 'android_build_type%': '<(android_build_type)', | |
34 | |
35 'OS': 'android', | |
36 'android_target_arch' : 'x86', | |
37 }, # variables | 12 }, # variables |
38 'target_defaults': { | 13 'target_defaults': { |
39 'defines': [ | |
40 'ANDROID', | |
41 ], | |
42 'configurations': { | 14 'configurations': { |
43 'Dart_Debug': { | 15 # It is very important to get the order of the linker arguments correct. |
| 16 # Therefore, we put them all in the architecture specific configurations, |
| 17 # even though there are many flags in common, to avoid splitting them |
| 18 # between two configurations and possibly accidentally mixing up the |
| 19 # order. |
| 20 'Dart_Android_Base': { |
| 21 'abstract': 1, |
| 22 'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter', |
| 23 '-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions',], |
| 24 'target_conditions': [ |
| 25 ['_toolset=="target"', { |
| 26 'defines': [ |
| 27 'ANDROID', |
| 28 'USE_STLPORT=1', |
| 29 '_STLP_USE_PTR_SPECIALIZATIONS=1', |
| 30 '_STLP_NO_CSTD_FUNCTION_IMPORTS=1', |
| 31 'HAVE_OFF64_T', |
| 32 'HAVE_SYS_UIO_H', |
| 33 ], |
| 34 'cflags!': [ |
| 35 '-pthread', # Not supported by Android toolchain. |
| 36 ], |
| 37 'cflags': [ |
| 38 '-U__linux__', # Don't allow toolchain to claim -D__linux__ |
| 39 '-ffunction-sections', |
| 40 '-funwind-tables', |
| 41 '-fstack-protector', |
| 42 '-fno-short-enums', |
| 43 '-finline-limit=64', |
| 44 '-Wa,--noexecstack', |
| 45 ], |
| 46 }], |
| 47 # Settings for building host targets using the system toolchain. |
| 48 ['_toolset=="host"', { |
| 49 'cflags': [ '-m32', '-pthread' ], |
| 50 }], |
| 51 ], |
| 52 }, |
| 53 'Dart_Android_Debug': { |
| 54 'abstract': 1, |
44 'defines': [ | 55 'defines': [ |
45 'DEBUG', | 56 'DEBUG', |
46 ], | 57 ], |
47 }, | 58 }, |
48 'Dart_Release': { | 59 'Dart_Android_Release': { |
| 60 'abstract': 1, |
49 'defines': [ | 61 'defines': [ |
50 'NDEBUG', | 62 'NDEBUG', |
51 ], | 63 ], |
52 'cflags!': [ | 64 'cflags!': [ |
53 '-O2', | 65 '-O2', |
54 '-Os', | 66 '-Os', |
55 ], | 67 ], |
56 'cflags': [ | 68 'cflags': [ |
57 '-fdata-sections', | 69 '-fdata-sections', |
58 '-ffunction-sections', | 70 '-ffunction-sections', |
59 '-fno-omit-frame-pointer', | 71 '-fno-omit-frame-pointer', |
60 '-O3', | 72 '-O3', |
61 ], | 73 ], |
62 }, | 74 }, |
63 }, # configurations | 75 'Dart_Android_ia32_Base': { |
64 'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter', | 76 'abstract': 1, |
65 '-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions', ], | 77 'variables': { |
66 'target_conditions': [ | 78 'android_sysroot': '<(android_ndk_root)/platforms/android-14/arch-x86'
, |
67 ['_toolset=="target"', { | 79 'android_ndk_include': '<(android_sysroot)/usr/include', |
68 'cflags!': [ | 80 'android_ndk_lib': '<(android_sysroot)/usr/lib', |
69 '-pthread', # Not supported by Android toolchain. | 81 }, |
70 ], | 82 'target_conditions': [ |
71 'cflags': [ | 83 ['_toolset=="target"', { |
72 '-U__linux__', # Don't allow toolchain to claim -D__linux__ | |
73 '-ffunction-sections', | |
74 '-funwind-tables', | |
75 '-fstack-protector', | |
76 '-fno-short-enums', | |
77 '-finline-limit=64', | |
78 '-Wa,--noexecstack', | |
79 # Note: This include is in cflags to ensure that it comes after | |
80 # all of the includes. | |
81 '-I<(android_ndk_include)', | |
82 ], | |
83 'defines': [ | |
84 'ANDROID', | |
85 'USE_STLPORT=1', | |
86 '_STLP_USE_PTR_SPECIALIZATIONS=1', | |
87 '_STLP_NO_CSTD_FUNCTION_IMPORTS=1', | |
88 'HAVE_OFF64_T', | |
89 'HAVE_SYS_UIO_H', | |
90 ], | |
91 'ldflags!': [ | |
92 '-pthread', # Not supported by Android toolchain. | |
93 ], | |
94 'ldflags': [ | |
95 '-nostdlib', | |
96 '-Wl,--no-undefined', | |
97 # Don't export symbols from statically linked libraries. | |
98 '-Wl,--exclude-libs=ALL', | |
99 ], | |
100 'libraries!': [ | |
101 '-lrt', # librt is built into Bionic. | |
102 # Not supported by Android toolchain. | |
103 # Where do these come from? Can't find references in | |
104 # any Chromium gyp or gypi file. Maybe they come from | |
105 # gyp itself? | |
106 '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4'
, '-lnspr4', | |
107 ], | |
108 'libraries': [ | |
109 '-l<(android_stlport_library)', | |
110 # Manually link the libgcc.a that the cross compiler uses. | |
111 # this picks up compiler-dependent math intrinsics. | |
112 '<!(${ANDROID_TOOLCHAIN}/*-gcc -print-libgcc-file-name)', | |
113 '-lc', | |
114 '-ldl', | |
115 '-lstdc++', | |
116 '-lm', | |
117 ], | |
118 'conditions': [ | |
119 ['android_build_type==0', { | |
120 'ldflags': [ | |
121 '-Wl,-rpath-link=<(android_ndk_lib)', | |
122 '-L<(android_ndk_lib)', | |
123 ], | |
124 }], | |
125 ['target_arch == "arm"', { | |
126 'ldflags': [ | |
127 # Enable identical code folding to reduce size. | |
128 '-Wl,--icf=safe', | |
129 ], | |
130 }], | |
131 ['target_arch=="arm" and armv7==1', { | |
132 'cflags': [ | |
133 '-march=armv7-a', | |
134 '-mtune=cortex-a8', | |
135 '-mfpu=vfp3', | |
136 ], | |
137 }], | |
138 # NOTE: The stlport header include paths below are specified in | |
139 # cflags rather than include_dirs because they need to come | |
140 # after include_dirs. Think of them like system headers, but | |
141 # don't use '-isystem' because the arm-linux-androideabi-4.4.3 | |
142 # toolchain (circa Gingerbread) will exhibit strange errors. | |
143 # The include ordering here is important; change with caution. | |
144 ['use_system_stlport==0', { | |
145 'cflags': [ | |
146 '-I<(android_ndk_root)/sources/cxx-stl/stlport/stlport', | |
147 ], | |
148 'conditions': [ | |
149 ['target_arch=="arm" and armv7==1', { | |
150 'ldflags': [ | |
151 '-L<(android_ndk_root)/sources/cxx-stl/stlport/libs/armeabi-v7
a', | |
152 ], | |
153 }], | |
154 ['target_arch=="arm" and armv7==0', { | |
155 'ldflags': [ | |
156 '-L<(android_ndk_root)/sources/cxx-stl/stlport/libs/armeabi', | |
157 ], | |
158 }], | |
159 ['target_arch=="ia32"', { | |
160 'ldflags': [ | |
161 '-L<(android_ndk_root)/sources/cxx-stl/stlport/libs/x86', | |
162 ], | |
163 }], | |
164 ], | |
165 }], | |
166 ['target_arch=="ia32"', { | |
167 # The x86 toolchain currently has problems with stack-protector. | 84 # The x86 toolchain currently has problems with stack-protector. |
168 'cflags!': [ | 85 'cflags!': [ |
169 '-fstack-protector', | 86 '-fstack-protector', |
170 ], | 87 ], |
171 'cflags': [ | 88 'cflags': [ |
| 89 '-I<(android_ndk_include)', |
| 90 '-I<(android_ndk_root)/sources/cxx-stl/stlport/stlport', |
172 '-fno-stack-protector', | 91 '-fno-stack-protector', |
173 ], | 92 ], |
174 }], | 93 'target_conditions': [ |
175 ], | 94 ['_type=="executable"', { |
176 'target_conditions': [ | 95 'ldflags!': ['-Wl,--exclude-libs=ALL,-shared',], |
177 ['_type=="executable"', { | 96 }], |
| 97 ['_type=="shared_library"', { |
| 98 'ldflags': ['-Wl,-shared,-Bsymbolic',], |
| 99 }], |
| 100 ], |
178 'ldflags': [ | 101 'ldflags': [ |
| 102 'ia32', '>(_type)', 'target', |
| 103 '-nostdlib', |
| 104 '-Wl,--no-undefined', |
| 105 # Don't export symbols from statically linked libraries. |
| 106 '-Wl,--exclude-libs=ALL', |
| 107 '-Wl,-rpath-link=<(android_ndk_lib)', |
| 108 '-L<(android_ndk_lib)', |
| 109 # NOTE: The stlport header include paths below are specified in |
| 110 # cflags rather than include_dirs because they need to come |
| 111 # after include_dirs. Think of them like system headers, but |
| 112 # don't use '-isystem' because the arm-linux-androideabi-4.4.3 |
| 113 # toolchain (circa Gingerbread) will exhibit strange errors. |
| 114 # The include ordering here is important; change with caution. |
| 115 '-L<(android_ndk_root)/sources/cxx-stl/stlport/libs/x86', |
| 116 '-z', |
| 117 'muldefs', |
179 '-Bdynamic', | 118 '-Bdynamic', |
180 '-Wl,-dynamic-linker,/system/bin/linker', | 119 '-Wl,-dynamic-linker,/system/bin/linker', |
181 '-Wl,--gc-sections', | 120 '-Wl,--gc-sections', |
| 121 '-Wl,-z,nocopyreloc', |
| 122 # crtbegin_dynamic.o should be the last item in ldflags. |
| 123 '<(android_ndk_lib)/crtbegin_dynamic.o', |
| 124 ], |
| 125 'ldflags!': [ |
| 126 '-pthread', # Not supported by Android toolchain. |
| 127 ], |
| 128 }], |
| 129 ['_toolset=="host"', { |
| 130 'ldflags': [ '-m32', '-pthread' ], |
| 131 }], |
| 132 ], |
| 133 }, |
| 134 'Dart_Android_arm_Base': { |
| 135 'abstract': 1, |
| 136 'variables': { |
| 137 'android_sysroot': '<(android_ndk_root)/platforms/android-14/arch-arm'
, |
| 138 'android_ndk_include': '<(android_sysroot)/usr/include', |
| 139 'android_ndk_lib': '<(android_sysroot)/usr/lib', |
| 140 }, |
| 141 'target_conditions': [ |
| 142 ['_toolset=="target"', { |
| 143 'cflags': [ |
| 144 '-I<(android_ndk_include)', |
| 145 '-I<(android_ndk_root)/sources/cxx-stl/stlport/stlport', |
| 146 '-march=armv7-a', |
| 147 '-mtune=cortex-a8', |
| 148 '-mfpu=vfp3', |
| 149 '-mfloat-abi=softfp', |
| 150 ], |
| 151 'target_conditions': [ |
| 152 ['_type=="executable"', { |
| 153 'ldflags!': ['-Wl,--exclude-libs=ALL,-shared',], |
| 154 }], |
| 155 ['_type=="shared_library"', { |
| 156 'ldflags': ['-Wl,-shared,-Bsymbolic',], |
| 157 }], |
| 158 ], |
| 159 'ldflags': [ |
| 160 'arm', '>(_type)', 'target', |
| 161 '-nostdlib', |
| 162 '-Wl,--no-undefined', |
| 163 # Don't export symbols from statically linked libraries. |
| 164 '-Wl,--exclude-libs=ALL', |
| 165 '-Wl,-rpath-link=<(android_ndk_lib)', |
| 166 '-L<(android_ndk_lib)', |
| 167 # Enable identical code folding to reduce size. |
| 168 '-Wl,--icf=safe', |
| 169 '-L<(android_ndk_root)/sources/cxx-stl/stlport/libs/armeabi-v7a', |
| 170 '-z', |
| 171 'muldefs', |
| 172 '-Bdynamic', |
| 173 '-Wl,-dynamic-linker,/system/bin/linker', |
| 174 '-Wl,--gc-sections', |
182 '-Wl,-z,nocopyreloc', | 175 '-Wl,-z,nocopyreloc', |
183 # crtbegin_dynamic.o should be the last item in ldflags. | 176 # crtbegin_dynamic.o should be the last item in ldflags. |
184 '<(android_ndk_lib)/crtbegin_dynamic.o', | 177 '<(android_ndk_lib)/crtbegin_dynamic.o', |
185 ], | 178 ], |
186 'libraries': [ | 179 'ldflags!': [ |
187 # crtend_android.o needs to be the last item in libraries. | 180 '-pthread', # Not supported by Android toolchain. |
188 # Do not add any libraries after this! | |
189 '<(android_ndk_lib)/crtend_android.o', | |
190 ], | 181 ], |
191 }], | 182 }], |
192 ['_type=="shared_library"', { | 183 ['_toolset=="host"', { |
193 'ldflags': [ | 184 'ldflags': [ '-m32', '-pthread' ], |
194 '-Wl,-shared,-Bsymbolic', | |
195 ], | |
196 }], | 185 }], |
197 ], | 186 ], |
198 }], # _toolset=="target" | 187 }, |
199 # Settings for building host targets using the system toolchain. | 188 }, # configurations |
200 ['_toolset=="host"', { | |
201 'cflags': [ '-m32', '-pthread' ], | |
202 'ldflags': [ '-m32', '-pthread' ], | |
203 'ldflags!': [ | |
204 '-Wl,-z,noexecstack', | |
205 '-Wl,--gc-sections', | |
206 '-Wl,-O1', | |
207 '-Wl,--as-needed', | |
208 ], | |
209 }], | |
210 ], # target_conditions | |
211 }, # target_defaults | 189 }, # target_defaults |
212 } | 190 } |
OLD | NEW |