Run rustfmt with Fuchsia config
No other changes.
Change-Id: I400743c8d3b8868ae15990721d3e50d42fed9ecd
diff --git a/cratest/src/main.rs b/cratest/src/main.rs
index 5072d93..7503ff6 100644
--- a/cratest/src/main.rs
+++ b/cratest/src/main.rs
@@ -55,17 +55,17 @@
fn main() {
let matches = clap_app!(cratest =>
- (version: "1.0")
- (author: "Tim Kilbourn <tkilbourn@google.com>")
- (about: "Tests the top crates from crates.io on Fuchsia")
- (@arg num: -n +takes_value "Number of crates to test")
- (@arg excludes: -x --exclude ... +takes_value
- "Exclude crates whose name exactly match")
- (@arg start: --start "Starts a Fuchsia emulator")
- (@arg restart: --restart "Stop all Fuchsia emulators and start a new one")
- (@arg keep: --keep "Keeps the temp dir after exiting")
- (@arg verbose: -v --verbose "Print verbose output while performing commands")
- )
+ (version: "1.0")
+ (author: "Tim Kilbourn <tkilbourn@google.com>")
+ (about: "Tests the top crates from crates.io on Fuchsia")
+ (@arg num: -n +takes_value "Number of crates to test")
+ (@arg excludes: -x --exclude ... +takes_value
+ "Exclude crates whose name exactly match")
+ (@arg start: --start "Starts a Fuchsia emulator")
+ (@arg restart: --restart "Stop all Fuchsia emulators and start a new one")
+ (@arg keep: --keep "Keeps the temp dir after exiting")
+ (@arg verbose: -v --verbose "Print verbose output while performing commands")
+ )
.get_matches();
let num = value_t!(matches, "num", usize).unwrap_or(DEFAULT_NUM);
@@ -77,18 +77,15 @@
values_t!(matches, "excludes", String).unwrap_or_else(|_| Vec::new()),
);
- println!(
- "Running cratest on the top {} crates from crates.io...",
- num
- );
+ println!("Running cratest on the top {} crates from crates.io...", num);
let crate_uri: String = [
"https://crates.io/api/v1/crates?page=1&per_page=",
&format!("{}", num),
"&sort=downloads",
]
- .join("")
- .into();
+ .join("")
+ .into();
if verbose {
println!("Downloading crates from {}", crate_uri);
@@ -105,15 +102,9 @@
let res: Crates = serde_json::from_str(&content).unwrap();
if restart_emu {
- Command::new("fargo")
- .arg("restart")
- .status()
- .expect("failed to run fargo restart");
+ Command::new("fargo").arg("restart").status().expect("failed to run fargo restart");
} else if start_emu {
- Command::new("fargo")
- .arg("start")
- .status()
- .expect("failed to run fargo start");
+ Command::new("fargo").arg("start").status().expect("failed to run fargo start");
}
let tmpdir = TempDir::new("cratest").unwrap();
@@ -126,10 +117,7 @@
if verbose {
println!("Skipping {} (excluded)", &cr.id);
}
- return CrateResult {
- id: cr.id.clone(),
- res: TestResult::Excluded,
- };
+ return CrateResult { id: cr.id.clone(), res: TestResult::Excluded };
}
let crdir = tmpdir.path().join(&cr.id);
fs::create_dir(&crdir).unwrap();
diff --git a/rustfmt.toml b/rustfmt.toml
index 9f63763..57d9942 100644
--- a/rustfmt.toml
+++ b/rustfmt.toml
@@ -1,57 +1,15 @@
-# This file was originally created by running the command
-# rustfmt --print-config default rustfmt.toml && sort -u rustfmt.toml -o rustfmt.toml.
-# Changes from the defaults are marked with comments.
-binop_separator = "Front"
-blank_lines_lower_bound = 0
-blank_lines_upper_bound = 1
-brace_style = "SameLineWhere"
-color = "Auto"
-combine_control_expr = true
-comment_width = 100 # Fuchsia uses 100
-condense_wildcard_suffixes = false
-control_brace_style = "AlwaysSameLine"
-disable_all_formatting = false
+# Fuchsia Format Style
+# last reviewed: Jan 29, 2019
+
+# Fuchsia uses 2018 edition only
edition = "2018"
-emit_mode = "Files"
-empty_item_single_line = true
-error_on_line_overflow = false
-error_on_unformatted = false
-fn_args_density = "Compressed" # Fuchsia prefers compressed
-fn_single_line = false
-force_explicit_abi = true
-force_multiline_blocks = false
-format_strings = false
-hard_tabs = false
-hide_parse_errors = false
-imports_indent = "Visual"
-imports_layout = "Mixed"
-indent_style = "Block"
-match_arm_blocks = true
-match_block_trailing_comma = false
-max_width = 100
-merge_derives = true
-merge_imports = false
+
+# The "Default" setting has a heuristic which splits lines too aggresively.
+# We are willing to revisit this setting in future versions of rustfmt.
+# Bugs:
+# * https://github.com/rust-lang/rustfmt/issues/3119
+# * https://github.com/rust-lang/rustfmt/issues/3120
+use_small_heuristics = "Max"
+
+# Prevent carriage returns
newline_style = "Unix"
-normalize_comments = false
-remove_nested_parens = true
-reorder_impl_items = false
-reorder_imports = true
-reorder_modules = true
-report_fixme = "Never"
-report_todo = "Never"
-skip_children = false
-space_after_colon = true
-space_before_colon = false
-spaces_around_ranges = false
-struct_field_align_threshold = 0
-struct_lit_single_line = true
-tab_spaces = 4
-trailing_comma = "Vertical"
-trailing_semicolon = true
-type_punctuation_density = "Wide"
-unstable_features = false
-use_field_init_shorthand = false
-use_small_heuristics = "Default"
-use_try_shorthand = true # Fuchsia prefers the shortcut
-where_single_line = false
-wrap_comments = true # otherwise comments will violate max_width
diff --git a/src/build_rustc.rs b/src/build_rustc.rs
index 31fdd99..0ca140d 100644
--- a/src/build_rustc.rs
+++ b/src/build_rustc.rs
@@ -1,5 +1,6 @@
-use crate::sdk::{clang_base_path, clang_resource_dir, shared_libraries_path, sysroot_path,
- TargetOptions};
+use crate::sdk::{
+ clang_base_path, clang_resource_dir, shared_libraries_path, sysroot_path, TargetOptions,
+};
use crate::X64;
use crate::{get_target_triple, get_triple_cpu};
@@ -13,11 +14,7 @@
pub fn build_rustc(rust_root: &Path, target_options: &TargetOptions<'_, '_>) -> Result<(), Error> {
let target_triple = get_target_triple(target_options);
let triple_cpu = get_triple_cpu(target_options);
- let targets_name = if target_options.config.fuchsia_arch == X64 {
- "X86"
- } else {
- "AArch64"
- };
+ let targets_name = if target_options.config.fuchsia_arch == X64 { "X86" } else { "AArch64" };
let clang_base_path = clang_base_path()?;
let clang_bin_path = clang_base_path.join("bin");
let staging = rust_root.join("fuchsia_staging");
@@ -70,9 +67,7 @@
let sysroot_path = sysroot_path(target_options)?;
let sysroot_lib_path = sysroot_path.join("lib");
- let clang_resource_lib = clang_resource_dir(&target_triple)?
- .join(&target_triple)
- .join("lib");
+ let clang_resource_lib = clang_resource_dir(&target_triple)?.join(&target_triple).join("lib");
let cargo_dir = staging.join(".cargo");
create_dir_all(&cargo_dir)?;
@@ -98,11 +93,8 @@
clang_resource_lib = clang_resource_lib.to_string_lossy(),
)?;
let x_py = rust_root.join("x.py");
- let common_c_flags = format!(
- "--sysroot={} --target={}-fuchsia",
- sysroot_path.to_str().unwrap(),
- triple_cpu
- );
+ let common_c_flags =
+ format!("--sysroot={} --target={}-fuchsia", sysroot_path.to_str().unwrap(), triple_cpu);
let ld_flags = format!(
"--sysroot={} --target={}-fuchsia -L{}",
sysroot_path.to_str().unwrap(),
diff --git a/src/cross.rs b/src/cross.rs
index 9d28c36..18eb065 100644
--- a/src/cross.rs
+++ b/src/cross.rs
@@ -23,7 +23,9 @@
}
pub fn run_pkg_config(
- verbose: bool, args: &[&str], target_options: &TargetOptions<'_, '_>,
+ verbose: bool,
+ args: &[&str],
+ target_options: &TargetOptions<'_, '_>,
) -> Result<i32, Error> {
let mut cmd = Command::new("pkg-config");
@@ -45,7 +47,10 @@
}
pub fn run_configure(
- verbose: bool, use_host: bool, args: &[&str], target_options: &TargetOptions<'_, '_>,
+ verbose: bool,
+ use_host: bool,
+ args: &[&str],
+ target_options: &TargetOptions<'_, '_>,
) -> Result<bool, Error> {
let cwd = fs::canonicalize(env::current_dir()?)
.context("run_configure: canonicalize working directory")?;
diff --git a/src/device.rs b/src/device.rs
index 22d0af4..f84caa1 100644
--- a/src/device.rs
+++ b/src/device.rs
@@ -18,26 +18,13 @@
args.push(device_name);
}
let netaddr_result = Command::new(netaddr_binary).args(args).output()?;
- let result = str::from_utf8(&netaddr_result.stdout)
- .unwrap()
- .trim()
- .to_string();
+ let result = str::from_utf8(&netaddr_result.stdout).unwrap().trim().to_string();
if verbose {
- println!(
- "netaddr status = {}, result = {}",
- netaddr_result.status, result
- );
+ println!("netaddr status = {}, result = {}", netaddr_result.status, result);
}
if !netaddr_result.status.success() {
- let err_str = str::from_utf8(&netaddr_result.stderr)
- .unwrap()
- .trim()
- .to_string();
- bail!(
- "netaddr failed with status {:?}: {}",
- netaddr_result.status,
- err_str
- );
+ let err_str = str::from_utf8(&netaddr_result.stderr).unwrap().trim().to_string();
+ bail!("netaddr failed with status {:?}: {}", netaddr_result.status, err_str);
}
Ok(result)
}
@@ -67,7 +54,10 @@
];
pub fn scp_to_device(
- verbose: bool, config: &FuchsiaConfig, netaddr: &str, source_path: &PathBuf,
+ verbose: bool,
+ config: &FuchsiaConfig,
+ netaddr: &str,
+ source_path: &PathBuf,
destination_path: &str,
) -> Result<(), Error> {
let destination_with_address = format!("[{}]:{}", netaddr, destination_path);
@@ -105,7 +95,10 @@
}
pub fn ssh(
- verbose: bool, config: &FuchsiaConfig, target_options: &TargetOptions<'_, '_>, command: &str,
+ verbose: bool,
+ config: &FuchsiaConfig,
+ target_options: &TargetOptions<'_, '_>,
+ command: &str,
) -> Result<(), Error> {
let netaddr = netaddr(verbose, target_options)?;
let ssh_config = target_out_dir(config)?.join("ssh-keys/ssh_config");
@@ -222,10 +215,7 @@
} else {
setup_network_linux(&user)?;
}
- Command::new("stty")
- .arg("sane")
- .status()
- .context("couldn't run stty")?;
+ Command::new("stty").arg("sane").status().context("couldn't run stty")?;
Ok(())
}
diff --git a/src/lib.rs b/src/lib.rs
index 30664ea..a1bddee 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -18,11 +18,15 @@
use crate::build_rustc::build_rustc;
use crate::cross::{pkg_config_path, run_configure, run_pkg_config};
-use crate::device::{enable_networking, netaddr, netls, scp_to_device, ssh, start_emulator,
- stop_emulator, StartEmulatorOptions};
-use crate::sdk::{cargo_out_dir, cargo_path, clang_archiver_path, clang_c_compiler_path,
- clang_cpp_compiler_path, clang_ranlib_path, clang_resource_dir, rustc_path,
- rustdoc_path, shared_libraries_path, sysroot_path, zircon_build_path};
+use crate::device::{
+ enable_networking, netaddr, netls, scp_to_device, ssh, start_emulator, stop_emulator,
+ StartEmulatorOptions,
+};
+use crate::sdk::{
+ cargo_out_dir, cargo_path, clang_archiver_path, clang_c_compiler_path, clang_cpp_compiler_path,
+ clang_ranlib_path, clang_resource_dir, rustc_path, rustdoc_path, shared_libraries_path,
+ sysroot_path, zircon_build_path,
+};
use crate::utils::strip_binary;
use clap::{App, AppSettings, Arg, SubCommand};
@@ -35,40 +39,41 @@
use std::time::SystemTime;
fn copy_to_target(
- source_path: &PathBuf, verbose: bool, config: &FuchsiaConfig,
+ source_path: &PathBuf,
+ verbose: bool,
+ config: &FuchsiaConfig,
target_options: &TargetOptions<'_, '_>,
) -> Result<String, Error> {
let netaddr = netaddr(verbose, target_options)?;
if verbose {
println!("netaddr {}", netaddr);
}
- let destination_path = format!(
- "/tmp/{}",
- source_path.file_name().unwrap().to_string_lossy()
- );
- println!(
- "copying {} to {}",
- source_path.to_string_lossy(),
- destination_path
- );
+ let destination_path = format!("/tmp/{}", source_path.file_name().unwrap().to_string_lossy());
+ println!("copying {} to {}", source_path.to_string_lossy(), destination_path);
scp_to_device(verbose, config, &netaddr, &source_path, &destination_path)?;
Ok(destination_path)
}
fn run_program_on_target(
- filename: &str, verbose: bool, nocapture: bool, config: &FuchsiaConfig,
- target_options: &TargetOptions<'_, '_>, run_mode: RunMode, story_name: &str, mod_name: &str,
- params: &[&str], test_args: Option<&str>,
+ filename: &str,
+ verbose: bool,
+ nocapture: bool,
+ config: &FuchsiaConfig,
+ target_options: &TargetOptions<'_, '_>,
+ run_mode: RunMode,
+ story_name: &str,
+ mod_name: &str,
+ params: &[&str],
+ test_args: Option<&str>,
) -> Result<(), Error> {
let source_path = PathBuf::from(&filename);
let stripped_source_path = strip_binary(&source_path)?;
let destination_path = copy_to_target(&stripped_source_path, verbose, config, target_options)?;
let mut command_string = match run_mode {
RunMode::Tiles => "tiles_ctl add ".to_string(),
- RunMode::Ermine => format!(
- "sessionctl --story_name={} --mod_name={} --mod_url=",
- story_name, mod_name
- ),
+ RunMode::Ermine => {
+ format!("sessionctl --story_name={} --mod_name={} --mod_url=", story_name, mod_name)
+ }
RunMode::Run => "run ".to_string(),
RunMode::Normal => "".to_string(),
};
@@ -111,7 +116,8 @@
use std::time::Duration;
fn autotest(
- run_cargo_options: &RunCargoOptions, target_options: &TargetOptions<'_, '_>,
+ run_cargo_options: &RunCargoOptions,
+ target_options: &TargetOptions<'_, '_>,
) -> Result<(), Error> {
let (tx, rx) = channel();
let mut watcher: RecommendedWatcher =
@@ -122,9 +128,7 @@
let tgt = cwd.join("target");
let git = cwd.join(".git");
- watcher
- .watch(&cwd, RecursiveMode::Recursive)
- .context("autotest: watch failed")?;
+ watcher.watch(&cwd, RecursiveMode::Recursive).context("autotest: watch failed")?;
println!("autotest: started");
loop {
@@ -147,8 +151,11 @@
}
fn run_tests(
- run_cargo_options: &RunCargoOptions, no_run: bool, target_options: &TargetOptions<'_, '_>,
- params: &[&str], target_params: Option<&str>,
+ run_cargo_options: &RunCargoOptions,
+ no_run: bool,
+ target_options: &TargetOptions<'_, '_>,
+ params: &[&str],
+ target_params: Option<&str>,
) -> Result<(), Error> {
let mut args = vec![];
@@ -171,54 +178,41 @@
Some(&formatted_target_params),
)?;
} else {
- run_cargo(
- &run_cargo_options,
- "test",
- &args,
- target_options,
- None,
- None,
- )?;
+ run_cargo(&run_cargo_options, "test", &args, target_options, None, None)?;
}
Ok(())
}
fn build_binary(
- run_cargo_options: &RunCargoOptions, target_options: &TargetOptions<'_, '_>, params: &[&str],
+ run_cargo_options: &RunCargoOptions,
+ target_options: &TargetOptions<'_, '_>,
+ params: &[&str],
) -> Result<(), Error> {
- run_cargo(
- run_cargo_options,
- "build",
- params,
- target_options,
- None,
- None,
- )
+ run_cargo(run_cargo_options, "build", params, target_options, None, None)
}
fn check_binary(
- run_cargo_options: &RunCargoOptions, target_options: &TargetOptions<'_, '_>, params: &[&str],
+ run_cargo_options: &RunCargoOptions,
+ target_options: &TargetOptions<'_, '_>,
+ params: &[&str],
) -> Result<(), Error> {
- run_cargo(
- run_cargo_options,
- "check",
- params,
- target_options,
- None,
- None,
- )
+ run_cargo(run_cargo_options, "check", params, target_options, None, None)
}
fn run_binary(
- run_cargo_options: &RunCargoOptions, target_options: &TargetOptions<'_, '_>, params: &[&str],
+ run_cargo_options: &RunCargoOptions,
+ target_options: &TargetOptions<'_, '_>,
+ params: &[&str],
) -> Result<(), Error> {
run_cargo(run_cargo_options, RUN, params, target_options, None, None)?;
Ok(())
}
fn build_doc(
- run_cargo_options: &RunCargoOptions, target_options: &TargetOptions<'_, '_>, no_deps: bool,
+ run_cargo_options: &RunCargoOptions,
+ target_options: &TargetOptions<'_, '_>,
+ no_deps: bool,
open: bool,
) -> Result<(), Error> {
let mut args = vec![];
@@ -232,18 +226,12 @@
}
fn load_driver(
- run_cargo_options: &RunCargoOptions, config: &FuchsiaConfig,
+ run_cargo_options: &RunCargoOptions,
+ config: &FuchsiaConfig,
target_options: &TargetOptions<'_, '_>,
) -> Result<(), Error> {
let args = vec![];
- run_cargo(
- run_cargo_options,
- "build",
- &args,
- target_options,
- None,
- None,
- )?;
+ run_cargo(run_cargo_options, "build", &args, target_options, None, None)?;
let cwd = std::env::current_dir()?;
let package = cwd
.file_name()
@@ -257,12 +245,7 @@
if run_cargo_options.verbose {
println!("running {}", command_string);
}
- ssh(
- run_cargo_options.verbose,
- config,
- target_options,
- &command_string,
- )?;
+ ssh(run_cargo_options.verbose, config, target_options, &command_string)?;
Ok(())
}
@@ -429,12 +412,7 @@
}
fn get_triple_cpu(target_options: &TargetOptions<'_, '_>) -> String {
- if (target_options.config.fuchsia_arch) == X64 {
- "x86_64"
- } else {
- "aarch64"
- }
- .to_string()
+ if (target_options.config.fuchsia_arch) == X64 { "x86_64" } else { "aarch64" }.to_string()
}
fn get_target_triple(target_options: &TargetOptions<'_, '_>) -> String {
@@ -444,14 +422,13 @@
}
fn get_rustflags(
- target_options: &TargetOptions<'_, '_>, sysroot_as_path: &PathBuf,
+ target_options: &TargetOptions<'_, '_>,
+ sysroot_as_path: &PathBuf,
) -> Result<String, Error> {
let target_triple = get_target_triple(target_options);
let sysroot_lib_pathbuf = sysroot_as_path.join("lib");
let sysroot_lib = sysroot_lib_pathbuf.to_str().unwrap();
- let clang_resource_lib = clang_resource_dir(&target_triple)?
- .join(&target_triple)
- .join("lib");
+ let clang_resource_lib = clang_resource_dir(&target_triple)?.join(&target_triple).join("lib");
let mut rust_flags = vec![
"-L".to_string(),
@@ -461,10 +438,7 @@
format!("-Clink-arg=-L{}", sysroot_lib),
format!("-Clink-arg=-L{}", clang_resource_lib.to_str().unwrap()),
format!("-Clink-arg=--sysroot={}", sysroot_as_path.to_str().unwrap()),
- format!(
- "-Lnative={}",
- shared_libraries_path(target_options)?.to_str().unwrap()
- ),
+ format!("-Lnative={}", shared_libraries_path(target_options)?.to_str().unwrap()),
];
if get_triple_cpu(target_options) == "aarch64" {
@@ -475,8 +449,11 @@
}
fn make_fargo_command(
- runner: Option<PathBuf>, options: &RunCargoOptions, nocapture: bool,
- target_options: &TargetOptions<'_, '_>, additional_target_args: Option<&str>,
+ runner: Option<PathBuf>,
+ options: &RunCargoOptions,
+ nocapture: bool,
+ target_options: &TargetOptions<'_, '_>,
+ additional_target_args: Option<&str>,
) -> Result<String, Error> {
let tiles_arg = format!("--{}", RUN_WITH_TILES);
let ermine_arg = format!(
@@ -494,11 +471,9 @@
fs::canonicalize(std::env::current_exe()?)?
};
- let mut runner_args = vec![
- fargo_path
- .to_str()
- .ok_or_else(|| err_msg("unable to convert path to utf8 encoding"))?,
- ];
+ let mut runner_args = vec![fargo_path
+ .to_str()
+ .ok_or_else(|| err_msg("unable to convert path to utf8 encoding"))?];
if options.verbose {
runner_args.push("-v");
@@ -568,8 +543,11 @@
/// );
/// ```
pub fn run_cargo(
- options: &RunCargoOptions, subcommand: &str, args: &[&str],
- target_options: &TargetOptions<'_, '_>, runner: Option<PathBuf>,
+ options: &RunCargoOptions,
+ subcommand: &str,
+ args: &[&str],
+ target_options: &TargetOptions<'_, '_>,
+ runner: Option<PathBuf>,
additional_target_args: Option<&str>,
) -> Result<(), Error> {
if options.verbose {
@@ -585,10 +563,7 @@
}
if options.verbose {
- println!(
- "target_options.target_cpu = {:?}",
- target_options.config.fuchsia_arch
- );
+ println!("target_options.target_cpu = {:?}", target_options.config.fuchsia_arch);
println!("triple_cpu = {:?}", triple_cpu);
println!("target_triple = {:?}", target_triple);
println!("target_args = {:?}", target_args);
@@ -614,10 +589,7 @@
let sysroot_as_path = sysroot_path(target_options)?;
let sysroot_as_str = sysroot_as_path.to_str().unwrap();
- let args: Vec<&str> = args
- .iter()
- .map(|a| if *a == "++" { "--" } else { *a })
- .collect();
+ let args: Vec<&str> = args.iter().map(|a| if *a == "++" { "--" } else { *a }).collect();
let runner_env_name = format!("CARGO_TARGET_{}_RUNNER", target_triple_uc);
let rustflags_env_name = format!("CARGO_TARGET_{}_RUSTFLAGS", target_triple_uc);
@@ -630,17 +602,11 @@
}
cmd.env(runner_env_name, fargo_command)
- .env(
- rustflags_env_name,
- get_rustflags(target_options, &sysroot_as_path)?,
- )
+ .env(rustflags_env_name, get_rustflags(target_options, &sysroot_as_path)?)
.env("RUSTC", rustc_path()?.to_str().unwrap())
.env("RUSTDOC", rustdoc_path()?.to_str().unwrap())
.env("RUSTDOCFLAGS", "--cap-lints allow -Z unstable-options")
- .env(
- "FUCHSIA_SHARED_ROOT",
- shared_libraries_path(target_options)?,
- )
+ .env("FUCHSIA_SHARED_ROOT", shared_libraries_path(target_options)?)
.env("ZIRCON_BUILD_ROOT", zircon_build_path(target_options)?)
.arg(subcommand)
.args(target_args)
@@ -680,7 +646,8 @@
}
fn write_config(
- options: &RunCargoOptions, target_options: &TargetOptions<'_, '_>,
+ options: &RunCargoOptions,
+ target_options: &TargetOptions<'_, '_>,
) -> Result<(), Error> {
let cargo_dir_path = Path::new(".cargo");
if cargo_dir_path.exists() {
@@ -698,11 +665,7 @@
let sysroot_as_path = sysroot_path(target_options)?;
writeln!(config, "[target.{}]", get_target_triple(target_options))?;
- writeln!(
- config,
- "rustflags = \"{}\"",
- get_rustflags(target_options, &sysroot_as_path)?
- )?;
+ writeln!(config, "rustflags = \"{}\"", get_rustflags(target_options, &sysroot_as_path)?)?;
writeln!(
config,
"runner = \"{}\"",
@@ -711,11 +674,7 @@
writeln!(config, "")?;
writeln!(config, "[build]")?;
writeln!(config, "rustc = \"{}\"", rustc_path()?.to_str().unwrap())?;
- writeln!(
- config,
- "rustdoc = \"{}\"",
- rustdoc_path()?.to_str().unwrap()
- )?;
+ writeln!(config, "rustdoc = \"{}\"", rustdoc_path()?.to_str().unwrap())?;
writeln!(config, "target = \"{}\"", get_target_triple(target_options))?;
Ok(())
}
@@ -767,373 +726,350 @@
#[doc(hidden)]
pub fn run() -> Result<(), Error> {
- let matches =
- App::new("fargo")
- .version("v0.2.0")
- .setting(AppSettings::GlobalVersion)
- .setting(AppSettings::ArgRequiredElseHelp)
- .about("Fargo is a prototype Fuchsia-specific wrapper around Cargo")
- .arg(
- Arg::with_name("verbose")
- .long("verbose")
- .short("v")
- .help("Print verbose output while performing commands"),
- )
- .arg(
- Arg::with_name(DISABLE_CROSS_ENV)
- .long(DISABLE_CROSS_ENV)
- .help("Disable the setting of CC, AR and such environmental variables."),
- )
- .arg(
- Arg::with_name("device-name")
- .long("device-name")
- .short("N")
- .value_name("device-name")
- .help(
- "Name of device to target, needed if there are multiple devices visible \
- on the network",
- ),
- )
- .arg(
- Arg::with_name(MANIFEST_PATH)
- .long(MANIFEST_PATH)
- .value_name(MANIFEST_PATH)
- .global(true)
- .help("Path to Cargo.toml"),
- )
- .subcommand(
- SubCommand::with_name("autotest")
- .about("Auto build and test in Fuchsia device or emulator")
- .arg(Arg::with_name(RELEASE).long(RELEASE).help("Build release"))
- .arg(
- Arg::with_name(NOCAPTURE)
- .long(NOCAPTURE)
- .help("Display all output when running tests."),
- ),
- )
- .subcommand(
- SubCommand::with_name(TEST)
- .about("Run unit tests on Fuchsia device or emulator")
- .arg(Arg::with_name(RELEASE).long(RELEASE).help(RELEASE_HELP))
- .arg(
- Arg::with_name(NOCAPTURE)
- .long(NOCAPTURE)
- .help("Display all output when running tests."),
- )
- .arg(
- Arg::with_name(TEST_TARGET_NAME)
- .long(TEST_TARGET_NAME)
- .value_name(TEST_TARGET_NAME)
- .help("Test only the specified test target"),
- )
- .arg(
- Arg::with_name("package")
- .short("p")
- .long("package")
- .takes_value(true)
- .help("Package to run tests for"),
- )
- .arg(
- Arg::with_name("bin")
- .long("bin")
- .value_name("bin")
- .help("Name of the bin target to run"),
- )
- .arg(
- Arg::with_name("test_args")
- .long("args")
- .value_name("args")
- .help("arguments to pass to the test runner"),
- )
- .arg(Arg::with_name("test_params").index(1).multiple(true)),
- )
- .subcommand(
- SubCommand::with_name("build")
- .about("Build binary targeting Fuchsia device or emulator")
- .arg(Arg::with_name(RELEASE).long(RELEASE).help(RELEASE_HELP))
- .arg(
- Arg::with_name("package")
- .short("p")
- .long("package")
- .takes_value(true)
- .help("Package to build"),
- )
- .arg(
- Arg::with_name("bin")
- .long("bin")
- .takes_value(true)
- .help("Name of the bin target to run"),
- )
- .arg(
- Arg::with_name("test")
- .long("test")
- .takes_value(true)
- .help("Build only the specified test target"),
- )
- .arg(
- Arg::with_name("tests")
- .long("tests")
- .help("Build all the tests"),
- )
- .arg(
- Arg::with_name("example")
- .long("example")
- .takes_value(true)
- .help("Build a specific example from the examples/ dir."),
- )
- .arg(
- Arg::with_name("examples")
- .long("examples")
- .help("Build all examples in the examples/ dir."),
- ),
- )
- .subcommand(
- SubCommand::with_name(CHECK)
- .about("Check binary targeting Fuchsia device or emulator")
- .arg(Arg::with_name(RELEASE).long(RELEASE).help(RELEASE_HELP))
- .arg(
- Arg::with_name("package")
- .short("p")
- .long("package")
- .takes_value(true)
- .help("Package to build"),
- )
- .arg(
- Arg::with_name("bin")
- .long("bin")
- .takes_value(true)
- .help("Name of the bin target to run"),
- )
- .arg(
- Arg::with_name("test")
- .long("test")
- .takes_value(true)
- .help("Build only the specified test target"),
- )
- .arg(
- Arg::with_name("tests")
- .long("tests")
- .help("Build all the tests"),
- )
- .arg(
- Arg::with_name(EXAMPLE)
- .long(EXAMPLE)
- .takes_value(true)
- .help("Check a specific example from the examples/ dir."),
- )
- .arg(
- Arg::with_name(EXAMPLES)
- .long(EXAMPLES)
- .help("Check all examples in the examples/ dir."),
- ),
- )
- .subcommand(
- SubCommand::with_name(DOC)
- .about("Build a package's documentation")
- .arg(Arg::with_name(RELEASE).long(RELEASE).help(RELEASE_HELP))
- .arg(
- Arg::with_name(DOC_NO_DEPS)
- .long(DOC_NO_DEPS)
- .help("Don't build documentation for dependencies"),
- )
- .arg(
- Arg::with_name(DOC_OPEN)
- .long(DOC_OPEN)
- .help("Opens the docs in a browser after the operation"),
- ),
- )
- .subcommand(
- SubCommand::with_name(RUN)
- .about("Run binary on Fuchsia device or emulator")
- .arg(Arg::with_name(RELEASE).long(RELEASE).help(RELEASE_HELP))
- .arg(
- Arg::with_name(STORY_NAME)
- .long(STORY_NAME)
- .short("n")
- .value_name(STORY_NAME)
- .help("Name of story to pass to sessionctl"),
- )
- .arg(
- Arg::with_name(MOD_NAME)
- .long(MOD_NAME)
- .short("m")
- .value_name(MOD_NAME)
- .help("Name of mod to pass to sessionctl"),
- )
- .arg(
- Arg::with_name(RUN_WITH_TILES)
- .long(RUN_WITH_TILES)
- .help("Use tiles_ctl add to run binary."),
- )
- .arg(
- Arg::with_name(RUN_WITH_RUN)
- .long(RUN_WITH_RUN)
- .help("Use run to run binary."),
- )
- .arg(
- Arg::with_name(RUN_WITH_SESSIONCTL)
- .long(RUN_WITH_SESSIONCTL)
- .help("Use sessionctl to run binary."),
- )
- .arg(
- Arg::with_name("package")
- .short("p")
- .long("package")
- .value_name("package")
- .help("Package to build"),
- )
- .arg(
- Arg::with_name("bin")
- .long("bin")
- .value_name("bin")
- .help("Name of the bin target to run"),
- )
- .arg(
- Arg::with_name("example")
- .long("example")
- .value_name("example")
- .help("Run a specific example from the examples/ dir."),
- ),
- )
- .subcommand(
- SubCommand::with_name("load-driver")
- .about("Build driver and load it on Fuchsia device or emulator.")
- .arg(Arg::with_name(RELEASE).long(RELEASE).help("Build release")),
- )
- .subcommand(SubCommand::with_name("list-devices").about("List visible Fuchsia devices"))
- .subcommand(
- SubCommand::with_name(START)
- .about("Start a Fuchsia emulator")
- .arg(
- Arg::with_name(GRAPHICS)
- .short("g")
- .help("Start a simulator with graphics enabled"),
- )
- .arg(Arg::with_name(DISABLE_VIRTCON).long(DISABLE_VIRTCON).help(
+ let matches = App::new("fargo")
+ .version("v0.2.0")
+ .setting(AppSettings::GlobalVersion)
+ .setting(AppSettings::ArgRequiredElseHelp)
+ .about("Fargo is a prototype Fuchsia-specific wrapper around Cargo")
+ .arg(
+ Arg::with_name("verbose")
+ .long("verbose")
+ .short("v")
+ .help("Print verbose output while performing commands"),
+ )
+ .arg(
+ Arg::with_name(DISABLE_CROSS_ENV)
+ .long(DISABLE_CROSS_ENV)
+ .help("Disable the setting of CC, AR and such environmental variables."),
+ )
+ .arg(
+ Arg::with_name("device-name")
+ .long("device-name")
+ .short("N")
+ .value_name("device-name")
+ .help(
+ "Name of device to target, needed if there are multiple devices visible \
+ on the network",
+ ),
+ )
+ .arg(
+ Arg::with_name(MANIFEST_PATH)
+ .long(MANIFEST_PATH)
+ .value_name(MANIFEST_PATH)
+ .global(true)
+ .help("Path to Cargo.toml"),
+ )
+ .subcommand(
+ SubCommand::with_name("autotest")
+ .about("Auto build and test in Fuchsia device or emulator")
+ .arg(Arg::with_name(RELEASE).long(RELEASE).help("Build release"))
+ .arg(
+ Arg::with_name(NOCAPTURE)
+ .long(NOCAPTURE)
+ .help("Display all output when running tests."),
+ ),
+ )
+ .subcommand(
+ SubCommand::with_name(TEST)
+ .about("Run unit tests on Fuchsia device or emulator")
+ .arg(Arg::with_name(RELEASE).long(RELEASE).help(RELEASE_HELP))
+ .arg(
+ Arg::with_name(NOCAPTURE)
+ .long(NOCAPTURE)
+ .help("Display all output when running tests."),
+ )
+ .arg(
+ Arg::with_name(TEST_TARGET_NAME)
+ .long(TEST_TARGET_NAME)
+ .value_name(TEST_TARGET_NAME)
+ .help("Test only the specified test target"),
+ )
+ .arg(
+ Arg::with_name("package")
+ .short("p")
+ .long("package")
+ .takes_value(true)
+ .help("Package to run tests for"),
+ )
+ .arg(
+ Arg::with_name("bin")
+ .long("bin")
+ .value_name("bin")
+ .help("Name of the bin target to run"),
+ )
+ .arg(
+ Arg::with_name("test_args")
+ .long("args")
+ .value_name("args")
+ .help("arguments to pass to the test runner"),
+ )
+ .arg(Arg::with_name("test_params").index(1).multiple(true)),
+ )
+ .subcommand(
+ SubCommand::with_name("build")
+ .about("Build binary targeting Fuchsia device or emulator")
+ .arg(Arg::with_name(RELEASE).long(RELEASE).help(RELEASE_HELP))
+ .arg(
+ Arg::with_name("package")
+ .short("p")
+ .long("package")
+ .takes_value(true)
+ .help("Package to build"),
+ )
+ .arg(
+ Arg::with_name("bin")
+ .long("bin")
+ .takes_value(true)
+ .help("Name of the bin target to run"),
+ )
+ .arg(
+ Arg::with_name("test")
+ .long("test")
+ .takes_value(true)
+ .help("Build only the specified test target"),
+ )
+ .arg(Arg::with_name("tests").long("tests").help("Build all the tests"))
+ .arg(
+ Arg::with_name("example")
+ .long("example")
+ .takes_value(true)
+ .help("Build a specific example from the examples/ dir."),
+ )
+ .arg(
+ Arg::with_name("examples")
+ .long("examples")
+ .help("Build all examples in the examples/ dir."),
+ ),
+ )
+ .subcommand(
+ SubCommand::with_name(CHECK)
+ .about("Check binary targeting Fuchsia device or emulator")
+ .arg(Arg::with_name(RELEASE).long(RELEASE).help(RELEASE_HELP))
+ .arg(
+ Arg::with_name("package")
+ .short("p")
+ .long("package")
+ .takes_value(true)
+ .help("Package to build"),
+ )
+ .arg(
+ Arg::with_name("bin")
+ .long("bin")
+ .takes_value(true)
+ .help("Name of the bin target to run"),
+ )
+ .arg(
+ Arg::with_name("test")
+ .long("test")
+ .takes_value(true)
+ .help("Build only the specified test target"),
+ )
+ .arg(Arg::with_name("tests").long("tests").help("Build all the tests"))
+ .arg(
+ Arg::with_name(EXAMPLE)
+ .long(EXAMPLE)
+ .takes_value(true)
+ .help("Check a specific example from the examples/ dir."),
+ )
+ .arg(
+ Arg::with_name(EXAMPLES)
+ .long(EXAMPLES)
+ .help("Check all examples in the examples/ dir."),
+ ),
+ )
+ .subcommand(
+ SubCommand::with_name(DOC)
+ .about("Build a package's documentation")
+ .arg(Arg::with_name(RELEASE).long(RELEASE).help(RELEASE_HELP))
+ .arg(
+ Arg::with_name(DOC_NO_DEPS)
+ .long(DOC_NO_DEPS)
+ .help("Don't build documentation for dependencies"),
+ )
+ .arg(
+ Arg::with_name(DOC_OPEN)
+ .long(DOC_OPEN)
+ .help("Opens the docs in a browser after the operation"),
+ ),
+ )
+ .subcommand(
+ SubCommand::with_name(RUN)
+ .about("Run binary on Fuchsia device or emulator")
+ .arg(Arg::with_name(RELEASE).long(RELEASE).help(RELEASE_HELP))
+ .arg(
+ Arg::with_name(STORY_NAME)
+ .long(STORY_NAME)
+ .short("n")
+ .value_name(STORY_NAME)
+ .help("Name of story to pass to sessionctl"),
+ )
+ .arg(
+ Arg::with_name(MOD_NAME)
+ .long(MOD_NAME)
+ .short("m")
+ .value_name(MOD_NAME)
+ .help("Name of mod to pass to sessionctl"),
+ )
+ .arg(
+ Arg::with_name(RUN_WITH_TILES)
+ .long(RUN_WITH_TILES)
+ .help("Use tiles_ctl add to run binary."),
+ )
+ .arg(Arg::with_name(RUN_WITH_RUN).long(RUN_WITH_RUN).help("Use run to run binary."))
+ .arg(
+ Arg::with_name(RUN_WITH_SESSIONCTL)
+ .long(RUN_WITH_SESSIONCTL)
+ .help("Use sessionctl to run binary."),
+ )
+ .arg(
+ Arg::with_name("package")
+ .short("p")
+ .long("package")
+ .value_name("package")
+ .help("Package to build"),
+ )
+ .arg(
+ Arg::with_name("bin")
+ .long("bin")
+ .value_name("bin")
+ .help("Name of the bin target to run"),
+ )
+ .arg(
+ Arg::with_name("example")
+ .long("example")
+ .value_name("example")
+ .help("Run a specific example from the examples/ dir."),
+ ),
+ )
+ .subcommand(
+ SubCommand::with_name("load-driver")
+ .about("Build driver and load it on Fuchsia device or emulator.")
+ .arg(Arg::with_name(RELEASE).long(RELEASE).help("Build release")),
+ )
+ .subcommand(SubCommand::with_name("list-devices").about("List visible Fuchsia devices"))
+ .subcommand(
+ SubCommand::with_name(START)
+ .about("Start a Fuchsia emulator")
+ .arg(
+ Arg::with_name(GRAPHICS)
+ .short("g")
+ .help("Start a simulator with graphics enabled"),
+ )
+ .arg(
+ Arg::with_name(DISABLE_VIRTCON).long(DISABLE_VIRTCON).help(
"Do not launch the virtual console service if this option is present",
- ))
- .arg(
- Arg::with_name(NO_NET)
- .long(NO_NET)
- .help("Don't set up networking."),
- )
- .arg(Arg::with_name(FX_RUN_PARAMS).index(1).multiple(true)),
- )
- .subcommand(SubCommand::with_name("stop").about("Stop all Fuchsia emulators"))
- .subcommand(
- SubCommand::with_name("enable-networking")
- .about("Enable networking for a running emulator"),
- )
- .subcommand(
- SubCommand::with_name(RESTART)
- .about("Stop all Fuchsia emulators and start a new one")
- .arg(
- Arg::with_name(GRAPHICS)
- .short("g")
- .help("Start a simulator with graphics enabled"),
- )
- .arg(Arg::with_name(DISABLE_VIRTCON).long(DISABLE_VIRTCON).help(
- "Do not launch the virtual console service if this option is present",
- ))
- .arg(
- Arg::with_name(NO_NET)
- .long(NO_NET)
- .help("Don't set up networking."),
- )
- .arg(Arg::with_name(FX_RUN_PARAMS).index(1).multiple(true)),
- )
- .subcommand(
- SubCommand::with_name("ssh").about("Open a shell on Fuchsia device or emulator"),
- )
- .subcommand(
- SubCommand::with_name("cargo")
- .about(
- "Run a cargo command for Fuchsia. Use -- to indicate that all following \
- arguments should be passed to cargo.",
- )
- .arg(Arg::with_name(SUBCOMMAND).required(true))
- .arg(Arg::with_name("cargo_params").index(2).multiple(true)),
- )
- .subcommand(
- SubCommand::with_name(RUN_ON_TARGET)
- .about("Act as a test runner for cargo")
- .arg(
- Arg::with_name("test_args")
- .long("args")
- .value_name("args")
- .help("arguments to pass to the test runner"),
- )
- .arg(
- Arg::with_name(NOCAPTURE)
- .long(NOCAPTURE)
- .help("Display all output when running tests."),
- )
- .arg(
- Arg::with_name(RUN_WITH_TILES)
- .long(RUN_WITH_TILES)
- .help("Use tiles to run binary."),
- )
- .arg(
- Arg::with_name(RUN_WITH_RUN)
- .long(RUN_WITH_RUN)
- .help("Use run to run binary."),
- )
- .arg(
- Arg::with_name(RUN_WITH_SESSIONCTL)
- .long(RUN_WITH_SESSIONCTL)
- .help("Use sessionctl to run binary."),
- )
- .arg(
- Arg::with_name(STORY_NAME)
- .long(STORY_NAME)
- .short("n")
- .value_name(STORY_NAME)
- .help("Name of story to pass to sessionctl"),
- )
- .arg(
- Arg::with_name(MOD_NAME)
- .long(MOD_NAME)
- .short("m")
- .value_name(MOD_NAME)
- .help("Name of mod to pass to sessionctl"),
- )
- .arg(
- Arg::with_name("run_on_target_params")
- .index(1)
- .multiple(true),
- )
- .setting(AppSettings::Hidden),
- )
- .subcommand(
- SubCommand::with_name("pkg-config")
- .about("Run pkg-config for the cross compilation environment")
- .arg(Arg::with_name("pkgconfig_param").index(1).multiple(true)),
- )
- .subcommand(
- SubCommand::with_name("configure")
- .about("Run a configure script for the cross compilation environment")
- .arg(Arg::with_name("configure_param").index(1).multiple(true))
- .arg(
- Arg::with_name("no-host")
- .long("no-host")
- .help("Don't pass --host to configure"),
),
- )
- .subcommand(SubCommand::with_name(WRITE_CONFIG).about(
+ )
+ .arg(Arg::with_name(NO_NET).long(NO_NET).help("Don't set up networking."))
+ .arg(Arg::with_name(FX_RUN_PARAMS).index(1).multiple(true)),
+ )
+ .subcommand(SubCommand::with_name("stop").about("Stop all Fuchsia emulators"))
+ .subcommand(
+ SubCommand::with_name("enable-networking")
+ .about("Enable networking for a running emulator"),
+ )
+ .subcommand(
+ SubCommand::with_name(RESTART)
+ .about("Stop all Fuchsia emulators and start a new one")
+ .arg(
+ Arg::with_name(GRAPHICS)
+ .short("g")
+ .help("Start a simulator with graphics enabled"),
+ )
+ .arg(
+ Arg::with_name(DISABLE_VIRTCON).long(DISABLE_VIRTCON).help(
+ "Do not launch the virtual console service if this option is present",
+ ),
+ )
+ .arg(Arg::with_name(NO_NET).long(NO_NET).help("Don't set up networking."))
+ .arg(Arg::with_name(FX_RUN_PARAMS).index(1).multiple(true)),
+ )
+ .subcommand(
+ SubCommand::with_name("ssh").about("Open a shell on Fuchsia device or emulator"),
+ )
+ .subcommand(
+ SubCommand::with_name("cargo")
+ .about(
+ "Run a cargo command for Fuchsia. Use -- to indicate that all following \
+ arguments should be passed to cargo.",
+ )
+ .arg(Arg::with_name(SUBCOMMAND).required(true))
+ .arg(Arg::with_name("cargo_params").index(2).multiple(true)),
+ )
+ .subcommand(
+ SubCommand::with_name(RUN_ON_TARGET)
+ .about("Act as a test runner for cargo")
+ .arg(
+ Arg::with_name("test_args")
+ .long("args")
+ .value_name("args")
+ .help("arguments to pass to the test runner"),
+ )
+ .arg(
+ Arg::with_name(NOCAPTURE)
+ .long(NOCAPTURE)
+ .help("Display all output when running tests."),
+ )
+ .arg(
+ Arg::with_name(RUN_WITH_TILES)
+ .long(RUN_WITH_TILES)
+ .help("Use tiles to run binary."),
+ )
+ .arg(Arg::with_name(RUN_WITH_RUN).long(RUN_WITH_RUN).help("Use run to run binary."))
+ .arg(
+ Arg::with_name(RUN_WITH_SESSIONCTL)
+ .long(RUN_WITH_SESSIONCTL)
+ .help("Use sessionctl to run binary."),
+ )
+ .arg(
+ Arg::with_name(STORY_NAME)
+ .long(STORY_NAME)
+ .short("n")
+ .value_name(STORY_NAME)
+ .help("Name of story to pass to sessionctl"),
+ )
+ .arg(
+ Arg::with_name(MOD_NAME)
+ .long(MOD_NAME)
+ .short("m")
+ .value_name(MOD_NAME)
+ .help("Name of mod to pass to sessionctl"),
+ )
+ .arg(Arg::with_name("run_on_target_params").index(1).multiple(true))
+ .setting(AppSettings::Hidden),
+ )
+ .subcommand(
+ SubCommand::with_name("pkg-config")
+ .about("Run pkg-config for the cross compilation environment")
+ .arg(Arg::with_name("pkgconfig_param").index(1).multiple(true)),
+ )
+ .subcommand(
+ SubCommand::with_name("configure")
+ .about("Run a configure script for the cross compilation environment")
+ .arg(Arg::with_name("configure_param").index(1).multiple(true))
+ .arg(
+ Arg::with_name("no-host")
+ .long("no-host")
+ .help("Don't pass --host to configure"),
+ ),
+ )
+ .subcommand(
+ SubCommand::with_name(WRITE_CONFIG).about(
"Write a .cargo/config file to allow cargo to operate correctly for Fuchsia",
- ))
- .subcommand(
- SubCommand::with_name(BUILD_RUSTC)
- .arg(
- Arg::with_name(RUST_ROOT)
- .long(RUST_ROOT)
- .value_name(RUST_ROOT)
- .required(true)
- .help("Path to rust checkout"),
- )
- .about("Build rustc targeting Fuchsia"),
- )
- .get_matches();
+ ),
+ )
+ .subcommand(
+ SubCommand::with_name(BUILD_RUSTC)
+ .arg(
+ Arg::with_name(RUST_ROOT)
+ .long(RUST_ROOT)
+ .value_name(RUST_ROOT)
+ .required(true)
+ .help("Path to rust checkout"),
+ )
+ .about("Build rustc targeting Fuchsia"),
+ )
+ .get_matches();
let verbose = matches.is_present("verbose");
let disable_cross = matches.is_present(DISABLE_CROSS_ENV);
@@ -1333,10 +1269,8 @@
}
if let Some(start_matches) = matches.subcommand_matches(START) {
- let fx_run_params = start_matches
- .values_of(FX_RUN_PARAMS)
- .map(|x| x.collect())
- .unwrap_or_else(|| vec![]);
+ let fx_run_params =
+ start_matches.values_of(FX_RUN_PARAMS).map(|x| x.collect()).unwrap_or_else(|| vec![]);
return start_emulator(
&StartEmulatorOptions {
@@ -1360,10 +1294,8 @@
if let Some(restart_matches) = matches.subcommand_matches(RESTART) {
stop_emulator()?;
- let fx_run_params = restart_matches
- .values_of(FX_RUN_PARAMS)
- .map(|x| x.collect())
- .unwrap_or_else(|| vec![]);
+ let fx_run_params =
+ restart_matches.values_of(FX_RUN_PARAMS).map(|x| x.collect()).unwrap_or_else(|| vec![]);
return start_emulator(
&StartEmulatorOptions {
@@ -1382,10 +1314,8 @@
if let Some(cargo_matches) = matches.subcommand_matches("cargo") {
let subcommand = cargo_matches.value_of(SUBCOMMAND).unwrap();
- let cargo_params = cargo_matches
- .values_of("cargo_params")
- .map(|x| x.collect())
- .unwrap_or_else(|| vec![]);
+ let cargo_params =
+ cargo_matches.values_of("cargo_params").map(|x| x.collect()).unwrap_or_else(|| vec![]);
return run_cargo(
&RunCargoOptions {
verbose,
@@ -1424,22 +1354,16 @@
&fuchsia_config,
&target_options,
run_mode,
- run_on_target_matches
- .value_of(STORY_NAME)
- .unwrap_or(&random_story_name()),
- run_on_target_matches
- .value_of(MOD_NAME)
- .unwrap_or(DEFAULT_MOD_NAME),
+ run_on_target_matches.value_of(STORY_NAME).unwrap_or(&random_story_name()),
+ run_on_target_matches.value_of(MOD_NAME).unwrap_or(DEFAULT_MOD_NAME),
args,
test_args,
);
}
if let Some(pkg_matches) = matches.subcommand_matches("pkg-config") {
- let pkg_params = pkg_matches
- .values_of("pkgconfig_param")
- .map(|x| x.collect())
- .unwrap_or_else(|| vec![]);
+ let pkg_params =
+ pkg_matches.values_of("pkgconfig_param").map(|x| x.collect()).unwrap_or_else(|| vec![]);
let exit_code = run_pkg_config(verbose, &pkg_params, &target_options)?;
if exit_code != 0 {
::std::process::exit(exit_code);
diff --git a/src/sdk.rs b/src/sdk.rs
index a608eb9..172071f 100644
--- a/src/sdk.rs
+++ b/src/sdk.rs
@@ -33,10 +33,7 @@
/// ```
pub fn new(config: &'a FuchsiaConfig, device_name: Option<&'b str>) -> TargetOptions<'a, 'b> {
- TargetOptions {
- device_name: device_name,
- config: config,
- }
+ TargetOptions { device_name: device_name, config: config }
}
}
@@ -44,11 +41,7 @@
if let Ok(file_value) = env::var(env_name) {
let file_path = PathBuf::from(&file_value);
if !file_path.exists() {
- bail!(
- "{} is set to '{}' but nothing exists at that path.",
- env_name,
- &file_value
- );
+ bail!("{} is set to '{}' but nothing exists at that path.", env_name, &file_value);
}
if require_dir {
if !file_path.is_dir() {
@@ -108,11 +101,7 @@
pub fn cargo_out_dir(options: &TargetOptions<'_, '_>) -> Result<PathBuf, Error> {
let fuchsia_dir = fuchsia_dir()?;
let target_triple = get_target_triple(options);
- Ok(fuchsia_dir
- .join("garnet")
- .join("target")
- .join(target_triple)
- .join("debug"))
+ Ok(fuchsia_dir.join("garnet").join("target").join(target_triple).join("debug"))
}
pub fn strip_tool_path() -> Result<PathBuf, Error> {
@@ -131,24 +120,14 @@
pub fn zircon_build_path(options: &TargetOptions<'_, '_>) -> Result<PathBuf, Error> {
let fuchsia_dir = fuchsia_dir()?;
- let build_name = if options.config.fuchsia_arch == X64 {
- "build-x64"
- } else {
- "build-arm64"
- };
- let zircon_build = fuchsia_dir
- .join("out")
- .join("build-zircon")
- .join(build_name);
+ let build_name = if options.config.fuchsia_arch == X64 { "build-x64" } else { "build-arm64" };
+ let zircon_build = fuchsia_dir.join("out").join("build-zircon").join(build_name);
Ok(zircon_build)
}
pub fn shared_libraries_path(options: &TargetOptions<'_, '_>) -> Result<PathBuf, Error> {
- let shared_name = if options.config.fuchsia_arch == X64 {
- "x64-shared"
- } else {
- "arm64-shared"
- };
+ let shared_name =
+ if options.config.fuchsia_arch == X64 { "x64-shared" } else { "arm64-shared" };
Ok(target_out_dir(&options.config)?.join(shared_name))
}
@@ -211,10 +190,7 @@
.context("Running `clang` to get resource dir")?;
if !output.status.success() {
- bail!(
- "Failed to get `clang` resource dir: {}",
- String::from_utf8_lossy(&output.stderr)
- );
+ bail!("Failed to get `clang` resource dir: {}", String::from_utf8_lossy(&output.stderr));
}
let path_string =
@@ -242,15 +218,11 @@
bail!("fx script not found at {:?}", fx_script);
}
let args = vec!["exec", "printenv"];
- let fx_exec_result = Command::new(fx_script)
- .args(args)
- .current_dir(&fuchsia_dir)
- .output()?;
+ let fx_exec_result =
+ Command::new(fx_script).args(args).current_dir(&fuchsia_dir).output()?;
let result = str::from_utf8(&fx_exec_result.stdout)?.trim().to_string();
- let mut config = FuchsiaConfig {
- fuchsia_build_dir: String::from(""),
- fuchsia_arch: String::from(""),
- };
+ let mut config =
+ FuchsiaConfig { fuchsia_build_dir: String::from(""), fuchsia_arch: String::from("") };
for one_line in result.lines() {
let parts: Vec<&str> = one_line.split("=").collect();
const QUOTE: char = '\'';