diff options
author | William Deegan <bill@baddogconsulting.com> | 2020-06-14 22:47:55 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2020-06-14 22:47:55 (GMT) |
commit | f1bd5c6881fa739240d8ae8bd7a0d242b5c9500d (patch) | |
tree | 2ce46548bf3226ec834682865c0a7e9fb090ab80 | |
parent | 1b283809124ef39b130045eb6e00c8e8b1cce781 (diff) | |
download | SCons-f1bd5c6881fa739240d8ae8bd7a0d242b5c9500d.zip SCons-f1bd5c6881fa739240d8ae8bd7a0d242b5c9500d.tar.gz SCons-f1bd5c6881fa739240d8ae8bd7a0d242b5c9500d.tar.bz2 |
Fix fake mylink.py was broken on win32.
-rw-r--r-- | test/fixture/mylink.py | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/test/fixture/mylink.py b/test/fixture/mylink.py index fe4af58..6c56427 100644 --- a/test/fixture/mylink.py +++ b/test/fixture/mylink.py @@ -1,15 +1,40 @@ import getopt import sys -opts, args = getopt.getopt(sys.argv[1:], 'o:s:') -for opt, arg in opts: - if opt == '-o': - out = arg - -with open(out, 'w') as ofp: - for f in args: - with open(f, 'r') as ifp: - for line in ifp.readlines(): - if line[:5] != '#link': - ofp.write(line) -sys.exit(0) +def fake_link(): + opts, args = getopt.getopt(sys.argv[1:], 'o:s:') + for opt, arg in opts: + if opt == '-o': + out = arg + + with open(out, 'w') as ofp: + for f in args: + with open(f, 'r') as ifp: + for line in ifp.readlines(): + if line[:5] != '#link': + ofp.write(line) + sys.exit(0) + +def fake_win32_link(): + args = sys.argv[1:] + while args: + a = args[0] + if a == '-o': + out = args[1] + args = args[2:] + continue + if not a[0] in '/-': + break + args = args[1:] + if a[:5].lower() == '/out:': out = a[5:] + with open(args[0], 'rb') as ifp, open(out, 'wb') as ofp: + for l in ifp.readlines(): + if not l.startswith(b'#link'): + ofp.write(l) + sys.exit(0) + +if __name__ == '__main__': + if sys.platform == 'win32': + fake_win32_link() + else: + fake_link() |