golang: Quote variables passed to the shell

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
This commit is contained in:
Jeffery To 2020-08-29 02:07:34 +08:00
parent 7aaaa8ae64
commit 4773c288cd
No known key found for this signature in database
GPG key ID: C616D9E719E868E4
3 changed files with 104 additions and 104 deletions

View file

@ -24,8 +24,8 @@ endef
# $(4) additional environment variables (optional) # $(4) additional environment variables (optional)
define GoCompiler/Default/Make define GoCompiler/Default/Make
( \ ( \
cd $(1)/src ; \ cd "$(1)/src" ; \
$(if $(2),GOROOT_FINAL=$(2)/lib/go-$(3)) \ $(if $(2),GOROOT_FINAL="$(2)/lib/go-$(3)") \
$(4) \ $(4) \
$(BASH) make.bash --no-banner ; \ $(BASH) make.bash --no-banner ; \
) )
@ -34,8 +34,8 @@ endef
# $(1) destination prefix # $(1) destination prefix
# $(2) go version id # $(2) go version id
define GoCompiler/Default/Install/make-dirs define GoCompiler/Default/Install/make-dirs
$(INSTALL_DIR) $(1)/lib/go-$(2) $(INSTALL_DIR) "$(1)/lib/go-$(2)"
$(INSTALL_DIR) $(1)/share/go-$(2) $(INSTALL_DIR) "$(1)/share/go-$(2)"
endef endef
# $(1) source go root # $(1) source go root
@ -43,8 +43,8 @@ endef
# $(3) go version id # $(3) go version id
# $(4) file/directory name # $(4) file/directory name
define GoCompiler/Default/Install/install-share-data define GoCompiler/Default/Install/install-share-data
$(CP) $(1)/$(4) $(2)/share/go-$(3)/ $(CP) "$(1)/$(4)" "$(2)/share/go-$(3)/"
$(LN) ../../share/go-$(3)/$(4) $(2)/lib/go-$(3)/ $(LN) "../../share/go-$(3)/$(4)" "$(2)/lib/go-$(3)/"
endef endef
# $(1) source go root # $(1) source go root
@ -57,35 +57,35 @@ define GoCompiler/Default/Install/Bin
$(call GoCompiler/Default/Install/install-share-data,$(1),$(2),$(3),api) $(call GoCompiler/Default/Install/install-share-data,$(1),$(2),$(3),api)
$(INSTALL_DATA) -p $(1)/VERSION $(2)/lib/go-$(3)/ $(INSTALL_DATA) -p "$(1)/VERSION" "$(2)/lib/go-$(3)/"
for file in AUTHORS CONTRIBUTING.md CONTRIBUTORS LICENSE PATENTS README.md SECURITY.md; do \ for file in AUTHORS CONTRIBUTING.md CONTRIBUTORS LICENSE PATENTS README.md SECURITY.md; do \
if [ -f $(1)/$$$$file ]; then \ if [ -f "$(1)/$$$$file" ]; then \
$(INSTALL_DATA) -p $(1)/$$$$file $(2)/share/go-$(3)/ ; \ $(INSTALL_DATA) -p "$(1)/$$$$file" "$(2)/share/go-$(3)/" ; \
fi ; \ fi ; \
done done
$(INSTALL_DIR) $(2)/lib/go-$(3)/bin $(INSTALL_DIR) "$(2)/lib/go-$(3)/bin"
ifeq ($(4),$(GO_HOST_OS_ARCH)) ifeq ($(4),$(GO_HOST_OS_ARCH))
$(INSTALL_BIN) -p $(1)/bin/* $(2)/lib/go-$(3)/bin/ $(INSTALL_BIN) -p "$(1)/bin"/* "$(2)/lib/go-$(3)/bin/"
else else
$(INSTALL_BIN) -p $(1)/bin/$(4)/* $(2)/lib/go-$(3)/bin/ $(INSTALL_BIN) -p "$(1)/bin/$(4)"/* "$(2)/lib/go-$(3)/bin/"
endif endif
$(INSTALL_DIR) $(2)/lib/go-$(3)/pkg $(INSTALL_DIR) "$(2)/lib/go-$(3)/pkg"
$(CP) $(1)/pkg/$(4)$(if $(5),_$(5)) $(2)/lib/go-$(3)/pkg/ $(CP) "$(1)/pkg/$(4)$(if $(5),_$(5))" "$(2)/lib/go-$(3)/pkg/"
$(INSTALL_DIR) $(2)/lib/go-$(3)/pkg/tool/$(4) $(INSTALL_DIR) "$(2)/lib/go-$(3)/pkg/tool/$(4)"
$(INSTALL_BIN) -p $(1)/pkg/tool/$(4)/* $(2)/lib/go-$(3)/pkg/tool/$(4)/ $(INSTALL_BIN) -p "$(1)/pkg/tool/$(4)"/* "$(2)/lib/go-$(3)/pkg/tool/$(4)/"
endef endef
# $(1) destination prefix # $(1) destination prefix
# $(2) go version id # $(2) go version id
define GoCompiler/Default/Install/BinLinks define GoCompiler/Default/Install/BinLinks
$(INSTALL_DIR) $(1)/bin $(INSTALL_DIR) "$(1)/bin"
$(LN) ../lib/go-$(2)/bin/go $(1)/bin/go $(LN) "../lib/go-$(2)/bin/go" "$(1)/bin/go"
$(LN) ../lib/go-$(2)/bin/gofmt $(1)/bin/gofmt $(LN) "../lib/go-$(2)/bin/gofmt" "$(1)/bin/gofmt"
endef endef
# $(1) source go root # $(1) source go root
@ -111,29 +111,29 @@ define GoCompiler/Default/Install/Src
$(call GoCompiler/Default/Install/install-share-data,$(1),$(2),$(3),test) $(call GoCompiler/Default/Install/install-share-data,$(1),$(2),$(3),test)
$(FIND) \ $(FIND) \
$(2)/share/go-$(3)/src/ \ "$(2)/share/go-$(3)/src/" \
\! -type d -a \( -name '*.bat' -o -name '*.rc' \) \ \! -type d -a \( -name "*.bat" -o -name "*.rc" \) \
-delete -delete
if [ -d $(1)/pkg/include ]; then \ if [ -d "$(1)/pkg/include" ]; then \
$(INSTALL_DIR) $(2)/lib/go-$(3)/pkg ; \ $(INSTALL_DIR) "$(2)/lib/go-$(3)/pkg" ; \
$(INSTALL_DIR) $(2)/share/go-$(3)/pkg ; \ $(INSTALL_DIR) "$(2)/share/go-$(3)/pkg" ; \
$(CP) $(1)/pkg/include $(2)/share/go-$(3)/pkg/ ; \ $(CP) "$(1)/pkg/include" "$(2)/share/go-$(3)/pkg/" ; \
$(LN) ../../../share/go-$(3)/pkg/include $(2)/lib/go-$(3)/pkg/ ; \ $(LN) "../../../share/go-$(3)/pkg/include" "$(2)/lib/go-$(3)/pkg/" ; \
fi fi
endef endef
# $(1) destination prefix # $(1) destination prefix
# $(2) go version id # $(2) go version id
define GoCompiler/Default/Uninstall define GoCompiler/Default/Uninstall
rm -rf $(1)/lib/go-$(2) rm -rf "$(1)/lib/go-$(2)"
rm -rf $(1)/share/go-$(2) rm -rf "$(1)/share/go-$(2)"
endef endef
# $(1) destination prefix # $(1) destination prefix
define GoCompiler/Default/Uninstall/BinLinks define GoCompiler/Default/Uninstall/BinLinks
rm -f $(1)/bin/go rm -f "$(1)/bin/go"
rm -f $(1)/bin/gofmt rm -f "$(1)/bin/gofmt"
endef endef

View file

@ -165,24 +165,24 @@ define GoPackage/GoSubMenu
endef endef
GO_PKG_TARGET_VARS= \ GO_PKG_TARGET_VARS= \
GOOS=$(GO_OS) \ GOOS="$(GO_OS)" \
GOARCH=$(GO_ARCH) \ GOARCH="$(GO_ARCH)" \
GO386=$(GO_386) \ GO386="$(GO_386)" \
GOARM=$(GO_ARM) \ GOARM="$(GO_ARM)" \
GOMIPS=$(GO_MIPS) \ GOMIPS="$(GO_MIPS)" \
GOMIPS64=$(GO_MIPS64) \ GOMIPS64="$(GO_MIPS64)" \
CGO_ENABLED=1 \ CGO_ENABLED=1 \
CC=$(TARGET_CC) \ CC="$(TARGET_CC)" \
CXX=$(TARGET_CXX) \ CXX="$(TARGET_CXX)" \
CGO_CFLAGS="$(filter-out $(GO_CFLAGS_TO_REMOVE),$(TARGET_CFLAGS))" \ CGO_CFLAGS="$(filter-out $(GO_CFLAGS_TO_REMOVE),$(TARGET_CFLAGS))" \
CGO_CPPFLAGS="$(TARGET_CPPFLAGS)" \ CGO_CPPFLAGS="$(TARGET_CPPFLAGS)" \
CGO_CXXFLAGS="$(filter-out $(GO_CFLAGS_TO_REMOVE),$(TARGET_CXXFLAGS))" \ CGO_CXXFLAGS="$(filter-out $(GO_CFLAGS_TO_REMOVE),$(TARGET_CXXFLAGS))" \
CGO_LDFLAGS="$(TARGET_LDFLAGS)" CGO_LDFLAGS="$(TARGET_LDFLAGS)"
GO_PKG_BUILD_VARS= \ GO_PKG_BUILD_VARS= \
GOPATH=$(GO_PKG_BUILD_DIR) \ GOPATH="$(GO_PKG_BUILD_DIR)" \
GOCACHE=$(GO_BUILD_CACHE_DIR) \ GOCACHE="$(GO_BUILD_CACHE_DIR)" \
GOMODCACHE=$(GO_MOD_CACHE_DIR) \ GOMODCACHE="$(GO_MOD_CACHE_DIR)" \
GOENV=off GOENV=off
GO_PKG_DEFAULT_VARS= \ GO_PKG_DEFAULT_VARS= \
@ -213,77 +213,77 @@ GO_PKG_INSTALL_ARGS= \
$(if $(GO_PKG_TAGS),-tags "$(GO_PKG_TAGS)") $(if $(GO_PKG_TAGS),-tags "$(GO_PKG_TAGS)")
# false if directory does not exist # false if directory does not exist
GoPackage/is_dir_not_empty=$$$$($(FIND) $(1) -maxdepth 0 -type d \! -empty 2>/dev/null) GoPackage/is_dir_not_empty=$$$$($(FIND) "$(1)" -maxdepth 0 -type d \! -empty 2>/dev/null)
GoPackage/has_binaries=$(call GoPackage/is_dir_not_empty,$(GO_PKG_BUILD_BIN_DIR)) GoPackage/has_binaries=$(call GoPackage/is_dir_not_empty,$(GO_PKG_BUILD_BIN_DIR))
define GoPackage/Build/Configure define GoPackage/Build/Configure
( \ ( \
cd $(PKG_BUILD_DIR) ; \ cd "$(PKG_BUILD_DIR)" ; \
mkdir -p \ mkdir -p \
$(GO_PKG_BUILD_DIR)/bin $(GO_PKG_BUILD_DIR)/src \ "$(GO_PKG_BUILD_DIR)/bin" "$(GO_PKG_BUILD_DIR)/src" \
$(GO_BUILD_CACHE_DIR) $(GO_MOD_CACHE_DIR) ; \ "$(GO_BUILD_CACHE_DIR)" "$(GO_MOD_CACHE_DIR)" ; \
\ \
files=$$$$($(FIND) ./ \ files="$$$$($(FIND) ./ \
-type d -a \( -path './.git' -o -path './$(GO_PKG_WORK_DIR_NAME)' \) -prune -o \ -type d -a \( -path "./.git" -o -path "./$(GO_PKG_WORK_DIR_NAME)" \) -prune -o \
\! -type d -print | \ \! -type d -print | \
sed 's|^\./||') ; \ sed 's|^\./||')" ; \
\ \
if [ "$(strip $(GO_PKG_INSTALL_ALL))" != 1 ]; then \ if [ "$(strip $(GO_PKG_INSTALL_ALL))" != 1 ]; then \
code=$$$$(echo "$$$$files" | grep '\.\(c\|cc\|cpp\|go\|h\|hh\|hpp\|proto\|s\)$$$$') ; \ code="$$$$(echo "$$$$files" | grep '\.\(c\|cc\|cpp\|go\|h\|hh\|hpp\|proto\|s\)$$$$')" ; \
testdata=$$$$(echo "$$$$files" | grep '\(^\|/\)testdata/') ; \ testdata="$$$$(echo "$$$$files" | grep '\(^\|/\)testdata/')" ; \
gomod=$$$$(echo "$$$$files" | grep '\(^\|/\)go\.\(mod\|sum\)$$$$') ; \ gomod="$$$$(echo "$$$$files" | grep '\(^\|/\)go\.\(mod\|sum\)$$$$')" ; \
\ \
for pattern in $(GO_PKG_INSTALL_EXTRA); do \ for pattern in $(GO_PKG_INSTALL_EXTRA); do \
extra=$$$$(echo "$$$$extra"; echo "$$$$files" | grep "$$$$pattern") ; \ extra="$$$$(echo "$$$$extra"; echo "$$$$files" | grep "$$$$pattern")" ; \
done ; \ done ; \
\ \
files=$$$$(echo "$$$$code"; echo "$$$$testdata"; echo "$$$$gomod"; echo "$$$$extra") ; \ files="$$$$(echo "$$$$code"; echo "$$$$testdata"; echo "$$$$gomod"; echo "$$$$extra")" ; \
files=$$$$(echo "$$$$files" | grep -v '^[[:space:]]*$$$$' | sort -u) ; \ files="$$$$(echo "$$$$files" | grep -v '^[[:space:]]*$$$$' | sort -u)" ; \
fi ; \ fi ; \
\ \
IFS=$$$$'\n' ; \ IFS=$$$$'\n' ; \
\ \
echo "Copying files from $(PKG_BUILD_DIR) into $(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG))" ; \ echo "Copying files from $(PKG_BUILD_DIR) into $(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG))" ; \
for file in $$$$files; do \ for file in $$$$files; do \
echo $$$$file ; \ echo "$$$$file" ; \
dest=$(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG))/$$$$file ; \ dest="$(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG))/$$$$file" ; \
mkdir -p $$$$(dirname $$$$dest) ; \ mkdir -p "$$$$(dirname "$$$$dest")" ; \
$(CP) $$$$file $$$$dest ; \ $(CP) "$$$$file" "$$$$dest" ; \
done ; \ done ; \
echo ; \ echo ; \
\ \
link_contents() { \ link_contents() { \
local src=$$$$1 ; \ local src="$$$$1" ; \
local dest=$$$$2 ; \ local dest="$$$$2" ; \
local dirs dir base ; \ local dirs dir base ; \
\ \
if [ -n "$$$$($(FIND) $$$$src -mindepth 1 -maxdepth 1 -name '*.go' \! -type d)" ]; then \ if [ -n "$$$$($(FIND) "$$$$src" -mindepth 1 -maxdepth 1 -name "*.go" \! -type d)" ]; then \
echo "$$$$src is already a Go library" ; \ echo "$$$$src is already a Go library" ; \
return 1 ; \ return 1 ; \
fi ; \ fi ; \
\ \
dirs=$$$$($(FIND) $$$$src -mindepth 1 -maxdepth 1 -type d) ; \ dirs="$$$$($(FIND) "$$$$src" -mindepth 1 -maxdepth 1 -type d)" ; \
for dir in $$$$dirs; do \ for dir in $$$$dirs; do \
base=$$$$(basename $$$$dir) ; \ base="$$$$(basename "$$$$dir")" ; \
if [ -d $$$$dest/$$$$base ]; then \ if [ -d "$$$$dest/$$$$base" ]; then \
case $$$$dir in \ case "$$$$dir" in \
*$(GO_PKG_PATH)/src/$(strip $(GO_PKG))) \ *$(GO_PKG_PATH)/src/$(strip $(GO_PKG))) \
echo "$(strip $(GO_PKG)) is already installed. Please check for circular dependencies." ;; \ echo "$(strip $(GO_PKG)) is already installed. Please check for circular dependencies." ;; \
*) \ *) \
link_contents $$$$src/$$$$base $$$$dest/$$$$base ;; \ link_contents "$$$$src/$$$$base" "$$$$dest/$$$$base" ;; \
esac ; \ esac ; \
else \ else \
echo "...$$$${src#$(GO_PKG_BUILD_DEPENDS_SRC)}/$$$$base" ; \ echo "...$$$${src#$(GO_PKG_BUILD_DEPENDS_SRC)}/$$$$base" ; \
$(LN) $$$$src/$$$$base $$$$dest/$$$$base ; \ $(LN) "$$$$src/$$$$base" "$$$$dest/$$$$base" ; \
fi ; \ fi ; \
done ; \ done ; \
} ; \ } ; \
\ \
if [ "$(strip $(GO_PKG_SOURCE_ONLY))" != 1 ]; then \ if [ "$(strip $(GO_PKG_SOURCE_ONLY))" != 1 ]; then \
if [ -d $(GO_PKG_BUILD_DEPENDS_SRC) ]; then \ if [ -d "$(GO_PKG_BUILD_DEPENDS_SRC)" ]; then \
echo "Symlinking directories from $(GO_PKG_BUILD_DEPENDS_SRC) into $(GO_PKG_BUILD_DIR)/src" ; \ echo "Symlinking directories from $(GO_PKG_BUILD_DEPENDS_SRC) into $(GO_PKG_BUILD_DIR)/src" ; \
link_contents $(GO_PKG_BUILD_DEPENDS_SRC) $(GO_PKG_BUILD_DIR)/src ; \ link_contents "$(GO_PKG_BUILD_DEPENDS_SRC)" "$(GO_PKG_BUILD_DIR)/src" ; \
else \ else \
echo "$(GO_PKG_BUILD_DEPENDS_SRC) does not exist, skipping symlinks" ; \ echo "$(GO_PKG_BUILD_DEPENDS_SRC) does not exist, skipping symlinks" ; \
fi ; \ fi ; \
@ -297,16 +297,16 @@ endef
# $(1) additional arguments for go command line (optional) # $(1) additional arguments for go command line (optional)
define GoPackage/Build/Compile define GoPackage/Build/Compile
( \ ( \
cd $(GO_PKG_BUILD_DIR) ; \ cd "$(GO_PKG_BUILD_DIR)" ; \
export $(GO_PKG_VARS) ; \ export $(GO_PKG_VARS) ; \
if [ -f "$(PKG_BUILD_DIR)/go.mod" ] ; then \ if [ -f "$(PKG_BUILD_DIR)/go.mod" ] ; then \
modargs="$(GO_MOD_ARGS)" ; \ modargs="$(GO_MOD_ARGS)" ; \
fi ; \ fi ; \
\ \
echo "Finding targets" ; \ echo "Finding targets" ; \
targets=$$$$(go list $$$$modargs $(GO_PKG_BUILD_PKG)) ; \ targets="$$$$(go list $$$$modargs $(GO_PKG_BUILD_PKG))" ; \
for pattern in $(GO_PKG_EXCLUDES); do \ for pattern in $(GO_PKG_EXCLUDES); do \
targets=$$$$(echo "$$$$targets" | grep -v "$$$$pattern") ; \ targets="$$$$(echo "$$$$targets" | grep -v "$$$$pattern")" ; \
done ; \ done ; \
echo ; \ echo ; \
\ \
@ -319,7 +319,7 @@ define GoPackage/Build/Compile
if [ "$(strip $(GO_PKG_SOURCE_ONLY))" != 1 ]; then \ if [ "$(strip $(GO_PKG_SOURCE_ONLY))" != 1 ]; then \
echo "Building targets" ; \ echo "Building targets" ; \
go install $(GO_PKG_INSTALL_ARGS) $$$$modargs $(1) $$$$targets ; \ go install $(GO_PKG_INSTALL_ARGS) $$$$modargs $(1) $$$$targets ; \
retval=$$$$? ; \ retval="$$$$?" ; \
echo ; \ echo ; \
\ \
if [ "$$$$retval" -eq 0 ] && [ -z "$(call GoPackage/has_binaries)" ]; then \ if [ "$$$$retval" -eq 0 ] && [ -z "$(call GoPackage/has_binaries)" ]; then \
@ -331,7 +331,7 @@ define GoPackage/Build/Compile
$(call Go/CacheCleanup) ; \ $(call Go/CacheCleanup) ; \
fi ; \ fi ; \
fi ; \ fi ; \
exit $$$$retval ; \ exit "$$$$retval" ; \
) )
endef endef
@ -341,15 +341,15 @@ endef
define GoPackage/Package/Install/Bin define GoPackage/Package/Install/Bin
if [ -n "$(call GoPackage/has_binaries)" ]; then \ if [ -n "$(call GoPackage/has_binaries)" ]; then \
$(INSTALL_DIR) $(1)/usr/bin ; \ $(INSTALL_DIR) "$(1)/usr/bin" ; \
$(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/* $(1)/usr/bin/ ; \ $(INSTALL_BIN) "$(GO_PKG_BUILD_BIN_DIR)"/* "$(1)/usr/bin/" ; \
fi fi
endef endef
define GoPackage/Package/Install/Src define GoPackage/Package/Install/Src
dir=$$$$(dirname $(GO_PKG)) ; \ dir="$$$$(dirname "$(GO_PKG)")" ; \
$(INSTALL_DIR) $(1)$(GO_PKG_PATH)/src/$$$$dir ; \ $(INSTALL_DIR) "$(1)$(GO_PKG_PATH)/src/$$$$dir" ; \
$(CP) $(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG)) $(1)$(GO_PKG_PATH)/src/$$$$dir/ $(CP) "$(GO_PKG_BUILD_DIR)/src/$(strip $(GO_PKG))" "$(1)$(GO_PKG_PATH)/src/$$$$dir/"
endef endef
define GoPackage/Package/Install define GoPackage/Package/Install

View file

@ -88,9 +88,9 @@ include $(INCLUDE_DIR)/package.mk
include ../golang-compiler.mk include ../golang-compiler.mk
include ../golang-package.mk include ../golang-package.mk
PKG_UNPACK:=$(HOST_TAR) -C $(PKG_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE) PKG_UNPACK:=$(HOST_TAR) -C "$(PKG_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(PKG_SOURCE)"
HOST_UNPACK:=$(HOST_TAR) -C $(HOST_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(PKG_SOURCE) HOST_UNPACK:=$(HOST_TAR) -C "$(HOST_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(PKG_SOURCE)"
BOOTSTRAP_UNPACK:=$(HOST_TAR) -C $(BOOTSTRAP_BUILD_DIR) --strip-components=1 -xzf $(DL_DIR)/$(BOOTSTRAP_SOURCE) BOOTSTRAP_UNPACK:=$(HOST_TAR) -C "$(BOOTSTRAP_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(BOOTSTRAP_SOURCE)"
# don't strip ELF executables in test data # don't strip ELF executables in test data
RSTRIP:=: RSTRIP:=:
@ -174,7 +174,7 @@ ifeq ($(BOOTSTRAP_ROOT_DIR),)
$(eval $(call Download,golang-bootstrap)) $(eval $(call Download,golang-bootstrap))
define Bootstrap/Prepare define Bootstrap/Prepare
mkdir -p $(BOOTSTRAP_BUILD_DIR) mkdir -p "$(BOOTSTRAP_BUILD_DIR)"
$(BOOTSTRAP_UNPACK) $(BOOTSTRAP_UNPACK)
endef endef
Hooks/HostPrepare/Post+=Bootstrap/Prepare Hooks/HostPrepare/Post+=Bootstrap/Prepare
@ -195,23 +195,23 @@ endif
$(eval $(call GoCompiler/AddProfile,Host,$(HOST_BUILD_DIR),$(HOST_GO_PREFIX),$(HOST_GO_VERSION_ID),$(GO_HOST_OS_ARCH),$(HOST_GO_INSTALL_SUFFIX))) $(eval $(call GoCompiler/AddProfile,Host,$(HOST_BUILD_DIR),$(HOST_GO_PREFIX),$(HOST_GO_VERSION_ID),$(GO_HOST_OS_ARCH),$(HOST_GO_INSTALL_SUFFIX)))
HOST_GO_VARS= \ HOST_GO_VARS= \
GOCACHE=$(GO_BUILD_CACHE_DIR) \ GOCACHE="$(GO_BUILD_CACHE_DIR)" \
GOENV=off \ GOENV=off \
CC=$(HOSTCC_NOCACHE) \ CC="$(HOSTCC_NOCACHE)" \
CXX=$(HOSTCXX_NOCACHE) CXX="$(HOSTCXX_NOCACHE)"
define Host/Compile define Host/Compile
$(call GoCompiler/Bootstrap/CheckHost,$(BOOTSTRAP_GO_VALID_OS_ARCH)) $(call GoCompiler/Bootstrap/CheckHost,$(BOOTSTRAP_GO_VALID_OS_ARCH))
$(call GoCompiler/Host/CheckHost,$(HOST_GO_VALID_OS_ARCH)) $(call GoCompiler/Host/CheckHost,$(HOST_GO_VALID_OS_ARCH))
mkdir -p $(GO_BUILD_CACHE_DIR) mkdir -p "$(GO_BUILD_CACHE_DIR)"
$(call GoCompiler/Bootstrap/Make, \ $(call GoCompiler/Bootstrap/Make, \
$(HOST_GO_VARS) \ $(HOST_GO_VARS) \
) )
$(call GoCompiler/Host/Make, \ $(call GoCompiler/Host/Make, \
GOROOT_BOOTSTRAP=$(BOOTSTRAP_ROOT_DIR) \ GOROOT_BOOTSTRAP="$(BOOTSTRAP_ROOT_DIR)" \
$(if $(HOST_GO_ENABLE_PIE),GO_LDFLAGS="-buildmode pie") \ $(if $(HOST_GO_ENABLE_PIE),GO_LDFLAGS="-buildmode pie") \
$(HOST_GO_VARS) \ $(HOST_GO_VARS) \
) )
@ -228,16 +228,16 @@ define Host/Install
$(call GoCompiler/Host/Install/BinLinks,) $(call GoCompiler/Host/Install/BinLinks,)
rm -rf $(HOST_GO_ROOT)/pkg/$(GO_HOST_OS_ARCH)$(if $(HOST_GO_INSTALL_SUFFIX),_$(HOST_GO_INSTALL_SUFFIX)) rm -rf "$(HOST_GO_ROOT)/pkg/$(GO_HOST_OS_ARCH)$(if $(HOST_GO_INSTALL_SUFFIX),_$(HOST_GO_INSTALL_SUFFIX))"
$(INSTALL_DIR) $(HOST_GO_ROOT)/openwrt $(INSTALL_DIR) "$(HOST_GO_ROOT)/openwrt"
$(INSTALL_BIN) ./files/go-gcc-helper $(HOST_GO_ROOT)/openwrt/ $(INSTALL_BIN) ./files/go-gcc-helper "$(HOST_GO_ROOT)/openwrt/"
$(LN) go-gcc-helper $(HOST_GO_ROOT)/openwrt/gcc $(LN) go-gcc-helper "$(HOST_GO_ROOT)/openwrt/gcc"
$(LN) go-gcc-helper $(HOST_GO_ROOT)/openwrt/g++ $(LN) go-gcc-helper "$(HOST_GO_ROOT)/openwrt/g++"
endef endef
define Host/Uninstall define Host/Uninstall
rm -rf $(HOST_GO_ROOT)/openwrt rm -rf "$(HOST_GO_ROOT)/openwrt"
$(call GoCompiler/Host/Uninstall/BinLinks,) $(call GoCompiler/Host/Uninstall/BinLinks,)
@ -261,13 +261,13 @@ PKG_GO_ZBOOTSTRAP_MODS:= \
s/defaultGOPPC64 = `[^`]*`/defaultGOPPC64 = `power8`/; s/defaultGOPPC64 = `[^`]*`/defaultGOPPC64 = `power8`/;
PKG_GO_VARS= \ PKG_GO_VARS= \
GOCACHE=$(GO_BUILD_CACHE_DIR) \ GOCACHE="$(GO_BUILD_CACHE_DIR)" \
GOENV=off \ GOENV=off \
GO_GCC_HELPER_PATH=$$$$PATH \ GO_GCC_HELPER_PATH="$$$$PATH" \
CC=gcc \ CC=gcc \
CXX=g++ \ CXX=g++ \
PKG_CONFIG=pkg-config \ PKG_CONFIG=pkg-config \
PATH=$(HOST_GO_ROOT)/openwrt:$$$$PATH PATH="$(HOST_GO_ROOT)/openwrt:$$$$PATH"
PKG_GO_LDFLAGS= \ PKG_GO_LDFLAGS= \
-buildid '$(SOURCE_DATE_EPOCH)' \ -buildid '$(SOURCE_DATE_EPOCH)' \
@ -283,34 +283,34 @@ PKG_GO_INSTALL_ARGS= \
$(if $(filter $(GO_PKG_ENABLE_PIE),1),-buildmode pie) $(if $(filter $(GO_PKG_ENABLE_PIE),1),-buildmode pie)
define Build/Compile define Build/Compile
mkdir -p $(GO_BUILD_CACHE_DIR) mkdir -p "$(GO_BUILD_CACHE_DIR)"
@echo "Building target Go first stage" @echo "Building target Go first stage"
$(call GoCompiler/Package/Make, \ $(call GoCompiler/Package/Make, \
GOROOT_BOOTSTRAP=$(HOST_GO_ROOT) \ GOROOT_BOOTSTRAP="$(HOST_GO_ROOT)" \
GO_GCC_HELPER_CC="$(HOSTCC)" \ GO_GCC_HELPER_CC="$(HOSTCC)" \
GO_GCC_HELPER_CXX="$(HOSTCXX)" \ GO_GCC_HELPER_CXX="$(HOSTCXX)" \
$(PKG_GO_VARS) \ $(PKG_GO_VARS) \
) )
$(SED) '$(PKG_GO_ZBOOTSTRAP_MODS)' \ $(SED) '$(PKG_GO_ZBOOTSTRAP_MODS)' \
$(PKG_BUILD_DIR)/src/cmd/internal/objabi/zbootstrap.go "$(PKG_BUILD_DIR)/src/cmd/internal/objabi/zbootstrap.go"
@echo "Building target Go second stage" @echo "Building target Go second stage"
( \ ( \
cd $(PKG_BUILD_DIR)/bin ; \ cd "$(PKG_BUILD_DIR)/bin" ; \
export $(GO_PKG_TARGET_VARS) ; \ export $(GO_PKG_TARGET_VARS) ; \
$(CP) go go-host ; \ $(CP) go go-host ; \
GOROOT_FINAL=$(PKG_GO_ROOT) \ GOROOT_FINAL="$(PKG_GO_ROOT)" \
GO_GCC_HELPER_CC="$(TARGET_CC)" \ GO_GCC_HELPER_CC="$(TARGET_CC)" \
GO_GCC_HELPER_CXX="$(TARGET_CXX)" \ GO_GCC_HELPER_CXX="$(TARGET_CXX)" \
$(PKG_GO_VARS) \ $(PKG_GO_VARS) \
./go-host install -a $(PKG_GO_INSTALL_ARGS) std cmd ; \ ./go-host install -a $(PKG_GO_INSTALL_ARGS) std cmd ; \
retval=$$$$? ; \ retval="$$$$?" ; \
rm -f go-host ; \ rm -f go-host ; \
exit $$$$retval ; \ exit "$$$$retval" ; \
) )
endef endef