golang: Allow additional arguments when compiling Go packages
authorJeffery To <jeffery.to@gmail.com>
Tue, 26 Jun 2018 19:05:11 +0000 (03:05 +0800)
committerJeffery To <jeffery.to@gmail.com>
Wed, 27 Jun 2018 18:51:09 +0000 (02:51 +0800)
This updates GoPackage/Build/Compile in golang-package.mk to accept
additional arguments that are passed to the go command line.

Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/golang/golang-package.mk

index a42bc64179650f17e032c0f5dcd47fe9006b388b..3c4aeab14f9b1b9dc5d26a13592d746f0764118d 100644 (file)
@@ -211,6 +211,7 @@ define GoPackage/Build/Configure
        )
 endef
 
+# $(1) additional arguments for go command line (optional)
 define GoPackage/Build/Compile
        ( \
                cd $(GO_PKG_BUILD_DIR) ; \
@@ -228,7 +229,7 @@ define GoPackage/Build/Compile
                done ; \
                \
                if [ "$(GO_PKG_GO_GENERATE)" = 1 ]; then \
-                       go generate -v $$$$targets ; \
+                       go generate -v $(1) $$$$targets ; \
                fi ; \
                \
                if [ "$(GO_PKG_SOURCE_ONLY)" != 1 ]; then \
@@ -238,7 +239,14 @@ define GoPackage/Build/Compile
                        esac ; \
                        trimpath="all=-trimpath=$(GO_PKG_BUILD_DIR)" ; \
                        ldflags="all=-linkmode external -extldflags '$(TARGET_LDFLAGS)'" ; \
-                       go install $$$$installsuffix -gcflags "$$$$trimpath" -asmflags "$$$$trimpath" -ldflags "$$$$ldflags" -v $$$$targets ; \
+                       go install \
+                               $$$$installsuffix \
+                               -gcflags "$$$$trimpath" \
+                               -asmflags "$$$$trimpath" \
+                               -ldflags "$$$$ldflags" \
+                               -v \
+                               $(1) \
+                               $$$$targets ; \
                        retval=$$$$? ; \
                        \
                        if [ "$$$$retval" -eq 0 ] && [ -z "$(call GoPackage/has_binaries)" ]; then \