summaryrefslogtreecommitdiff
path: root/Mk
diff options
context:
space:
mode:
authorTobias Kortkamp <tobik@FreeBSD.org>2019-12-05 06:42:22 +0000
committerTobias Kortkamp <tobik@FreeBSD.org>2019-12-05 06:42:22 +0000
commitbb415dbba686ccf2c69bfe0dd3be774c107ee8a5 (patch)
tree9771c0a87e5dcd68254df6463ac082405baf3978 /Mk
parent8b867c996a103a57772e91ff40b57438c5f9f200 (diff)
downloadfreebsd-ports-bb415dbba686ccf2c69bfe0dd3be774c107ee8a5.zip
Mk/Uses/cargo.mk: Support new Cargo.lock format
The new format [1,2] dropped the [metadata] table. As a consequence our cargo-crates.awk script no longer outputs CARGO_CRATES. We can get the crate list from the various [[package]] tables instead. This should work with the new as well as the old format. [1] https://github.com/rust-lang/cargo/pull/7070 [2] https://github.com/rust-lang/cargo/pull/7579 PR: 242416 Reported by: jbeich
Diffstat (limited to 'Mk')
-rw-r--r--Mk/Scripts/cargo-crates.awk39
1 files changed, 31 insertions, 8 deletions
diff --git a/Mk/Scripts/cargo-crates.awk b/Mk/Scripts/cargo-crates.awk
index a15bc4bcf080..182d25e45c9a 100644
--- a/Mk/Scripts/cargo-crates.awk
+++ b/Mk/Scripts/cargo-crates.awk
@@ -6,6 +6,9 @@ BEGIN {
gl_tuple_len = 0
crates_len = 0
package_name = "<unknown>"
+ crate_name = "<unknown>"
+ crate_version = "<unknown>"
+ crate_source = "<unknown>"
gitlab_sites["https://gitlab.com"] = 1
gitlab_sites["https://gitlab.freedesktop.org"] = 1
@@ -13,19 +16,37 @@ BEGIN {
gitlab_sites["https://gitlab.redox-os.org"] = 1
}
-/^"checksum .* .* \(registry\+.*\)" = ".*"/ {
- # $2: crate
- # $3: version
- # $4: url
- # $6: checksum
- crates[crates_len++] = sprintf("%s-%s", $2, $3)
-}
-
/^name = ".*"/ {
+ crate_name = $3
+ gsub(/"/, "", crate_name)
+
package_name = $3
gsub("[^a-zA-Z_]", "", package_name)
}
+/^version = ".*"/ {
+ crate_version = $3
+ gsub(/"/, "", crate_version)
+}
+
+/^source = ".*"/ {
+ crate_source = $3
+ gsub(/"/, "", crate_source)
+}
+
+/^\[\[package\]\]$/ {
+ add_crate()
+}
+
+function add_crate() {
+ if (crate_source == "registry+https://github.com/rust-lang/crates.io-index") {
+ crates[crates_len++] = sprintf("%s-%s", crate_name, crate_version)
+ }
+ crate_name = "<unknown>"
+ crate_version = "<unknown>"
+ crate_source = "<unknown>"
+}
+
function split_url(s) {
# scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment]
split(s, url_scheme, "://")
@@ -112,6 +133,8 @@ function print_array(start, arr, arrlen) {
}
END {
+ add_crate()
+
if (gh_tuple_len > 0 && ENVIRON["USE_GITHUB"] == "") {
printf "USE_GITHUB=\tnodefault\n"
}