-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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/app: support all-Go app development on windows #9306
Comments
you can use the syscall package to access dll exported functions without |
Like @minux said. And yes you can download any .DLL as part of go get, but you would have to put it somewhere in your PATH to be able to use it. |
syscall.LoadLibrary looks like it would work, but it would mean generating a lot of code for the mobile/gl package. That is, something like https://github.com/golang/mobile/blob/master/gl/gldebug.go that replaces all the cgo calls with syscall.GetProcAddress+syscall.Syscall in a gl_windows.go file. That's probably the way to go. |
If you really want to avoid cgo on windows, that is probably the way to go. The generator That said, there does exist an easier way to avoid gcc, which I'd call frozen cgo. The idea This approach should work well for cases where we know the interface won't change The frozen cgo approach does work. As an example, given this simple cgo program: First go build -work cgo.go, record the $WORK it showed. And then create a new directory, and copy these four files into it: And go build -x inside that directory. You will see that cgo and gcc are not invoked. This generalizes all cgo programs, just copy all.o to cgo$GOOS_$GOARCH.syso, Although this means that you need to separate windows support to separate package and This is the first time I publicly discuss this concept, hopefully it has not been proposed before. :-) |
@minux, I tried following your instructions, but it fails. C:\go\path\mine\src\foo>dir Directory of C:\go\path\mine\src\foo 16/12/2014 10:36 AM .16/12/2014 10:36 AM .. 16/12/2014 10:12 AM 87 cgo.go 1 File(s) 87 bytes 2 Dir(s) 112,487,620,608 bytes free C:\go\path\mine\src\foo>type cgo.go /* func main() { C:\go\path\mine\src\foo>go build -work cgo.go C:\go\path\mine\src\foo>set WORK=C:\DOCUME C:\go\path\mine\src\foo>copy %WORK%\command-line-arguments_obj_all.o cgo_windows_386.syso C:\go\path\mine\src\foo>copy %WORK%\command-line-arguments_obj_cgo_gotypes.o z_cgo_gotypes_windows_386.go C:\go\path\mine\src\foo> I am also not convinced that general C code can be packaged into executable on Windows. Some C libs might be configured to be built as DLLs. Then you have to ship these DLLs as part of your app. Some C libs might rely on external libs (DLLs) (for example Microsoft C runtime or similar). Then again you have to distribute these along with your app. Mind you, you could, probably, create DLL file in /tmp on the fly and load it on your app startup. I have never tried that, but I don't see why it won't work. Maybe anti-virus might complain ... I am also not sure why you want to run mobile app natively on Windows desktop. I think it would be nuch more useful to be able to launch mobile app inside of some emulator that runs on Windows desktop. The emulator that creates environment that looks as close as possible to real device. Or just launch mobile app on real device. Alex |
Configuring build environments for mobile devices is hard. For iOS, you just cannot do it on windows. For android, you need to install the SDK+NDK+Go cross compiler. What we have right now for Mac and Linux lets you download the stock Go build, write a 15-line app and type go build. Compile+test cycles are dramatically faster than working on the real device, and the whole experience is a lot more fun. I'd like to bring that to windows users. I'm sure we can, there's just work to do. |
Sure, lets try. |
@alexbrainman, If you're using tip, copy all Go files in $WORK, but rename them so that |
I think doing iOS development on Linux is possible, if we tried hard clang is definitely buildable on windows, as and ld64 are harder. The code I doubt any iOS app developer want to develop on Windows, though. |
@minux I am using C:\go\path\mine\src\foo>go version |
It seems the end goal is to make it work very seamless on Windows, but it sounds hard to do right away. What do you think about taking a smaller step first, getting it to work at least as well as Doing that can be done very quickly and allow google/gxui#86 to proceed. There are a few ways to make it happen:
|
I like the idea of using GLOW - I didn't realise that it was usable outside of the go-gl library. |
A Windows version of the gldriver shares a lot of common code with the existing windriver. This CL factors it out into a new internal pacakge, win32. For golang/go#9306 Change-Id: If602bb42946f1df662b2529d5b277257ae7706d3 Reviewed-on: https://go-review.googlesource.com/17676 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
For golang/go#9306 Change-Id: Ib6a7b23288bebebb5e111221338323a2692187b0 Reviewed-on: https://go-review.googlesource.com/17721 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
For golang/go#9306 Change-Id: I2e4029e261307e08748b7088c495512247f10d21 Reviewed-on: https://go-review.googlesource.com/17722 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
This allows a subsequent CL to introduce windows support by directly calling an ANGLE dll. For golang/go#9306 Change-Id: I7dbe8f2b77b9e2c744f0d848f716ee4448916fe7 Reviewed-on: https://go-review.googlesource.com/17674 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
ANGLE is an open source project that implements OpenGL ES on top of DirectX. It is used by Chrome to implement WebGL: https://github.com/google/angle It can be compiled into libGLESv2.dll/libEGL.dll and used directly from Go. This CL includes the changes necessary to the gl package to use ANGLE. For the EGL changes, I intend to get x/exp/shiny/driver/gldriver working, and then make x/mobile/app use it when compiling for GOOS=windows. (The dependency on shiny's screen package will only hold when building for desktop OSs.) For golang/go#9306 Change-Id: I01cb39bc8b56547584b7992eab437bd7ed0312b5 Reviewed-on: https://go-review.googlesource.com/17675 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Each GL context is used serially, so make the map context-specific. For golang/go#9306 Change-Id: Ic8261795312bf404f765a9ae8969468f4d170dae Reviewed-on: https://go-review.googlesource.com/17772 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
For golang/go#9306 Change-Id: Ia8778f5b371371d103c55c12606257ee7ca45fd4 Reviewed-on: https://go-review.googlesource.com/17778 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
CL https://golang.org/cl/17777 mentions this issue. |
CL https://golang.org/cl/17810 mentions this issue. |
For golang/go#9306 Change-Id: Ibb469d843d2bddeaa3690c59bc9ad532ea3473f7 Reviewed-on: https://go-review.googlesource.com/17810 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Combined with the outstanding shiny CLs and prebuilt ANGLE dlls in the right place, this makes it possible to run example/basic on a windows machine. Eventually this shiny backend will also replace the app package's custom darwin_amd64 and linux_x11 backends. For golang/go#9306 Change-Id: Ia4bf9a85b9d903d79cee36abb470a0ad57f09f36 Reviewed-on: https://go-review.googlesource.com/17777 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
For golang/go#9306 Change-Id: Ib6a7b23288bebebb5e1d53917d67af72692187b0 Reviewed-on: https://go-review.googlesource.com/17677 Reviewed-by: Nigel Tao <nigeltao@golang.org>
Although this is an old issue I still want to point you to my Direct3D9 wrapper. |
Fixes golang/go#12212 Workaround for golang/go#12261 until golang/go#9306 is fixed. Change-Id: I51c1bcfc92c1553fe2132586a0234b1c1af6aeb1 Reviewed-on: https://go-review.googlesource.com/13745 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This allows a subsequent CL to introduce windows support by directly calling an ANGLE dll. For golang/go#9306 Change-Id: I7dbe8f2b77b9e2c744f0d848f716ee4448916fe7 Reviewed-on: https://go-review.googlesource.com/17674 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
ANGLE is an open source project that implements OpenGL ES on top of DirectX. It is used by Chrome to implement WebGL: https://github.com/google/angle It can be compiled into libGLESv2.dll/libEGL.dll and used directly from Go. This CL includes the changes necessary to the gl package to use ANGLE. For the EGL changes, I intend to get x/exp/shiny/driver/gldriver working, and then make x/mobile/app use it when compiling for GOOS=windows. (The dependency on shiny's screen package will only hold when building for desktop OSs.) For golang/go#9306 Change-Id: I01cb39bc8b56547584b7992eab437bd7ed0312b5 Reviewed-on: https://go-review.googlesource.com/17675 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Each GL context is used serially, so make the map context-specific. For golang/go#9306 Change-Id: Ic8261795312bf404f765a9ae8969468f4d170dae Reviewed-on: https://go-review.googlesource.com/17772 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
For golang/go#9306 Change-Id: Ia8778f5b371371d103c55c12606257ee7ca45fd4 Reviewed-on: https://go-review.googlesource.com/17778 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
For golang/go#9306 Change-Id: Ibb469d843d2bddeaa3690c59bc9ad532ea3473f7 Reviewed-on: https://go-review.googlesource.com/17810 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Combined with the outstanding shiny CLs and prebuilt ANGLE dlls in the right place, this makes it possible to run example/basic on a windows machine. Eventually this shiny backend will also replace the app package's custom darwin_amd64 and linux_x11 backends. For golang/go#9306 Change-Id: Ia4bf9a85b9d903d79cee36abb470a0ad57f09f36 Reviewed-on: https://go-review.googlesource.com/17777 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Fixes golang/go#12212 Workaround for golang/go#12261 until golang/go#9306 is fixed. Change-Id: I51c1bcfc92c1553fe2132586a0234b1c1af6aeb1 Reviewed-on: https://go-review.googlesource.com/13745 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This allows a subsequent CL to introduce windows support by directly calling an ANGLE dll. For golang/go#9306 Change-Id: I7dbe8f2b77b9e2c744f0d848f716ee4448916fe7 Reviewed-on: https://go-review.googlesource.com/17674 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
ANGLE is an open source project that implements OpenGL ES on top of DirectX. It is used by Chrome to implement WebGL: https://github.com/google/angle It can be compiled into libGLESv2.dll/libEGL.dll and used directly from Go. This CL includes the changes necessary to the gl package to use ANGLE. For the EGL changes, I intend to get x/exp/shiny/driver/gldriver working, and then make x/mobile/app use it when compiling for GOOS=windows. (The dependency on shiny's screen package will only hold when building for desktop OSs.) For golang/go#9306 Change-Id: I01cb39bc8b56547584b7992eab437bd7ed0312b5 Reviewed-on: https://go-review.googlesource.com/17675 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Each GL context is used serially, so make the map context-specific. For golang/go#9306 Change-Id: Ic8261795312bf404f765a9ae8969468f4d170dae Reviewed-on: https://go-review.googlesource.com/17772 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
For golang/go#9306 Change-Id: Ia8778f5b371371d103c55c12606257ee7ca45fd4 Reviewed-on: https://go-review.googlesource.com/17778 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
For golang/go#9306 Change-Id: Ibb469d843d2bddeaa3690c59bc9ad532ea3473f7 Reviewed-on: https://go-review.googlesource.com/17810 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Combined with the outstanding shiny CLs and prebuilt ANGLE dlls in the right place, this makes it possible to run example/basic on a windows machine. Eventually this shiny backend will also replace the app package's custom darwin_amd64 and linux_x11 backends. For golang/go#9306 Change-Id: Ia4bf9a85b9d903d79cee36abb470a0ad57f09f36 Reviewed-on: https://go-review.googlesource.com/17777 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
The http://golang.org/x/mobile/app package lets you run all-Go apps on desktop darwin and linux with nothing more than the stock Go build. Just
go get
and you're programming. This is done via cgo: we ask for a window, get an OpenGL context, and map mouse events to touch events.We should do the same for Windows. There are a few complications.
The first is by default there is C compiler for cgo on windows. On both linux and OS X we can rely on the user to install gcc/xcode because the platform makes it easy. By comparison MinGW is an extra, non-obvious step for windows users and VC++ isn't supported (and not necessarily any more obvious).
The second is there is no OpenGL. Well, there is kinda, as provided by graphics card makers, but support in particular for OpenGL ES 2 and EGL is spotty. Luckily, Chrome has this problem too and maintain an open source project implementing ES 2 and EGL for Windows on top of DirectX: https://code.google.com/p/angleproject/
I want to avoid importing angleproject directly into the mobile repository as it has several licenses and I want to keep the notices story for the Go repository simple. So we will need another repository that contains a package that links against angleproject and creates the window.
Is there any way about needing windows users to install a C compiler? Can we ship a binary .dll in a repository that is downloaded with go get? If we do, what about the cgo parts of
mobile/app
andmobile/gl
? Can they be provided by the .dll even if we fetch it as part of a different repository? Formobile/app
probably, butmobile/gl
is harder.The text was updated successfully, but these errors were encountered: