| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: cargo.mk,v 1.30 2022/05/24 09:51:51 nia Exp $ | | 1 | # $NetBSD: cargo.mk,v 1.31 2022/12/15 21:47:46 jperkin Exp $ |
2 | # | | 2 | # |
3 | # Common logic that can be used by packages that depend on cargo crates | | 3 | # Common logic that can be used by packages that depend on cargo crates |
4 | # from crates.io. This lets existing pkgsrc infrastructure fetch and verify | | 4 | # from crates.io. This lets existing pkgsrc infrastructure fetch and verify |
5 | # cargo crates instead of using the rust package manager in the build phase. | | 5 | # cargo crates instead of using the rust package manager in the build phase. |
6 | # Inspired by cargo.mk from FreeBSD ports. | | 6 | # Inspired by cargo.mk from FreeBSD ports. |
7 | # | | 7 | # |
8 | # Usage example: | | 8 | # Usage example: |
9 | # | | 9 | # |
10 | # CARGO_CRATE_DEPENDS+= sha1-0.20 | | 10 | # CARGO_CRATE_DEPENDS+= sha1-0.20 |
11 | # .include "../../lang/rust/cargo.mk" | | 11 | # .include "../../lang/rust/cargo.mk" |
12 | # | | 12 | # |
13 | # If modifying the list of dependencies, re-run the build once without | | 13 | # If modifying the list of dependencies, re-run the build once without |
14 | # --offline in CARGO_ARGS to generate a new valid Cargo.lock. | | 14 | # --offline in CARGO_ARGS to generate a new valid Cargo.lock. |
| @@ -26,26 +26,29 @@ CHECK_SSP_SUPPORTED= no | | | @@ -26,26 +26,29 @@ CHECK_SSP_SUPPORTED= no |
26 | .include "../../lang/rust/rust.mk" | | 26 | .include "../../lang/rust/rust.mk" |
27 | | | 27 | |
28 | USE_TOOLS+= bsdtar | | 28 | USE_TOOLS+= bsdtar |
29 | CARGO_VENDOR_DIR= ${WRKDIR}/vendor | | 29 | CARGO_VENDOR_DIR= ${WRKDIR}/vendor |
30 | CARGO_WRKSRC?= ${WRKSRC} | | 30 | CARGO_WRKSRC?= ${WRKSRC} |
31 | | | 31 | |
32 | DISTFILES?= ${DEFAULT_DISTFILES} | | 32 | DISTFILES?= ${DEFAULT_DISTFILES} |
33 | .for crate in ${CARGO_CRATE_DEPENDS} | | 33 | .for crate in ${CARGO_CRATE_DEPENDS} |
34 | DISTFILES+= ${crate}.crate | | 34 | DISTFILES+= ${crate}.crate |
35 | SITES.${crate}.crate+= -${MASTER_SITE_CRATESIO}${crate:C/-[0-9]+\.[0-9.]+.*$//}/${crate:C/^.*-([0-9]+\.[0-9.]+.*)$/\1/}/download | | 35 | SITES.${crate}.crate+= -${MASTER_SITE_CRATESIO}${crate:C/-[0-9]+\.[0-9.]+.*$//}/${crate:C/^.*-([0-9]+\.[0-9.]+.*)$/\1/}/download |
36 | EXTRACT_DIR.${crate}.crate?= ${CARGO_VENDOR_DIR} | | 36 | EXTRACT_DIR.${crate}.crate?= ${CARGO_VENDOR_DIR} |
37 | .endfor | | 37 | .endfor |
38 | | | 38 | |
| | | 39 | # pkgsrc handles stripping and we might need to generate CTF data. |
| | | 40 | BUILDLINK_TRANSFORM.SunOS+= rm:-Wl,--strip-all |
| | | 41 | |
39 | .include "../../mk/bsd.prefs.mk" | | 42 | .include "../../mk/bsd.prefs.mk" |
40 | # Triggers NetBSD ld.so bug (PR toolchain/54192) | | 43 | # Triggers NetBSD ld.so bug (PR toolchain/54192) |
41 | # See Makefile for further information. | | 44 | # See Makefile for further information. |
42 | .if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 099957 | | 45 | .if ${OPSYS} == "NetBSD" && ${OPSYS_VERSION} < 099957 |
43 | MAKE_JOBS_SAFE= no | | 46 | MAKE_JOBS_SAFE= no |
44 | .endif | | 47 | .endif |
45 | | | 48 | |
46 | post-extract: cargo-vendor-crates | | 49 | post-extract: cargo-vendor-crates |
47 | .PHONY: cargo-vendor-crates | | 50 | .PHONY: cargo-vendor-crates |
48 | cargo-vendor-crates: | | 51 | cargo-vendor-crates: |
49 | @${STEP_MSG} "Extracting local cargo crates" | | 52 | @${STEP_MSG} "Extracting local cargo crates" |
50 | ${RUN}${MKDIR} ${CARGO_WRKSRC}/.cargo | | 53 | ${RUN}${MKDIR} ${CARGO_WRKSRC}/.cargo |
51 | ${RUN}${PRINTF} "[source.crates-io]\nreplace-with = \"vendored-sources\"\n[source.vendored-sources]\ndirectory = \"${CARGO_VENDOR_DIR}\"\n" > ${CARGO_WRKSRC}/.cargo/config | | 54 | ${RUN}${PRINTF} "[source.crates-io]\nreplace-with = \"vendored-sources\"\n[source.vendored-sources]\ndirectory = \"${CARGO_VENDOR_DIR}\"\n" > ${CARGO_WRKSRC}/.cargo/config |