2011-12-05 10:09:35 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import subprocess
|
2011-12-06 15:31:58 +01:00
|
|
|
from os import environ
|
2011-12-05 10:09:35 +01:00
|
|
|
|
|
|
|
libs = [ ]
|
|
|
|
objects = [ ]
|
|
|
|
output = None
|
|
|
|
|
|
|
|
|
|
|
|
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") or opt.startswith("-L"):
|
|
|
|
libs.append(opt)
|
|
|
|
continue
|
|
|
|
|
2011-12-06 15:31:58 +01:00
|
|
|
if opt in ("-r", "-pipe", "-no-cpp-precomp"):
|
2011-12-05 10:09:35 +01:00
|
|
|
continue
|
|
|
|
|
|
|
|
if opt in ("--sysroot", "-isysroot", "-framework", "-undefined",
|
|
|
|
"-macosx_version_min"):
|
|
|
|
i += 1
|
|
|
|
continue
|
|
|
|
|
|
|
|
if opt.startswith("-I"):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if opt.startswith("-m"):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if opt.startswith("-f"):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if opt.startswith("-O"):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if opt.startswith("-g"):
|
|
|
|
continue
|
|
|
|
|
|
|
|
if opt.startswith("-D"):
|
|
|
|
continue
|
2013-10-08 11:02:05 +02:00
|
|
|
|
|
|
|
if opt.startswith('-arch'):
|
|
|
|
continue
|
2014-02-03 06:53:30 +01:00
|
|
|
|
2014-11-24 02:50:02 +01:00
|
|
|
if opt.startswith("-Wl,"):
|
|
|
|
continue
|
|
|
|
|
2011-12-05 10:09:35 +01:00
|
|
|
if opt.startswith("-"):
|
2014-02-03 06:53:30 +01:00
|
|
|
print(sys.argv)
|
|
|
|
print("Unknown option: ", opt)
|
2011-12-05 10:09:35 +01:00
|
|
|
sys.exit(1)
|
|
|
|
|
2011-12-06 10:49:14 +01:00
|
|
|
if not opt.endswith('.o'):
|
|
|
|
continue
|
|
|
|
|
2011-12-05 10:09:35 +01:00
|
|
|
objects.append(opt)
|
|
|
|
|
|
|
|
|
2014-02-03 06:53:30 +01:00
|
|
|
f = open(output, "w")
|
2011-12-05 10:09:35 +01:00
|
|
|
f.close()
|
|
|
|
|
2014-02-03 06:53:30 +01:00
|
|
|
f = open(output + ".libs", "w")
|
2011-12-05 10:09:35 +01:00
|
|
|
f.write(" ".join(libs))
|
|
|
|
f.close()
|
|
|
|
|
2014-02-03 06:53:30 +01:00
|
|
|
print('Liblink redirect linking with', objects)
|
2015-02-09 23:34:02 +01:00
|
|
|
ld = environ.get('ARM_LD')
|
|
|
|
arch = environ.get('ARCH', 'armv7')
|
|
|
|
subprocess.call([ld, '-r', '-o', output + '.o', '-arch', arch] + objects)
|