build: reduce build environment pollution

Instead of exporting various variables (unintendedly making them
available to the OpenWrt build, possibly bypassing .config), pass the
environment only to commands that need it.
This commit is contained in:
Matthias Schiffer 2020-03-07 13:47:59 +01:00 committed by Martin Weinelt
parent a180bb8689
commit 6155bf82c8

View File

@ -14,6 +14,8 @@ define mkabspath
override $(1) := $(abspath $($(1)))
endef
escape = '$(subst ','\'',$(1))'
GLUON_SITEDIR ?= site
$(eval $(call mkabspath,GLUON_SITEDIR))
@ -44,8 +46,13 @@ $(eval $(call mkabspath,GLUON_PATCHESDIR))
GLUON_MULTIDOMAIN ?= 0
GLUON_DEBUG ?= 0
export GLUON_RELEASE GLUON_REGION GLUON_MULTIDOMAIN GLUON_DEBUG GLUON_DEPRECATED GLUON_DEVICES \
GLUON_TARGETSDIR GLUON_PATCHESDIR GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR
GLUON_VARS = \
GLUON_RELEASE GLUON_REGION GLUON_MULTIDOMAIN GLUON_DEBUG GLUON_DEPRECATED GLUON_DEVICES \
GLUON_TARGETSDIR GLUON_PATCHESDIR GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR \
GLUON_SITEDIR GLUON_RELEASE GLUON_BRANCH GLUON_LANGS BOARD SUBTARGET
unexport $(GLUON_VARS)
GLUON_ENV = $(foreach var,$(GLUON_VARS),$(var)=$(call escape,$($(var))))
show-release:
@echo '$(GLUON_RELEASE)'
@ -53,18 +60,20 @@ show-release:
update: FORCE
@
GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update.sh
GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/patch.sh
GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/feeds.sh
export $(GLUON_ENV)
scripts/update.sh
scripts/patch.sh
scripts/feeds.sh
update-patches: FORCE
@
GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update.sh
GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/update-patches.sh
GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/patch.sh
export $(GLUON_ENV)
scripts/update.sh
scripts/update-patches.sh
scripts/patch.sh
update-feeds: FORCE
@GLUON_SITEDIR='$(GLUON_SITEDIR)' scripts/feeds.sh
@$(GLUON_ENV) scripts/feeds.sh
GLUON_TARGETS :=
@ -84,14 +93,6 @@ OPENWRTMAKE = $(MAKE) -C openwrt
BOARD := $(GLUON_TARGET_$(GLUON_TARGET)_BOARD)
SUBTARGET := $(GLUON_TARGET_$(GLUON_TARGET)_SUBTARGET)
GLUON_CONFIG_VARS := \
GLUON_SITEDIR='$(GLUON_SITEDIR)' \
GLUON_RELEASE='$(GLUON_RELEASE)' \
GLUON_BRANCH='$(GLUON_BRANCH)' \
GLUON_LANGS='$(GLUON_LANGS)' \
BOARD='$(BOARD)' \
SUBTARGET='$(SUBTARGET)'
define CheckTarget
if [ -z '$(BOARD)' ]; then
@ -177,21 +178,21 @@ config: $(LUA) FORCE
$(call CheckSite,$(conf)); \
)
$(GLUON_CONFIG_VARS) \
$(GLUON_ENV) \
$(LUA) scripts/target_config.lua '$(GLUON_TARGET)' '$(GLUON_DEFAULT_PACKAGES)' '$(GLUON_CLASS_PACKAGES_standard)' '$(GLUON_CLASS_PACKAGES_tiny)' \
> openwrt/.config
$(OPENWRTMAKE) defconfig
$(GLUON_CONFIG_VARS) \
$(GLUON_ENV) \
$(LUA) scripts/target_config_check.lua '$(GLUON_TARGET)' '$(GLUON_DEFAULT_PACKAGES)' '$(GLUON_CLASS_PACKAGES_standard)' '$(GLUON_CLASS_PACKAGES_tiny)'
all: config
+@
$(GLUON_CONFIG_VARS) \
$(GLUON_ENV) \
$(LUA) scripts/clean_output.lua
$(OPENWRTMAKE)
$(GLUON_CONFIG_VARS) \
$(GLUON_ENV) \
$(LUA) scripts/copy_output.lua '$(GLUON_TARGET)'
clean download: config
@ -210,12 +211,13 @@ manifest: $(LUA) FORCE
$(CheckExternal)
(
export $(GLUON_ENV)
echo 'BRANCH=$(GLUON_BRANCH)'
echo "DATE=$$($(LUA) scripts/rfc3339date.lua)"
echo 'PRIORITY=$(GLUON_PRIORITY)'
echo
for target in $(GLUON_TARGETS); do
GLUON_SITEDIR='$(GLUON_SITEDIR)' $(LUA) scripts/generate_manifest.lua "$$target"
$(LUA) scripts/generate_manifest.lua "$$target"
done
) > 'tmp/$(GLUON_BRANCH).manifest.tmp'