1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
# This file contains the default configuration to compile for Android
# platforms. It contains sensitive enviroment configuration that
# shouldn't be modified unless you know what you are doing.
# PLEASE, DO NOT EDIT THIS FILE
import os
from cerbero.config import Architecture, DistroVersion
from cerbero.errors import FatalError
import cerbero.utils.messages as m
variants += ['nopython', 'notestspackage']
# We don't want anything from linux system to be used on android :)
allow_system_libs=False
if not toolchain_prefix:
toolchain_prefix = os.path.join(home_dir, 'android-ndk-r13b')
toolchain_path = None
toolchain_version = None
if target_arch == Architecture.ARM or target_arch == Architecture.ARMv7:
tools_prefix = 'arm-linux-androideabi'
host = "arm-linux-androideabi"
_arch = 'arm'
for tc_version in ['4.9', '4.8', '4.7', '4.6']:
for tc_arch in ['darwin-x86', 'darwin-x86_64', 'linux-x86', 'linux-x86_64']:
tmp = '%s/toolchains/arm-linux-androideabi-%s/prebuilt/%s/bin' % (toolchain_prefix, tc_version, tc_arch)
if os.path.exists(tmp):
toolchain_path = tmp
toolchain_version = tc_version
break
if toolchain_path:
break
elif target_arch == Architecture.ARM64:
tools_prefix = 'aarch64-linux-android'
host = "aarch64-linux-android"
_arch = 'arm64'
for tc_version in ['4.9', '4.8', '4.7', '4.6']:
for tc_arch in ['darwin-x86', 'darwin-x86_64', 'linux-x86', 'linux-x86_64']:
tmp = '%s/toolchains/aarch64-linux-android-%s/prebuilt/%s/bin' % (toolchain_prefix, tc_version, tc_arch)
if os.path.exists(tmp):
toolchain_path = tmp
toolchain_version = tc_version
break
if toolchain_path:
break
elif target_arch == Architecture.X86:
tools_prefix = 'i686-linux-android'
host = "i686-linux-android"
_arch = 'x86'
for tc_version in ['4.9', '4.8', '4.7', '4.6']:
for tc_arch in ['darwin-x86', 'darwin-x86_64', 'linux-x86', 'linux-x86_64']:
tmp = '%s/toolchains/x86-%s/prebuilt/%s/bin' % (toolchain_prefix, tc_version, tc_arch)
if os.path.exists(tmp):
toolchain_path = tmp
toolchain_version = tc_version
break
if toolchain_path:
break
elif target_arch == Architecture.X86_64:
tools_prefix = 'x86_64-linux-android'
host = "x86_64-linux-android"
_arch = 'x86_64'
for tc_version in ['4.9', '4.8', '4.7', '4.6']:
for tc_arch in ['darwin-x86', 'darwin-x86_64', 'linux-x86', 'linux-x86_64']:
tmp = '%s/toolchains/x86_64-%s/prebuilt/%s/bin' % (toolchain_prefix, tc_version, tc_arch)
if os.path.exists(tmp):
toolchain_path = tmp
toolchain_version = tc_version
break
if toolchain_path:
break
elif target_arch == Architecture.UNIVERSAL:
_arch = ''
tools_prefix = ''
toolchain_path = '.'
else:
raise FatalError("Arch %s not supported" % target_arch)
if not toolchain_path:
m.warning ("Android NDK not found")
if target_distro_version == DistroVersion.ANDROID_GINGERBREAD:
v = '9'
elif target_distro_version == DistroVersion.ANDROID_ICE_CREAM_SANDWICH:
v = '14'
elif target_distro_version == DistroVersion.ANDROID_JELLY_BEAN:
v = '16'
elif target_distro_version == DistroVersion.ANDROID_KITKAT:
v = '19'
elif target_distro_version == DistroVersion.ANDROID_LOLLIPOP:
v = '21'
elif target_distro_version == DistroVersion.ANDROID_MARSHMALLOW:
v = '23'
elif target_distro_version == DistroVersion.ANDROID_NOUGAT:
v = '24'
else:
raise FatalError("DistroVersion not supported")
sysroot = "%s/platforms/android-%s/arch-%s" % (toolchain_prefix, v, _arch)
# Default compiler flags
os.environ['CFLAGS'] = '-Wall -g -Os '
os.environ['CXXFLAGS'] = '-Wall -g -Os '
os.environ['OBJCFLAGS'] = '-Wall -g -Os '
ccache = use_ccache and 'ccache ' or ''
defines = '-DANDROID -DPIC'
cflags = '--sysroot=%s -I%s/usr/include -ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes -fPIC' % (sysroot, sysroot)
ldflags = '--sysroot=%s -fPIC -no-canonical-prefixes -Wl,-no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,-dynamic-linker,/system/bin/linker ' % (sysroot)
if not target_arch in [Architecture.ARM64, Architecture.X86_64]:
# nocopyreloc causes broken linking on arm64
ldflags += ' -Wl,-z,nocopyreloc '
if target_arch in [Architecture.X86_64]:
ldflags += ' -L%s/usr/lib64 ' % sysroot
else:
ldflags += ' -L%s/usr/lib ' % sysroot
ldvariant = 'gold'
# from android-ndk-r8b/toolchains/$NAME-$VERSION/setup.mk
if target_arch in [Architecture.ARM, Architecture.ARMv7, Architecture.ARM64]:
if target_arch == Architecture.ARM:
defines += ' -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ '
cflags += ' -mthumb -march=armv5te -mtune=xscale -msoft-float'
elif target_arch == Architecture.ARMv7:
defines += ' -D__ARM_ARCH_7A__ '
cflags += ' -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16'
ldflags += "-march=armv7-a -Wl,--fix-cortex-a8 "
elif target_arch == Architecture.X86:
cflags += ' -march=i686 '
# Toolchain environment
os.environ['CPPFLAGS'] = '--sysroot=%s -I%s/usr/include %s' % (sysroot, sysroot, defines)
os.environ['CFLAGS'] += "%s %s -Wa,--noexecstack" % (cflags, defines)
os.environ['CXXFLAGS'] = os.environ['CFLAGS'] + ' -fno-rtti -fno-exceptions'
os.environ['LDFLAGS'] = '%s' % (ldflags,)
def cmd(command):
return '%s-%s' % (tools_prefix, command)
os.environ['CC']= '%s%s' % (ccache, cmd('gcc'))
os.environ['CC'] += ' -fuse-ld=%s' % ldvariant
os.environ['CXX']= '%s%s' % (ccache, cmd('g++'))
os.environ['CXX'] += ' -fuse-ld=%s' % ldvariant
os.environ['LD']= cmd('ld.%s' % ldvariant)
os.environ['CPP']= cmd('cpp')
os.environ['RANLIB']= cmd('ranlib')
os.environ['AR']= cmd('ar')
os.environ['AS']= cmd('as')
os.environ['NM']= cmd('nm')
os.environ['STRIP']= cmd('strip')
os.environ['OBJCOPY']= cmd('objcopy')
os.environ['PATH'] = '%s:%s:%s' % (toolchain_prefix, toolchain_path, os.environ['PATH'])
# For the libc.so dependency in i686-linux-android-as
if target_arch == Architecture.X86:
extra_lib_path = '%s/usr/lib' % (sysroot)
elif target_arch == Architecture.X86_64:
extra_lib_path = '%s/usr/lib64' % (sysroot)
# For GLib
os.environ['glib_cv_stack_grows'] = 'yes'
os.environ['glib_cv_uscore'] = 'no'
os.environ['ac_cv_func_posix_getpwuid_r'] = 'no'
os.environ['ac_cv_func_nonposix_getpwuid_r'] = 'no'
os.environ['ac_cv_func_posix_getgrgid_r'] = 'no'
os.environ['ac_cv_func_nonposix_getgrgid_r'] = 'no'
# For cairo
# FIXME : IF WE ADD BIG-ENDIAN PLATFORMS, FIX THIS !
os.environ['ax_cv_c_float_words_bigendian'] = 'no'
#No, really, it doesn't have uselocale
os.environ['ac_cv_func_uselocale'] = 'no'
|