2017-08-13 03:24:00 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import subprocess
|
|
|
|
|
2022-12-02 21:15:34 +01:00
|
|
|
sofiles = []
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
for directory in sys.argv[2:]:
|
|
|
|
|
|
|
|
for fn in os.listdir(directory):
|
|
|
|
fn = os.path.join(directory, fn)
|
|
|
|
|
|
|
|
if not fn.endswith(".so.o"):
|
|
|
|
continue
|
|
|
|
if not os.path.exists(fn[:-2] + ".libs"):
|
|
|
|
continue
|
|
|
|
|
|
|
|
sofiles.append(fn[:-2])
|
|
|
|
|
|
|
|
# The raw argument list.
|
2022-12-02 21:15:34 +01:00
|
|
|
args = []
|
2017-08-13 03:24:00 +02:00
|
|
|
|
|
|
|
for fn in sofiles:
|
|
|
|
afn = fn + ".o"
|
|
|
|
libsfn = fn + ".libs"
|
|
|
|
|
|
|
|
args.append(afn)
|
|
|
|
with open(libsfn) as fd:
|
|
|
|
data = fd.read()
|
|
|
|
args.extend(data.split(" "))
|
|
|
|
|
2022-12-02 21:15:34 +01:00
|
|
|
unique_args = []
|
2017-08-13 03:24:00 +02:00
|
|
|
while args:
|
|
|
|
a = args.pop()
|
|
|
|
if a in ('-L', ):
|
|
|
|
continue
|
|
|
|
if a not in unique_args:
|
|
|
|
unique_args.insert(0, a)
|
|
|
|
unique_args = [x for x in unique_args if x]
|
|
|
|
|
|
|
|
print('Biglink create %s library' % sys.argv[1])
|
|
|
|
print('Biglink arguments:')
|
|
|
|
for arg in unique_args:
|
|
|
|
print(' %s' % arg)
|
|
|
|
|
|
|
|
args = os.environ['CC'].split() + \
|
|
|
|
['-shared', '-O3', '-o', sys.argv[1]] + \
|
|
|
|
unique_args
|
|
|
|
|
|
|
|
sys.exit(subprocess.call(args))
|