Move edition from rustflags to an attribute
Pigweed GN rules does validations on "editions". It requires "edition"
being a attribute.
Test: cargo test --locked
Change-Id: I14b40b96b89f4f5f8cb028b67d189d0434a90a40
Reviewed-on: https://pigweed-review.googlesource.com/c/third_party/fuchsia/cargo-gnaw/+/235654
Reviewed-by: Erik Gilling <konkers@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
diff --git a/src/gn.rs b/src/gn.rs
index 8ad3252..86ecec1 100644
--- a/src/gn.rs
+++ b/src/gn.rs
@@ -405,7 +405,6 @@
// Associate unique metadata with this crate
rustflags.add_cfg("--cap-lints=allow");
- rustflags.add_cfg(format!("--edition={}", target.edition));
rustflags.add_cfg(format!("-Cmetadata={}", target.metadata_hash()));
rustflags.add_cfg(format!("-Cextra-filename=-{}", target.metadata_hash()));
if is_test {
@@ -464,6 +463,8 @@
}
}
+ let edition = format!("edition = \"{}\"", target.edition);
+
let visibility = if visibility.is_empty() {
String::from("visibility = [\":*\"]\n")
} else {
@@ -623,6 +624,7 @@
cfgs = configs.render_gn(),
rustenv = rustenv.render_gn(),
rustflags = rustflags.render_gn(),
+ edition = edition,
visibility = visibility,
optional_testonly = optional_testonly,
applicable_licenses = applicable_licenses.render_gn(),
@@ -744,8 +746,9 @@
rustenv = []
- rustflags = ["--cap-lints=allow","--edition=2018","-Cmetadata=c5bf97c44457465a","-Cextra-filename=-c5bf97c44457465a"]
+ rustflags = ["--cap-lints=allow","-Cmetadata=c5bf97c44457465a","-Cextra-filename=-c5bf97c44457465a"]
+ edition = "2018"
visibility = [":*"]
@@ -808,8 +811,9 @@
rustenv = []
- rustflags = ["--cap-lints=allow","--edition=2018","-Cmetadata=bf8f4a806276c599","-Cextra-filename=-bf8f4a806276c599"]
+ rustflags = ["--cap-lints=allow","-Cmetadata=bf8f4a806276c599","-Cextra-filename=-bf8f4a806276c599"]
+ edition = "2018"
visibility = [":*"]
@@ -871,8 +875,9 @@
rustenv = []
- rustflags = ["--cap-lints=allow","--edition=2018","-Cmetadata=bf8f4a806276c599","-Cextra-filename=-bf8f4a806276c599"]
+ rustflags = ["--cap-lints=allow","-Cmetadata=bf8f4a806276c599","-Cextra-filename=-bf8f4a806276c599"]
+ edition = "2018"
visibility = [":*"]
diff --git a/templates_pw/gn_rule.template b/templates_pw/gn_rule.template
index 797f520..6158a7c 100644
--- a/templates_pw/gn_rule.template
+++ b/templates_pw/gn_rule.template
@@ -6,6 +6,7 @@
{dependencies}
{rustenv}
{rustflags}
+ {edition}
{aliased_deps}
{visibility}
{optional_testonly}