Skip to content
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

Closed
hyangah opened this issue Mar 17, 2015 · 3 comments

Comments

@hyangah
Copy link
Contributor

hyangah commented Mar 17, 2015

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.

@hyangah hyangah self-assigned this Mar 17, 2015
@mikioh mikioh changed the title gomobile init needs to detect when to fetch ndk archives or reuse existing ones. cmd/gomobile: init needs to detect when to fetch ndk archives or reuse existing ones. Mar 17, 2015
@rakyll
Copy link
Contributor

rakyll commented Apr 3, 2015

But, this adds complexity and more points to break compared to letting gomobile init always start from scratch.

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.

@hyangah
Copy link
Contributor Author

hyangah commented Apr 3, 2015

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.

@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title cmd/gomobile: init needs to detect when to fetch ndk archives or reuse existing ones. x/mobile/cmd/gomobile: init needs to detect when to fetch ndk archives or reuse existing ones. Apr 14, 2015
@rsc rsc modified the milestones: Unreleased, Unplanned Apr 14, 2015
@rsc rsc removed the repo-mobile label Apr 14, 2015
@gopherbot
Copy link

CL https://golang.org/cl/9685 mentions this issue.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 10, 2021
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>
imWildCat pushed a commit to imWildCat/go-mobile that referenced this issue Apr 11, 2021
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>
@rsc rsc unassigned hyangah Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants