summaryrefslogtreecommitdiff
path: root/Mk/Scripts/cargo-crates-git-fetch.awk
diff options
context:
space:
mode:
authorTobias Kortkamp <tobik@FreeBSD.org>2021-09-07 16:08:46 +0200
committerTobias Kortkamp <tobik@FreeBSD.org>2021-10-25 10:49:06 +0200
commit2bad8d171afe848ac88585270964342a55d504ce (patch)
tree51e86c9ac94ceb6d2e7e54a7aeec821849452159 /Mk/Scripts/cargo-crates-git-fetch.awk
parentlang/rust: Update to 1.56.0 (diff)
Uses/cargo: Rework git source support based on patch-in-config sections
Git sources from `Cargo.lock` are added to `CARGO_CRATES` through the normal mechanism of `make cargo-crates` by the porter. They are used to populate `MASTER_SITES`, `DISTFILES` with static git-archive(1) tarballs a la `USE_GITHUB`, `USE_GITLAB`. In the configure phase we generate `[patch]` sections in the config file which will cause `cargo update` to auto-update `Cargo.lock` to point to the appropriate extraction directories. Normally `cargo update` would connect to the network to update all Git sources but since rust-1.55.0 our cargo has been patched to skip this when `CARGO_FREEBSD_PORTS_SKIP_GIT_UPDATE` is set in the environment. This replaces the old `CARGO_USE_GITHUB`, `CARGO_USE_GITLAB` hacks where this was done by editing all `Cargo.toml` with sed(1) calls. Additionally, we try to automatically infer the individiual crate sub-directories inside the Git sources based on `package.name` in `Cargo.toml` to remove the need for `CARGO_GIT_SUBDIR`. USES=cargo also now sets `WRKSRC_crate_$name` for each crate to point to the crate extraction directories. PR: 256581 Reviewed by: jbeich
Diffstat (limited to 'Mk/Scripts/cargo-crates-git-fetch.awk')
-rw-r--r--Mk/Scripts/cargo-crates-git-fetch.awk20
1 files changed, 20 insertions, 0 deletions
diff --git a/Mk/Scripts/cargo-crates-git-fetch.awk b/Mk/Scripts/cargo-crates-git-fetch.awk
new file mode 100644
index 000000000000..241b6d3b72f2
--- /dev/null
+++ b/Mk/Scripts/cargo-crates-git-fetch.awk
@@ -0,0 +1,20 @@
+# MAINTAINER: rust@FreeBSD.org
+#
+# Return (index, site, filename, wrksrc, crates) 5-tuples from git URL specs in CARGO_CRATES
+
+END {
+ split(GIT_SOURCES, git_sources)
+ for (i = 1; i <= length(git_sources); i++) {
+ git_source = git_sources[i]
+ j = index(git_source, "@")
+ if (j == 0) {
+ warn("invalid source: %s", git_source)
+ } else {
+ crate_source = substr(git_source, j + 1)
+ crates = substr(git_source, 0, j - 1)
+ if (split_git_url(git_info, crate_source)) {
+ printf("%d %s %s %s %s\n", group++, git_info["site"], git_info["filename"], git_info["dir"], crates)
+ }
+ }
+ }
+}