blob: e5629293760b57ed0ee2ec5d58b12575aeeca646 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001# SPDX-License-Identifier: GPL-2.0-only
2#
3# Copyright (C) 2023 Luca Barbato and Donald Hoskins
4
5# Variables (all optional) to be set in package Makefiles:
6#
7# RUST_HOST_FEATURES - list of options, default empty
8#
9# Space or comma separated list of features to activate
10#
11# e.g. RUST_HOST_FEATURES:=enable-foo,with-bar
12
13ifeq ($(origin RUST_INCLUDE_DIR),undefined)
14 RUST_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
15endif
16include $(RUST_INCLUDE_DIR)/rust-values.mk
17
18CARGO_HOST_VARS= \
19 $(CARGO_HOST_CONFIG_VARS) \
20 CC=$(HOSTCC_NOCACHE) \
21 MAKEFLAGS="$(HOST_JOBS)"
22
23# $(1) path to the package (optional)
24# $(2) additional arguments to cargo (optional)
25define Host/Compile/Cargo
26 +$(CARGO_HOST_VARS) \
27 cargo install -v \
28 --profile $(CARGO_HOST_PROFILE) \
29 $(if $(RUST_HOST_FEATURES),--features "$(RUST_HOST_FEATURES)") \
30 --root $(HOST_INSTALL_DIR) \
31 --path "$(HOST_BUILD_DIR)/$(if $(strip $(1)),$(strip $(1)))" \
32 $(if $(filter --jobserver%,$(HOST_JOBS)),,-j1) \
33 $(2)
34endef
35
36define Host/Uninstall/Cargo
37 +$(CARGO_HOST_VARS) \
38 cargo uninstall -v \
39 --root $(HOST_INSTALL_DIR) \
40 || true
41endef
42
43define RustBinHostBuild
44 define Host/Install
45 $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/bin
46 $(INSTALL_BIN) $(HOST_INSTALL_DIR)/bin/* $(STAGING_DIR_HOSTPKG)/bin/
47 endef
48endef
49
50Host/Compile=$(call Host/Compile/Cargo)
51Host/Uninstall=$(call Host/Uninstall/Cargo)