forked from kivy/python-for-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathliblink
More file actions
executable file
·82 lines (63 loc) · 1.88 KB
/
liblink
File metadata and controls
executable file
·82 lines (63 loc) · 1.88 KB
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
#!/usr/bin/env python
import sys
import subprocess
from os import environ
from os.path import basename, join
libs = [ ]
objects = [ ]
output = None
copylibs = environ.get('COPYLIBS', '0') == '1'
i = 1
while i < len(sys.argv):
opt = sys.argv[i]
i += 1
if opt == "-o":
output = sys.argv[i]
i += 1
continue
if opt.startswith(("-l", "-L")):
libs.append(opt)
continue
if opt in ("-r", "-pipe", "-no-cpp-precomp"):
continue
if opt in ("--sysroot", "-isysroot", "-framework", "-undefined",
"-macosx_version_min"):
i += 1
continue
if opt.startswith(
("-I", "-isystem", "-m", "-f", "-O", "-g", "-D", "-R")):
continue
if opt.startswith("-"):
print(sys.argv)
print("Unknown option: %s" % opt)
sys.exit(1)
if not opt.endswith('.o'):
continue
objects.append(opt)
print('liblink path is', str(environ.get('LIBLINK_PATH')))
abs_output = join(environ.get('LIBLINK_PATH'), basename(output))
if not copylibs:
f = open(output, "w")
f.close()
output = abs_output
f = open(output + ".libs", "w")
f.write(" ".join(libs))
f.close()
sys.exit(subprocess.call([
environ.get('LD'), '-r',
'-o', output + '.o'
#, '-arch', environ.get('ARCH')
] + objects))
else:
with open(abs_output + '.libs', 'w') as f_libs:
with open(abs_output + '.libdirs', 'w') as f_libdirs:
for l in libs:
if l[1] == 'l':
f_libs.write(l[2:])
f_libs.write(' ')
else:
f_libdirs.write(l[2:])
f_libdirs.write(' ')
libargs = ' '.join(["'%s'" % arg for arg in sys.argv[1:]])
cmd = '%s -shared %s %s' % (environ['CC'], environ['LDFLAGS'], libargs)
sys.exit(subprocess.call(cmd, shell=True))