Skip to content
Open
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
- `script`: Allow flist formats to use `only-sources`/`only-includes`/`only-defines` flags.
- Add check to ensure files referenced in all manifests exist.
- Add warnings for unknown fields in manifest.
- Add support to indicate and read in external file lists in manifest.
- Enumerate warnings and add `--suppress` flag to hide warnings.

### Changed
- `update`: Clean up alignment of manual resolution output.
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ sources:
# Source files can use glob patterns to include all matching files:
- src/more_stuff/**/*.sv

# File list in another external file, supporting simple file names, `+define+` and `+incdir+`
- external_flists:
- other_file_list.f
files: []

# A list of include directories which should implicitly be added to source
# file groups of packages that have the current package as a dependency.
# Optional.
Expand Down
56 changes: 43 additions & 13 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ pub fn main() -> Result<()> {
.value_parser(value_parser!(usize))
.help("Sets the maximum number of concurrent git operations"),
)
.arg(
Arg::new("suppress")
.long("suppress")
.global(true)
.num_args(1)
.action(ArgAction::Append)
.help("Suppresses specific warnings. Use `all` to suppress all warnings.")
.value_parser(value_parser!(String)),
)
.subcommand(cmd::update::new())
.subcommand(cmd::path::new())
.subcommand(cmd::parents::new())
Expand Down Expand Up @@ -95,6 +104,19 @@ pub fn main() -> Result<()> {
// Parse the arguments.
let matches = app.clone().get_matches();

let suppressed_warnings: IndexSet<String> = matches
.get_many::<String>("suppress")
.unwrap_or_default()
.map(|s| s.to_owned())
.collect();

let suppressed_warnings: IndexSet<String> =
if suppressed_warnings.contains("all") || suppressed_warnings.contains("Wall") {
(1..22).map(|i| format!("W{:02}", i)).collect()
} else {
suppressed_warnings
};

// Enable debug outputs if needed.
if matches.contains_id("debug") && matches.get_flag("debug") {
ENABLE_DEBUG.store(true, std::sync::atomic::Ordering::Relaxed);
Expand All @@ -111,7 +133,7 @@ pub fn main() -> Result<()> {

let mut force_fetch = false;
if let Some(("update", intern_matches)) = matches.subcommand() {
force_fetch = cmd::update::setup(intern_matches)?;
force_fetch = cmd::update::setup(intern_matches, &suppressed_warnings)?;
}

// Determine the root working directory, which has either been provided via
Expand All @@ -128,13 +150,14 @@ pub fn main() -> Result<()> {

// Parse the manifest file of the package.
let manifest_path = root_dir.join("Bender.yml");
let manifest = read_manifest(&manifest_path)?;
let manifest = read_manifest(&manifest_path, &suppressed_warnings)?;
debugln!("main: {:#?}", manifest);

// Gather and parse the tool configuration.
let config = load_config(
&root_dir,
matches!(matches.subcommand(), Some(("update", _))),
matches!(matches.subcommand(), Some(("update", _))) && !suppressed_warnings.contains("W02"),
&suppressed_warnings,
)?;
debugln!("main: {:#?}", config);

Expand All @@ -156,6 +179,7 @@ pub fn main() -> Result<()> {
matches.get_flag("local"),
force_fetch,
git_throttle,
suppressed_warnings,
);

if let Some(("clean", intern_matches)) = matches.subcommand() {
Expand Down Expand Up @@ -223,11 +247,13 @@ pub fn main() -> Result<()> {
)
})?;
if !meta.file_type().is_symlink() {
warnln!(
"Skipping link to package {} at {:?} since there is something there",
pkg_name,
path
);
if !sess.suppress_warnings.contains("W01") {
warnln!(
"[W01] Skipping link to package {} at {:?} since there is something there",
pkg_name,
path
);
}
continue;
}
if path.read_link().map(|d| d != pkg_path).unwrap_or(true) {
Expand Down Expand Up @@ -358,7 +384,7 @@ fn find_package_root(from: &Path) -> Result<PathBuf> {
}

/// Read a package manifest from a file.
pub fn read_manifest(path: &Path) -> Result<Manifest> {
pub fn read_manifest(path: &Path, suppress_warnings: &IndexSet<String>) -> Result<Manifest> {
use crate::config::PartialManifest;
use std::fs::File;
debugln!("read_manifest: {:?}", path);
Expand All @@ -369,12 +395,16 @@ pub fn read_manifest(path: &Path) -> Result<Manifest> {
partial
.prefix_paths(path.parent().unwrap())
.map_err(|cause| Error::chain(format!("Error in manifest prefixing {:?}.", path), cause))?
.validate("", false)
.validate("", false, suppress_warnings)
.map_err(|cause| Error::chain(format!("Error in manifest {:?}.", path), cause))
}

/// Load a configuration by traversing a directory hierarchy upwards.
fn load_config(from: &Path, warn_config_loaded: bool) -> Result<Config> {
fn load_config(
from: &Path,
warn_config_loaded: bool,
suppress_warnings: &IndexSet<String>,
) -> Result<Config> {
#[cfg(unix)]
use std::os::unix::fs::MetadataExt;

Expand Down Expand Up @@ -447,7 +477,7 @@ fn load_config(from: &Path, warn_config_loaded: bool) -> Result<Config> {

// Validate the configuration.
let mut out = out
.validate("", false)
.validate("", false, suppress_warnings)
.map_err(|cause| Error::chain("Invalid configuration:", cause))?;

out.overrides = out
Expand All @@ -471,7 +501,7 @@ fn maybe_load_config(path: &Path, warn_config_loaded: bool) -> Result<Option<Par
let partial: PartialConfig = serde_yaml::from_reader(file)
.map_err(|cause| Error::chain(format!("Syntax error in config {:?}.", path), cause))?;
if warn_config_loaded {
warnln!("Using config at {:?} for overrides.", path)
warnln!("[W02] Using config at {:?} for overrides.", path)
};
Ok(Some(partial.prefix_paths(path.parent().unwrap())?))
}
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ pub fn run(sess: &Session, path: &Path, matches: &ArgMatches) -> Result<()> {
{
Err(Error::new("git fetch failed".to_string()))?;
}
} else {
warnln!("fetch not performed due to --local argument.");
} else if !sess.suppress_warnings.contains("W14") {
warnln!("[W14] fetch not performed due to --local argument.");
}

println!(
Expand Down Expand Up @@ -263,7 +263,7 @@ pub fn run(sess: &Session, path: &Path, matches: &ArgMatches) -> Result<()> {
})?;
if !meta.file_type().is_symlink() {
warnln!(
"Skipping link to package {} at {:?} since there is something there",
"[W15] Skipping link to package {} at {:?} since there is something there",
pkg_name,
link_path
);
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/fusesoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ pub fn run_single(sess: &Session, matches: &ArgMatches) -> Result<()> {
Error::chain(format!("Unable to write corefile for {:?}.", &name), cause)
})?;

if fuse_depend_string.len() > 1 {
warnln!("Depend strings may be wrong for the included dependencies!");
if fuse_depend_string.len() > 1 && !sess.suppress_warnings.contains("W16") {
warnln!("[W16] Depend strings may be wrong for the included dependencies!");
}

Ok(())
Expand Down
12 changes: 7 additions & 5 deletions src/cmd/parents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
.unwrap();
// Filter out dependencies without a manifest
if dep_manifest.is_none() {
warnln!("{} is shown to include dependency, but manifest does not have this information.", pkg_name.to_string());
if !sess.suppress_warnings.contains("W17") {
warnln!("[W17] {} is shown to include dependency, but manifest does not have this information.", pkg_name.to_string());
}
continue;
}
let dep_manifest = dep_manifest.unwrap();
Expand All @@ -77,9 +79,9 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
),
],
);
} else {
} else if !sess.suppress_warnings.contains("W17") {
// Filter out dependencies with mismatching manifest
warnln!("{} is shown to include dependency, but manifest does not have this information.", pkg_name.to_string());
warnln!("[W17] {} is shown to include dependency, but manifest does not have this information.", pkg_name.to_string());
}
}
}
Expand Down Expand Up @@ -130,9 +132,9 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
}
);

if sess.config.overrides.contains_key(dep) {
if sess.config.overrides.contains_key(dep) && !sess.suppress_warnings.contains("W18") {
warnln!(
"An override is configured for {} to {:?}",
"[W18] An override is configured for {} to {:?}",
dep,
sess.config.overrides[dep]
)
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
let srcs = srcs
.flatten()
.into_iter()
.map(|f| f.validate("", false))
.map(|f| f.validate("", false, &sess.suppress_warnings))
.collect::<Result<Vec<_>>>()?;

// Validate format-specific options.
Expand Down
9 changes: 6 additions & 3 deletions src/cmd/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,13 @@ pub fn new() -> Command {
}

/// Execute the `update` subcommand.
pub fn setup(matches: &ArgMatches) -> Result<bool> {
pub fn setup(matches: &ArgMatches, suppress_warnings: &IndexSet<String>) -> Result<bool> {
let force_fetch = matches.get_flag("fetch");
if matches.get_flag("local") && matches.get_flag("fetch") {
warnln!("As --local argument is set for bender command, no fetching will be performed.");
if matches.get_flag("local") && matches.get_flag("fetch") && !suppress_warnings.contains("W14")
{
warnln!(
"[W14] As --local argument is set for bender command, no fetching will be performed."
);
}
Ok(force_fetch)
}
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
git.clone().spawn_with(|c| c.arg("clone").arg(url).arg("."))
.map_err(move |cause| {
if url.contains("git@") {
warnln!("Please ensure your public ssh key is added to the git server.");
warnln!("[W07] Please ensure your public ssh key is added to the git server.");
}
warnln!("Please ensure the url is correct and you have access to the repository.");
warnln!("[W07] Please ensure the url is correct and you have access to the repository.");
Error::chain(
format!("Failed to initialize git database in {:?}.", tmp_path),
cause,
Expand Down Expand Up @@ -280,7 +280,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
}
},
None => {
warnln!("No patch directory specified for package {}, mapping {} => {}. Skipping patch generation.", vendor_package.name.clone(), patch_link.from_prefix.to_str().unwrap(), patch_link.to_prefix.to_str().unwrap());
warnln!("[W15] No patch directory specified for package {}, mapping {} => {}. Skipping patch generation.", vendor_package.name.clone(), patch_link.from_prefix.to_str().unwrap(), patch_link.to_prefix.to_str().unwrap());
Ok(())
},
}
Expand Down Expand Up @@ -330,7 +330,7 @@ pub fn init(
// Check if includes exist
for path in vendor_package.include_from_upstream.clone() {
if !PathBuf::from(extend_paths(&[path.clone()], dep_path, true)?[0].clone()).exists() {
warnln!("{} not found in upstream, continuing.", path);
warnln!("[W16] {} not found in upstream, continuing.", path);
}
}

Expand Down Expand Up @@ -361,7 +361,7 @@ pub fn init(
})?;
} else {
warnln!(
"{} not found in upstream, continuing.",
"[W16] {} not found in upstream, continuing.",
link_from.to_str().unwrap()
);
}
Expand Down
Loading
Loading