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:
Родитель
08407a4b1b
Коммит
960fedd178
|
@ -6,7 +6,10 @@
|
||||||
|
|
||||||
package app
|
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.
|
// 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
|
// bindings which requires deconstructing seq into something
|
||||||
// gnarly. So don't get too attached to the design.
|
// 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.
|
// Transact calls a method on a foreign object instance.
|
||||||
// It blocks until the call is complete.
|
// 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
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
package app
|
package mobileinit
|
||||||
|
|
||||||
/*
|
/*
|
||||||
To view the log output run:
|
To view the log output run:
|
||||||
|
@ -16,6 +16,8 @@ adb logcat GoLog:I *:S
|
||||||
// Unfortunately, logcat is line oriented, so we must buffer.
|
// Unfortunately, logcat is line oriented, so we must buffer.
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
#cgo LDFLAGS: -landroid -llog
|
||||||
|
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
*/
|
*/
|
||||||
|
@ -37,7 +39,7 @@ type infoWriter struct{}
|
||||||
|
|
||||||
func (infoWriter) Write(p []byte) (n int, err error) {
|
func (infoWriter) Write(p []byte) (n int, err error) {
|
||||||
cstr := C.CString(string(p))
|
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))
|
C.free(unsafe.Pointer(cstr))
|
||||||
return len(p), nil
|
return len(p), nil
|
||||||
}
|
}
|
Загрузка…
Ссылка в новой задаче