mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
Replace deprecated fs::walk_dir call with walkdir crate
This commit is contained in:
parent
743e0c9c87
commit
12100edffc
3 changed files with 54 additions and 20 deletions
31
support/android/build-apk/Cargo.lock
generated
31
support/android/build-apk/Cargo.lock
generated
|
@ -1,4 +1,35 @@
|
||||||
[root]
|
[root]
|
||||||
name = "build-apk"
|
name = "build-apk"
|
||||||
version = "0.0.1"
|
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"
|
||||||
|
|
||||||
|
|
|
@ -11,3 +11,5 @@ test = false
|
||||||
doc = false
|
doc = false
|
||||||
bench = false
|
bench = false
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
walkdir = "0.1.5"
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
//extern crate num;
|
extern crate walkdir;
|
||||||
#![feature(dir_builder, fs_walk)]
|
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
@ -11,6 +11,7 @@ use std::fs::DirBuilder;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process;
|
use std::process;
|
||||||
use std::process::{Command, Stdio};
|
use std::process::{Command, Stdio};
|
||||||
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let (args, passthrough) = parse_arguments();
|
let (args, passthrough) = parse_arguments();
|
||||||
|
@ -263,25 +264,25 @@ fn find_native_libs(args: &Args) -> HashMap<String, PathBuf> {
|
||||||
let mut native_shared_libs: HashMap<String, PathBuf> = HashMap::new();
|
let mut native_shared_libs: HashMap<String, PathBuf> = HashMap::new();
|
||||||
|
|
||||||
// Add requested .so files
|
// Add requested .so files
|
||||||
fs::walk_dir(&args.target_path).and_then(|dir_walker| {
|
for dir_entry in WalkDir::new(&args.target_path) {
|
||||||
for path in dir_walker {
|
let dir_entry = dir_entry.unwrap();
|
||||||
let path = path.unwrap().path();
|
let path = dir_entry.path();
|
||||||
|
|
||||||
match (path.file_name(), path.extension()) {
|
match (path.file_name(), path.extension()) {
|
||||||
(Some(filename), Some(ext)) => {
|
(Some(file_name), Some(extension)) => {
|
||||||
let filename = filename.to_str().unwrap();
|
let file_name = file_name.to_str().unwrap();
|
||||||
if filename.starts_with("lib")
|
|
||||||
&& ext == "so"
|
if file_name.starts_with("lib")
|
||||||
&& args.shared_libraries.contains(filename) {
|
&& extension == "so"
|
||||||
println!("Adding the file {:?}", filename);
|
&& args.shared_libraries.contains(file_name) {
|
||||||
native_shared_libs.insert(filename.to_string(), path.clone());
|
println!("Adding the file {:?}", file_name);
|
||||||
|
native_shared_libs.insert(file_name.to_string(), path.to_path_buf().clone());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
|
||||||
}).ok();
|
|
||||||
|
|
||||||
native_shared_libs
|
native_shared_libs
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue