diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2016-03-07 19:16:02 +0530 |
---|---|---|
committer | bors-servo <lbergstrom+bors@mozilla.com> | 2016-03-07 19:16:02 +0530 |
commit | dedae5e459724d32ada7d3f4e33d8533bddb43fa (patch) | |
tree | f2624e7e3f921e2d0f9e59c4d207c2acd037c053 | |
parent | 743e0c9c878a78da873fed4edaa9c8284b2fd12d (diff) | |
parent | 12100edffccf14241fabfb94ef5d3825e284eab1 (diff) | |
download | servo-dedae5e459724d32ada7d3f4e33d8533bddb43fa.tar.gz servo-dedae5e459724d32ada7d3f4e33d8533bddb43fa.zip |
Auto merge of #9891 - cengizIO:master, r=ecoal95
Replace deprecated fs::walk_dir call with walkdir crate
While working on #8351 I discovered that deprecated fs::walk_dir is used in android support files.
This is my first PR to any Rust project, so any constructive feedback is more than welcome!
Thanks
<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9891)
<!-- Reviewable:end -->
-rw-r--r-- | support/android/build-apk/Cargo.lock | 31 | ||||
-rw-r--r-- | support/android/build-apk/Cargo.toml | 2 | ||||
-rw-r--r-- | support/android/build-apk/src/main.rs | 41 |
3 files changed, 54 insertions, 20 deletions
diff --git a/support/android/build-apk/Cargo.lock b/support/android/build-apk/Cargo.lock index aa6f83fabec..86f35c0c8f3 100644 --- a/support/android/build-apk/Cargo.lock +++ b/support/android/build-apk/Cargo.lock @@ -1,4 +1,35 @@ [root] name = "build-apk" version = "0.0.1" +dependencies = [ + "walkdir 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "walkdir" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/support/android/build-apk/Cargo.toml b/support/android/build-apk/Cargo.toml index 23257facd3b..c50da011cce 100644 --- a/support/android/build-apk/Cargo.toml +++ b/support/android/build-apk/Cargo.toml @@ -11,3 +11,5 @@ test = false doc = false bench = false +[dependencies] +walkdir = "0.1.5" diff --git a/support/android/build-apk/src/main.rs b/support/android/build-apk/src/main.rs index 27230305acb..dde9ad7c811 100644 --- a/support/android/build-apk/src/main.rs +++ b/support/android/build-apk/src/main.rs @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -//extern crate num; -#![feature(dir_builder, fs_walk)] +extern crate walkdir; + use std::collections::{HashMap, HashSet}; use std::env; use std::fs; @@ -11,6 +11,7 @@ use std::fs::DirBuilder; use std::path::{Path, PathBuf}; use std::process; use std::process::{Command, Stdio}; +use walkdir::WalkDir; fn main() { let (args, passthrough) = parse_arguments(); @@ -167,7 +168,7 @@ fn main() { .stderr(Stdio::inherit()) .current_dir(directory.clone()) .status(); - if keytoolcreatecmd.is_err() || + if keytoolcreatecmd.is_err() || keytoolcreatecmd.unwrap().code().unwrap() != 0 { println!("Error while using `keytool` to create the debug keystore."); process::exit(1); @@ -193,7 +194,7 @@ fn main() { println!("Error while using `jarsign` to sign the APK."); process::exit(1); } - + fs::copy(&directory.join("bin").join("Servo-release-unsigned.apk"), &args.output).unwrap(); } @@ -263,25 +264,25 @@ fn find_native_libs(args: &Args) -> HashMap<String, PathBuf> { let mut native_shared_libs: HashMap<String, PathBuf> = HashMap::new(); // Add requested .so files - fs::walk_dir(&args.target_path).and_then(|dir_walker| { - for path in dir_walker { - let path = path.unwrap().path(); - match (path.file_name(), path.extension()) { - (Some(filename), Some(ext)) => { - let filename = filename.to_str().unwrap(); - if filename.starts_with("lib") - && ext == "so" - && args.shared_libraries.contains(filename) { - println!("Adding the file {:?}", filename); - native_shared_libs.insert(filename.to_string(), path.clone()); - break; - } + for dir_entry in WalkDir::new(&args.target_path) { + let dir_entry = dir_entry.unwrap(); + let path = dir_entry.path(); + + match (path.file_name(), path.extension()) { + (Some(file_name), Some(extension)) => { + let file_name = file_name.to_str().unwrap(); + + if file_name.starts_with("lib") + && extension == "so" + && args.shared_libraries.contains(file_name) { + println!("Adding the file {:?}", file_name); + native_shared_libs.insert(file_name.to_string(), path.to_path_buf().clone()); + break; } - _ => {} } + _ => {} } - Ok(()) - }).ok(); + } native_shared_libs } |