From f8ee283af3b482fe7ec89d005f6469ee7c4d5ce3 Mon Sep 17 00:00:00 2001 From: Matthew Camp Date: Wed, 13 Jul 2016 15:38:22 +0700 Subject: [PATCH] Add jobs flag to package --- src/bin/package.rs | 4 +++- src/bin/publish.rs | 4 ++++ src/cargo/ops/cargo_package.rs | 7 ++++--- src/cargo/ops/registry.rs | 2 ++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/bin/package.rs b/src/bin/package.rs index dda718373db..4a454085409 100644 --- a/src/bin/package.rs +++ b/src/bin/package.rs @@ -13,6 +13,7 @@ pub struct Options { flag_no_metadata: bool, flag_list: bool, flag_allow_dirty: bool, + flag_jobs: Option, } pub const USAGE: &'static str = " @@ -28,10 +29,10 @@ Options: --no-metadata Ignore warnings about a lack of human-usable metadata --allow-dirty Allow dirty working directories to be packaged --manifest-path PATH Path to the manifest to compile + -j N, --jobs N Number of parallel jobs, defaults to # of CPUs -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never - "; pub fn execute(options: Options, config: &Config) -> CliResult> { @@ -46,6 +47,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { list: options.flag_list, check_metadata: !options.flag_no_metadata, allow_dirty: options.flag_allow_dirty, + jobs: options.flag_jobs, })); Ok(None) } diff --git a/src/bin/publish.rs b/src/bin/publish.rs index 13006686883..97aa2e13764 100644 --- a/src/bin/publish.rs +++ b/src/bin/publish.rs @@ -13,6 +13,7 @@ pub struct Options { flag_color: Option, flag_no_verify: bool, flag_allow_dirty: bool, + flag_jobs: Option, } pub const USAGE: &'static str = " @@ -28,6 +29,7 @@ Options: --no-verify Don't verify package tarball before publish --allow-dirty Allow publishing with a dirty source directory --manifest-path PATH Path to the manifest of the package to publish + -j N, --jobs N Number of parallel jobs, defaults to # of CPUs -v, --verbose ... Use verbose output -q, --quiet No output printed to stdout --color WHEN Coloring: auto, always, never @@ -44,6 +46,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { flag_manifest_path, flag_no_verify: no_verify, flag_allow_dirty: allow_dirty, + flag_jobs: jobs, .. } = options; @@ -55,6 +58,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult> { index: host, verify: !no_verify, allow_dirty: allow_dirty, + jobs: jobs, })); Ok(None) } diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index 461068fb407..c22f44cd6ee 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -19,6 +19,7 @@ pub struct PackageOpts<'cfg> { pub check_metadata: bool, pub allow_dirty: bool, pub verify: bool, + pub jobs: Option, } pub fn package(ws: &Workspace, @@ -68,7 +69,7 @@ pub fn package(ws: &Workspace, })); if opts.verify { try!(dst.seek(SeekFrom::Start(0))); - try!(run_verify(ws, dst.file()).chain_error(|| { + try!(run_verify(ws, dst.file(), opts).chain_error(|| { human("failed to verify package tarball") })) } @@ -228,7 +229,7 @@ fn tar(ws: &Workspace, Ok(()) } -fn run_verify(ws: &Workspace, tar: &File) -> CargoResult<()> { +fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()> { let config = ws.config(); let pkg = try!(ws.current()); @@ -268,7 +269,7 @@ fn run_verify(ws: &Workspace, tar: &File) -> CargoResult<()> { let ws = Workspace::one(new_pkg, config); try!(ops::compile_ws(&ws, None, &ops::CompileOptions { config: config, - jobs: None, + jobs: opts.jobs, target: None, features: &[], no_default_features: false, diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index a076f01d4d1..cda3d9abec9 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -35,6 +35,7 @@ pub struct PublishOpts<'cfg> { pub index: Option, pub verify: bool, pub allow_dirty: bool, + pub jobs: Option, } pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> { @@ -58,6 +59,7 @@ pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> { list: false, check_metadata: true, allow_dirty: opts.allow_dirty, + jobs: opts.jobs, })).unwrap(); // Upload said tarball to the specified destination