Skip to content

Commit

Permalink
feat: added glflags
Browse files Browse the repository at this point in the history
Allows passing `-mod=mod` to `gomobile` to fix golang/go#67927.
  • Loading branch information
baizon authored and benma committed Jul 27, 2024
1 parent 1ad2df2 commit 0cc14f9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
5 changes: 3 additions & 2 deletions cmd/gomobile/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ classes.
The -v flag provides verbose output, including the list of packages built.
The build flags -a, -n, -x, -gcflags, -ldflags, -tags, -trimpath, and -work
The build flags -a, -n, -x, -gcflags, -ldflags, -tags, -glflags, -trimpath, and -work
are shared with the build command. For documentation, see 'go help build'.
`,
}
Expand Down Expand Up @@ -231,9 +231,10 @@ func getModuleVersions(targetPlatform string, targetArch string, src string) (*m
cmd.Env = append(os.Environ(), "GOOS="+platformOS(targetPlatform), "GOARCH="+targetArch)

tags := append(buildTags[:], platformTags(targetPlatform)...)
glflags := buildGoListFlags

// TODO(hyangah): probably we don't need to add all the dependencies.
cmd.Args = append(cmd.Args, "-m", "-json", "-tags="+strings.Join(tags, ","), "all")
cmd.Args = append(cmd.Args, glflags, "-m", "-json", "-tags="+strings.Join(tags, ","), "all")
cmd.Dir = src

output, err := cmd.Output()
Expand Down
32 changes: 17 additions & 15 deletions cmd/gomobile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,27 +233,29 @@ func printcmd(format string, args ...interface{}) {

// "Build flags", used by multiple commands.
var (
buildA bool // -a
buildI bool // -i
buildN bool // -n
buildV bool // -v
buildX bool // -x
buildO string // -o
buildGcflags string // -gcflags
buildLdflags string // -ldflags
buildTarget string // -target
buildTrimpath bool // -trimpath
buildWork bool // -work
buildBundleID string // -bundleid
buildIOSVersion string // -iosversion
buildAndroidAPI int // -androidapi
buildTags stringsFlag // -tags
buildA bool // -a
buildI bool // -i
buildN bool // -n
buildV bool // -v
buildX bool // -x
buildO string // -o
buildGcflags string // -gcflags
buildLdflags string // -ldflags
buildTarget string // -target
buildTrimpath bool // -trimpath
buildWork bool // -work
buildBundleID string // -bundleid
buildIOSVersion string // -iosversion
buildAndroidAPI int // -androidapi
buildTags stringsFlag // -tags
buildGoListFlags string // -glflags
)

func addBuildFlags(cmd *command) {
cmd.flag.StringVar(&buildO, "o", "", "")
cmd.flag.StringVar(&buildGcflags, "gcflags", "", "")
cmd.flag.StringVar(&buildLdflags, "ldflags", "", "")
cmd.flag.StringVar(&buildGoListFlags, "glflags", "", "")
cmd.flag.StringVar(&buildTarget, "target", "android", "")
cmd.flag.StringVar(&buildBundleID, "bundleid", "", "")
cmd.flag.StringVar(&buildIOSVersion, "iosversion", "13.0", "")
Expand Down

0 comments on commit 0cc14f9

Please sign in to comment.