File tree 9 files changed +147
-4
lines changed
9 files changed +147
-4
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <!--
3
+ Copyright 2014 The Go Authors. All rights reserved.
4
+ Use of this source code is governed by a BSD-style
5
+ license that can be found in the LICENSE file.
6
+ -->
7
+ <manifest
8
+ xmlns:android=" http://schemas.android.com/apk/res/android"
9
+ package=" com.example.sprite"
10
+ android:versionCode=" 1"
11
+ android:versionName=" 1.0" >
12
+
13
+ <uses-sdk android : minSdkVersion =" 9" />
14
+ <application android : label =" Sprite" android : hasCode =" false" >
15
+ <activity android : name =" android.app.NativeActivity"
16
+ android:label=" Sprite"
17
+ android:configChanges=" orientation|keyboardHidden" >
18
+ <meta-data android : name =" android.app.lib_name" android : value =" sprite" />
19
+ <intent-filter >
20
+ <action android : name =" android.intent.action.MAIN" />
21
+ <category android : name =" android.intent.category.LAUNCHER" />
22
+ </intent-filter >
23
+ </activity >
24
+ </application >
25
+ </manifest >
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # Copyright 2014 The Go Authors. All rights reserved.
3
+ # Use of this source code is governed by a BSD-style
4
+ # license that can be found in the LICENSE file.
5
+
6
+ # Script to build and launch the app on an android device.
7
+
8
+ set -e
9
+
10
+ ./make.bash
11
+
12
+ adb install -r bin/nativeactivity-debug.apk
13
+
14
+ adb shell am start -a android.intent.action.MAIN \
15
+ -n com.example.sprite/android.app.NativeActivity
Original file line number Diff line number Diff line change
1
+ :: Copyright 2014 The Go Authors. All rights reserved.
2
+ :: Use of this source code is governed by a BSD-style
3
+ :: license that can be found in the LICENSE file.
4
+
5
+ @ echo off
6
+
7
+ setlocal
8
+
9
+ echo # building sprite
10
+ call make.bat
11
+
12
+ echo # installing bin/nativeactivity-debug.apk
13
+ adb install -r bin/nativeactivity-debug.apk > nul
14
+
15
+ echo # starting android.app.NativeActivity
16
+ adb shell am start -a android.intent.action.MAIN -n com.example.sprite/android.app.NativeActivity > nul
File renamed without changes.
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <!--
3
+ Copyright 2014 The Go Authors. All rights reserved.
4
+ Use of this source code is governed by a BSD-style
5
+ license that can be found in the LICENSE file.
6
+ -->
7
+ <project name =" nativeactivity" default =" help" >
8
+ <property name =" target" value =" android-19" />
9
+ <property environment =" env" />
10
+ <condition property =" sdk.dir" value =" ${ env.ANDROID_HOME } " >
11
+ <isset property =" env.ANDROID_HOME" />
12
+ </condition >
13
+ <fail message =" missing ANDROID_HOME env variable" unless =" sdk.dir" />
14
+ <import file =" ${ sdk.dir } /tools/ant/build.xml" />
15
+ </project >
Original file line number Diff line number Diff line change
1
+ # Copyright 2014 The Go Authors. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style
3
+ # license that can be found in the LICENSE file.
4
+
5
+ LOCAL_PATH := $(call my-dir)
6
+ include $(CLEAR_VARS )
7
+
8
+ LOCAL_MODULE := sprite
9
+ LOCAL_SRC_FILES := $(TARGET_ARCH_ABI ) /libsprite.so
10
+
11
+ include $(PREBUILT_SHARED_LIBRARY )
Original file line number Diff line number Diff line change 8
8
"image"
9
9
"log"
10
10
"math"
11
- "os"
12
11
"time"
13
12
14
13
_ "image/jpeg"
@@ -125,12 +124,13 @@ const (
125
124
)
126
125
127
126
func loadTextures () []sprite.SubTex {
128
- f , err := os .Open ("../../testdata/ waza-gophers.jpeg" )
127
+ a , err := app .Open ("waza-gophers.jpeg" )
129
128
if err != nil {
130
129
log .Fatal (err )
131
130
}
132
- defer f .Close ()
133
- img , _ , err := image .Decode (f )
131
+ defer a .Close ()
132
+
133
+ img , _ , err := image .Decode (a )
134
134
if err != nil {
135
135
log .Fatal (err )
136
136
}
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+ # Copyright 2014 The Go Authors. All rights reserved.
3
+ # Use of this source code is governed by a BSD-style
4
+ # license that can be found in the LICENSE file.
5
+
6
+ set -e
7
+
8
+ if [ ! -f make.bash ]; then
9
+ echo ' make.bash must be run from $GOPATH/src/golang.org/x/mobile/example/sprite'
10
+ exit 1
11
+ fi
12
+
13
+ mkdir -p jni/armeabi
14
+ CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 \
15
+ go build -ldflags=" -shared" -o jni/armeabi/libsprite.so .
16
+ ndk-build NDK_DEBUG=1
17
+ ant debug
Original file line number Diff line number Diff line change
1
+ :: Copyright 2014 The Go Authors. All rights reserved.
2
+ :: Use of this source code is governed by a BSD-style
3
+ :: license that can be found in the LICENSE file.
4
+
5
+ @ echo off
6
+
7
+ setlocal
8
+
9
+ if not exist make.bat goto error-invalid-path
10
+
11
+ if not exist jni\armeabi mkdir jni\armeabi
12
+
13
+ set CGO_ENABLED = 1
14
+ set GOOS = android
15
+ set GOARCH = arm
16
+ set GOARM = 7
17
+
18
+ go build -ldflags=" -shared" -o jni/armeabi/libsprite.so .
19
+ if errorlevel 1 goto error-go-build
20
+
21
+ if defined NDK_ROOT goto ndk-build
22
+ echo NDK_ROOT path not defined
23
+ goto end
24
+
25
+ :ndk-build
26
+ call %NDK_ROOT% \ndk-build.cmd NDK_DEBUG=1 > nul
27
+
28
+ if defined ANT_HOME goto ant-build
29
+ echo ANT_HOME path not defined
30
+ goto end
31
+
32
+ :ant-build
33
+ call %ANT_HOME% \bin\ant.bat debug > nul
34
+ goto end
35
+
36
+ :error-invalid-path
37
+ echo make.bat must be run from %% GOPATH%% \src\golang.org\x\mobile\example\sprite
38
+ goto end
39
+
40
+ :error-go-build
41
+ echo Error building go lib
42
+ goto end
43
+
44
+ :end
You can’t perform that action at this time.
0 commit comments