curl: update to 8.11.1
[oi-userland.git] / make-rules / cargo.mk
blobf430c13586f2c25b71aa67cc5400f14d0132db61
2 # This file and its contents are supplied under the terms of the
3 # Common Development and Distribution License ("CDDL"), version 1.0.
4 # You may only use this file in accordance with the terms of version
5 # 1.0 of the CDDL.
7 # A full copy of the text of the CDDL should have accompanied this
8 # source. A copy of the CDDL is also available via the Internet at
9 # http://www.illumos.org/license/CDDL.
13 # Copyright 2024 Marcel Telka
17 # cargo build style
19 # Cargo is the Rust package manager used to download, compile, and install Rust
20 # packages and their dependencies.
23 # Common Cargo home used as a cache for downloaded crates
24 CARGO_ARCHIVES ?= $(USERLAND_ARCHIVES)/.cargo
26 # The full path to the cargo binary. It lives in the rustc package.
27 CARGO = /usr/bin/cargo
28 USERLAND_REQUIRED_PACKAGES += developer/lang/rustc
30 # Fetch all dependencies and vendor them locally
31 CARGO_VENDOR_DIR = $(BUILD_DIR)/cargo-vendor
32 COMPONENT_PREP_ACTION += [ -f $(SOURCE_DIR)/Cargo.toml ] || exit 1 ;
33 COMPONENT_PREP_ACTION += $(ENV) CARGO_HOME=$(CARGO_ARCHIVES) \
34 $(CARGO) fetch --manifest-path $(SOURCE_DIR)/Cargo.toml || exit 1 ;
35 COMPONENT_PREP_ACTION += $(MKDIR) $(SOURCE_DIR)/.cargo ;
36 COMPONENT_PREP_ACTION += $(ENV) CARGO_HOME=$(CARGO_ARCHIVES) \
37 $(CARGO) vendor --manifest-path $(SOURCE_DIR)/Cargo.toml \
38 --versioned-dirs --offline $(CARGO_VENDOR_DIR) \
39 | $(TEE) $(SOURCE_DIR)/.cargo/config.toml ;
41 # Common cargo environment
42 CARGO_ENV += CARGO_HOME=$(@D)/.cargo
43 CARGO_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
45 # Configure
46 # Some tests fails with the default symlink cloney mode
47 CLONEY_MODE = copy
48 # this is needed to override the default set in shared-macros.mk
49 CONFIG_SHELL =
51 # Build
52 COMPONENT_BUILD_CMD = $(CARGO) build
53 COMPONENT_BUILD_ARGS += --release
54 COMPONENT_BUILD_ARGS += --offline
55 COMPONENT_BUILD_ENV += $(CARGO_ENV)
57 # https://www.illumos.org/issues/15767
58 LD_Z_IGNORE=
60 # Install
61 COMPONENT_INSTALL_CMD = $(CARGO) install
62 COMPONENT_INSTALL_ARGS += --path .
63 COMPONENT_INSTALL_ARGS += --root $(PROTOUSRDIR)
64 COMPONENT_INSTALL_ARGS += --force
65 COMPONENT_INSTALL_ARGS += --no-track
66 COMPONENT_INSTALL_ARGS += --offline
67 COMPONENT_INSTALL_ARGS += --locked
68 # this is needed to override the default set in shared-macros.mk
69 COMPONENT_INSTALL_TARGETS =
70 COMPONENT_INSTALL_ENV += $(CARGO_ENV)
72 # Test
73 COMPONENT_TEST_CMD = $(CARGO) test
74 COMPONENT_TEST_ARGS += --release
75 COMPONENT_TEST_ARGS += --offline
76 COMPONENT_TEST_TARGETS =
77 COMPONENT_TEST_ENV += $(CARGO_ENV)
79 # drop header
80 COMPONENT_TEST_TRANSFORMS += "-e '0,/Finished/d'"
81 # remove timing
82 COMPONENT_TEST_TRANSFORMS += "-e 's/\(finished\) in [0-9]\{1,\}\.[0-9]\{2\}s\$$/\1/g'"
83 # sort tests
84 COMPONENT_TEST_TRANSFORMS += "| ( while true ; do \
85 $(GSED) -u -e '/^running [0-9]\{1,\} tests\$$/q1' && break ; \
86 $(GSED) -u -e '/^\$$/Q' | $(SORT) ; \
87 echo "" ; \
88 done ) | $(COMPONENT_TEST_TRANSFORMER) -e ''"
90 # Cleanup
91 clean::
92 $(RM) -r $(SOURCE_DIR) $(BUILD_DIR)
94 # Use common rules
95 USE_COMMON_RULES = yes