Skip to content
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
12 changes: 5 additions & 7 deletions src/data/import/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fs::remove_dir_all;
use anyhow::{anyhow, Context as _, Error};
use camino::{Utf8Path, Utf8PathBuf};
use git_cache::GitCacheClonerBuilder;
use log::info;
use log::debug;
use rust_embed::RustEmbed;

use super::Import;
Expand Down Expand Up @@ -65,7 +65,7 @@ impl Import for Download {

match &self.source {
Source::Git(Git::Commit { url, commit }) => {
info!("IMPORT Git {url}:{commit} -> {target_path}");
debug!("IMPORT Git {url}:{commit} -> {target_path}");

git_clone_commit(url, &target_path, commit).with_context(|| {
format!("cloning git url: \"{url}\" commit: \"{commit}\"")
Expand All @@ -81,7 +81,7 @@ impl Import for Download {
url,
tag: branch_or_tag,
}) => {
info!("IMPORT Git {url}:{branch_or_tag} -> {target_path}");
debug!("IMPORT Git {url}:{branch_or_tag} -> {target_path}");

git_clone_branch(url, &target_path, branch_or_tag).with_context(|| {
format!("cloning git url: \"{url}\" branch/tag: \"{branch_or_tag}\"")
Expand All @@ -90,7 +90,7 @@ impl Import for Download {
self.create_tagfile(tagfile)?;
}
Source::Git(Git::Default { url }) => {
info!("IMPORT Git {url} -> {target_path}");
debug!("IMPORT Git {url} -> {target_path}");

git_cloner(url, &target_path)?
.do_clone()
Expand Down Expand Up @@ -141,9 +141,7 @@ impl Import for Download {
Source::Git(Git::Commit { url, .. })
| Source::Git(Git::Branch { url, .. })
| Source::Git(Git::Tag { url, .. })
| Source::Git(Git::Default { url, .. }) => {
url.split('/').next_back().map(|x| x.to_string())
}
| Source::Git(Git::Default { url, .. }) => url.split('/').next_back().map(|x| x.to_string()),
Source::Laze(name) => {
let prefix = format!("{}/", name);

Expand Down
30 changes: 16 additions & 14 deletions src/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//! It expects data structures as created by the data module.

use core::hash::Hash;
use log::info;
use log::{debug, error, trace};
use std::borrow::Cow;
use std::collections::hash_map::DefaultHasher;
use std::fmt;
Expand Down Expand Up @@ -125,22 +125,24 @@ impl Generator {

match GenerateResult::try_from(&self) {
Ok(cached) => {
info!("laze: reading cache took {:?}.", start.elapsed());
trace!("laze: reading cache took {:?}.", start.elapsed());
return Ok(cached);
}
Err(x) => info!("laze: reading cache: {x}"),
Err(x) => debug!("laze: reading cache: {x}"),
}

let (contexts, treestate, load_stats) = load(&self.project_file, &self.build_dir)?;

info!(
trace!(
"laze: parsing {} files took {:?}",
load_stats.files, load_stats.parsing_time,
load_stats.files,
load_stats.parsing_time,
);

info!(
trace!(
"laze: stat'ing {} files took {:?}",
load_stats.files, load_stats.stat_time
load_stats.files,
load_stats.stat_time
);

std::fs::create_dir_all(&self.build_dir)?;
Expand Down Expand Up @@ -314,7 +316,7 @@ impl Generator {
}

let num_built = builds.len();
info!(
trace!(
"configured {} builds (took {:?}).",
num_built,
start.elapsed()
Expand Down Expand Up @@ -410,7 +412,7 @@ fn configure_build(
true
}
} {
info!("{}", reason);
trace!("{}", reason);
return Ok(reason.into());
}

Expand All @@ -423,11 +425,11 @@ fn configure_build(
builder.name,
contexts.context_by_id(binary.context_id.unwrap()).name,
));
info!("{}", reason);
trace!("{}", reason);
return Ok(reason.into());
}

info!("configuring {} for {}", binary.name, builder.name);
debug!("configuring {} for {}", binary.name, builder.name);

// create build instance (binary A for builder X)
let build = Build::new(binary, builder, contexts, select);
Expand All @@ -454,7 +456,7 @@ fn configure_build(
let resolved = match build.resolve_selects(disabled_modules, required_modules) {
Err(e) => {
reason.msg(format!("laze: not building {:?}", e));
info!("{}", reason);
debug!("{}", reason);
return Ok(reason.into());
}
Ok(val) => val,
Expand Down Expand Up @@ -606,7 +608,7 @@ fn configure_build(
"error: {} for {}: build dependency cycle detected.",
binary.name, builder.name
));
info!("{}", reason);
error!("{}", reason);
return Ok(reason.into());
}
}
Expand Down Expand Up @@ -1151,7 +1153,7 @@ impl GenerateResult {
bincode::serialize_into(&mut buffer, &build_uuid::get().as_bytes())?;

let result = bincode::serialize_into(buffer, self);
info!("laze: writing cache took {:?}.", start.elapsed());
trace!("laze: writing cache took {:?}.", start.elapsed());
result
}
}
Expand Down
31 changes: 17 additions & 14 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use camino::{Utf8Path, Utf8PathBuf};
use git_cache::GitCache;
use itertools::Itertools;
use jobserver::JOBSERVER;
use log::{debug, error, info, log_enabled, Level::Debug, LevelFilter};
use log::{debug, error, info, log_enabled, warn, Level::Debug, LevelFilter};
use signal_hook::{consts::SIGINT, flag::register_conditional_shutdown};

#[global_allocator]
Expand Down Expand Up @@ -189,7 +189,7 @@ fn try_main_build(matches: clap::ArgMatches) -> Result<i32> {
start_relpath
};

info!(
debug!(
"laze: project root: {project_root} relpath: {start_relpath} project_file: {project_file}",
);

Expand Down Expand Up @@ -225,7 +225,6 @@ fn cmd_completion(matches: &clap::ArgMatches) -> Result<i32> {
}
if let Some(generator) = matches.get_one::<clap_complete::Shell>("shell").copied() {
let mut cmd = cli::clap();
info!("Generating completion file for {}...", generator);
print_completions(generator, &mut cmd);
}
Ok(0)
Expand Down Expand Up @@ -368,8 +367,8 @@ fn cmd_build(
if matches.get_flag("compile-commands") {
let mut compile_commands = project_root.clone();
compile_commands.push("compile_commands.json");
info!("laze: generating {compile_commands}");
ninja::generate_compile_commands(&ninja_build_file, &compile_commands)?;
info!("laze: generated {compile_commands}");
}

// collect (optional) task and it's arguments
Expand Down Expand Up @@ -401,7 +400,7 @@ fn cmd_build(
for t in &b.tasks {
if t.1.is_err() && t.0 == task {
not_available += 1;
debug!(
warn!(
"laze: warn: task \"{task}\" for binary \"{}\" on builder \"{}\": {}",
b.binary,
b.builder,
Expand All @@ -412,23 +411,27 @@ fn cmd_build(
}

if not_available > 0 {
info!("laze hint: {not_available} target(s) not available, try `--verbose` to list why");
error!("laze hint: {not_available} target(s) not available, try `--verbose` to list why");
}
return Err(anyhow!("no matching target for task \"{}\" found.", task));
}

let multiple = matches.get_flag("multiple");

if builds.len() > 1 && !multiple {
info!("laze: multiple task targets found:");
for build_info in builds {
info!("{} {}", build_info.builder, build_info.binary);
}

// TODO: allow running tasks for multiple targets
return Err(anyhow!(
"please specify one of these builders, or -m/--multiple-tasks."
if log_enabled!(Debug) {
debug!("laze: multiple task targets found:");
for build_info in builds {
debug!("{} {}", build_info.builder, build_info.binary);
}
return Err(anyhow!(
"please specify only one builder, or add `-m`/`--multiple-tasks`."
));
} else {
return Err(anyhow!(
"multiple task targets found. Choose one (use `--verbose` to see options), or add `-m`/`--multiple-tasks`."
));
}
}

let task_name = task;
Expand Down
Loading