Disable licenses for Pigweed GN
Pigweed has no well defined format for reference third-party crates
license. Disable license generation at the moment.
Change-Id: If18e5c91d3aa7e1783902c0c77404e82eff0df05
Reviewed-on: https://pigweed-review.googlesource.com/c/third_party/fuchsia/cargo-gnaw/+/235656
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 23465f4..68d533c 100644
--- a/src/gn.rs
+++ b/src/gn.rs
@@ -517,10 +517,12 @@
};
let mut license_files_found = false;
- let mut applicable_licenses = GnField::new("applicable_licenses");
+ let mut gn_applicable_licenses : Option<GnField> = None;
let gn_crate_name = target.name().replace('-', "_");
if scan_for_licenses {
+ let mut applicable_licenses = GnField::new("applicable_licenses");
+
// Scan for LICENSE* files in the crate's root dir.
// Disabled in unit tests, where package_root always fails.
let mut license_files = vec![];
@@ -593,6 +595,8 @@
target.version()
);
}
+
+ gn_applicable_licenses = Some(applicable_licenses);
}
writeln!(
@@ -611,7 +615,12 @@
edition = edition,
visibility = visibility,
optional_testonly = optional_testonly,
- applicable_licenses = applicable_licenses.render_gn(),
+ applicable_licenses =
+ if let Some(applicable_licenses) = gn_applicable_licenses {
+ applicable_licenses.render_gn()
+ } else {
+ "".to_string()
+ }
)
.map_err(Into::into)
}
@@ -737,8 +746,7 @@
visibility = [":*"]
- applicable_licenses = []
-
+
}
"#
@@ -802,8 +810,7 @@
visibility = [":*"]
- applicable_licenses = []
-
+
}
"#
@@ -866,8 +873,7 @@
visibility = [":*"]
- applicable_licenses = []
-
+
}
"#
diff --git a/src/lib.rs b/src/lib.rs
index 2570bb6..6606d8e 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -747,7 +747,7 @@
testonly_targets.contains(target),
false,
renamed_rules.get(target).copied(),
- true,
+ false, // Pigweed GN has no defined format for licenses
)
.with_context(|| format!("writing rule for: {} {}", target.name(), target.version()))?;
@@ -762,7 +762,7 @@
true,
true,
renamed_rules.get(&target).copied(),
- true,
+ false, // Pigweed GN has no defined format for licenses
)
.with_context(|| format!("writing rule for: {} {}", target.name(), target.version()))?;
}