This consolidates all environment variables for cargo into:
* CARGO_HOST_CONFIG_VARS / CARGO_PKG_CONFIG_VARS
These contain all cargo-specific environment variables, i.e. without
"common" variables like CC.
* CARGO_HOST_VARS / CARGO_PKG_VARS (renamed from CARGO_VARS)
These contain all environment variables to be passed to cargo.
This also:
* Set the CARGO_BUILD_TARGET environment variable instead of using the
--target command-line option
* Update Python include files to use CARGO_HOST_CONFIG_VARS /
CARGO_PKG_CONFIG_VARS
Signed-off-by: Jeffery To <[email protected]>
CFLAGS="$(HOST_CFLAGS)" \
CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib" \
- CARGO_HOME="$(CARGO_HOME)"
+ $(CARGO_HOST_CONFIG_VARS)
# $(1) => directory of python script
# $(2) => python script and its arguments
_python_sysroot="$(STAGING_DIR)" \
_python_prefix="/usr" \
_python_exec_prefix="/usr" \
- CARGO_BUILD_TARGET="$(RUSTC_TARGET_ARCH)" \
- CARGO_HOME="$(CARGO_HOME)" \
- PYO3_CROSS_LIB_DIR="$(PYTHON3_LIB_DIR)" \
- RUSTFLAGS="$(CARGO_RUSTFLAGS)"
+ $(CARGO_PKG_CONFIG_VARS) \
+ PYO3_CROSS_LIB_DIR="$(PYTHON3_LIB_DIR)"
# $(1) => directory of python script
# $(2) => python script and its arguments
endif
include $(RUST_INCLUDE_DIR)/rust-values.mk
+CARGO_HOST_VARS= \
+ $(CARGO_HOST_CONFIG_VARS) \
+ CC=$(HOSTCC_NOCACHE)
+
# $(1) path to the package (optional)
# $(2) additional arguments to cargo (optional)
define Host/Compile/Cargo
( \
cd $(HOST_BUILD_DIR) ; \
- CARGO_HOME=$(CARGO_HOME) \
- CC=$(HOSTCC_NOCACHE) \
+ $(CARGO_HOST_VARS) \
cargo install -v \
--profile $(CARGO_HOST_PROFILE) \
$(if $(RUST_HOST_FEATURES),--features "$(RUST_HOST_FEATURES)") \
define Host/Uninstall/Cargo
( \
cd $(HOST_BUILD_DIR) ; \
- CARGO_HOME=$(CARGO_HOME) \
- CC=$(HOSTCC_NOCACHE) \
+ $(CARGO_HOST_VARS) \
cargo uninstall -v \
--root $(HOST_INSTALL_DIR) || true ; \
)
endif
include $(RUST_INCLUDE_DIR)/rust-values.mk
+CARGO_PKG_VARS= \
+ $(CARGO_PKG_CONFIG_VARS) \
+ CC=$(HOSTCC_NOCACHE)
+
# $(1) path to the package (optional)
# $(2) additional arguments to cargo (optional)
define Build/Compile/Cargo
( \
cd $(PKG_BUILD_DIR) ; \
- CARGO_HOME=$(CARGO_HOME) \
- CARGO_PROFILE_RELEASE_OPT_LEVEL=s \
- CARGO_TARGET_$(subst -,_,$(call toupper,$(RUSTC_TARGET_ARCH)))_LINKER=$(TARGET_CC_NOCACHE) \
- TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUSTC_CFLAGS)" \
- TARGET_CC=$(TARGET_CC_NOCACHE) \
- CC=$(HOSTCC_NOCACHE) \
- RUSTFLAGS="$(CARGO_RUSTFLAGS)" \
- $(CARGO_VARS) \
+ $(CARGO_PKG_VARS) \
cargo install -v \
--profile $(CARGO_PKG_PROFILE) \
- --target $(RUSTC_TARGET_ARCH) \
$(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") \
--root $(PKG_INSTALL_DIR) \
--path "$(if $(strip $(1)),$(strip $(1)),.)" \
RUSTC_HOST_SUFFIX:=$(word 4, $(subst -, ,$(GNU_HOST_NAME)))
RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(RUSTC_HOST_SUFFIX)
CARGO_HOME:=$(DL_DIR)/cargo
-CARGO_VARS?=
ifeq ($(CONFIG_USE_MUSL),y)
# Force linking of the SSP library for musl
# Support only a subset for now.
RUST_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mipsel||mips64||mips64el||mipsel||powerpc64||riscv64||x86_64)
+CARGO_HOST_CONFIG_VARS= \
+ CARGO_HOME=$(CARGO_HOME)
+
CARGO_HOST_PROFILE:=release
+CARGO_PKG_CONFIG_VARS= \
+ CARGO_BUILD_TARGET=$(RUSTC_TARGET_ARCH) \
+ CARGO_HOME=$(CARGO_HOME) \
+ CARGO_PROFILE_RELEASE_OPT_LEVEL=s \
+ CARGO_TARGET_$(subst -,_,$(call toupper,$(RUSTC_TARGET_ARCH)))_LINKER=$(TARGET_CC_NOCACHE) \
+ RUSTFLAGS="$(CARGO_RUSTFLAGS)" \
+ TARGET_CC=$(TARGET_CC_NOCACHE) \
+ TARGET_CFLAGS="$(TARGET_CFLAGS) $(RUSTC_CFLAGS)"
+
CARGO_PKG_PROFILE:=$(if $(CONFIG_DEBUG),dev,release)
/etc/config/netavark
endef
-CARGO_VARS += \
+CARGO_PKG_VARS += \
PROTOC=$(STAGING_DIR_HOSTPKG)/bin/protoc
define Package/netavark/install