Skip to content

Commit

Permalink
cmd/gomobile: enable Go modules at gomobile-build
Browse files Browse the repository at this point in the history
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
  • Loading branch information
hajimehoshi authored and andydotxyz committed Mar 5, 2020
1 parent 11c5287 commit a98ab3b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
13 changes: 3 additions & 10 deletions cmd/fyne/internal/mobile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"io"
"os"
"os/exec"
"path"
"regexp"
"strings"

Expand Down Expand Up @@ -97,7 +96,7 @@ func runBuildImpl(cmd *command) (*packages.Package, error) { cleanup, err := bui
case 0:
buildPath = "."
case 1:
buildPath = path.Clean(args[0])
buildPath = args[0]
default:
cmd.usage()
os.Exit(1)
Expand Down Expand Up @@ -126,10 +125,7 @@ func runBuildImpl(cmd *command) (*packages.Package, error) { cleanup, err := bui
case "android":
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 {
if err := goBuild(pkg.PkgPath, androidEnv[arch]); err != nil {
return nil, err
}
}
Expand All @@ -149,10 +145,7 @@ 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 {
if err := goBuild(pkg.PkgPath, darwinEnv[arch]); err != nil {
return nil, err
}
}
Expand Down
5 changes: 1 addition & 4 deletions cmd/fyne/internal/mobile/build_androidapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ func goAndroidBuild(pkg *packages.Package, bundleID string, androidArchs []strin
nmpkgs := make(map[string]map[string]bool) // map: arch -> extractPkgs' output

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 All @@ -78,7 +75,7 @@ func goAndroidBuild(pkg *packages.Package, bundleID string, androidArchs []strin
}
err = goBuild(
pkg.PkgPath,
env,
androidEnv[arch],
"-buildmode=c-shared",
"-o", libAbsPath,
)
Expand Down
5 changes: 1 addition & 4 deletions cmd/fyne/internal/mobile/build_iosapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@ 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.
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 {
if err := goBuild(src, darwinEnv[arch], "-ldflags=-w", "-o="+path); err != nil {
return nil, err
}
if nmpkgs == nil {
Expand Down

0 comments on commit a98ab3b

Please sign in to comment.