Skip to content

Commit b269076

Browse files
hajimehoshiandydotxyz
authored andcommitted
cmd/gomobile: make gomobile-init support Go modules
Before this change, all the gomobile commands forced Go modules to be off internally, regardless of the current Go modules state. After this change, gomobile-init command follows the current Go modules state. The other gomobile commands are not changed. This is also a preparation to support Go modules in gomobile-bind and gomobile-build. Updates golang/go#27234 Cherry picked from github.com/golang/mobile
1 parent c1e4508 commit b269076

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

cmd/fyne/internal/mobile/build.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ func runBuildImpl(cmd *command) (*packages.Package, error) { cleanup, err := bui
127127
if pkg.Name != "main" {
128128
for _, arch := range targetArchs {
129129
env := androidEnv[arch]
130+
// gomobile-build does not support Go modules yet.
131+
env = append(env, "GO111MODULE=off")
130132
if err := goBuild(pkg.PkgPath, env); err != nil {
131133
return nil, err
132134
}
@@ -148,6 +150,8 @@ func runBuildImpl(cmd *command) (*packages.Package, error) { cleanup, err := bui
148150
if pkg.Name != "main" {
149151
for _, arch := range targetArchs {
150152
env := darwinEnv[arch]
153+
// gomobile-build does not support Go modules yet.
154+
env = append(env, "GO111MODULE=off")
151155
if err := goBuild(pkg.PkgPath, env); err != nil {
152156
return nil, err
153157
}
@@ -351,8 +355,6 @@ func goCmdAt(at string, subcmd string, srcs []string, env []string, args ...stri
351355
cmd.Args = append(cmd.Args, args...)
352356
cmd.Args = append(cmd.Args, srcs...)
353357
cmd.Env = append([]string{}, env...)
354-
// gomobile does not support modules yet.
355-
cmd.Env = append(cmd.Env, "GO111MODULE=off")
356358
cmd.Dir = at
357359
return runCmd(cmd)
358360
}

cmd/fyne/internal/mobile/build_androidapp.go

+2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ func goAndroidBuild(pkg *packages.Package, bundleID string, androidArchs []strin
6868

6969
for _, arch := range androidArchs {
7070
env := androidEnv[arch]
71+
// gomobile-build does not support Go modules yet.
72+
env = append(env, "GO111MODULE=off")
7173
toolchain := ndk.Toolchain(arch)
7274
libPath := "lib/" + toolchain.abi + "/lib" + libName + ".so"
7375
libAbsPath := filepath.Join(tmpdir, libPath)

cmd/fyne/internal/mobile/build_iosapp.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ 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-
if err := goBuild(src, darwinEnv[arch], "-ldflags=-w", "-o="+path); err != nil {
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 {
6972
return nil, err
7073
}
7174
if nmpkgs == nil {

0 commit comments

Comments
 (0)