Skip to content

Commit 4074146

Browse files
committed
Add flag for rtl target to files without target
1 parent 1987d87 commit 4074146

File tree

4 files changed

+56
-0
lines changed

4 files changed

+56
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
88
### Fixed
99
- Put `vcs`, `vsim`, and `riviera` defines in quotes.
1010

11+
### Added
12+
- Add flag for `rtl` target to files without target in script and sources.
13+
1114
## 0.28.1 - 2024-02-22
1215
### Added
1316
- Add `flist-plus` script format for file list with plusargs.

src/cmd/script.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,13 @@ pub fn new() -> Command {
188188
.num_args(1)
189189
.value_parser(value_parser!(String)),
190190
)
191+
.arg(
192+
Arg::new("assume_rtl")
193+
.long("assume-rtl")
194+
.help("Add the `rtl` target to any fileset without a target specification")
195+
.num_args(0)
196+
.action(ArgAction::SetTrue)
197+
)
191198
}
192199

193200
fn get_package_strings<I>(packages: I) -> IndexSet<String>
@@ -245,6 +252,11 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
245252
)
246253
})
247254
.unwrap_or_else(|| TargetSet::new(format_targets));
255+
256+
if matches.get_flag("assume_rtl") {
257+
srcs = srcs.assign_target("rtl".to_string());
258+
}
259+
248260
srcs = srcs
249261
.filter_targets(&targets)
250262
.unwrap_or_else(|| SourceGroup {

src/cmd/sources.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ pub fn new() -> Command {
6262
.action(ArgAction::Append)
6363
.value_parser(value_parser!(String)),
6464
)
65+
.arg(
66+
Arg::new("assume_rtl")
67+
.long("assume-rtl")
68+
.help("Add the `rtl` target to any fileset without a target specification")
69+
.num_args(0)
70+
.action(ArgAction::SetTrue),
71+
)
6572
.arg(
6673
Arg::new("raw")
6774
.long("raw")
@@ -100,6 +107,11 @@ pub fn run(sess: &Session, matches: &ArgMatches) -> Result<()> {
100107
.get_many::<String>("target")
101108
.map(TargetSet::new)
102109
.unwrap_or_else(TargetSet::empty);
110+
111+
if matches.get_flag("assume_rtl") {
112+
srcs = srcs.assign_target("rtl".to_string());
113+
}
114+
103115
srcs = srcs
104116
.filter_targets(&targets)
105117
.unwrap_or_else(|| SourceGroup {

src/src.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,35 @@ impl<'ctx> SourceGroup<'ctx> {
107107
)
108108
}
109109

110+
/// Assigns target to SourceGroup without target
111+
pub fn assign_target(&self, target: String) -> SourceGroup<'ctx> {
112+
let files = self
113+
.files
114+
.iter()
115+
.filter_map(|file| match *file {
116+
SourceFile::Group(ref group) => Some(group.assign_target(target.clone()))
117+
.map(|g| SourceFile::Group(Box::new(g))),
118+
ref other => Some(other.clone()),
119+
})
120+
.collect();
121+
122+
SourceGroup {
123+
package: self.package,
124+
independent: self.independent,
125+
target: if self.target.is_wildcard() {
126+
TargetSpec::Name(target)
127+
} else {
128+
self.target.clone()
129+
},
130+
include_dirs: self.include_dirs.clone(),
131+
export_incdirs: self.export_incdirs.clone(),
132+
defines: self.defines.clone(),
133+
files,
134+
dependencies: self.dependencies.clone(),
135+
version: self.version.clone(),
136+
}
137+
}
138+
110139
/// Recursively get dependency names.
111140
fn get_deps(
112141
&self,

0 commit comments

Comments
 (0)