New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
x/mobile/cmd/gomobile: init needs to detect when to fetch ndk archives or reuse existing ones. #10187
Comments
Could you explain in detail what the breaking points are? Is it the corruption of the cached archives or overriding an existing installment? The third option is still my personal stand. It allows us to cache, do an integrity check of what's cached and run the installation from scratch if user's existing installment is broken. |
literally more lines of code with if statements (init is already ~600lines of code) and unpredictable zero state which adds one more thing to consider in testing/debugging. I also prefer the third option. |
CL https://golang.org/cl/9685 mentions this issue. |
Instead of trying to preserve the unpacked NDK, this stores the downloaded archives in GOPATH/pkg/gomobile/dl and completely rebuilds on reinitialization. Also introduce checking that the version of Go we are using to do the build matches the GOROOT we are building from. Fixes golang/go#10187 Change-Id: I4a861718d8a413855917a5b1f1073e2cd84c9bb1 Reviewed-on: https://go-review.googlesource.com/9685 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Instead of trying to preserve the unpacked NDK, this stores the downloaded archives in GOPATH/pkg/gomobile/dl and completely rebuilds on reinitialization. Also introduce checking that the version of Go we are using to do the build matches the GOROOT we are building from. Fixes golang/go#10187 Change-Id: I4a861718d8a413855917a5b1f1073e2cd84c9bb1 Reviewed-on: https://go-review.googlesource.com/9685 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Moving the discussion from https://go-review.googlesource.com/#/c/7162/ to here.
The gomobile init command fetches android NDK and open AL archives and builds necessary tools for android app build. When the go version used to build those tools differs from the current go root version, the gomobile init command has to rerun. In order to avoid downloading the archives again whenever we sync the go root (tip), we added a small hack - If a small file that's written at the end of previous gomobile init run exists, we skip downloading the archive and just build the tools against the new go root.
Note: users can always request to start from scratch by supplying the -u option.
This simple hack is not sufficient when the required set of archives changes. (e.g. initially we were okay with android NDK, and now we need openAL archive too).
cl/7162 was an attempt to detect this condition.
The initial version was to record the required archive list in a json file. If it doesn't match with what the gomobile tool requires now, we start from scratch. It's simple, but cannot detect corrupted tool chains - what if the files are gone or misplaced.
The second version was to check the tool directory and see if necessary files are in the expected places. It's not perfect because we don't check all files. Checking against some checksums is the next thing to do.
Another proposal is to store the fetched archives (tar.gz files) in a directory under GOPATH/pkg/gomobile, and if all of the required archives exist, reuse them and start the init process from extracting the archives. Which is much cleaner than the second version. But, this adds complexity and more points to break compared to letting gomobile init always start from scratch.
Finally, we can make 'gomobile init' always start from scratch by default. Make it possible to skip the ndk fetch optionally - for developers who have to work with tip.
The text was updated successfully, but these errors were encountered: