Skip to content

Commit 1cd19a2

Browse files
authored
Auto merge of #2867 - mattscamp:add_jobs_flag, r=alexcrichton
Add jobs flag to package #2860
2 parents c20e060 + f8ee283 commit 1cd19a2

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

src/bin/package.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct Options {
1313
flag_no_metadata: bool,
1414
flag_list: bool,
1515
flag_allow_dirty: bool,
16+
flag_jobs: Option<u32>,
1617
}
1718

1819
pub const USAGE: &'static str = "
@@ -28,10 +29,10 @@ Options:
2829
--no-metadata Ignore warnings about a lack of human-usable metadata
2930
--allow-dirty Allow dirty working directories to be packaged
3031
--manifest-path PATH Path to the manifest to compile
32+
-j N, --jobs N Number of parallel jobs, defaults to # of CPUs
3133
-v, --verbose ... Use verbose output
3234
-q, --quiet No output printed to stdout
3335
--color WHEN Coloring: auto, always, never
34-
3536
";
3637

3738
pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
@@ -46,6 +47,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
4647
list: options.flag_list,
4748
check_metadata: !options.flag_no_metadata,
4849
allow_dirty: options.flag_allow_dirty,
50+
jobs: options.flag_jobs,
4951
}));
5052
Ok(None)
5153
}

src/bin/publish.rs

+4
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct Options {
1313
flag_color: Option<String>,
1414
flag_no_verify: bool,
1515
flag_allow_dirty: bool,
16+
flag_jobs: Option<u32>,
1617
}
1718

1819
pub const USAGE: &'static str = "
@@ -28,6 +29,7 @@ Options:
2829
--no-verify Don't verify package tarball before publish
2930
--allow-dirty Allow publishing with a dirty source directory
3031
--manifest-path PATH Path to the manifest of the package to publish
32+
-j N, --jobs N Number of parallel jobs, defaults to # of CPUs
3133
-v, --verbose ... Use verbose output
3234
-q, --quiet No output printed to stdout
3335
--color WHEN Coloring: auto, always, never
@@ -44,6 +46,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
4446
flag_manifest_path,
4547
flag_no_verify: no_verify,
4648
flag_allow_dirty: allow_dirty,
49+
flag_jobs: jobs,
4750
..
4851
} = options;
4952

@@ -55,6 +58,7 @@ pub fn execute(options: Options, config: &Config) -> CliResult<Option<()>> {
5558
index: host,
5659
verify: !no_verify,
5760
allow_dirty: allow_dirty,
61+
jobs: jobs,
5862
}));
5963
Ok(None)
6064
}

src/cargo/ops/cargo_package.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub struct PackageOpts<'cfg> {
1919
pub check_metadata: bool,
2020
pub allow_dirty: bool,
2121
pub verify: bool,
22+
pub jobs: Option<u32>,
2223
}
2324

2425
pub fn package(ws: &Workspace,
@@ -68,7 +69,7 @@ pub fn package(ws: &Workspace,
6869
}));
6970
if opts.verify {
7071
try!(dst.seek(SeekFrom::Start(0)));
71-
try!(run_verify(ws, dst.file()).chain_error(|| {
72+
try!(run_verify(ws, dst.file(), opts).chain_error(|| {
7273
human("failed to verify package tarball")
7374
}))
7475
}
@@ -228,7 +229,7 @@ fn tar(ws: &Workspace,
228229
Ok(())
229230
}
230231

231-
fn run_verify(ws: &Workspace, tar: &File) -> CargoResult<()> {
232+
fn run_verify(ws: &Workspace, tar: &File, opts: &PackageOpts) -> CargoResult<()> {
232233
let config = ws.config();
233234
let pkg = try!(ws.current());
234235

@@ -268,7 +269,7 @@ fn run_verify(ws: &Workspace, tar: &File) -> CargoResult<()> {
268269
let ws = Workspace::one(new_pkg, config);
269270
try!(ops::compile_ws(&ws, None, &ops::CompileOptions {
270271
config: config,
271-
jobs: None,
272+
jobs: opts.jobs,
272273
target: None,
273274
features: &[],
274275
no_default_features: false,

src/cargo/ops/registry.rs

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ pub struct PublishOpts<'cfg> {
3535
pub index: Option<String>,
3636
pub verify: bool,
3737
pub allow_dirty: bool,
38+
pub jobs: Option<u32>,
3839
}
3940

4041
pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {
@@ -58,6 +59,7 @@ pub fn publish(ws: &Workspace, opts: &PublishOpts) -> CargoResult<()> {
5859
list: false,
5960
check_metadata: true,
6061
allow_dirty: opts.allow_dirty,
62+
jobs: opts.jobs,
6163
})).unwrap();
6264

6365
// Upload said tarball to the specified destination

0 commit comments

Comments
 (0)