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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
## Unreleased
### Added
- Add flag for `rtl` target to files without target in script and sources.
- Add `pass_targets` to dependencies to allow passing targets for hierarchical file filtering (not only global).

## 0.29.1 - 2025-11-24
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ dependencies:
common_verification: { git: "[email protected]:pulp-platform/common_verification.git", version: "0.1" }

# Git revision dependency.
common_cells: { git: "[email protected]:pulp-platform/common_cells.git", rev: master }
common_cells: { git: "[email protected]:pulp-platform/common_cells.git", rev: master, pass_targets: ["CC_CUSTOM_TARGET"] }

# Freeze any dependency updates. Optional. False if omitted.
# Useful for chip packages. Once the chip is in final tapeout mode, and
Expand Down
4 changes: 2 additions & 2 deletions src/cmd/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn run(sess: &Session, path: &Path, matches: &ArgMatches) -> Result<()> {
// Check current config for matches
if sess.config.overrides.contains_key(dep) {
match &sess.config.overrides[dep] {
config::Dependency::Path(p) => {
config::Dependency::Path(p, _) => {
Err(Error::new(format!(
"Dependency `{}` already has a path override at\n\t{}\n\tPlease check Bender.local or .bender.yml",
dep,
Expand Down Expand Up @@ -355,7 +355,7 @@ pub fn get_path_subdeps(
}
.iter()
.filter_map(|(k, v)| match v {
config::Dependency::Path(p) => {
config::Dependency::Path(p, _) => {
if p.starts_with(&old_path) {
Some((
k.clone(),
Expand Down
4 changes: 4 additions & 0 deletions src/cmd/fusesoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub fn run_single(sess: &Session, matches: &ArgMatches) -> Result<()> {
sess.manifest.dependencies.keys().cloned().collect(),
IndexMap::new(),
version_string.clone(),
IndexMap::new(),
)
.flatten()),
None => Err(Error::new("Error in loading sources")),
Expand Down Expand Up @@ -356,6 +357,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
files: Default::default(),
dependencies: Default::default(),
version: None,
passed_targets: TargetSet::empty(),
})
.flatten();

Expand Down Expand Up @@ -557,6 +559,7 @@ fn get_fuse_depend_string(
files: Default::default(),
dependencies: Default::default(),
version: None,
passed_targets: TargetSet::empty(),
})
.flatten();

Expand All @@ -573,6 +576,7 @@ fn get_fuse_depend_string(
files: group.files.clone(),
dependencies: group.dependencies.clone(),
version: version_string.clone(),
passed_targets: TargetSet::empty(),
})
.collect()
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/cmd/packages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio::runtime::Runtime;
use crate::error::*;
use crate::sess::{DependencySource, Session, SessionIo};
use crate::src::SourceGroup;
use crate::target::TargetSpec;
use crate::target::{TargetSet, TargetSpec};

/// Assemble the `packages` subcommand.
pub fn new() -> Command {
Expand Down Expand Up @@ -83,6 +83,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
files: Default::default(),
dependencies: Default::default(),
version: None,
passed_targets: TargetSet::empty(),
})
.get_avail_targets()
));
Expand All @@ -102,6 +103,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
files: Default::default(),
dependencies: Default::default(),
version: None,
passed_targets: TargetSet::empty(),
})
.get_avail_targets()
));
Expand Down
94 changes: 69 additions & 25 deletions src/cmd/parents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use indexmap::IndexMap;
use tabwriter::TabWriter;
use tokio::runtime::Runtime;

use crate::config::Dependency;
use crate::error::*;
use crate::sess::{DependencyConstraint, DependencySource};
use crate::sess::{Session, SessionIo};
Expand All @@ -18,12 +19,19 @@ use crate::sess::{Session, SessionIo};
pub fn new() -> Command {
Command::new("parents")
.about("List packages calling this dependency")
.alias("parent")
.arg(
Arg::new("name")
.required(true)
.num_args(1)
.help("Package names to get the parents for"),
)
.arg(
Arg::new("targets")
.long("targets")
.num_args(0)
.help("Print the passed targets to the dependency"),
)
}

/// Execute the `parents` subcommand.
Expand All @@ -36,18 +44,30 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
let parent_array = {
let mut map = IndexMap::<String, Vec<String>>::new();
if sess.manifest.dependencies.contains_key(dep) {
let dep_str = format!(
"{}",
DependencyConstraint::from(&sess.manifest.dependencies[dep])
);
let dep_source = format!(
"{}",
DependencySource::from(&sess.manifest.dependencies[dep])
);
map.insert(
sess.manifest.package.name.clone(),
vec![dep_str, dep_source],
);
if matches.get_flag("targets") {
map.insert(
sess.manifest.package.name.clone(),
match sess.manifest.dependencies.get(dep).unwrap() {
Dependency::Version(_, tgts) => tgts.clone(),
Dependency::Path(_, tgts) => tgts.clone(),
Dependency::GitRevision(_, _, tgts) => tgts.clone(),
Dependency::GitVersion(_, _, tgts) => tgts.clone(),
},
);
} else {
let dep_str = format!(
"{}",
DependencyConstraint::from(&sess.manifest.dependencies[dep])
);
let dep_source = format!(
"{}",
DependencySource::from(&sess.manifest.dependencies[dep])
);
map.insert(
sess.manifest.package.name.clone(),
vec![dep_str, dep_source],
);
}
}
for (&pkg, deps) in sess.graph().iter() {
let pkg_name = sess.dependency_name(pkg);
Expand All @@ -66,19 +86,31 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
}
let dep_manifest = dep_manifest.unwrap();
if dep_manifest.dependencies.contains_key(dep) {
map.insert(
pkg_name.to_string(),
vec![
format!(
"{}",
DependencyConstraint::from(&dep_manifest.dependencies[dep])
),
format!(
"{}",
DependencySource::from(&dep_manifest.dependencies[dep])
),
],
);
if matches.get_flag("targets") {
map.insert(
pkg_name.to_string(),
match dep_manifest.dependencies.get(dep).unwrap() {
Dependency::Version(_, tgts) => tgts.clone(),
Dependency::Path(_, tgts) => tgts.clone(),
Dependency::GitRevision(_, _, tgts) => tgts.clone(),
Dependency::GitVersion(_, _, tgts) => tgts.clone(),
},
);
} else {
map.insert(
pkg_name.to_string(),
vec![
format!(
"{}",
DependencyConstraint::from(&dep_manifest.dependencies[dep])
),
format!(
"{}",
DependencySource::from(&dep_manifest.dependencies[dep])
),
],
);
}
} else if !sess.suppress_warnings.contains("W17") {
// Filter out dependencies with mismatching manifest
warnln!("[W17] {} is shown to include dependency, but manifest does not have this information.", pkg_name.to_string());
Expand All @@ -89,6 +121,18 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
map
};

if matches.get_flag("targets") {
let mut res = String::from("");
for (k, v) in parent_array.iter() {
res.push_str(&format!(" {}\tpasses: {:?}\n", k, v).to_string());
}
let mut tw = TabWriter::new(vec![]);
write!(&mut tw, "{}", res).unwrap();
tw.flush().unwrap();
print!("{}", String::from_utf8(tw.into_inner().unwrap()).unwrap());
return Ok(());
}

if parent_array.is_empty() {
let _ = writeln!(std::io::stdout(), "No parents found for {}.", dep);
} else {
Expand Down
21 changes: 20 additions & 1 deletion src/cmd/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ pub fn new() -> Command {
.num_args(0)
.action(ArgAction::SetTrue)
)
.arg(
Arg::new("ignore-passed-targets")
.long("ignore-passed-targets")
.help("Ignore passed targets")
.num_args(0)
.action(ArgAction::SetTrue),
)
}

fn get_package_strings<I>(packages: I) -> IndexSet<String>
Expand Down Expand Up @@ -260,7 +267,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
}

srcs = srcs
.filter_targets(&targets)
.filter_targets(&targets, !matches.get_flag("ignore-passed-targets"))
.unwrap_or_else(|| SourceGroup {
package: Default::default(),
independent: true,
Expand All @@ -271,6 +278,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
files: Default::default(),
dependencies: Default::default(),
version: None,
passed_targets: TargetSet::empty(),
});

// Filter the sources by specified packages.
Expand Down Expand Up @@ -303,6 +311,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
files: Default::default(),
dependencies: Default::default(),
version: None,
passed_targets: TargetSet::empty(),
});
}

