git: 8fae936cf5a6 - main - Mk/Scripts/cargo-crates-git-configure.awk: Generate the patch.crates-io section after parsing all the Cargo.toml files
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 08 Oct 2023 16:41:20 UTC
The branch main has been updated by mikael: URL: https://cgit.FreeBSD.org/ports/commit/?id=8fae936cf5a65db050d6b0950a912a4f028e34d8 commit 8fae936cf5a65db050d6b0950a912a4f028e34d8 Author: Mikael Urankar <mikael@FreeBSD.org> AuthorDate: 2023-10-08 16:36:11 +0000 Commit: Mikael Urankar <mikael@FreeBSD.org> CommitDate: 2023-10-08 16:41:17 +0000 Mk/Scripts/cargo-crates-git-configure.awk: Generate the patch.crates-io section after parsing all the Cargo.toml files If we have multiple Cargo.toml files with the same crates in the [patch.crates-io] section we will end up with crates defined mutiple times and cargo will refuse to proceed. Write this section after parsing all the Cargo.toml files. PR: 273280 Reviewed by: tobik --- Mk/Scripts/cargo-crates-git-configure.awk | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/Mk/Scripts/cargo-crates-git-configure.awk b/Mk/Scripts/cargo-crates-git-configure.awk index ade8718e44f6..bb2884479d22 100644 --- a/Mk/Scripts/cargo-crates-git-configure.awk +++ b/Mk/Scripts/cargo-crates-git-configure.awk @@ -90,8 +90,8 @@ function find_replaced_crates(input, output, in_patch_crates_io, line, cols) { close(output) } -function add_crates_io_patches( header_printed, cmd, cargotoml, source, crates) { - header_printed = 0 +function add_crates_io_patches( print_header, local_crates, cmd, cargotoml, source, crates) { + print_header = 0 # --exclude-dir not supported on FreeBSD < 13 # cmd = GREP " --include='*/Cargo.toml' --exclude-dir='" CARGO_VENDOR_DIR "' -Flr 'patch.crates-io' " WRKSRC cmd = FIND " " WRKSRC " -name Cargo.toml -not -path '" CARGO_VENDOR_DIR "/*' -exec " GREP " -Flr 'patch.crates-io' {} \\\+" @@ -106,16 +106,20 @@ function add_crates_io_patches( header_printed, cmd, cargotoml, source, crates) split(source_crates[source], crates) for (j in crates) { if (replaced_crates[crates[j]]) { - if (!header_printed) { - printf("[patch.crates-io]\n") - header_printed = 1 - } - printf("%s = { path = '%s' }\n", crates[j], get_source_dir(source, crates[j])) + print_header = 1 + local_crates[crates[j]] = get_source_dir(source, crates[j]) } } } } } + if (print_header == 1) { + printf("[patch.crates-io]\n") + + for (i in local_crates) { + printf("%s = { path = '%s' }\n", i, local_crates[i]) + } + } close(cmd) }