internal/mobileinit: new package for shared logic
Package app contains some logic that we want to share with gobind-based libraries. So move it to a new internal package that both can import. Long term the log changes should be in the standard library, but the Go tree is currently frozen. Fixes golang/go#11630. Change-Id: I9ff622fc499bf255bce18df23cb68b03f667947f Reviewed-on: https://go-review.googlesource.com/11981 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
This commit is contained in:
parent
08407a4b1b
commit
960fedd178
|
@ -6,7 +6,10 @@
|
|||
|
||||
package app
|
||||
|
||||
import "golang.org/x/mobile/event"
|
||||
import (
|
||||
"golang.org/x/mobile/event"
|
||||
_ "golang.org/x/mobile/internal/mobileinit"
|
||||
)
|
||||
|
||||
// Main is called by the main.main function to run the mobile application.
|
||||
//
|
||||
|
|
|
@ -16,7 +16,11 @@ package seq // import "golang.org/x/mobile/bind/seq"
|
|||
// bindings which requires deconstructing seq into something
|
||||
// gnarly. So don't get too attached to the design.
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
_ "golang.org/x/mobile/internal/mobileinit"
|
||||
)
|
||||
|
||||
// Transact calls a method on a foreign object instance.
|
||||
// It blocks until the call is complete.
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package mobileinit contains common initialization logic for mobile platforms
|
||||
// that is relevant to both all-Go apps and gobind-based apps.
|
||||
//
|
||||
// Long-term, any code in this package should consider moving into Go stdlib.
|
||||
package mobileinit
|
|
@ -2,7 +2,7 @@
|
|||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package app
|
||||
package mobileinit
|
||||
|
||||
/*
|
||||
To view the log output run:
|
||||
|
@ -16,6 +16,8 @@ adb logcat GoLog:I *:S
|
|||
// Unfortunately, logcat is line oriented, so we must buffer.
|
||||
|
||||
/*
|
||||
#cgo LDFLAGS: -landroid -llog
|
||||
|
||||
#include <android/log.h>
|
||||
#include <string.h>
|
||||
*/
|
||||
|
@ -37,7 +39,7 @@ type infoWriter struct{}
|
|||
|
||||
func (infoWriter) Write(p []byte) (n int, err error) {
|
||||
cstr := C.CString(string(p))
|
||||
C.__android_log_write(C.ANDROID_LOG_INFO, ctagLog, cstr)
|
||||
C.__android_log_write(C.ANDROID_LOG_INFO, ctag, cstr)
|
||||
C.free(unsafe.Pointer(cstr))
|
||||
return len(p), nil
|
||||
}
|
Loading…
Reference in New Issue