Skip to content

Commit

Permalink
cmd/gomobile: make gomobile-init support Go modules
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hajimehoshi authored and andydotxyz committed Mar 5, 2020
1 parent c1e4508 commit b269076
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cmd/fyne/internal/mobile/build.go
Expand Up @@ -127,6 +127,8 @@ func runBuildImpl(cmd *command) (*packages.Package, error) { cleanup, err := bui
if pkg.Name != "main" {
for _, arch := range targetArchs {
env := androidEnv[arch]
// gomobile-build does not support Go modules yet.
env = append(env, "GO111MODULE=off")
if err := goBuild(pkg.PkgPath, env); err != nil {
return nil, err
}
Expand All @@ -148,6 +150,8 @@ func runBuildImpl(cmd *command) (*packages.Package, error) { cleanup, err := bui
if pkg.Name != "main" {
for _, arch := range targetArchs {
env := darwinEnv[arch]
// gomobile-build does not support Go modules yet.
env = append(env, "GO111MODULE=off")
if err := goBuild(pkg.PkgPath, env); err != nil {
return nil, err
}
Expand Down Expand Up @@ -351,8 +355,6 @@ func goCmdAt(at string, subcmd string, srcs []string, env []string, args ...stri
cmd.Args = append(cmd.Args, args...)
cmd.Args = append(cmd.Args, srcs...)
cmd.Env = append([]string{}, env...)
// gomobile does not support modules yet.
cmd.Env = append(cmd.Env, "GO111MODULE=off")
cmd.Dir = at
return runCmd(cmd)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/fyne/internal/mobile/build_androidapp.go
Expand Up @@ -68,6 +68,8 @@ func goAndroidBuild(pkg *packages.Package, bundleID string, androidArchs []strin

for _, arch := range androidArchs {
env := androidEnv[arch]
// gomobile-build does not support Go modules yet.
env = append(env, "GO111MODULE=off")
toolchain := ndk.Toolchain(arch)
libPath := "lib/" + toolchain.abi + "/lib" + libName + ".so"
libAbsPath := filepath.Join(tmpdir, libPath)
Expand Down
5 changes: 4 additions & 1 deletion cmd/fyne/internal/mobile/build_iosapp.go
Expand Up @@ -65,7 +65,10 @@ func goIOSBuild(pkg *packages.Package, bundleID string, archs []string, appName
for _, arch := range archs {
path := filepath.Join(tmpdir, arch)
// Disable DWARF; see golang.org/issues/25148.
if err := goBuild(src, darwinEnv[arch], "-ldflags=-w", "-o="+path); err != nil {
env := darwinEnv[arch]
// gomobile-build does not support Go modules yet.
env = append(env, "GO111MODULE=off")
if err := goBuild(src, env, "-ldflags=-w", "-o="+path); err != nil {
return nil, err
}
if nmpkgs == nil {
Expand Down

0 comments on commit b269076

Please sign in to comment.