|
|
@ -1,31 +1,36 @@
|
|
|
|
use crate::internal::structs::{ErroredPackage, Repo};
|
|
|
|
|
|
|
|
use crate::internal::AppExitCode;
|
|
|
|
|
|
|
|
use crate::{crash, info, log, repository, workspace};
|
|
|
|
use crate::{crash, info, log, repository, workspace};
|
|
|
|
|
|
|
|
use crate::internal::AppExitCode;
|
|
|
|
|
|
|
|
use crate::internal::structs::{ErroredPackage, Repo};
|
|
|
|
|
|
|
|
|
|
|
|
pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
|
|
|
|
pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool, verbose: bool) {
|
|
|
|
// Read config struct from mlc.toml
|
|
|
|
// Read config struct from mlc.toml
|
|
|
|
let config = workspace::read_cfg();
|
|
|
|
let config = workspace::read_cfg(verbose);
|
|
|
|
log!("Config: {:?}", config);
|
|
|
|
log!(verbose, "Config: {:?}", config);
|
|
|
|
let all = packages.is_empty();
|
|
|
|
let all = packages.is_empty();
|
|
|
|
log!("All: {:?}", all);
|
|
|
|
log!(verbose, "All: {:?}", all);
|
|
|
|
log!("Signing: {:?}", config.sign);
|
|
|
|
log!(verbose, "Signing: {:?}", config.sign);
|
|
|
|
|
|
|
|
|
|
|
|
// Get list of repos and subtract exclude
|
|
|
|
// Get list of repos and subtract exclude
|
|
|
|
let mut repos: Vec<Repo> = config.repo;
|
|
|
|
let mut repos: Vec<Repo> = config.repo;
|
|
|
|
log!("{} Repos: {:?}", repos.len(), repos );
|
|
|
|
log!(verbose, "{} Repos: {:?}", repos.len(), repos);
|
|
|
|
if !exclude.is_empty() {
|
|
|
|
if !exclude.is_empty() {
|
|
|
|
log!("Exclude not empty: {:?}", exclude);
|
|
|
|
log!(verbose, "Exclude not empty: {:?}", exclude);
|
|
|
|
for ex in exclude {
|
|
|
|
for ex in exclude {
|
|
|
|
repos.retain(|x| *x.name != ex);
|
|
|
|
repos.retain(|x| *x.name != ex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
log!("Exclusions parsed. Now {} Repos: {:?}", repos.len(), repos);
|
|
|
|
log!(
|
|
|
|
|
|
|
|
verbose,
|
|
|
|
|
|
|
|
"Exclusions parsed. Now {} Repos: {:?}",
|
|
|
|
|
|
|
|
repos.len(),
|
|
|
|
|
|
|
|
repos
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// If packages is not empty and all isn't specified, build specified packages
|
|
|
|
// If packages is not empty and all isn't specified, build specified packages
|
|
|
|
let mut errored: Vec<ErroredPackage> = vec![];
|
|
|
|
let mut errored: Vec<ErroredPackage> = vec![];
|
|
|
|
if !packages.is_empty() && !all {
|
|
|
|
if !packages.is_empty() && !all {
|
|
|
|
log!("Packages not empty: {:?}", packages);
|
|
|
|
log!(verbose, "Packages not empty: {:?}", packages);
|
|
|
|
for pkg in &packages {
|
|
|
|
for pkg in &packages {
|
|
|
|
// If repo is not in config, crash
|
|
|
|
// If repo is not in config, crash
|
|
|
|
if !repos.iter().map(|x| x.name.clone()).any(|x| x == *pkg) {
|
|
|
|
if !repos.iter().map(|x| x.name.clone()).any(|x| x == *pkg) {
|
|
|
@ -36,9 +41,14 @@ pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Otherwise, build
|
|
|
|
// Otherwise, build
|
|
|
|
log!("Building {}", pkg);
|
|
|
|
log!(verbose, "Building {}", pkg);
|
|
|
|
let code = repository::build(pkg, config.sign);
|
|
|
|
let code = repository::build(pkg, config.sign, verbose);
|
|
|
|
log!("Package {} finished with exit code: {:?}", pkg, code);
|
|
|
|
log!(
|
|
|
|
|
|
|
|
verbose,
|
|
|
|
|
|
|
|
"Package {} finished with exit code: {:?}",
|
|
|
|
|
|
|
|
pkg,
|
|
|
|
|
|
|
|
code
|
|
|
|
|
|
|
|
);
|
|
|
|
if code != 0 {
|
|
|
|
if code != 0 {
|
|
|
|
let error = ErroredPackage {
|
|
|
|
let error = ErroredPackage {
|
|
|
|
name: pkg.to_string(),
|
|
|
|
name: pkg.to_string(),
|
|
|
@ -52,16 +62,21 @@ pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
|
|
|
|
|
|
|
|
|
|
|
|
// If all is specified, attempt to build a package from all repos
|
|
|
|
// If all is specified, attempt to build a package from all repos
|
|
|
|
if all {
|
|
|
|
if all {
|
|
|
|
log!("Proceeding to build all");
|
|
|
|
log!(verbose, "Proceeding to build all");
|
|
|
|
|
|
|
|
|
|
|
|
// Sort by package priority
|
|
|
|
// Sort by package priority
|
|
|
|
log!("Sorting by priority: {:?}", repos);
|
|
|
|
log!(verbose, "Sorting by priority: {:?}", repos);
|
|
|
|
repos.sort_by(|a, b| b.priority.cmp(&a.priority));
|
|
|
|
repos.sort_by(|a, b| b.priority.cmp(&a.priority));
|
|
|
|
log!("Sorted: {:?}", repos);
|
|
|
|
log!(verbose, "Sorted: {:?}", repos);
|
|
|
|
for pkg in repos {
|
|
|
|
for pkg in repos {
|
|
|
|
log!("Building {}", pkg.name);
|
|
|
|
log!(verbose, "Building {}", pkg.name);
|
|
|
|
let code = repository::build(&pkg.name, config.sign);
|
|
|
|
let code = repository::build(&pkg.name, config.sign, verbose);
|
|
|
|
log!("Package {} finished with exit code: {:?}", pkg.name, code);
|
|
|
|
log!(
|
|
|
|
|
|
|
|
verbose,
|
|
|
|
|
|
|
|
"Package {} finished with exit code: {:?}",
|
|
|
|
|
|
|
|
pkg.name,
|
|
|
|
|
|
|
|
code
|
|
|
|
|
|
|
|
);
|
|
|
|
if code != 0 {
|
|
|
|
if code != 0 {
|
|
|
|
let error = ErroredPackage {
|
|
|
|
let error = ErroredPackage {
|
|
|
|
name: pkg.name,
|
|
|
|
name: pkg.name,
|
|
|
@ -74,14 +89,14 @@ pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
|
|
|
|
|
|
|
|
|
|
|
|
// If all is not specified, but packages is empty, crash
|
|
|
|
// If all is not specified, but packages is empty, crash
|
|
|
|
if !all && packages.is_empty() {
|
|
|
|
if !all && packages.is_empty() {
|
|
|
|
log!("Packages empty. Crashing");
|
|
|
|
log!(verbose, "Packages empty. Crashing");
|
|
|
|
crash!(AppExitCode::NoPkgs, "No packages specified");
|
|
|
|
crash!(AppExitCode::NoPkgs, "No packages specified");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If no_regen is passed, do not generate a repository
|
|
|
|
// If no_regen is passed, do not generate a repository
|
|
|
|
if !no_regen {
|
|
|
|
if !no_regen {
|
|
|
|
log!("Generating repository");
|
|
|
|
log!(verbose, "Generating repository");
|
|
|
|
repository::generate();
|
|
|
|
repository::generate(verbose);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Map errored packages to a string for display
|
|
|
|
// Map errored packages to a string for display
|
|
|
@ -92,10 +107,10 @@ pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
|
|
|
|
|
|
|
|
|
|
|
|
// If errored is not empty, let the user know which packages failed
|
|
|
|
// If errored is not empty, let the user know which packages failed
|
|
|
|
if !errored.is_empty() {
|
|
|
|
if !errored.is_empty() {
|
|
|
|
log!("Errored packages: \n{:?}", error_strings);
|
|
|
|
log!(verbose, "Errored packages: \n{:?}", error_strings);
|
|
|
|
info!(
|
|
|
|
info!(
|
|
|
|
"The following packages build jobs returned a non-zero exit code: {}",
|
|
|
|
"The following packages build jobs returned a non-zero exit code: {}",
|
|
|
|
error_strings.join("\n")
|
|
|
|
error_strings.join("\n")
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|