Skip to content

Commit

Permalink
Add flag for rtl target to files without target
Browse files Browse the repository at this point in the history
  • Loading branch information
micprog committed Oct 20, 2024
1 parent 1987d87 commit 4074146
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
### Fixed
- Put `vcs`, `vsim`, and `riviera` defines in quotes.

### Added
- Add flag for `rtl` target to files without target in script and sources.

## 0.28.1 - 2024-02-22
### Added
- Add `flist-plus` script format for file list with plusargs.
Expand Down
12 changes: 12 additions & 0 deletions src/cmd/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ pub fn new() -> Command {
.num_args(1)
.value_parser(value_parser!(String)),
)
.arg(
Arg::new("assume_rtl")
.long("assume-rtl")
.help("Add the `rtl` target to any fileset without a target specification")
.num_args(0)
.action(ArgAction::SetTrue)
)
}

fn get_package_strings<I>(packages: I) -> IndexSet<String>
Expand Down Expand Up @@ -245,6 +252,11 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
)
})
.unwrap_or_else(|| TargetSet::new(format_targets));

if matches.get_flag("assume_rtl") {
srcs = srcs.assign_target("rtl".to_string());
}

srcs = srcs
.filter_targets(&targets)
.unwrap_or_else(|| SourceGroup {
Expand Down
12 changes: 12 additions & 0 deletions src/cmd/sources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ pub fn new() -> Command {
.action(ArgAction::Append)
.value_parser(value_parser!(String)),
)
.arg(
Arg::new("assume_rtl")
.long("assume-rtl")
.help("Add the `rtl` target to any fileset without a target specification")
.num_args(0)
.action(ArgAction::SetTrue),
)
.arg(
Arg::new("raw")
.long("raw")
Expand Down Expand Up @@ -100,6 +107,11 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
.get_many::<String>("target")
.map(TargetSet::new)
.unwrap_or_else(TargetSet::empty);

if matches.get_flag("assume_rtl") {
srcs = srcs.assign_target("rtl".to_string());
}

srcs = srcs
.filter_targets(&targets)
.unwrap_or_else(|| SourceGroup {
Expand Down
29 changes: 29 additions & 0 deletions src/src.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,35 @@ impl<'ctx> SourceGroup<'ctx> {
)
}

/// Assigns target to SourceGroup without target
pub fn assign_target(&self, target: String) -> SourceGroup<'ctx> {
let files = self
.files
.iter()
.filter_map(|file| match *file {
SourceFile::Group(ref group) => Some(group.assign_target(target.clone()))
.map(|g| SourceFile::Group(Box::new(g))),
ref other => Some(other.clone()),
})
.collect();

SourceGroup {
package: self.package,
independent: self.independent,
target: if self.target.is_wildcard() {
TargetSpec::Name(target)
} else {
self.target.clone()
},
include_dirs: self.include_dirs.clone(),
export_incdirs: self.export_incdirs.clone(),
defines: self.defines.clone(),
files,
dependencies: self.dependencies.clone(),
version: self.version.clone(),
}
}

/// Recursively get dependency names.
fn get_deps(
&self,
Expand Down

0 comments on commit 4074146

Please sign in to comment.