Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jobs flag to package #2867

Merged
merged 1 commit into from
Jul 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/bin/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct Options {
flag_no_metadata: bool,
flag_list: bool,
flag_allow_dirty: bool,
flag_jobs: Option<u32>,
}

pub const USAGE: &'static str = "
Expand All @@ -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<Option<()>> {
Expand All @@ -46,6 +47,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
list: options.flag_list,
check_metadata: !options.flag_no_metadata,
allow_dirty: options.flag_allow_dirty,
jobs: options.flag_jobs,
}));
Ok(None)
}
4 changes: 4 additions & 0 deletions src/bin/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub struct Options {
flag_color: Option<String>,
flag_no_verify: bool,
flag_allow_dirty: bool,
flag_jobs: Option<u32>,
}

pub const USAGE: &'static str = "
Expand All @@ -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
Expand All @@ -44,6 +46,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
flag_manifest_path,
flag_no_verify: no_verify,
flag_allow_dirty: allow_dirty,
flag_jobs: jobs,
..
} = options;

Expand All @@ -55,6 +58,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
index: host,
verify: !no_verify,
allow_dirty: allow_dirty,
jobs: jobs,
}));
Ok(None)
}
7 changes: 4 additions & 3 deletions src/cargo/ops/cargo_package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct PackageOpts<'cfg> {
pub check_metadata: bool,
pub allow_dirty: bool,
pub verify: bool,
pub jobs: Option<u32>,
}

pub fn package(ws: &Workspace,
Expand Down Expand Up @@ -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")
}))
}
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions src/cargo/ops/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct PublishOpts<'cfg> {
pub index: Option<String>,
pub verify: bool,
pub allow_dirty: bool,
pub jobs: Option<u32>,
}

pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {
Expand All @@ -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
Expand Down