blob: 0a281b89c571f0bcdbf166adf831906acc79f268 [file] [log] [blame]
Alex Crichtondefd1b32016-03-08 07:15:551// Copyright 2016 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.
4//
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.
10
Alex Crichtonf72bfe62016-05-02 22:16:1511//! Implementation of the various `check-*` targets of the build system.
12//!
13//! This file implements the various regression test suites that we execute on
14//! our CI.
15
Alex Crichton147e2da2016-10-07 06:30:3816use std::collections::{HashMap, HashSet};
Alex Crichtonbb9062a2016-04-29 21:23:1517use std::env;
Alex Crichton147e2da2016-10-07 06:30:3818use std::fs;
Alex Crichtonede89442016-04-15 01:00:3519use std::path::{PathBuf, Path};
20use std::process::Command;
Alex Crichton73c2d2a2016-04-14 21:27:5121
Alex Crichton126e09e2016-04-14 22:51:0322use build_helper::output;
Alex Crichton147e2da2016-10-07 06:30:3823use rustc_serialize::json;
Alex Crichton126e09e2016-04-14 22:51:0324
Alex Crichton48a07bf2016-07-06 04:58:2025use {Build, Compiler, Mode};
26use util::{self, dylib_path, dylib_path_var};
Alex Crichton39a5d3f2016-06-28 20:31:3027
28const ADB_TEST_DIR: &'static str = "/data/tmp";
Alex Crichtondefd1b32016-03-08 07:15:5529
Alex Crichton147e2da2016-10-07 06:30:3830#[derive(RustcDecodable)]
31struct Output {
32 packages: Vec<Package>,
33 resolve: Resolve,
34}
35
36#[derive(RustcDecodable)]
37struct Package {
38 id: String,
39 name: String,
40 source: Option<String>,
41}
42
43#[derive(RustcDecodable)]
44struct Resolve {
45 nodes: Vec<ResolveNode>,
46}
47
48#[derive(RustcDecodable)]
49struct ResolveNode {
50 id: String,
51 dependencies: Vec<String>,
52}
53
Alex Crichtonf72bfe62016-05-02 22:16:1554/// Runs the `linkchecker` tool as compiled in `stage` by the `host` compiler.
55///
56/// This tool in `src/tools` will verify the validity of all our links in the
57/// documentation to ensure we don't have a bunch of dead ones.
Alex Crichtondefd1b32016-03-08 07:15:5558pub fn linkcheck(build: &Build, stage: u32, host: &str) {
59 println!("Linkcheck stage{} ({})", stage, host);
60 let compiler = Compiler::new(stage, host);
Alex Crichton4a917e02016-03-12 00:21:0561 build.run(build.tool_cmd(&compiler, "linkchecker")
62 .arg(build.out.join(host).join("doc")));
Alex Crichtondefd1b32016-03-08 07:15:5563}
Brian Anderson3a790ac2016-03-18 20:54:3164
Alex Crichtonf72bfe62016-05-02 22:16:1565/// Runs the `cargotest` tool as compiled in `stage` by the `host` compiler.
66///
67/// This tool in `src/tools` will check out a few Rust projects and run `cargo
68/// test` to ensure that we don't regress the test suites there.
Brian Anderson3a790ac2016-03-18 20:54:3169pub fn cargotest(build: &Build, stage: u32, host: &str) {
70 let ref compiler = Compiler::new(stage, host);
Brian Anderson80199222016-04-06 18:03:4271
72 // Configure PATH to find the right rustc. NB. we have to use PATH
73 // and not RUSTC because the Cargo test suite has tests that will
74 // fail if rustc is not spelled `rustc`.
75 let path = build.sysroot(compiler).join("bin");
76 let old_path = ::std::env::var("PATH").expect("");
77 let sep = if cfg!(windows) { ";" } else {":" };
78 let ref newpath = format!("{}{}{}", path.display(), sep, old_path);
79
Alex Crichton73c2d2a2016-04-14 21:27:5180 // Note that this is a short, cryptic, and not scoped directory name. This
81 // is currently to minimize the length of path on Windows where we otherwise
82 // quickly run into path name limit constraints.
83 let out_dir = build.out.join("ct");
84 t!(fs::create_dir_all(&out_dir));
85
Brian Anderson3a790ac2016-03-18 20:54:3186 build.run(build.tool_cmd(compiler, "cargotest")
Alex Crichton73c2d2a2016-04-14 21:27:5187 .env("PATH", newpath)
88 .arg(&build.cargo)
89 .arg(&out_dir));
Brian Anderson3a790ac2016-03-18 20:54:3190}
Alex Crichton9dd3c542016-03-29 20:14:5291
Alex Crichtonf72bfe62016-05-02 22:16:1592/// Runs the `tidy` tool as compiled in `stage` by the `host` compiler.
93///
94/// This tool in `src/tools` checks up on various bits and pieces of style and
95/// otherwise just implements a few lint-like checks that are specific to the
96/// compiler itself.
Alex Crichton9dd3c542016-03-29 20:14:5297pub fn tidy(build: &Build, stage: u32, host: &str) {
98 println!("tidy check stage{} ({})", stage, host);
99 let compiler = Compiler::new(stage, host);
100 build.run(build.tool_cmd(&compiler, "tidy")
101 .arg(build.src.join("src")));
102}
Alex Crichtonb325baf2016-04-05 18:34:23103
104fn testdir(build: &Build, host: &str) -> PathBuf {
105 build.out.join(host).join("test")
106}
107
Alex Crichtonf72bfe62016-05-02 22:16:15108/// Executes the `compiletest` tool to run a suite of tests.
109///
110/// Compiles all tests with `compiler` for `target` with the specified
111/// compiletest `mode` and `suite` arguments. For example `mode` can be
112/// "run-pass" or `suite` can be something like `debuginfo`.
Alex Crichtonb325baf2016-04-05 18:34:23113pub fn compiletest(build: &Build,
114 compiler: &Compiler,
115 target: &str,
116 mode: &str,
117 suite: &str) {
Alex Crichton39a5d3f2016-06-28 20:31:30118 println!("Check compiletest {} ({} -> {})", suite, compiler.host, target);
Alex Crichtonb325baf2016-04-05 18:34:23119 let mut cmd = build.tool_cmd(compiler, "compiletest");
120
Alex Crichtonf72bfe62016-05-02 22:16:15121 // compiletest currently has... a lot of arguments, so let's just pass all
122 // of them!
123
Alex Crichtonb325baf2016-04-05 18:34:23124 cmd.arg("--compile-lib-path").arg(build.rustc_libdir(compiler));
125 cmd.arg("--run-lib-path").arg(build.sysroot_libdir(compiler, target));
126 cmd.arg("--rustc-path").arg(build.compiler_path(compiler));
127 cmd.arg("--rustdoc-path").arg(build.rustdoc(compiler));
128 cmd.arg("--src-base").arg(build.src.join("src/test").join(suite));
Alex Crichtonb325baf2016-04-05 18:34:23129 cmd.arg("--build-base").arg(testdir(build, compiler.host).join(suite));
130 cmd.arg("--stage-id").arg(format!("stage{}-{}", compiler.stage, target));
131 cmd.arg("--mode").arg(mode);
132 cmd.arg("--target").arg(target);
133 cmd.arg("--host").arg(compiler.host);
134 cmd.arg("--llvm-filecheck").arg(build.llvm_filecheck(&build.config.build));
135
Brian Anderson8401e372016-09-15 19:42:26136 if let Some(nodejs) = build.config.nodejs.as_ref() {
137 cmd.arg("--nodejs").arg(nodejs);
138 }
139
Alex Crichton39a5d3f2016-06-28 20:31:30140 let mut flags = vec!["-Crpath".to_string()];
Alex Crichtonf4e4ec72016-05-13 22:26:41141 if build.config.rust_optimize_tests {
Alex Crichton39a5d3f2016-06-28 20:31:30142 flags.push("-O".to_string());
Alex Crichtonf4e4ec72016-05-13 22:26:41143 }
144 if build.config.rust_debuginfo_tests {
Alex Crichton39a5d3f2016-06-28 20:31:30145 flags.push("-g".to_string());
Alex Crichtonf4e4ec72016-05-13 22:26:41146 }
147
Alex Crichton39a5d3f2016-06-28 20:31:30148 let mut hostflags = build.rustc_flags(&compiler.host);
149 hostflags.extend(flags.clone());
150 cmd.arg("--host-rustcflags").arg(hostflags.join(" "));
Alex Crichtonf4e4ec72016-05-13 22:26:41151
Alex Crichton39a5d3f2016-06-28 20:31:30152 let mut targetflags = build.rustc_flags(&target);
153 targetflags.extend(flags);
154 targetflags.push(format!("-Lnative={}",
155 build.test_helpers_out(target).display()));
156 cmd.arg("--target-rustcflags").arg(targetflags.join(" "));
Alex Crichtoncbe62922016-04-19 16:44:19157
Alex Crichtonb325baf2016-04-05 18:34:23158 // FIXME: CFG_PYTHON should probably be detected more robustly elsewhere
Alex Crichtoncbe62922016-04-19 16:44:19159 let python_default = "python";
160 cmd.arg("--docck-python").arg(python_default);
161
162 if build.config.build.ends_with("apple-darwin") {
163 // Force /usr/bin/python on OSX for LLDB tests because we're loading the
164 // LLDB plugin's compiled module which only works with the system python
165 // (namely not Homebrew-installed python)
166 cmd.arg("--lldb-python").arg("/usr/bin/python");
167 } else {
168 cmd.arg("--lldb-python").arg(python_default);
169 }
Alex Crichtonb325baf2016-04-05 18:34:23170
171 if let Some(ref vers) = build.gdb_version {
172 cmd.arg("--gdb-version").arg(vers);
173 }
174 if let Some(ref vers) = build.lldb_version {
175 cmd.arg("--lldb-version").arg(vers);
176 }
177 if let Some(ref dir) = build.lldb_python_dir {
178 cmd.arg("--lldb-python-dir").arg(dir);
179 }
Alex Crichton96283fc2016-09-01 17:52:44180 let llvm_config = build.llvm_config(target);
181 let llvm_version = output(Command::new(&llvm_config).arg("--version"));
182 cmd.arg("--llvm-version").arg(llvm_version);
Alex Crichtonb325baf2016-04-05 18:34:23183
184 cmd.args(&build.flags.args);
185
186 if build.config.verbose || build.flags.verbose {
187 cmd.arg("--verbose");
188 }
189
Corey Farwellc8c6d2c2016-10-30 01:58:52190 if build.config.quiet_tests {
191 cmd.arg("--quiet");
192 }
193
Alex Crichtonf72bfe62016-05-02 22:16:15194 // Only pass correct values for these flags for the `run-make` suite as it
195 // requires that a C++ compiler was configured which isn't always the case.
Alex Crichton126e09e2016-04-14 22:51:03196 if suite == "run-make" {
Alex Crichton126e09e2016-04-14 22:51:03197 let llvm_components = output(Command::new(&llvm_config).arg("--components"));
198 let llvm_cxxflags = output(Command::new(&llvm_config).arg("--cxxflags"));
199 cmd.arg("--cc").arg(build.cc(target))
200 .arg("--cxx").arg(build.cxx(target))
201 .arg("--cflags").arg(build.cflags(target).join(" "))
202 .arg("--llvm-components").arg(llvm_components.trim())
203 .arg("--llvm-cxxflags").arg(llvm_cxxflags.trim());
204 } else {
205 cmd.arg("--cc").arg("")
206 .arg("--cxx").arg("")
207 .arg("--cflags").arg("")
208 .arg("--llvm-components").arg("")
209 .arg("--llvm-cxxflags").arg("");
210 }
211
212 // Running a C compiler on MSVC requires a few env vars to be set, to be
213 // sure to set them here.
214 if target.contains("msvc") {
215 for &(ref k, ref v) in build.cc[target].0.env() {
216 if k != "PATH" {
217 cmd.env(k, v);
218 }
219 }
220 }
Brian Andersond3c59052016-10-18 22:42:01221 build.add_bootstrap_key(&mut cmd);
Alex Crichton126e09e2016-04-14 22:51:03222
Alex Crichton39a5d3f2016-06-28 20:31:30223 cmd.arg("--adb-path").arg("adb");
224 cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR);
225 if target.contains("android") {
226 // Assume that cc for this target comes from the android sysroot
227 cmd.arg("--android-cross-path")
228 .arg(build.cc(target).parent().unwrap().parent().unwrap());
229 } else {
230 cmd.arg("--android-cross-path").arg("");
231 }
232
Alex Crichtonb325baf2016-04-05 18:34:23233 build.run(&mut cmd);
234}
Alex Crichtonede89442016-04-15 01:00:35235
Alex Crichtonf72bfe62016-05-02 22:16:15236/// Run `rustdoc --test` for all documentation in `src/doc`.
237///
238/// This will run all tests in our markdown documentation (e.g. the book)
239/// located in `src/doc`. The `rustdoc` that's run is the one that sits next to
240/// `compiler`.
Alex Crichtonede89442016-04-15 01:00:35241pub fn docs(build: &Build, compiler: &Compiler) {
Alex Crichtonf72bfe62016-05-02 22:16:15242 // Do a breadth-first traversal of the `src/doc` directory and just run
243 // tests for all files that end in `*.md`
Alex Crichtonede89442016-04-15 01:00:35244 let mut stack = vec![build.src.join("src/doc")];
245
246 while let Some(p) = stack.pop() {
247 if p.is_dir() {
248 stack.extend(t!(p.read_dir()).map(|p| t!(p).path()));
249 continue
250 }
251
252 if p.extension().and_then(|s| s.to_str()) != Some("md") {
253 continue
254 }
255
256 println!("doc tests for: {}", p.display());
257 markdown_test(build, compiler, &p);
258 }
259}
260
Alex Crichtonf72bfe62016-05-02 22:16:15261/// Run the error index generator tool to execute the tests located in the error
262/// index.
263///
264/// The `error_index_generator` tool lives in `src/tools` and is used to
265/// generate a markdown file from the error indexes of the code base which is
266/// then passed to `rustdoc --test`.
Alex Crichtonede89442016-04-15 01:00:35267pub fn error_index(build: &Build, compiler: &Compiler) {
268 println!("Testing error-index stage{}", compiler.stage);
269
270 let output = testdir(build, compiler.host).join("error-index.md");
271 build.run(build.tool_cmd(compiler, "error_index_generator")
272 .arg("markdown")
273 .arg(&output)
274 .env("CFG_BUILD", &build.config.build));
275
276 markdown_test(build, compiler, &output);
277}
278
279fn markdown_test(build: &Build, compiler: &Compiler, markdown: &Path) {
280 let mut cmd = Command::new(build.rustdoc(compiler));
281 build.add_rustc_lib_path(compiler, &mut cmd);
282 cmd.arg("--test");
283 cmd.arg(markdown);
Corey Farwellc8c6d2c2016-10-30 01:58:52284
285 let mut test_args = build.flags.args.join(" ");
286 if build.config.quiet_tests {
287 test_args.push_str(" --quiet");
288 }
289 cmd.arg("--test-args").arg(test_args);
290
Alex Crichtonede89442016-04-15 01:00:35291 build.run(&mut cmd);
292}
Alex Crichtonbb9062a2016-04-29 21:23:15293
294/// Run all unit tests plus documentation tests for an entire crate DAG defined
295/// by a `Cargo.toml`
296///
297/// This is what runs tests for crates like the standard library, compiler, etc.
298/// It essentially is the driver for running `cargo test`.
299///
300/// Currently this runs all tests for a DAG by passing a bunch of `-p foo`
Alex Crichton147e2da2016-10-07 06:30:38301/// arguments, and those arguments are discovered from `cargo metadata`.
Alex Crichtonbb9062a2016-04-29 21:23:15302pub fn krate(build: &Build,
303 compiler: &Compiler,
304 target: &str,
305 mode: Mode) {
Alex Crichton147e2da2016-10-07 06:30:38306 let (name, path, features, root) = match mode {
Ahmed Charles9ca382f2016-09-02 08:55:29307 Mode::Libstd => {
Alex Crichton147e2da2016-10-07 06:30:38308 ("libstd", "src/rustc/std_shim", build.std_features(), "std_shim")
Ahmed Charles9ca382f2016-09-02 08:55:29309 }
310 Mode::Libtest => {
Alex Crichton147e2da2016-10-07 06:30:38311 ("libtest", "src/rustc/test_shim", String::new(), "test_shim")
Ahmed Charles9ca382f2016-09-02 08:55:29312 }
313 Mode::Librustc => {
Alex Crichton147e2da2016-10-07 06:30:38314 ("librustc", "src/rustc", build.rustc_features(), "rustc-main")
Ahmed Charles9ca382f2016-09-02 08:55:29315 }
Alex Crichtonbb9062a2016-04-29 21:23:15316 _ => panic!("can only test libraries"),
317 };
318 println!("Testing {} stage{} ({} -> {})", name, compiler.stage,
319 compiler.host, target);
320
Alex Crichton147e2da2016-10-07 06:30:38321 // Run `cargo metadata` to figure out what crates we're testing.
322 //
323 // Down below we're going to call `cargo test`, but to test the right set
324 // of packages we're going to have to know what `-p` arguments to pass it
325 // to know what crates to test. Here we run `cargo metadata` to learn about
326 // the dependency graph and what `-p` arguments there are.
327 let mut cargo = Command::new(&build.cargo);
328 cargo.arg("metadata")
329 .arg("--manifest-path").arg(build.src.join(path).join("Cargo.toml"));
330 let output = output(&mut cargo);
331 let output: Output = json::decode(&output).unwrap();
332 let id2pkg = output.packages.iter()
333 .map(|pkg| (&pkg.id, pkg))
334 .collect::<HashMap<_, _>>();
335 let id2deps = output.resolve.nodes.iter()
336 .map(|node| (&node.id, &node.dependencies))
337 .collect::<HashMap<_, _>>();
338
Alex Crichtonbb9062a2016-04-29 21:23:15339 // Build up the base `cargo test` command.
Alex Crichton147e2da2016-10-07 06:30:38340 //
341 // Pass in some standard flags then iterate over the graph we've discovered
342 // in `cargo metadata` with the maps above and figure out what `-p`
343 // arguments need to get passed.
Alex Crichtonbb9062a2016-04-29 21:23:15344 let mut cargo = build.cargo(compiler, mode, target, "test");
345 cargo.arg("--manifest-path")
346 .arg(build.src.join(path).join("Cargo.toml"))
347 .arg("--features").arg(features);
348
Alex Crichton147e2da2016-10-07 06:30:38349 let mut visited = HashSet::new();
350 let root_pkg = output.packages.iter().find(|p| p.name == root).unwrap();
351 let mut next = vec![&root_pkg.id];
352 while let Some(id) = next.pop() {
353 // Skip any packages with sources listed, as these come from crates.io
354 // and we shouldn't be testing them.
355 if id2pkg[id].source.is_some() {
Alex Crichtonbb9062a2016-04-29 21:23:15356 continue
357 }
Alex Crichton147e2da2016-10-07 06:30:38358 // Right now jemalloc is our only target-specific crate in the sense
359 // that it's not present on all platforms. Custom skip it here for now,
360 // but if we add more this probably wants to get more generalized.
361 if !id.contains("jemalloc") {
362 cargo.arg("-p").arg(&id2pkg[id].name);
363 }
364 for dep in id2deps[id] {
365 if visited.insert(dep) {
366 next.push(dep);
Alex Crichtonbb9062a2016-04-29 21:23:15367 }
368 }
Alex Crichtonbb9062a2016-04-29 21:23:15369 }
370
371 // The tests are going to run with the *target* libraries, so we need to
372 // ensure that those libraries show up in the LD_LIBRARY_PATH equivalent.
373 //
374 // Note that to run the compiler we need to run with the *host* libraries,
375 // but our wrapper scripts arrange for that to be the case anyway.
376 let mut dylib_path = dylib_path();
377 dylib_path.insert(0, build.sysroot_libdir(compiler, target));
378 cargo.env(dylib_path_var(), env::join_paths(&dylib_path).unwrap());
Alex Crichtonbb9062a2016-04-29 21:23:15379
Corey Farwellc8c6d2c2016-10-30 01:58:52380 if build.config.quiet_tests {
381 cargo.arg("--");
382 cargo.arg("--quiet");
383 }
384
Alex Crichton39a5d3f2016-06-28 20:31:30385 if target.contains("android") {
386 build.run(cargo.arg("--no-run"));
387 krate_android(build, compiler, target, mode);
Brian Andersonb8b50f02016-09-06 00:41:50388 } else if target.contains("emscripten") {
Ross Schulmanad9184c2016-09-05 23:56:48389 build.run(cargo.arg("--no-run"));
Brian Andersonb8b50f02016-09-06 00:41:50390 krate_emscripten(build, compiler, target, mode);
Alex Crichton39a5d3f2016-06-28 20:31:30391 } else {
392 cargo.args(&build.flags.args);
393 build.run(&mut cargo);
394 }
395}
396
397fn krate_android(build: &Build,
398 compiler: &Compiler,
399 target: &str,
400 mode: Mode) {
401 let mut tests = Vec::new();
402 let out_dir = build.cargo_out(compiler, mode, target);
403 find_tests(&out_dir, target, &mut tests);
404 find_tests(&out_dir.join("deps"), target, &mut tests);
405
406 for test in tests {
407 build.run(Command::new("adb").arg("push").arg(&test).arg(ADB_TEST_DIR));
408
409 let test_file_name = test.file_name().unwrap().to_string_lossy();
410 let log = format!("{}/check-stage{}-T-{}-H-{}-{}.log",
411 ADB_TEST_DIR,
412 compiler.stage,
413 target,
414 compiler.host,
415 test_file_name);
416 let program = format!("(cd {dir}; \
417 LD_LIBRARY_PATH=./{target} ./{test} \
418 --logfile {log} \
419 {args})",
420 dir = ADB_TEST_DIR,
421 target = target,
422 test = test_file_name,
423 log = log,
424 args = build.flags.args.join(" "));
425
426 let output = output(Command::new("adb").arg("shell").arg(&program));
427 println!("{}", output);
428 build.run(Command::new("adb")
429 .arg("pull")
430 .arg(&log)
431 .arg(build.out.join("tmp")));
432 build.run(Command::new("adb").arg("shell").arg("rm").arg(&log));
433 if !output.contains("result: ok") {
434 panic!("some tests failed");
435 }
436 }
437}
438
Brian Andersonb8b50f02016-09-06 00:41:50439fn krate_emscripten(build: &Build,
440 compiler: &Compiler,
441 target: &str,
442 mode: Mode) {
Ross Schulmanad9184c2016-09-05 23:56:48443 let mut tests = Vec::new();
444 let out_dir = build.cargo_out(compiler, mode, target);
445 find_tests(&out_dir, target, &mut tests);
446 find_tests(&out_dir.join("deps"), target, &mut tests);
447
448 for test in tests {
449 let test_file_name = test.to_string_lossy().into_owned();
Brian Andersonfcd32792016-09-06 20:36:14450 println!("running {}", test_file_name);
Brian Anderson8401e372016-09-15 19:42:26451 let nodejs = build.config.nodejs.as_ref().expect("nodejs not configured");
Brian Andersonbadfd622016-09-27 19:56:50452 let status = Command::new(nodejs)
Brian Andersonfcd32792016-09-06 20:36:14453 .arg(&test_file_name)
454 .stderr(::std::process::Stdio::inherit())
Brian Andersonbadfd622016-09-27 19:56:50455 .status();
456 match status {
457 Ok(status) => {
458 if !status.success() {
459 panic!("some tests failed");
460 }
461 }
Brian Andersonfcd32792016-09-06 20:36:14462 Err(e) => panic!(format!("failed to execute command: {}", e)),
463 };
Ross Schulmanad9184c2016-09-05 23:56:48464 }
465 }
466
467
Alex Crichton39a5d3f2016-06-28 20:31:30468fn find_tests(dir: &Path,
469 target: &str,
470 dst: &mut Vec<PathBuf>) {
471 for e in t!(dir.read_dir()).map(|e| t!(e)) {
472 let file_type = t!(e.file_type());
473 if !file_type.is_file() {
474 continue
475 }
476 let filename = e.file_name().into_string().unwrap();
477 if (target.contains("windows") && filename.ends_with(".exe")) ||
Ross Schulmanad9184c2016-09-05 23:56:48478 (!target.contains("windows") && !filename.contains(".")) ||
Brian Andersonfcd32792016-09-06 20:36:14479 (target.contains("emscripten") && filename.contains(".js")){
Alex Crichton39a5d3f2016-06-28 20:31:30480 dst.push(e.path());
481 }
482 }
483}
484
485pub fn android_copy_libs(build: &Build,
486 compiler: &Compiler,
487 target: &str) {
488 println!("Android copy libs to emulator ({})", target);
489 build.run(Command::new("adb").arg("remount"));
490 build.run(Command::new("adb").args(&["shell", "rm", "-r", ADB_TEST_DIR]));
491 build.run(Command::new("adb").args(&["shell", "mkdir", ADB_TEST_DIR]));
492 build.run(Command::new("adb")
493 .arg("push")
494 .arg(build.src.join("src/etc/adb_run_wrapper.sh"))
495 .arg(ADB_TEST_DIR));
496
497 let target_dir = format!("{}/{}", ADB_TEST_DIR, target);
498 build.run(Command::new("adb").args(&["shell", "mkdir", &target_dir[..]]));
499
500 for f in t!(build.sysroot_libdir(compiler, target).read_dir()) {
501 let f = t!(f);
502 let name = f.file_name().into_string().unwrap();
503 if util::is_dylib(&name) {
504 build.run(Command::new("adb")
505 .arg("push")
506 .arg(f.path())
507 .arg(&target_dir));
508 }
509 }
Alex Crichtonbb9062a2016-04-29 21:23:15510}