-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig_android.py
182 lines (134 loc) · 5.35 KB
/
config_android.py
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
180
181
182
print "Importing Android Config"
"""
WORKING:
../../../../../../android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin/arm-linux-androideabi-gcc
-nostdlib
-Wl,-soname,lib.so
-Wl,-shared,-Bsymbolic
<object files>
-Wl,--no-whole-archive --sysroot=../../../../../../android-ndk-r5/platforms/android-8/arch-arm
../../../../../../android-ndk-r5/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
../../../../../../android-ndk-r5/platforms/android-8/arch-arm/usr/lib/libc.so
../../../../../../android-ndk-r5/platforms/android-8/arch-arm/usr/lib/libstdc++.so
../../../../../../android-ndk-r5/platforms/android-8/arch-arm/usr/lib/libm.so
-Wl,--no-undefined
-Wl,-z,noexecstack
-L../../../../../../android-ndk-r5/platforms/android-8/arch-arm/usr/lib
-lGLESv1_CM
-lGLESv2
-llog
-Wl,-rpath-link=../../../../../../android-ndk-r5/platforms/android-8/arch-arm/usr/lib
-o libs/armeabi/liboyk-core.so
"""
NDK_ROOT = "../../android-ndk-r5"
NDK_TOOLCHAIN_ROOT = NDK_ROOT + "/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86"
NDK_TOOLSBIN = NDK_TOOLCHAIN_ROOT+"/bin"
NDK_TOOLSLIB = NDK_TOOLCHAIN_ROOT+"/lib/gcc/arm-linux-androideabi/4.4.3"
NDK_PLATFORM_ROOT = NDK_ROOT + "/platforms/android-8/arch-arm"
NDK_PLATFORMLIB = NDK_PLATFORM_ROOT+"/usr/lib"
NDK_STLPORT_ROOT = NDK_ROOT+"/sources/cxx-stl/stlport"
NDK_STLPORTLIB = NDK_STLPORT_ROOT+"/libs/armeabi"
NDK_STLPORTINC = NDK_STLPORT_ROOT+"/stlport"
LINKDLL = NDK_TOOLSBIN + "/arm-linux-androideabi-gcc"
LINKDLL_FLAGS = " -nostdlib -Wl,-soname,lib.so -Wl,-shared,-Bsymbolic"
LINKDLL_FLAGS_POST = "-Wl,--no-whole-archive --sysroot="+NDK_PLATFORM_ROOT
LINKDLL_FLAGS_POST += "-Wl,--no-undefined -Wl,-z,noexecstack"
LINKDLL_FLAGS_POST += "-Wl,-rpath-link="+NDK_PLATFORMLIB
linkdll_out = "-o"
############################################################
def scons_make_dynamiclib(mod, env, config, settings):
# This will only be called once for a given mod, and mod._fulldeps
# will all have their ._target arrays set correctly
# Our build requirements:
objects = mod._objects
deplibs = []
depldflags = []
for d in mod._fulldeps:
deplibs += d._target
depldflags += d._ldflags
depldflags += mod._ldflags
dllout = settings.DLLPATH + "/lib" + mod._name + ".so"
deplibsS = [ str(l) for l in deplibs ]
deplibS = " ".join(deplibsS)
objectsS = [ str(o) for o in objects ]
objectS = " ".join(objectsS)
# Construct the command
syslibs = settings.dllsyslibs
syslibpaths = settings.syslibpaths
cmd = LINKDLL + " " + LINKDLL_FLAGS
cmd += " " + objectS
cmd += " " + LINKDLL_FLAGS_POST
cmd += " " + deplibS
cmd += " " + " ".join(syslibs)
cmd += " " + " ".join(depldflags)
cmd += " " + " ".join([ "-L"+path for path in syslibpaths ])
cmd += " " + linkdll_out + " $TARGET"
# Add the rule and extra dependencies
target = env.Command(dllout, objects, cmd)
env.Depends(target, deplibs)
# Return the array of created targets
return target
############################################################
############################################################
#
#
#
def _config(config, settings):
# System libs and paths
settings.syslibpaths += [ NDK_PLATFORMLIB ]
settings.syslibs += [ NDK_TOOLSLIB+"/libgcc.a",
NDK_PLATFORMLIB+"/libc.so",
NDK_PLATFORMLIB+"/libstdc++.so",
NDK_PLATFORMLIB+"/libm.so",
NDK_STLPORTLIB+"/libstlport_static.a",
"-llog",
"-lz"
]
# "-lGLESv1_CM",
settings.dllsyslibs += settings.syslibs
# Compile flags
commonflags = [ "-fpic",
"-mthumb-interwork",
"-ffunction-sections",
"-funwind-tables",
"-fstack-protector",
"-fno-short-enums",
"-fno-exceptions",
"-march=armv5te",
"-mtune=xscale",
"-msoft-float",
"-fomit-frame-pointer",
"-fno-strict-aliasing",
"-finline-limit=64",
"-Wall",
"-Wno-psabi",
"-D__ARM_ARCH_5__",
"-D__ARM_ARCH_5T__",
"-D__ARM_ARCH_5E__",
"-D__ARM_ARCH_5TE__",
"-DANDROID" ]
if config.buildconfig == "debug":
commonflags += [ "-O0" ]
else:
commonflags += [ "-Os" ]
# CXX
cxxflags = commonflags + [ "-fno-rtti", "-Wno-reorder" ]
settings.CXX = NDK_TOOLSBIN+"/arm-linux-androideabi-g++"
settings.CXXFLAGS += cxxflags
# CC
cflags = commonflags
settings.CC = NDK_TOOLSBIN+"/arm-linux-androideabi-gcc"
settings.CFLAGS += cflags
# Include dirs
settings.sysincdirs += [
NDK_PLATFORM_ROOT+"/usr/include",
NDK_ROOT+"/sources/cxx-stl/system/include",
NDK_STLPORTINC ]
# AR
settings.AR = NDK_TOOLSBIN+"/arm-linux-androideabi-ar"
settings.RANLIB = NDK_TOOLSBIN+"/arm-linux-androideabi-ranlib"
# Dynamic libs
settings.scons_make_dynamiclib = scons_make_dynamiclib
# LINK
settings.LIBTOOL = "adsf"
settings.LINK = "afadsf"