Skip to content

Commit a98ab3b

Browse files
hajimehoshiandydotxyz
authored andcommitted
cmd/gomobile: enable Go modules at gomobile-build
This CL enables Go modules at gomobile-build command. This CL is a counterpart for the change gomobile-bind: https://golang.org/cl/210380 Updates golang/go#27234 Cherry picked from github.com/golang/mobile
1 parent 11c5287 commit a98ab3b

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

cmd/fyne/internal/mobile/build.go

+3-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"io"
1515
"os"
1616
"os/exec"
17-
"path"
1817
"regexp"
1918
"strings"
2019

@@ -97,7 +96,7 @@ func runBuildImpl(cmd *command) (*packages.Package, error) { cleanup, err := bui
9796
case 0:
9897
buildPath = "."
9998
case 1:
100-
buildPath = path.Clean(args[0])
99+
buildPath = args[0]
101100
default:
102101
cmd.usage()
103102
os.Exit(1)
@@ -126,10 +125,7 @@ func runBuildImpl(cmd *command) (*packages.Package, error) { cleanup, err := bui
126125
case "android":
127126
if pkg.Name != "main" {
128127
for _, arch := range targetArchs {
129-
env := androidEnv[arch]
130-
// gomobile-build does not support Go modules yet.
131-
env = append(env, "GO111MODULE=off")
132-
if err := goBuild(pkg.PkgPath, env); err != nil {
128+
if err := goBuild(pkg.PkgPath, androidEnv[arch]); err != nil {
133129
return nil, err
134130
}
135131
}
@@ -149,10 +145,7 @@ func runBuildImpl(cmd *command) (*packages.Package, error) { cleanup, err := bui
149145

150146
if pkg.Name != "main" {
151147
for _, arch := range targetArchs {
152-
env := darwinEnv[arch]
153-
// gomobile-build does not support Go modules yet.
154-
env = append(env, "GO111MODULE=off")
155-
if err := goBuild(pkg.PkgPath, env); err != nil {
148+
if err := goBuild(pkg.PkgPath, darwinEnv[arch]); err != nil {
156149
return nil, err
157150
}
158151
}

cmd/fyne/internal/mobile/build_androidapp.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ func goAndroidBuild(pkg *packages.Package, bundleID string, androidArchs []strin
6767
nmpkgs := make(map[string]map[string]bool) // map: arch -> extractPkgs' output
6868

6969
for _, arch := range androidArchs {
70-
env := androidEnv[arch]
71-
// gomobile-build does not support Go modules yet.
72-
env = append(env, "GO111MODULE=off")
7370
toolchain := ndk.Toolchain(arch)
7471
libPath := "lib/" + toolchain.abi + "/lib" + libName + ".so"
7572
libAbsPath := filepath.Join(tmpdir, libPath)
@@ -78,7 +75,7 @@ func goAndroidBuild(pkg *packages.Package, bundleID string, androidArchs []strin
7875
}
7976
err = goBuild(
8077
pkg.PkgPath,
81-
env,
78+
androidEnv[arch],
8279
"-buildmode=c-shared",
8380
"-o", libAbsPath,
8481
)

cmd/fyne/internal/mobile/build_iosapp.go

+1-4
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,7 @@ func goIOSBuild(pkg *packages.Package, bundleID string, archs []string, appName
6565
for _, arch := range archs {
6666
path := filepath.Join(tmpdir, arch)
6767
// Disable DWARF; see golang.org/issues/25148.
68-
env := darwinEnv[arch]
69-
// gomobile-build does not support Go modules yet.
70-
env = append(env, "GO111MODULE=off")
71-
if err := goBuild(src, env, "-ldflags=-w", "-o="+path); err != nil {
68+
if err := goBuild(src, darwinEnv[arch], "-ldflags=-w", "-o="+path); err != nil {
7269
return nil, err
7370
}
7471
if nmpkgs == nil {

0 commit comments

Comments
 (0)