mirror of
https://github.com/openwrt/packages.git
synced 2025-01-31 01:22:13 +00:00
0dfc1b508d
This allows cargo to use make's jobserver when building packages, by marking the cargo command as recursive (with the + prefix[1]) and setting MAKEFLAGS. This also: * Give cargo/x.py the build directory instead of having to change the current directory (and opening subshells) * Set PKG_BUILD_PARALLEL/HOST_BUILD_PARALLEL for Rust packages to enable the use of make's jobserver [1]: https://www.gnu.org/software/make/manual/html_node/POSIX-Jobserver.html Signed-off-by: Jeffery To <jeffery.to@gmail.com>
46 lines
1.2 KiB
Makefile
46 lines
1.2 KiB
Makefile
# SPDX-License-Identifier: GPL-2.0-only
|
|
#
|
|
# Copyright (C) 2023 Luca Barbato and Donald Hoskins
|
|
|
|
# Variables (all optional) to be set in package Makefiles:
|
|
#
|
|
# RUST_PKG_FEATURES - list of options, default empty
|
|
#
|
|
# Space or comma separated list of features to activate
|
|
#
|
|
# e.g. RUST_PKG_FEATURES:=enable-foo,with-bar
|
|
|
|
ifeq ($(origin RUST_INCLUDE_DIR),undefined)
|
|
RUST_INCLUDE_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
|
|
endif
|
|
include $(RUST_INCLUDE_DIR)/rust-values.mk
|
|
|
|
CARGO_PKG_VARS= \
|
|
$(CARGO_PKG_CONFIG_VARS) \
|
|
CC=$(HOSTCC_NOCACHE) \
|
|
MAKEFLAGS="$(PKG_JOBS)"
|
|
|
|
# $(1) path to the package (optional)
|
|
# $(2) additional arguments to cargo (optional)
|
|
define Build/Compile/Cargo
|
|
+$(CARGO_PKG_VARS) \
|
|
cargo install -v \
|
|
--profile $(CARGO_PKG_PROFILE) \
|
|
$(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") \
|
|
--root $(PKG_INSTALL_DIR) \
|
|
--path "$(PKG_BUILD_DIR)/$(if $(strip $(1)),$(strip $(1)))" \
|
|
$(if $(filter --jobserver%,$(PKG_JOBS)),,-j1) \
|
|
$(2)
|
|
endef
|
|
|
|
define RustBinPackage
|
|
ifndef Package/$(1)/install
|
|
define Package/$(1)/install
|
|
$$(INSTALL_DIR) $$(1)/usr/bin/
|
|
$$(INSTALL_BIN) $$(PKG_INSTALL_DIR)/bin/* $$(1)/usr/bin/
|
|
endef
|
|
endif
|
|
endef
|
|
|
|
Build/Compile=$(call Build/Compile/Cargo)
|