-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: build tool and configuration across android and iOS #9508
Comments
That's very nice! So far, we've seen the cases that need proper permission settings (e.g. android.permission.INTERNET to access network, android.permission.WRITE_EXTERNAL_STORAGE to read/write data, etc). -- Through the explicit _ import from main sounds fine. But I wish we could infer the minimum set of required permission during build time. For example, since it imports net package eventually, this needs permission to access network. Screen orientation if fullscreen deserves a separate configuration import. What about application/activity attributes such as icon/theme? Some apps may require a specific set of screen sizes or hardware features (camera, motion sensors) so that only users with the right sets of devices can see the app in Play Store. But that's probably not a high priority. http://developer.android.com/guide/topics/manifest/manifest-intro.html |
I don't think a configuration parameter for fullscreen mode is necessary. One should simply be able to call app.Fullscreen(true) (or whatever) in app.Callbacks.Start. I guess this similarly true for screen orientation? I just a did a comparison of setting the fullscreen attribute in AndroidManifest.xml vs setting the fullscreen flag in app.Callbacks.Start and there is only the slightest difference in timing, it's hardly noticeable, I think it is negligible. Regarding the proposed configuration syntax: it'll be a bit wordy if every parameter needs golang.org/x/mobile/config as a prefix. Also, it might not work so well for non-boolean parameters, should any arise. How about //go:mobile foo=bar comments instead? |
Some more:
|
And more
and so on. All of these things can have a place in a native game. It'd likely be simpler to ask what you don't want to support. Having so many variations makes I have a similar tool I put together for producing shared lib: https://github.com/dskinner/mobilize and sympathize with the effort here, nice work on binary_xml.go. It would be nice if But, this feels like a perilous path leading down a dead end trying to support too many features of AndroidManifest and I'd likely never use it (or find it useful) in any currently conceivable fashion beyond prototyping. I know the discussion is pure go games written for Android/iOS, but realistically, games are likely to include features such as push notifications, in-app purchases, ads, etc. and much of this functionality on android is brought in with third party libs and configured in the manifest and/or resource files. |
When I experimented with https://github.com/bryanturley/goapk
It also would read them from init() funcs but only from the main package. I don't think you can generalize the android build system out, it is too wonky. I also considered doing something like cgo
I didn't get much further after becoming frustrated with the android build system once again... ;) |
Having the |
I had a third idea this morning. The apk build starts a tool or a subsection of the go tool that works similar to "go test". example ApkManifest for stdlib net package
Might want to tell godoc to ignore ApkManifest with the proper definition, or not. |
I just now realized that would treat entire packages like interfaces.
I think my brain has become fully Go saturated... |
@bryanturley actually, for addressing just a handful of cases, I'm partial to your suggestion of Having an I'd guess things like Overall, I think I'd prefer to see But, the |
Magic comments and importing packages are the only two options that can be analyzed easily without running the program. I think @bryanturley's latter suggestion is perhaps a bit overzealous |
The zealot is back ;) I wrote a prototype for my third idea, had to know if actually worked. Only took 6ish hours to write the prototype (which isn't finished). Remember in reality those fake packages would have code other than the target funcs in them. |
Just curious - what is the motivation behind this request? What's wrong with having an AndroidManifest.xml like every other Android app does? |
For the sake of inventing as little as possible, my current plan for the gomobile tool is: If an AndroidManifest.xml is present, use it. We can build a common configuration system later if there is strong evidence to suggest it is better than having separate android/iOS configurations. |
@keithkml Not having extraneous config files during build is part of the Go ideology. |
@crawshaw So in my head it sounds like you are talking about gomobile having a predefined import to permission/need map (I am easily wrong here). I would prefer the packages inform gomobile. If it where per package strings instead of funcs, that could be read without having to build another program. People seemed to not want go generate doing that despite go test already doing it. // unicode "wrapped present" (bundle) rune in there I think the func version would be easiest to write and maintain though, no extra parsers need to be written just one bundle struct per target. Just a suggestion. |
An Android app is not a binary, it's an archive of resources. An AndroidManifest.xml is not a Makefile. Go ideology you mention above is mostly in the scope of building a binary. From that point on, it's not that opinionated. (I don't think the apk/app builder should ever go in go build, but should be a separate tool on the other hand.) I don't think at the current stage, it's any worthy to think about how we will represent this stuff in vanilla Go. Reusing AndroidManifest or generating one sounds fair to me. |
|
@rakyll the sentences following the one you quoted are in agreement with you. I should have written them more clearly. |
Done. The gomobile tool exists. Documentation: https://golang.org/x/mobile/cmd/gomobile |
Over the holiday break I got Go building .apk files: github.com/crawshaw/apk
This could theoretically be embedded directly in the go tool, so go build produces a .apk when GOOS=android. However there is another issue: it should be possible to build an app without an AndroidManfiest.xml, with a shared configuration across iOS.
This could be a tool, golang.org/x/mobile/cmd/gombile. My original design doc described such a thing, but I have been avoiding it until we got closer to a working iOS build. Now we are getting closer, it's worth thinking about.
Several of the gomobile properties are straightforward: it should look as much like the Go tool as possible, it should produce a .apk for android, and a .app for iOS. It should know how to use ios-deploy if you have it installed. It should build the platform-specific configuration files for you.
First question: what (if any) of the configuration parameters in AndroidManfiest.xml need to be exposed through the build system? https://go-review.googlesource.com/#/c/2162/ brings up the fullscreen attribute. What else?
Second question: what should the configuration look like? It should be easily determinable at build time, and involve the least amount of invention. One very minimal possibility:
package main
import (
_ "golang.org/x/mobile/config/fullscreen"
)
The text was updated successfully, but these errors were encountered: