separate generated env files between container and make uses

This commit is contained in:
Lance Vick 2023-06-08 05:37:19 -07:00
parent 3f14cf21ba
commit a8c0099576
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
2 changed files with 26 additions and 12 deletions

View File

@ -45,13 +45,23 @@ BIN_DIR := $(CACHE_DIR_ROOT)/bin
SRC_DIR := src SRC_DIR := src
KEY_DIR := keys KEY_DIR := keys
OUT_DIR := out OUT_DIR := out
export
docker = docker docker = docker
include $(CONFIG_DIR)/toolchain.env include $(CONFIG_DIR)/toolchain.env
export $(shell sed 's/=.*//' $(CONFIG_DIR)/toolchain.env) export $(shell sed 's/=.*//' $(CONFIG_DIR)/toolchain.env)
export
AUTOBUILD_TOOLCHAIN := true
ifeq ($(AUTOBUILD_TOOLCHAIN),true)
ifeq ("$(wildcard $(CACHE_DIR_ROOT)/make.env)","")
echo := $(info $(shell echo "Initializing toolchain."))
build_env := $(shell $(MAKE) AUTOBUILD_TOOLCHAIN=false toolchain )
endif
endif
ifneq (,$(wildcard $(CACHE_DIR_ROOT)/make.env))
include $(CACHE_DIR_ROOT)/make.env
export $(shell sed 's/=.*//' $(CACHE_DIR_ROOT)/make.env)
endif
## Use env vars from existing release if present ## Use env vars from existing release if present
ifneq (,$(wildcard $(DIST_DIR)/release.env)) ifneq (,$(wildcard $(DIST_DIR)/release.env))
@ -68,7 +78,8 @@ toolchain: \
$(BIN_DIR) \ $(BIN_DIR) \
$(OUT_DIR) \ $(OUT_DIR) \
$(CACHE_DIR_ROOT)/toolchain.state \ $(CACHE_DIR_ROOT)/toolchain.state \
$(CACHE_DIR_ROOT)/toolchain.env $(CACHE_DIR_ROOT)/container.env \
$(CACHE_DIR_ROOT)/make.env
# Launch a shell inside the toolchain container # Launch a shell inside the toolchain container
.PHONY: toolchain-shell .PHONY: toolchain-shell
@ -129,7 +140,7 @@ $(FETCH_DIR):
$(OUT_DIR): $(OUT_DIR):
mkdir -p $@ mkdir -p $@
$(CACHE_DIR_ROOT)/toolchain.env: \ $(CACHE_DIR_ROOT)/make.env $(CACHE_DIR_ROOT)/container.env: \
$(CACHE_DIR_ROOT)/toolchain.state $(CACHE_DIR_ROOT)/toolchain.state
env > $(CACHE_DIR)/bootstrap.env env > $(CACHE_DIR)/bootstrap.env
docker run \ docker run \
@ -141,7 +152,7 @@ $(CACHE_DIR_ROOT)/toolchain.env: \
--volume $(TOOLCHAIN_VOLUME) \ --volume $(TOOLCHAIN_VOLUME) \
--workdir $(TOOLCHAIN_WORKDIR) \ --workdir $(TOOLCHAIN_WORKDIR) \
$(shell cat cache/toolchain.state 2> /dev/null) \ $(shell cat cache/toolchain.state 2> /dev/null) \
$(SRC_DIR)/toolchain/scripts/environment > $@ $(SRC_DIR)/toolchain/scripts/environment $(CACHE_DIR_ROOT)
rm $(CACHE_DIR)/bootstrap.env rm $(CACHE_DIR)/bootstrap.env
$(CACHE_DIR_ROOT)/toolchain.tar: \ $(CACHE_DIR_ROOT)/toolchain.tar: \
@ -234,7 +245,7 @@ define toolchain
--cpus $(CPUS) \ --cpus $(CPUS) \
--volume $(TOOLCHAIN_VOLUME) \ --volume $(TOOLCHAIN_VOLUME) \
--workdir $(TOOLCHAIN_WORKDIR) \ --workdir $(TOOLCHAIN_WORKDIR) \
--env-file=$(CACHE_DIR_ROOT)/toolchain.env \ --env-file=$(CACHE_DIR_ROOT)/container.env \
$(shell cat cache/toolchain.state 2> /dev/null) \ $(shell cat cache/toolchain.state 2> /dev/null) \
$(SRC_DIR)/toolchain/scripts/host-env bash -c $(1) $(SRC_DIR)/toolchain/scripts/host-env bash -c $(1)
endef endef

View File

@ -1,11 +1,12 @@
#!/bin/sh #!/bin/sh
CACHE_DIR_ROOT=${1?}
HOME=/home/build HOME=/home/build
CONFIG_DIR=/home/build/config CONFIG_DIR=/home/build/config
cat ${CONFIG_DIR}/toolchain.env cat ${CONFIG_DIR}/toolchain.env > ${CACHE_DIR_ROOT}/container.env
cat <<- EOF cat <<- EOF >> ${CACHE_DIR_ROOT}/container.env
HOME=${HOME} HOME=${HOME}
PATH=${HOME}/${BIN_DIR}:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PATH=${HOME}/${BIN_DIR}:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
TZ=UTC TZ=UTC
@ -38,4 +39,6 @@ cat <<- EOF
FETCH_DIR=${HOME}/${FETCH_DIR} FETCH_DIR=${HOME}/${FETCH_DIR}
EOF EOF
envsubst < ${CONFIG_DIR}/global.env envsubst < ${CONFIG_DIR}/global.env > ${CACHE_DIR_ROOT}/make.env
cat ${CACHE_DIR_ROOT}/make.env >> ${CACHE_DIR_ROOT}/container.env