summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2020-06-14 22:47:55 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2020-06-14 22:47:55 (GMT)
commitf1bd5c6881fa739240d8ae8bd7a0d242b5c9500d (patch)
tree2ce46548bf3226ec834682865c0a7e9fb090ab80
parent1b283809124ef39b130045eb6e00c8e8b1cce781 (diff)
downloadSCons-f1bd5c6881fa739240d8ae8bd7a0d242b5c9500d.zip
SCons-f1bd5c6881fa739240d8ae8bd7a0d242b5c9500d.tar.gz
SCons-f1bd5c6881fa739240d8ae8bd7a0d242b5c9500d.tar.bz2
Fix fake mylink.py was broken on win32.
-rw-r--r--test/fixture/mylink.py49
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()