separate generated env files between container and make uses
This commit is contained in:
parent
3f14cf21ba
commit
a8c0099576
25
Makefile
25
Makefile
|
@ -45,13 +45,23 @@ BIN_DIR := $(CACHE_DIR_ROOT)/bin
|
|||
SRC_DIR := src
|
||||
KEY_DIR := keys
|
||||
OUT_DIR := out
|
||||
|
||||
export
|
||||
|
||||
docker = docker
|
||||
|
||||
include $(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
|
||||
ifneq (,$(wildcard $(DIST_DIR)/release.env))
|
||||
|
@ -68,7 +78,8 @@ toolchain: \
|
|||
$(BIN_DIR) \
|
||||
$(OUT_DIR) \
|
||||
$(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
|
||||
.PHONY: toolchain-shell
|
||||
|
@ -129,7 +140,7 @@ $(FETCH_DIR):
|
|||
$(OUT_DIR):
|
||||
mkdir -p $@
|
||||
|
||||
$(CACHE_DIR_ROOT)/toolchain.env: \
|
||||
$(CACHE_DIR_ROOT)/make.env $(CACHE_DIR_ROOT)/container.env: \
|
||||
$(CACHE_DIR_ROOT)/toolchain.state
|
||||
env > $(CACHE_DIR)/bootstrap.env
|
||||
docker run \
|
||||
|
@ -141,7 +152,7 @@ $(CACHE_DIR_ROOT)/toolchain.env: \
|
|||
--volume $(TOOLCHAIN_VOLUME) \
|
||||
--workdir $(TOOLCHAIN_WORKDIR) \
|
||||
$(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
|
||||
|
||||
$(CACHE_DIR_ROOT)/toolchain.tar: \
|
||||
|
@ -234,7 +245,7 @@ define toolchain
|
|||
--cpus $(CPUS) \
|
||||
--volume $(TOOLCHAIN_VOLUME) \
|
||||
--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) \
|
||||
$(SRC_DIR)/toolchain/scripts/host-env bash -c $(1)
|
||||
endef
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
CACHE_DIR_ROOT=${1?}
|
||||
HOME=/home/build
|
||||
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}
|
||||
PATH=${HOME}/${BIN_DIR}:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
TZ=UTC
|
||||
|
@ -38,4 +39,6 @@ cat <<- EOF
|
|||
FETCH_DIR=${HOME}/${FETCH_DIR}
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue