|
|
@ -1,23 +1,31 @@
|
|
|
|
use crate::internal::structs::{ErroredPackage, Repo};
|
|
|
|
use crate::internal::structs::{ErroredPackage, Repo};
|
|
|
|
use crate::internal::AppExitCode;
|
|
|
|
use crate::internal::AppExitCode;
|
|
|
|
use crate::{crash, info, repository, workspace};
|
|
|
|
use crate::{crash, info, log, repository, workspace};
|
|
|
|
|
|
|
|
|
|
|
|
pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
|
|
|
|
pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
|
|
|
|
// Read config struct from mlc.toml
|
|
|
|
// Read config struct from mlc.toml
|
|
|
|
let config = workspace::read_cfg();
|
|
|
|
let config = workspace::read_cfg();
|
|
|
|
|
|
|
|
log!("Config: {:?}", config);
|
|
|
|
let all = packages.is_empty();
|
|
|
|
let all = packages.is_empty();
|
|
|
|
|
|
|
|
log!("All: {:?}", all);
|
|
|
|
|
|
|
|
log!("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 );
|
|
|
|
if !exclude.is_empty() {
|
|
|
|
if !exclude.is_empty() {
|
|
|
|
|
|
|
|
log!("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);
|
|
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
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) {
|
|
|
@ -28,7 +36,9 @@ pub fn build(packages: Vec<String>, exclude: Vec<String>, no_regen: bool) {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Otherwise, build
|
|
|
|
// Otherwise, build
|
|
|
|
|
|
|
|
log!("Building {}", pkg);
|
|
|
|
let code = repository::build(pkg, config.sign);
|
|
|
|
let code = repository::build(pkg, config.sign);
|
|
|
|
|
|
|
|
log!("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(),
|
|
|
@ -42,10 +52,16 @@ 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");
|
|
|
|
|
|
|
|
|
|
|
|
// Sort by package priority
|
|
|
|
// Sort by package priority
|
|
|
|
|
|
|
|
log!("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);
|
|
|
|
for pkg in repos {
|
|
|
|
for pkg in repos {
|
|
|
|
|
|
|
|
log!("Building {}", pkg.name);
|
|
|
|
let code = repository::build(&pkg.name, config.sign);
|
|
|
|
let code = repository::build(&pkg.name, config.sign);
|
|
|
|
|
|
|
|
log!("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,
|
|
|
@ -58,11 +74,13 @@ 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");
|
|
|
|
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");
|
|
|
|
repository::generate();
|
|
|
|
repository::generate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -74,6 +92,7 @@ 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);
|
|
|
|
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")
|
|
|
|