Expand Down Expand Up @@ -539,6 +548,11 @@ fn emit_template(
all_files.append(&mut src.files.clone());
}
all_defines.extend(target_defines.clone());
all_defines.extend(srcs.iter().flat_map(|src| {
src.passed_targets
.iter()
.map(|t| (format!("TARGET_{}", t.to_uppercase()), None))
}));
add_defines_from_matches(&mut all_defines, matches);
let all_defines = if (!matches.get_flag("only-includes") && !matches.get_flag("only-sources"))
|| matches.get_flag("only-defines")
Expand Down Expand Up @@ -601,6 +615,11 @@ fn emit_template(
.map(|(k, &v)| (k.to_string(), v.map(String::from))),
);
local_defines.extend(target_defines.clone());
local_defines.extend(
src.passed_targets
.iter()
.map(|t| (format!("TARGET_{}", t.to_uppercase()), None)),
);
add_defines_from_matches(&mut local_defines, matches);
local_defines.into_iter().collect()
},
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {

// Loop through existing deps to find the ones that are overridden to the working directory
for (name, dep) in sess.config.overrides.iter() {
if let Dependency::Path(override_path) = dep {
if let Dependency::Path(override_path, _) = dep {
if override_path.starts_with(sess.root.join(working_dir)) {
if let DependencySource::Path(dep_path) =
sess.dependency_source(sess.dependency_with_name(name)?)
Expand Down
11 changes: 10 additions & 1 deletion src/cmd/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ pub fn new() -> Command {
.num_args(0)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("ignore-passed-targets")
.long("ignore-passed-targets")
.help("Ignore passed targets")
.num_args(0)
.action(ArgAction::SetTrue),
)
}

fn get_package_strings<I>(packages: I) -> IndexSet<String>
Expand Down Expand Up @@ -115,7 +122,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
}

srcs = srcs
.filter_targets(&targets)
.filter_targets(&targets, !matches.get_flag("ignore-passed-targets"))
.unwrap_or_else(|| SourceGroup {
package: Default::default(),
independent: true,
Expand All @@ -126,6 +133,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
files: Default::default(),
dependencies: Default::default(),
version: None,
passed_targets: TargetSet::empty(),
});

// Filter the sources by specified packages.
Expand Down Expand Up @@ -158,6 +166,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
files: Default::default(),
dependencies: Default::default(),
version: None,
passed_targets: TargetSet::empty(),
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
)
}).await?;
let rev_hash = match vendor_package.upstream {
config::Dependency::GitRevision(_, ref rev) => Ok(rev),
config::Dependency::GitRevision(_, ref rev, _) => Ok(rev),
_ => Err(Error::new("Please ensure your vendor reference is a commit hash to avoid upstream changes impacting your checkout")),
}?;
git.clone().spawn_with(|c| c.arg("checkout").arg(rev_hash)).await?;
Expand Down
Loading