Added OS X building. Go 1.5 required because of https://github.com/golang/go/issues/9411 which affects this. Also set up proper multithreading on OS X. Currently crashes due to similar issue I've had with libui.
This commit is contained in:
parent
4689c6c0ab
commit
4760ad7c5a
|
@ -10,7 +10,7 @@ It runs on/requires:
|
||||||
- Mac OS X: cgo, Mac OS X 10.7 and newer
|
- Mac OS X: cgo, Mac OS X 10.7 and newer
|
||||||
- other Unixes: cgo, GTK+ 3.4 and newer
|
- other Unixes: cgo, GTK+ 3.4 and newer
|
||||||
|
|
||||||
TODO figure out the minimum required version of Go
|
It also requires Go 1.5 or newer (due to various bugs in cgo that were fixed only starting with 1.5).
|
||||||
|
|
||||||
(this README needs some work)
|
(this README needs some work)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
// 13 december 2015
|
||||||
|
|
||||||
|
package ui
|
||||||
|
|
||||||
|
// #cgo LDFLAGS: -L${SRCDIR} -lui -framework CoreFoundation -lpthread
|
||||||
|
// #include <CoreFoundation/CoreFoundation.h>
|
||||||
|
// #include <pthread.h>
|
||||||
|
// extern void _CFRunLoopSetCurrent(CFRunLoopRef);
|
||||||
|
// extern pthread_t _CFMainPThread;
|
||||||
|
import "C"
|
||||||
|
|
||||||
|
// OS X cares very deeply if we don't run on the very first thread the OS creates
|
||||||
|
// why? who knows. it's stupid and completely indefensible. let's use undocumented APIs to get around it.
|
||||||
|
// apple uses them too: http://www.opensource.apple.com/source/kext_tools/kext_tools-19.2/kextd_main.c?txt
|
||||||
|
// apple HAS SUGGESTED them too: http://lists.apple.com/archives/darwin-development/2002/Sep/msg00250.html
|
||||||
|
// gstreamer uses them too: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/tree/sys/osxvideo/osxvideosink.m
|
||||||
|
func ensureMainThread() {
|
||||||
|
// TODO set to nil like the apple code?
|
||||||
|
C._CFRunLoopSetCurrent(C.CFRunLoopGetMain())
|
||||||
|
// TODO is this part necessary?
|
||||||
|
C._CFMainPThread = C.pthread_self()
|
||||||
|
}
|
|
@ -7,3 +7,7 @@ package ui
|
||||||
|
|
||||||
// #cgo LDFLAGS: -L${SRCDIR} -lui -Wl,-rpath=$ORIGIN
|
// #cgo LDFLAGS: -L${SRCDIR} -lui -Wl,-rpath=$ORIGIN
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
|
func ensureMainThread() {
|
||||||
|
// do nothing; GTK+ doesn't care which thread we're on so long as we don't change it after starting
|
||||||
|
}
|
||||||
|
|
|
@ -4,3 +4,7 @@ package ui
|
||||||
|
|
||||||
// #cgo LDFLAGS: -L${SRCDIR} -lui
|
// #cgo LDFLAGS: -L${SRCDIR} -lui
|
||||||
import "C"
|
import "C"
|
||||||
|
|
||||||
|
func ensureMainThread() {
|
||||||
|
// do nothing; Windows doesn't care which thread we're on so long as we don't change it after starting
|
||||||
|
}
|
||||||
|
|
2
main.go
2
main.go
|
@ -40,7 +40,7 @@ func Main(f func()) error {
|
||||||
func start(errchan chan error, f func()) {
|
func start(errchan chan error, f func()) {
|
||||||
runtime.LockOSThread()
|
runtime.LockOSThread()
|
||||||
|
|
||||||
// TODO set main thread on OS X
|
ensureMainThread()
|
||||||
|
|
||||||
// TODO HEAP SAFETY
|
// TODO HEAP SAFETY
|
||||||
opts := C.uiInitOptions{}
|
opts := C.uiInitOptions{}
|
||||||
|
|
Loading…
Reference in New Issue