cmd/gogio: add -tags flag for supplying extra tags to the build

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-06-22 20:57:35 +02:00
parent 342c0da320
commit 5bd0ecea5e
5 changed files with 8 additions and 1 deletions
+1
View File
@@ -203,6 +203,7 @@ func compileAndroid(tmpDir string, tools *androidTools, bi *buildInfo) (err erro
"build", "build",
"-ldflags=-w -s "+bi.ldflags, "-ldflags=-w -s "+bi.ldflags,
"-buildmode=c-shared", "-buildmode=c-shared",
"-tags", bi.tags,
"-o", libFile, "-o", libFile,
bi.pkg, bi.pkg,
) )
+2
View File
@@ -34,6 +34,8 @@ and archive. Buildmode exe outputs an .ipa file for iOS or tvOS, an .apk file
for Android or a directory with the WebAssembly module and support files for for Android or a directory with the WebAssembly module and support files for
a browser. a browser.
The -ldflags and -tags flags pass extra linker flags and tags to the go tool.
As a special case for iOS or tvOS, specifying a path that ends with ".app" As a special case for iOS or tvOS, specifying a path that ends with ".app"
will output an app directory suitable for a simulator. will output an app directory suitable for a simulator.
+1 -1
View File
@@ -411,7 +411,7 @@ func archiveIOS(tmpDir, target, frameworkRoot string, bi *buildInfo) error {
"-ldflags=-s -w "+bi.ldflags, "-ldflags=-s -w "+bi.ldflags,
"-buildmode=c-archive", "-buildmode=c-archive",
"-o", lib, "-o", lib,
"-tags", "ios", "-tags", "ios "+bi.tags,
bi.pkg, bi.pkg,
) )
lipo.Args = append(lipo.Args, lib) lipo.Args = append(lipo.Args, lib)
+1
View File
@@ -22,6 +22,7 @@ func buildJS(bi *buildInfo) error {
"go", "go",
"build", "build",
"-ldflags="+bi.ldflags, "-ldflags="+bi.ldflags,
"-tags="+bi.tags,
"-o", filepath.Join(out, "main.wasm"), "-o", filepath.Join(out, "main.wasm"),
bi.pkg, bi.pkg,
) )
+3
View File
@@ -33,12 +33,14 @@ var (
keepWorkdir = flag.Bool("work", false, "print the name of the temporary work directory and do not delete it when exiting.") keepWorkdir = flag.Bool("work", false, "print the name of the temporary work directory and do not delete it when exiting.")
linkMode = flag.String("linkmode", "", "set the -linkmode flag of the go tool") linkMode = flag.String("linkmode", "", "set the -linkmode flag of the go tool")
extraLdflags = flag.String("ldflags", "", "extra flags to the Go linker") extraLdflags = flag.String("ldflags", "", "extra flags to the Go linker")
extraTags = flag.String("tags", "", "extra tags to the Go tool")
) )
type buildInfo struct { type buildInfo struct {
name string name string
pkg string pkg string
ldflags string ldflags string
tags string
target string target string
appID string appID string
version int version int
@@ -96,6 +98,7 @@ func mainErr() error {
dir: dir, dir: dir,
version: *version, version: *version,
minsdk: *minsdk, minsdk: *minsdk,
tags: *extraTags,
} }
if bi.appID == "" { if bi.appID == "" {
bi.appID = appIDFromPackage(pkgPath) bi.appID = appIDFromPackage(pkgPath)