Skip to content

Commit

Permalink
sort srcs in targets (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnynek authored Sep 24, 2024
1 parent cb840ca commit 8169f35
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
20 changes: 14 additions & 6 deletions crates/driver/src/print_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ impl TargetEntry {
));

for (k, v) in &self.extra_kv_pairs {
if k == "srcs" {
return Err(anyhow!("srcs cannot appear in extra_kv_pairs in: {}", self.name))
}
let mut normv: Vec<MaybeLabel> = v.iter().map(|item| MaybeLabel::from_str(item)).collect();
normv.sort();

Expand Down Expand Up @@ -348,12 +351,17 @@ impl SrcType {
)
}

SrcType::List(files) => ast_builder::as_py_list(
files
.iter()
.map(|e| ast_builder::with_constant_str(e.clone()))
.collect(),
),
SrcType::List(files) => {
let mut srcs: Vec<MaybeLabel> =
files.iter().map(|src| MaybeLabel::from_str(&src)).collect();
srcs.sort();
ast_builder::as_py_list(
srcs
.into_iter()
.map(|e| e.to_expr())
.collect()
)
}
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/python_utilities/src/ast_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ mod tests {
proto_library(
name = "aa_proto",
srcs = ["aa.proto"],
srcs = [
"aa.proto",
"bb.proto",
],
deps = [
"//x",
"//y",
Expand Down

0 comments on commit 8169f35

Please sign in to comment.