Skip to content

Commit 9c997ea

Browse files
dopsilvacrawshaw
authored andcommitted
example: add windows batch files
Add windows batch files to build and run examples Change-Id: I9102ceb5c47f692730a8b024648b1d10ff49b624 Reviewed-on: https://go-review.googlesource.com/1622 Reviewed-by: David Crawshaw <[email protected]>
1 parent 3bb5e71 commit 9c997ea

File tree

5 files changed

+162
-0
lines changed

5 files changed

+162
-0
lines changed

example/basic/all.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 basic
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.basic/android.app.NativeActivity >nul

example/basic/make.bat

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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/libbasic.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 example\basic
38+
goto end
39+
40+
:error-go-build
41+
echo Error building go lib
42+
goto end
43+
44+
45+
:end

example/libhello/all.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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 libhello
10+
call make.bat
11+
12+
echo # installing bin/Hello-debug.apk
13+
adb install -r bin/Hello-debug.apk >nul
14+
15+
echo # starting com.example.hello.MainActivity
16+
adb shell am start -a android.intent.action.MAIN -n com.example.hello/com.example.hello.MainActivity >nul

example/libhello/make.bat

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
:go-build
12+
if not exist libs\armeabi-v7a mkdir libs\armeabi-v7a
13+
if not exist src\go\hi mkdir src\go\hi
14+
if not exist jni\armeabi mkdir jni\armeabi
15+
16+
set CGO_ENABLED=1
17+
set GOOS=android
18+
set GOARCH=arm
19+
set GOARM=7
20+
set ANDROID_APP=%CD%
21+
22+
xcopy /y ..\..\app\*.java %ANDROID_APP%\src\go >nul
23+
copy /y ..\..\bind\java\Seq.java %ANDROID_APP%\src\go\Seq.java >nul
24+
25+
go build -ldflags="-shared" .
26+
if errorlevel 1 goto error-go-build
27+
28+
move /y libhello libs\armeabi-v7a\libgojni.so >nul
29+
30+
if defined ANT_HOME goto ant-build
31+
echo ANT_HOME path not defined
32+
goto end
33+
34+
:ant-build
35+
call %ANT_HOME%\bin\ant.bat debug >nul
36+
goto end
37+
38+
:error-invalid-path
39+
echo make.bat must be run from example\libhello
40+
goto end
41+
42+
:error-go-build
43+
echo Error building go lib
44+
goto end
45+
46+
:end

example/libhellojni/make.bat

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
set CGO_ENABLED=1
12+
set GOOS=android
13+
set GOARCH=arm
14+
set GOARM=7
15+
set ANDROID_APP=%CD%
16+
17+
if not exist src\main\jniLibs\armeabi mkdir src\main\jniLibs\armeabi
18+
if not exist src\main\java\go mkdir src\main\java\go
19+
if not exist src\main\java\demo mkdir src\main\java\demo
20+
21+
xcopy /y ..\..\app\*.java %ANDROID_APP%\src\main\java\go >nul
22+
xcopy /y ..\..\bind\java\*.java %ANDROID_APP%\src\main\java\go >nul
23+
xcopy /y %CD%\*.java %ANDROID_APP%\src\main\java\demo >nul
24+
25+
go build -ldflags="-shared" .
26+
if errorlevel 1 goto error-go-build
27+
28+
move /y libhellojni %ANDROID_APP%\src\main\jniLibs\armeabi\libgojni.so >nul
29+
goto end
30+
31+
:error-invalid-path
32+
echo make.bat must be run from example\libhellojni
33+
goto end
34+
35+
:error-go-build
36+
echo Error building go lib
37+
goto end
38+
39+
:end

0 commit comments

Comments
 (0)