rust: Consolidate cargo environment variables
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 <jeffery.to@gmail.com>
This commit is contained in:
parent
853c9c9e86
commit
9db7284d58
6 changed files with 27 additions and 20 deletions
|
@ -78,7 +78,7 @@ HOST_PYTHON3_VARS = \
|
||||||
CFLAGS="$(HOST_CFLAGS)" \
|
CFLAGS="$(HOST_CFLAGS)" \
|
||||||
CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
|
CPPFLAGS="$(HOST_CPPFLAGS) -I$(HOST_PYTHON3_INC_DIR)" \
|
||||||
LDFLAGS="$(HOST_LDFLAGS) -lpython$(PYTHON3_VERSION) -Wl$(comma)-rpath$(comma)$(STAGING_DIR_HOSTPKG)/lib" \
|
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
|
# $(1) => directory of python script
|
||||||
# $(2) => python script and its arguments
|
# $(2) => python script and its arguments
|
||||||
|
|
|
@ -45,10 +45,8 @@ PYTHON3_VARS = \
|
||||||
_python_sysroot="$(STAGING_DIR)" \
|
_python_sysroot="$(STAGING_DIR)" \
|
||||||
_python_prefix="/usr" \
|
_python_prefix="/usr" \
|
||||||
_python_exec_prefix="/usr" \
|
_python_exec_prefix="/usr" \
|
||||||
CARGO_BUILD_TARGET="$(RUSTC_TARGET_ARCH)" \
|
$(CARGO_PKG_CONFIG_VARS) \
|
||||||
CARGO_HOME="$(CARGO_HOME)" \
|
PYO3_CROSS_LIB_DIR="$(PYTHON3_LIB_DIR)"
|
||||||
PYO3_CROSS_LIB_DIR="$(PYTHON3_LIB_DIR)" \
|
|
||||||
RUSTFLAGS="$(CARGO_RUSTFLAGS)"
|
|
||||||
|
|
||||||
# $(1) => directory of python script
|
# $(1) => directory of python script
|
||||||
# $(2) => python script and its arguments
|
# $(2) => python script and its arguments
|
||||||
|
|
|
@ -15,13 +15,16 @@ ifeq ($(origin RUST_INCLUDE_DIR),undefined)
|
||||||
endif
|
endif
|
||||||
include $(RUST_INCLUDE_DIR)/rust-values.mk
|
include $(RUST_INCLUDE_DIR)/rust-values.mk
|
||||||
|
|
||||||
|
CARGO_HOST_VARS= \
|
||||||
|
$(CARGO_HOST_CONFIG_VARS) \
|
||||||
|
CC=$(HOSTCC_NOCACHE)
|
||||||
|
|
||||||
# $(1) path to the package (optional)
|
# $(1) path to the package (optional)
|
||||||
# $(2) additional arguments to cargo (optional)
|
# $(2) additional arguments to cargo (optional)
|
||||||
define Host/Compile/Cargo
|
define Host/Compile/Cargo
|
||||||
( \
|
( \
|
||||||
cd $(HOST_BUILD_DIR) ; \
|
cd $(HOST_BUILD_DIR) ; \
|
||||||
CARGO_HOME=$(CARGO_HOME) \
|
$(CARGO_HOST_VARS) \
|
||||||
CC=$(HOSTCC_NOCACHE) \
|
|
||||||
cargo install -v \
|
cargo install -v \
|
||||||
--profile $(CARGO_HOST_PROFILE) \
|
--profile $(CARGO_HOST_PROFILE) \
|
||||||
$(if $(RUST_HOST_FEATURES),--features "$(RUST_HOST_FEATURES)") \
|
$(if $(RUST_HOST_FEATURES),--features "$(RUST_HOST_FEATURES)") \
|
||||||
|
@ -33,8 +36,7 @@ endef
|
||||||
define Host/Uninstall/Cargo
|
define Host/Uninstall/Cargo
|
||||||
( \
|
( \
|
||||||
cd $(HOST_BUILD_DIR) ; \
|
cd $(HOST_BUILD_DIR) ; \
|
||||||
CARGO_HOME=$(CARGO_HOME) \
|
$(CARGO_HOST_VARS) \
|
||||||
CC=$(HOSTCC_NOCACHE) \
|
|
||||||
cargo uninstall -v \
|
cargo uninstall -v \
|
||||||
--root $(HOST_INSTALL_DIR) || true ; \
|
--root $(HOST_INSTALL_DIR) || true ; \
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,22 +15,18 @@ ifeq ($(origin RUST_INCLUDE_DIR),undefined)
|
||||||
endif
|
endif
|
||||||
include $(RUST_INCLUDE_DIR)/rust-values.mk
|
include $(RUST_INCLUDE_DIR)/rust-values.mk
|
||||||
|
|
||||||
|
CARGO_PKG_VARS= \
|
||||||
|
$(CARGO_PKG_CONFIG_VARS) \
|
||||||
|
CC=$(HOSTCC_NOCACHE)
|
||||||
|
|
||||||
# $(1) path to the package (optional)
|
# $(1) path to the package (optional)
|
||||||
# $(2) additional arguments to cargo (optional)
|
# $(2) additional arguments to cargo (optional)
|
||||||
define Build/Compile/Cargo
|
define Build/Compile/Cargo
|
||||||
( \
|
( \
|
||||||
cd $(PKG_BUILD_DIR) ; \
|
cd $(PKG_BUILD_DIR) ; \
|
||||||
CARGO_HOME=$(CARGO_HOME) \
|
$(CARGO_PKG_VARS) \
|
||||||
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 install -v \
|
cargo install -v \
|
||||||
--profile $(CARGO_PKG_PROFILE) \
|
--profile $(CARGO_PKG_PROFILE) \
|
||||||
--target $(RUSTC_TARGET_ARCH) \
|
|
||||||
$(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") \
|
$(if $(strip $(RUST_PKG_FEATURES)),--features "$(strip $(RUST_PKG_FEATURES))") \
|
||||||
--root $(PKG_INSTALL_DIR) \
|
--root $(PKG_INSTALL_DIR) \
|
||||||
--path "$(if $(strip $(1)),$(strip $(1)),.)" \
|
--path "$(if $(strip $(1)),$(strip $(1)),.)" \
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
RUSTC_HOST_SUFFIX:=$(word 4, $(subst -, ,$(GNU_HOST_NAME)))
|
RUSTC_HOST_SUFFIX:=$(word 4, $(subst -, ,$(GNU_HOST_NAME)))
|
||||||
RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(RUSTC_HOST_SUFFIX)
|
RUSTC_HOST_ARCH:=$(HOST_ARCH)-unknown-linux-$(RUSTC_HOST_SUFFIX)
|
||||||
CARGO_HOME:=$(DL_DIR)/cargo
|
CARGO_HOME:=$(DL_DIR)/cargo
|
||||||
CARGO_VARS?=
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_USE_MUSL),y)
|
ifeq ($(CONFIG_USE_MUSL),y)
|
||||||
# Force linking of the SSP library for musl
|
# Force linking of the SSP library for musl
|
||||||
|
@ -63,6 +62,18 @@ endif
|
||||||
# Support only a subset for now.
|
# Support only a subset for now.
|
||||||
RUST_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mipsel||mips64||mips64el||mipsel||powerpc64||riscv64||x86_64)
|
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_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)
|
CARGO_PKG_PROFILE:=$(if $(CONFIG_DEBUG),dev,release)
|
||||||
|
|
|
@ -36,7 +36,7 @@ define Package/netavark/conffiles
|
||||||
/etc/config/netavark
|
/etc/config/netavark
|
||||||
endef
|
endef
|
||||||
|
|
||||||
CARGO_VARS += \
|
CARGO_PKG_VARS += \
|
||||||
PROTOC=$(STAGING_DIR_HOSTPKG)/bin/protoc
|
PROTOC=$(STAGING_DIR_HOSTPKG)/bin/protoc
|
||||||
|
|
||||||
define Package/netavark/install
|
define Package/netavark/install
|
||||||
|
|
Loading…
Reference in a new issue