Use CARGO_HOME on the host

This lets cargo's cache persist across builds, so there are fewer (often
zero) network pulls during the build process.
This commit is contained in:
Andrew Eikum 2022-03-03 11:21:32 -06:00 committed by Arkadiusz Hiler
parent ab06ba22a0
commit 14ffc4d0f7
2 changed files with 4 additions and 1 deletions

View File

@ -67,6 +67,9 @@ else
override DOCKER_OPTS := $(CCACHE_ENV) -e CCACHE_DISABLE=1 $(DOCKER_OPTS)
endif
export CARGO_HOME := $(if $(CARGO_HOME),$(CARGO_HOME),$(HOME)/.cargo)
override DOCKER_OPTS := -v $(CARGO_HOME):$(CARGO_HOME)$(CONTAINER_MOUNT_OPTS) -e CARGO_HOME=$(CARGO_HOME) $(DOCKER_OPTS)
ifneq ($(ROOTLESS_CONTAINER),1)
override DOCKER_OPTS := -e HOME -e USER -e USERID=$(shell id -u) -u $(shell id -u):$(shell id -g) $(DOCKER_OPTS)
endif
@ -113,6 +116,7 @@ J := $(shell nproc)
ifeq ($(ENABLE_CCACHE),1)
container-build: $(shell mkdir -p $(CCACHE_DIR))
endif
container-build: $(shell mkdir -p $(CARGO_HOME))
container-build: private SHELL := $(CONTAINER_SHELL)
container-build:
+$(MAKE) -j$(J) $(filter -j%,$(MAKEFLAGS)) -f $(firstword $(MAKEFILE_LIST)) $(MFLAGS) $(MAKEOVERRIDES) CONTAINER=1 $(CONTAINERGOALS)

View File

@ -113,7 +113,6 @@ $(2)_LIBFLAGS$(3) = $$(foreach d,$$($(2)_DEPS$(3)),-L$$($$(d)_LIBDIR$(3))) \
# native version doesn't exist.
$(2)_ENV$(3) = \
CARGO_HOME=$$(OBJ)/.cargo \
CARGO_TARGET_$$(call toupper,$$(CARGO_TARGET_$(3)))_LINKER="$$(TARGET_$(4)$(3))-gcc" \
CCACHE_BASEDIR="$$(CCACHE_BASEDIR)" \
STRIP="$$(STRIP)" \