1 # Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
15 target_triple = sys.argv[14]
17 def normalize_path(v):
18 """msys1/msys2 automatically converts `/abs/path1:/abs/path2` into
19 `c:\real\abs\path1;c:\real\abs\path2` (semicolons) if shell thinks
20 the value is list of paths.
21 (if there is only one path, it becomes `c:/real/abs/path`.)
22 this causes great confusion and error: shell and Makefile doesn't like
23 windows paths so it is really error-prone. revert it for peace."""
24 v = v.replace('\\', '/')
26 # "c:/path" -> "/c/path"
29 v = v[:start - 1] + '/' + v[start - 1:start] + v[start + 1:]
34 def putenv(name, value):
36 value = normalize_path(value)
37 os.putenv(name, value)
40 def convert_path_spec(name, value):
41 if os.name == 'nt' and name != 'PATH':
42 value = ":".join(normalize_path(v) for v in value.split(";"))
46 putenv('RUSTC', os.path.abspath(sys.argv[3]))
47 putenv('TMPDIR', os.path.abspath(sys.argv[4]))
48 putenv('CC', sys.argv[5] + ' ' + sys.argv[6])
49 putenv('CFLAGS', sys.argv[6])
50 putenv('RUSTDOC', os.path.abspath(sys.argv[7]))
52 putenv('LD_LIB_PATH_ENVVAR', sys.argv[9])
53 putenv('HOST_RPATH_DIR', os.path.abspath(sys.argv[10]))
54 putenv('TARGET_RPATH_DIR', os.path.abspath(sys.argv[11]))
55 putenv('RUST_BUILD_STAGE', sys.argv[12])
56 putenv('S', os.path.abspath(sys.argv[13]))
57 putenv('RUSTFLAGS', sys.argv[15])
58 putenv('LLVM_COMPONENTS', sys.argv[16])
59 putenv('LLVM_CXXFLAGS', sys.argv[17])
60 putenv('CXX', sys.argv[18])
61 putenv('PYTHON', sys.executable)
62 os.putenv('TARGET', target_triple)
64 if 'msvc' in target_triple:
65 os.putenv('IS_MSVC', '1')
67 if filt not in sys.argv[1]:
69 print('maketest: ' + os.path.basename(os.path.dirname(sys.argv[1])))
73 # msys1 has a bug that `make` fails to include `../tools.mk` (parent dir)
74 # if `-C path` option is given and `path` is absolute directory with
75 # trailing slash (`c:/path/to/test/`).
76 # the easist workaround is to remove the slash (`c:/path/to/test`).
77 # msys2 seems to fix this problem.
80 proc = subprocess.Popen([make, '-C', path],
81 stdout=subprocess.PIPE,
82 stderr=subprocess.PIPE)
83 out, err = proc.communicate()
88 ----- %s --------------------
89 ------ stdout ---------------------------------------------
91 ------ stderr ---------------------------------------------
93 ------ ---------------------------------------------
94 """ % (sys.argv[1], out, err)