1212import os
1313import sys
1414
15+ target_triple = sys .argv [14 ]
1516
1617def normalize_path (v ):
1718 """msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
@@ -22,8 +23,11 @@ def normalize_path(v):
2223 windows paths so it is really error-prone. revert it for peace."""
2324 v = v .replace ('\\ ' , '/' )
2425 # c:/path -> /c/path
25- if ':/' in v :
26- v = '/' + v .replace (':/' , '/' )
26+ # "c:/path" -> "/c/path"
27+ start = v .find (':/' )
28+ while start != - 1 :
29+ v = v [:start - 1 ] + '/' + v [start - 1 :start ] + v [start + 1 :]
30+ start = v .find (':/' )
2731 return v
2832
2933
@@ -39,17 +43,21 @@ def convert_path_spec(name, value):
3943 return value
4044
4145make = sys .argv [2 ]
42- putenv ('RUSTC' , os .path .abspath (sys .argv [3 ]))
43- putenv ('TMPDIR' , os .path .abspath (sys .argv [4 ]))
44- putenv ('CC' , sys .argv [5 ] + ' ' + sys .argv [6 ])
45- putenv ('RUSTDOC' , os .path .abspath (sys .argv [7 ]))
46+ os . putenv ('RUSTC' , os .path .abspath (sys .argv [3 ]))
47+ os . putenv ('TMPDIR' , os .path .abspath (sys .argv [4 ]))
48+ os . putenv ('CC' , sys .argv [5 ] + ' ' + sys .argv [6 ])
49+ os . putenv ('RUSTDOC' , os .path .abspath (sys .argv [7 ]))
4650filt = sys .argv [8 ]
4751putenv ('LD_LIB_PATH_ENVVAR' , sys .argv [9 ])
4852putenv ('HOST_RPATH_DIR' , os .path .abspath (sys .argv [10 ]))
4953putenv ('TARGET_RPATH_DIR' , os .path .abspath (sys .argv [11 ]))
5054putenv ('RUST_BUILD_STAGE' , sys .argv [12 ])
51- putenv ('S' , os .path .abspath (sys .argv [13 ]))
52- putenv ('PYTHON' , sys .executable )
55+ os .putenv ('S' , os .path .abspath (sys .argv [13 ]))
56+ os .putenv ('PYTHON' , sys .executable )
57+ os .putenv ('TARGET' , target_triple )
58+
59+ if 'msvc' in target_triple :
60+ os .putenv ('IS_MSVC' , '1' )
5361
5462if filt not in sys .argv [1 ]:
5563 sys .exit (0 )
0 commit comments