Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 5f490cc

Browse files
committed
Add static library scripts
1 parent d283d6e commit 5f490cc

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.pyc
2+
actual_files.txt

ld.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python
2+
3+
import argparse
4+
import paths
5+
import subprocess
6+
7+
8+
def ld_command(arch, isysroot, library_search_path, linked_libraries, filelist,
9+
output):
10+
return [
11+
"libtool",
12+
"-static",
13+
"-arch_only", arch,
14+
"-syslibroot", isysroot,
15+
"-L{}".format(library_search_path),
16+
"-filelist", filelist,
17+
] + ["-l{}".format(x) for x in linked_libraries] + [
18+
"-o", output,
19+
]
20+
21+
22+
def build_parser():
23+
parser = argparse.ArgumentParser()
24+
parser.add_argument("-arch", required=True)
25+
parser.add_argument("-isysroot", required=True)
26+
parser.add_argument("-filelist", required=True)
27+
parser.add_argument("-o", dest="output", required=True)
28+
parser.add_argument("-L", action="append", dest="library_paths",
29+
required=True)
30+
parser.add_argument("-l", action="append", dest="linked_libraries",
31+
default=[])
32+
return parser
33+
34+
if __name__ == "__main__":
35+
arguments, _ = build_parser().parse_known_args()
36+
command = ld_command(arguments.arch, arguments.isysroot,
37+
arguments.library_paths[0],
38+
arguments.linked_libraries, arguments.filelist,
39+
arguments.output)
40+
print(" ".join(command))
41+
print(subprocess.check_output(command))

lipo.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
3+
import argparse
4+
import paths
5+
import subprocess
6+
7+
8+
def lipo_command(inputs, output):
9+
return [
10+
"lipo",
11+
"-create"
12+
] + inputs + [
13+
"-output", output,
14+
]
15+
16+
17+
def build_parser():
18+
parser = argparse.ArgumentParser()
19+
parser.add_argument("-create", dest="inputs", nargs="+", required=True)
20+
parser.add_argument("-output", required=True)
21+
return parser
22+
23+
if __name__ == "__main__":
24+
arguments = build_parser().parse_args()
25+
command = lipo_command(arguments.inputs, arguments.output)
26+
print(" ".join(command))
27+
print(subprocess.check_output(command))

paths.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
3+
4+
def get_toolchain_dir(env=os.environ):
5+
return env["TOOLCHAIN_DIR"]
6+
7+
8+
def bin_directory(toolchain):
9+
return os.path.join(toolchain, "usr/bin")
10+
11+
12+
def executable_path(toolchain, executable):
13+
return os.path.join(bin_directory(toolchain), executable)

0 commit comments

Comments
 (0)