2
0
mirror of synced 2025-02-22 22:38:18 +00:00

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 <crawshaw@golang.org>
This commit is contained in:
Daniel Ortiz Pereira da Silva 2014-12-12 14:07:10 -02:00 committed by David Crawshaw
parent 3bb5e71983
commit 9c997eaee4
5 changed files with 162 additions and 0 deletions

16
example/basic/all.bat Normal file
View File

@ -0,0 +1,16 @@
:: Copyright 2014 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.
@echo off
setlocal
echo # building basic
call make.bat
echo # installing bin/nativeactivity-debug.apk
adb install -r bin/nativeactivity-debug.apk >nul
echo # starting android.app.NativeActivity
adb shell am start -a android.intent.action.MAIN -n com.example.basic/android.app.NativeActivity >nul

45
example/basic/make.bat Normal file
View File

@ -0,0 +1,45 @@
:: Copyright 2014 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.
@echo off
setlocal
if not exist make.bat goto error-invalid-path
if not exist jni\armeabi mkdir jni\armeabi
set CGO_ENABLED=1
set GOOS=android
set GOARCH=arm
set GOARM=7
go build -ldflags="-shared" -o jni/armeabi/libbasic.so .
if errorlevel 1 goto error-go-build
if defined NDK_ROOT goto ndk-build
echo NDK_ROOT path not defined
goto end
:ndk-build
call %NDK_ROOT%\ndk-build.cmd NDK_DEBUG=1 >nul
if defined ANT_HOME goto ant-build
echo ANT_HOME path not defined
goto end
:ant-build
call %ANT_HOME%\bin\ant.bat debug >nul
goto end
:error-invalid-path
echo make.bat must be run from example\basic
goto end
:error-go-build
echo Error building go lib
goto end
:end

16
example/libhello/all.bat Normal file
View File

@ -0,0 +1,16 @@
:: Copyright 2014 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.
@echo off
setlocal
echo # building libhello
call make.bat
echo # installing bin/Hello-debug.apk
adb install -r bin/Hello-debug.apk >nul
echo # starting com.example.hello.MainActivity
adb shell am start -a android.intent.action.MAIN -n com.example.hello/com.example.hello.MainActivity >nul

46
example/libhello/make.bat Normal file
View File

@ -0,0 +1,46 @@
:: Copyright 2014 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.
@echo off
setlocal
if not exist make.bat goto error-invalid-path
:go-build
if not exist libs\armeabi-v7a mkdir libs\armeabi-v7a
if not exist src\go\hi mkdir src\go\hi
if not exist jni\armeabi mkdir jni\armeabi
set CGO_ENABLED=1
set GOOS=android
set GOARCH=arm
set GOARM=7
set ANDROID_APP=%CD%
xcopy /y ..\..\app\*.java %ANDROID_APP%\src\go >nul
copy /y ..\..\bind\java\Seq.java %ANDROID_APP%\src\go\Seq.java >nul
go build -ldflags="-shared" .
if errorlevel 1 goto error-go-build
move /y libhello libs\armeabi-v7a\libgojni.so >nul
if defined ANT_HOME goto ant-build
echo ANT_HOME path not defined
goto end
:ant-build
call %ANT_HOME%\bin\ant.bat debug >nul
goto end
:error-invalid-path
echo make.bat must be run from example\libhello
goto end
:error-go-build
echo Error building go lib
goto end
:end

View File

@ -0,0 +1,39 @@
:: Copyright 2014 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.
@echo off
setlocal
if not exist make.bat goto error-invalid-path
set CGO_ENABLED=1
set GOOS=android
set GOARCH=arm
set GOARM=7
set ANDROID_APP=%CD%
if not exist src\main\jniLibs\armeabi mkdir src\main\jniLibs\armeabi
if not exist src\main\java\go mkdir src\main\java\go
if not exist src\main\java\demo mkdir src\main\java\demo
xcopy /y ..\..\app\*.java %ANDROID_APP%\src\main\java\go >nul
xcopy /y ..\..\bind\java\*.java %ANDROID_APP%\src\main\java\go >nul
xcopy /y %CD%\*.java %ANDROID_APP%\src\main\java\demo >nul
go build -ldflags="-shared" .
if errorlevel 1 goto error-go-build
move /y libhellojni %ANDROID_APP%\src\main\jniLibs\armeabi\libgojni.so >nul
goto end
:error-invalid-path
echo make.bat must be run from example\libhellojni
goto end
:error-go-build
echo Error building go lib
goto end
:end