forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes: aptos-labs#1568 Approved by: metajack
- Loading branch information
1 parent
85df5c7
commit e818d9c
Showing
5 changed files
with
120 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
[alias] | ||
x = "run --package x --bin x --" | ||
xcheck = "run --package x --bin x -- check" | ||
xtest = "run --package x --bin x -- test" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
use crate::{ | ||
cargo::{CargoArgs, CargoCommand}, | ||
config::Config, | ||
utils, Result, | ||
}; | ||
use structopt::StructOpt; | ||
|
||
#[derive(Debug, StructOpt)] | ||
pub struct Args { | ||
#[structopt(long, short, number_of_values = 1)] | ||
/// Run check on the provided packages | ||
package: Vec<String>, | ||
#[structopt(long)] | ||
/// Run check on all packages in the workspace | ||
workspace: bool, | ||
#[structopt(long)] | ||
/// Run check on all targets of a package (lib, bin, test, example) | ||
all_targets: bool, | ||
} | ||
|
||
pub fn run(args: Args, config: Config) -> Result<()> { | ||
let cmd = CargoCommand::Check; | ||
// If we've been asked to build all targets then we need to enable all_features so that | ||
// building the testing targets works | ||
let base_args = CargoArgs { | ||
all_features: args.all_targets, | ||
all_targets: args.all_targets, | ||
}; | ||
|
||
if !args.package.is_empty() { | ||
let run_together = args.package.iter().filter(|p| !config.is_exception(p)); | ||
let run_separate = args.package.iter().filter_map(|p| { | ||
config.package_exceptions().get(p).map(|e| { | ||
( | ||
p, | ||
CargoArgs { | ||
all_features: if args.all_targets { | ||
e.all_features | ||
} else { | ||
false | ||
}, | ||
..base_args | ||
}, | ||
) | ||
}) | ||
}); | ||
cmd.run_on_packages_together(run_together, &base_args)?; | ||
cmd.run_on_packages_separate(run_separate)?; | ||
} else if utils::project_is_root()? || args.workspace { | ||
cmd.run_with_exclusions( | ||
config.package_exceptions().iter().map(|(p, _)| p), | ||
&base_args, | ||
)?; | ||
cmd.run_on_packages_separate(config.package_exceptions().iter().map(|(name, pkg)| { | ||
( | ||
name, | ||
CargoArgs { | ||
all_features: if args.all_targets { | ||
pkg.all_features | ||
} else { | ||
false | ||
}, | ||
..base_args | ||
}, | ||
) | ||
}))?; | ||
} else { | ||
let package = utils::get_local_package()?; | ||
let cargo_args = if args.all_targets { | ||
let all_features = config | ||
.package_exceptions() | ||
.get(&package) | ||
.map(|pkg| pkg.all_features) | ||
.unwrap_or(true); | ||
CargoArgs { | ||
all_features, | ||
..base_args | ||
} | ||
} else { | ||
base_args | ||
}; | ||
|
||
cmd.run_on_local_package(&cargo_args)?; | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters