Skip to content

Commit 7606331

Browse files
committed
add libcopy for jb 4.3
1 parent 19aa462 commit 7606331

File tree

3 files changed

+168
-7
lines changed

3 files changed

+168
-7
lines changed

distribute.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export BIGLINK="$ROOT_PATH/src/tools/biglink"
6363
export PIP=$PIP_NAME
6464
export VIRTUALENV=$VIRTUALENV_NAME
6565

66-
JELLYBEAN=0
66+
export JELLYBEAN=0
6767

6868
MD5SUM=$(which md5sum)
6969
if [ "X$MD5SUM" == "X" ]; then
@@ -219,10 +219,11 @@ function push_arm() {
219219
export LD="$TOOLCHAIN_PREFIX-ld"
220220
export STRIP="$TOOLCHAIN_PREFIX-strip --strip-unneeded"
221221
export MAKE="make -j5"
222+
export READELF="$TOOLCHAIN_PREFIX-readelf"
222223

223-
if [ "$JELLYBEAN" == "1" ]; then
224-
export LIBLINK="$CC -shared $LDFLAGS"
225-
fi
224+
#if [ "$JELLYBEAN" == "1" ]; then
225+
# export LIBLINK="$CC -shared $LDFLAGS"
226+
#fi
226227

227228
# Use ccache ?
228229
which ccache &>/dev/null
@@ -772,7 +773,9 @@ function run_distribute() {
772773
try cp -a python-install/lib private/
773774
try mkdir -p private/include/python2.7
774775

775-
if [ "$JELLYBEAN" == "0" ]; then
776+
if [ "$JELLYBEAN" == "1" ]; then
777+
try sh -c "cat libs/$ARCH/copylibs | xargs -d'\n' cp -t private/"
778+
else
776779
try mv libs/$ARCH/libpymodules.so private/
777780
fi
778781
try cp python-install/include/python2.7/pyconfig.h private/include/python2.7/
@@ -800,11 +803,13 @@ function run_distribute() {
800803
}
801804

802805
function run_biglink() {
806+
push_arm
803807
if [ "$JELLYBEAN" == "0" ]; then
804-
push_arm
805808
try $BIGLINK $LIBS_PATH/libpymodules.so $LIBLINK_PATH
806-
pop_arm
809+
else
810+
try $BIGLINK $LIBS_PATH/copylibs $LIBLINK_PATH
807811
fi
812+
pop_arm
808813
}
809814

810815
function run() {
@@ -852,6 +857,8 @@ while getopts ":hjvlfxm:u:d:s" opt; do
852857
;;
853858
j)
854859
JELLYBEAN=1
860+
LIBLINK=${LIBLINK}-jb
861+
BIGLINK=${BIGLINK}-jb
855862
;;
856863
l)
857864
list_modules

src/tools/biglink-jb

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/usr/bin/env python
2+
3+
from __future__ import print_function
4+
import os
5+
import sys
6+
import subprocess
7+
import re
8+
9+
re_needso = re.compile(r'^.*\(NEEDED\)\s+Shared library: \[lib(.*)\.so\]\s*$')
10+
11+
blacklist_libs = (
12+
'c',
13+
'stdc++',
14+
'dl',
15+
'python2.7',
16+
'sdl',
17+
'sdl_image',
18+
'sdl_ttf',
19+
'z',
20+
'm',
21+
'GLESv2',
22+
'jpeg',
23+
'png',
24+
'log',
25+
)
26+
27+
found_libs = []
28+
sofiles = [ ]
29+
30+
for directory in sys.argv[2:]:
31+
32+
for fn in os.listdir(directory):
33+
fn = os.path.join(directory, fn)
34+
35+
if not fn.endswith(".libs"):
36+
continue
37+
38+
dirfn = fn[:-1] + 'dirs'
39+
if not os.path.exists(dirfn):
40+
continue
41+
42+
with open(fn) as f:
43+
needed_libs = [lib for lib in {ln.strip() for ln in f} if lib not in blacklist_libs and lib not in found_libs]
44+
45+
while needed_libs:
46+
print('need libs:\n\t' + '\n\t'.join(needed_libs))
47+
48+
start_needed_libs = needed_libs[:]
49+
found_sofiles = []
50+
51+
with open(dirfn) as f:
52+
for libdir in f:
53+
if not needed_libs:
54+
break
55+
56+
libdir = libdir.strip()
57+
print('scanning %s' % libdir)
58+
for lib in needed_libs[:]:
59+
if lib in found_libs:
60+
continue
61+
62+
if lib.endswith('.a'):
63+
needed_libs.remove(lib)
64+
found_libs.append(lib)
65+
continue
66+
67+
lib_a = 'lib' + lib + '.a'
68+
libpath_a = os.path.join(libdir, lib_a)
69+
lib_so = 'lib' + lib + '.so'
70+
libpath_so = os.path.join(libdir, lib_so)
71+
plain_so = lib + '.so'
72+
plainpath_so = os.path.join(libdir, plain_so)
73+
74+
sopath = None
75+
if os.path.exists(libpath_so):
76+
sopath = libpath_so
77+
elif os.path.exists(plainpath_so):
78+
sopath = plainpath_so
79+
80+
if sopath:
81+
print('found %s in %s' % (lib, libdir))
82+
found_sofiles.append(sopath)
83+
needed_libs.remove(lib)
84+
found_libs.append(lib)
85+
continue
86+
87+
if os.path.exists(libpath_a):
88+
print('found %s (static) in %s' % (lib, libdir))
89+
needed_libs.remove(lib)
90+
found_libs.append(lib)
91+
continue
92+
93+
for sofile in found_sofiles:
94+
print('scanning dependencies for %s' % sofile)
95+
out = subprocess.check_output([os.environ['READELF'], '-d', sofile])
96+
for line in out.splitlines():
97+
needso = re_needso.match(line)
98+
if needso:
99+
lib = needso.group(1)
100+
if lib not in needed_libs and lib not in found_libs and lib not in blacklist_libs:
101+
needed_libs.append(needso.group(1))
102+
103+
sofiles += found_sofiles
104+
105+
if needed_libs == start_needed_libs:
106+
raise RuntimeError('Failed to located needed libraries!\n\t' + '\n\t'.join(needed_libs))
107+
108+
output = sys.argv[1]
109+
110+
with open(output, 'w') as f:
111+
f.write('\n'.join(sofiles))

src/tools/liblink-jb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python
2+
3+
from __future__ import print_function
4+
import sys
5+
import subprocess
6+
from os import environ
7+
from os.path import basename, join
8+
9+
libs = [ ]
10+
libdirs = [ ]
11+
output = None
12+
13+
14+
i = 1
15+
while i < len(sys.argv):
16+
opt = sys.argv[i]
17+
i += 1
18+
19+
if opt == "-o":
20+
output = sys.argv[i]
21+
i ++ 1
22+
continue
23+
24+
if opt.startswith("-l"):
25+
libs.append(opt[2:])
26+
continue
27+
28+
if opt.startswith("-L"):
29+
libdirs.append(opt[2:])
30+
continue
31+
32+
output = join(environ.get('LIBLINK_PATH'), basename(output))
33+
34+
with open(output + ".libs", "w") as f:
35+
f.write("\n".join(libs))
36+
37+
with open(output + ".libdirs", "w") as f:
38+
f.write("\n".join(libdirs))
39+
40+
41+
libargs = ' '.join(["'%s'" % arg for arg in sys.argv[1:]])
42+
cmd = '%s -shared %s %s' % (environ['CC'], environ['LDFLAGS'], libargs)
43+
sys.exit(subprocess.call(cmd, shell=True))

0 commit comments

Comments
 (0)