Gerrit Bot has uploaded this change for review.
cmd/gomobile: add a flag to manually specify a work dir
Added a flag to manually specify a work dir to avoid having to rebuild everything from scratch when using gomobile through go module.
Particularly useful in the context of a large project that takes several tens of minutes to build, especially when only one or two packages need to be recompiled.
Fixes https://github.com/golang/go/issues/37902
Change-Id: I23fb636fc6d5c0e6f9cb953a5795bad36a9cbda3
GitHub-Last-Rev: cf4536637fc0debdf5de56c4042ec5b9651d5cc9
GitHub-Pull-Request: golang/mobile#58
---
M cmd/gomobile/bind.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M cmd/gomobile/install.go
4 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/cmd/gomobile/bind.go b/cmd/gomobile/bind.go
index ef62d05..d2709b0 100644
--- a/cmd/gomobile/bind.go
+++ b/cmd/gomobile/bind.go
@@ -60,6 +60,9 @@
control the bootstrap classpath and the classpath for Go wrappers to Java
classes.
+The -cache flag specifies the build cache directory. If not specified,
+ioutil.TempDir() is used.
+
The -v flag provides verbose output, including the list of packages built.
The build flags -a, -n, -x, -gcflags, -ldflags, -tags, -trimpath, and -work
diff --git a/cmd/gomobile/build.go b/cmd/gomobile/build.go
index 4811ab7..163d2b3 100644
--- a/cmd/gomobile/build.go
+++ b/cmd/gomobile/build.go
@@ -58,6 +58,9 @@
The -o flag specifies the output file name. If not specified, the
output file name depends on the package built.
+The -cache flag specifies the build cache directory. If not specified,
+ioutil.TempDir() is used.
+
The -v flag provides verbose output, including the list of packages built.
The build flags -a, -i, -n, -x, -gcflags, -ldflags, -tags, -trimpath, and -work are
@@ -224,6 +227,7 @@
buildTarget string // -target
buildTrimpath bool // -trimpath
buildWork bool // -work
+ buildCache string // -cache
buildBundleID string // -bundleid
buildIOSVersion string // -iosversion
buildAndroidAPI int // -androidapi
@@ -245,11 +249,12 @@
cmd.flag.Var(&buildTags, "tags", "")
}
-func addBuildFlagsNVXWork(cmd *command) {
+func addBuildFlagsNVXWorkCache(cmd *command) {
cmd.flag.BoolVar(&buildN, "n", false, "")
cmd.flag.BoolVar(&buildV, "v", false, "")
cmd.flag.BoolVar(&buildX, "x", false, "")
cmd.flag.BoolVar(&buildWork, "work", false, "")
+ cmd.flag.StringVar(&buildCache, "cache", "", "")
}
type binInfo struct {
@@ -259,17 +264,17 @@
func init() {
addBuildFlags(cmdBuild)
- addBuildFlagsNVXWork(cmdBuild)
+ addBuildFlagsNVXWorkCache(cmdBuild)
addBuildFlags(cmdInstall)
- addBuildFlagsNVXWork(cmdInstall)
+ addBuildFlagsNVXWorkCache(cmdInstall)
- addBuildFlagsNVXWork(cmdInit)
+ addBuildFlagsNVXWorkCache(cmdInit)
addBuildFlags(cmdBind)
- addBuildFlagsNVXWork(cmdBind)
+ addBuildFlagsNVXWorkCache(cmdBind)
- addBuildFlagsNVXWork(cmdClean)
+ addBuildFlagsNVXWorkCache(cmdClean)
}
func goBuild(src string, env []string, args ...string) error {
diff --git a/cmd/gomobile/env.go b/cmd/gomobile/env.go
index 6dacc63..d81e499 100644
--- a/cmd/gomobile/env.go
+++ b/cmd/gomobile/env.go
@@ -61,11 +61,18 @@
fmt.Printf("WORK=%s\n", tmpdir)
return
}
- removeAll(tmpdir)
+ if buildCache == "" {
+ removeAll(tmpdir)
+ }
}
if buildN {
tmpdir = "$WORK"
cleanupFn = func() {}
+ } else if buildCache != "" {
+ tmpdir = buildCache
+ if err = os.MkdirAll(tmpdir, 0700); err != nil {
+ return nil, err
+ }
} else {
tmpdir, err = ioutil.TempDir("", "gomobile-work-")
if err != nil {
diff --git a/cmd/gomobile/install.go b/cmd/gomobile/install.go
index beb7e52..a1481a3 100644
--- a/cmd/gomobile/install.go
+++ b/cmd/gomobile/install.go
@@ -23,6 +23,9 @@
Only -target android is supported. The 'adb' tool must be on the PATH.
+The -cache flag specifies the build cache directory. If not specified,
+ioutil.TempDir() is used.
+
The build flags -a, -i, -n, -x, -gcflags, -ldflags, -tags, -trimpath, and -work are
shared with the build command.
For documentation, see 'go help build'.
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #2 to this change.
cmd/gomobile: add a flag to manually specify a work dir
Added a flag to manually specify a work dir to avoid having to rebuild everything from scratch when using gomobile through go module.
Particularly useful in the context of a large project that takes several tens of minutes to build, especially when only one or two packages need to be recompiled.
Fixes https://github.com/golang/go/issues/37902
Change-Id: I23fb636fc6d5c0e6f9cb953a5795bad36a9cbda3
GitHub-Last-Rev: bfaf3f599c258f105d375229058338e443fba8aa
GitHub-Pull-Request: golang/mobile#58
---
M cmd/gomobile/bind.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M cmd/gomobile/install.go
4 files changed, 25 insertions(+), 7 deletions(-)
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Patch set 2:Run-TryBot +1
1 comment:
File cmd/gomobile/bind.go:
Patch Set #2, Line 63: The -cache flag specifies the build cache directory. If not specified,
I feel like -workdir sounds better rather than -cache.
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hajime Hoshi.
1 comment:
File cmd/gomobile/bind.go:
Patch Set #2, Line 63: The -cache flag specifies the build cache directory. If not specified,
I feel like -workdir sounds better rather than -cache.
There is -work flag already, so it may be confusing.
Is the purpose to possibly reuse the temporary results, or to just control the temp directory access? If the former, we need proper design to handle how to invalidate/clean stale data, how to determine the data there can be reused, and how to handle existing directory. (`go help cache` may be inspiring?). If the later, you can control the temporary directory by setting TMPDIR or TMP (https://golang.org/pkg/os/#TempDir)
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
1 comment:
File cmd/gomobile/bind.go:
Patch Set #2, Line 63: The -cache flag specifies the build cache directory. If not specified,
There is -work flag already, so it may be confusing. […]
Yes I actually named it -cache instead of -workdir to avoid confusion with the -work flag.
The purpose is indeed to reuse the temporary results / not rebuild the whole codebase and its dependencies every time a change was made. On our project, we use Gomobile as a module since the support has been added.
Before that, when we made a small change, Gomobile would rebuild only the impacted module and those for which it was a dependency, so it took a few seconds on a computer that already built the project.
Since the switch to module, because Gomobile put everything in a random temporary directory, the slightest change required to rebuild everything which took a good ten minutes.
I don't know if there is a cleaner way to achieve this result but today we use this branch via a replace in our go.mod and it saves us a lot of time.
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Antoine Eddi, Hajime Hoshi.
1 comment:
File cmd/gomobile/bind.go:
Patch Set #2, Line 63: The -cache flag specifies the build cache directory. If not specified,
Yes I actually named it -cache instead of -workdir to avoid confusion with the -work flag. […]
Thanks for the info. Good to know it helps improving the speed, which is promising. Since we still don't fully understand what in the directory can be reliably reusable or not, how about rolling this out as an environment variable now (EXPERIMENTAL_GOBIND_CODEGEN_CACHE maybe?) and once we have better understanding and satisfied, promoting it as a supported flag? What do you think?
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
1 comment:
File cmd/gomobile/bind.go:
Patch Set #2, Line 63: The -cache flag specifies the build cache directory. If not specified,
Thanks for the info. Good to know it helps improving the speed, which is promising. […]
Sounds good to me.
I don't know exactly what needs to be reused either, but this change seems to make the behavior identical in terms of build/rebuild between gomobile as a module or not.
Do you want me to take care of removing the flag and adding the env variable you suggest?
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
Gerrit Bot uploaded patch set #3 to this change.
cmd/gomobile: add a flag to manually specify a work dir
Added a flag to manually specify a work dir to avoid having to rebuild everything from scratch when using gomobile through go module.
Particularly useful in the context of a large project that takes several tens of minutes to build, especially when only one or two packages need to be recompiled.
Fixes https://github.com/golang/go/issues/37902
Change-Id: I23fb636fc6d5c0e6f9cb953a5795bad36a9cbda3
GitHub-Last-Rev: e7699dcc678afce05643f6aa63bce82cf8ea20e9
GitHub-Pull-Request: golang/mobile#58
---
M cmd/gomobile/bind.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M cmd/gomobile/install.go
4 files changed, 25 insertions(+), 7 deletions(-)
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim, Hajime Hoshi.
Gerrit Bot uploaded patch set #4 to this change.
cmd/gomobile: add a flag to manually specify a work dir
Added a flag to manually specify a work dir to avoid having to rebuild everything from scratch when using gomobile through go module.
Particularly useful in the context of a large project that takes several tens of minutes to build, especially when only one or two packages need to be recompiled.
Fixes https://github.com/golang/go/issues/37902
Change-Id: I23fb636fc6d5c0e6f9cb953a5795bad36a9cbda3
GitHub-Last-Rev: bfaf3f599c258f105d375229058338e443fba8aa
GitHub-Pull-Request: golang/mobile#58
---
M cmd/gomobile/bind.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M cmd/gomobile/install.go
4 files changed, 25 insertions(+), 7 deletions(-)
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #5 to this change.
cmd/gomobile: add a flag to manually specify a work dir
Added a flag to manually specify a work dir to avoid having to rebuild everything from scratch when using gomobile through go module.
Particularly useful in the context of a large project that takes several tens of minutes to build, especially when only one or two packages need to be recompiled.
Fixes https://github.com/golang/go/issues/37902
Change-Id: I23fb636fc6d5c0e6f9cb953a5795bad36a9cbda3
GitHub-Last-Rev: 2ebcbb6bfc10e67234bccbbef1693ec538893f24
GitHub-Pull-Request: golang/mobile#58
---
M cmd/gomobile/bind.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M cmd/gomobile/install.go
4 files changed, 42 insertions(+), 7 deletions(-)
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hajime Hoshi, Hyang-Ah Hana Kim.
1 comment:
File cmd/gomobile/bind.go:
Patch Set #2, Line 63: The -cache flag specifies the build cache directory. If not specified,
Sounds good to me. […]
Hello, we are still waiting for an answer from you to know what to do.
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hajime Hoshi, Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #6 to this change.
cmd/gomobile: add a flag to manually specify a work dir
Added a flag to manually specify a work dir to avoid having to rebuild everything from scratch when using gomobile through go module.
Particularly useful in the context of a large project that takes several tens of minutes to build, especially when only one or two packages need to be recompiled.
Fixes https://github.com/golang/go/issues/37902
Change-Id: I23fb636fc6d5c0e6f9cb953a5795bad36a9cbda3
GitHub-Last-Rev: b169a720413b692240ffcfee1354dd23de7dcd6e
GitHub-Pull-Request: golang/mobile#58
---
M cmd/gomobile/bind.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M cmd/gomobile/init.go
M cmd/gomobile/install.go
5 files changed, 50 insertions(+), 7 deletions(-)
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.
Attention is currently required from: Hajime Hoshi, Hyang-Ah Hana Kim.
Gerrit Bot uploaded patch set #7 to this change.
cmd/gomobile: add a flag to manually specify a work dir
Added a flag to manually specify a work dir to avoid having to rebuild everything from scratch when using gomobile through go module.
Particularly useful in the context of a large project that takes several tens of minutes to build, especially when only one or two packages need to be recompiled.
Fixes https://github.com/golang/go/issues/37902
Change-Id: I23fb636fc6d5c0e6f9cb953a5795bad36a9cbda3
GitHub-Last-Rev: bee19d45b5f8487de96d19e6df2d8ca2df64ae72
GitHub-Pull-Request: golang/mobile#58
---
M cmd/gomobile/bind.go
M cmd/gomobile/build.go
M cmd/gomobile/env.go
M cmd/gomobile/init.go
M cmd/gomobile/install.go
5 files changed, 50 insertions(+), 7 deletions(-)
To view, visit change 273406. To unsubscribe, or for help writing mail filters, visit settings.