parent
f8e4b10248
commit
4c7a8f8d24
7 changed files with 136 additions and 41 deletions
@ -0,0 +1,5 @@ |
|||||||
|
@ECHO OFF |
||||||
|
PUSHD %~dp0 |
||||||
|
SET PROJECT_NAME=android-opencv |
||||||
|
CALL ..\scripts\cmake_android.cmd |
||||||
|
POPD |
@ -1,11 +1,96 @@ |
|||||||
cd %~dp0\.. |
@ECHO OFF |
||||||
|
|
||||||
::rmdir /S /Q build |
:: don't modify the caller's environment |
||||||
mkdir build 2>nul |
SETLOCAL |
||||||
|
|
||||||
SET ANDROID_NDK=C:\apps\android-ndk-r5b |
:: enable command extensions |
||||||
SET CMAKE_EXE=C:\apps\cmake\bin\cmake.exe |
VERIFY BADVALUE 2>NUL |
||||||
SET MAKE_EXE=C:\apps\gnuport\make.exe |
SETLOCAL ENABLEEXTENSIONS |
||||||
|
IF ERRORLEVEL 1 ECHO Unable to enable command extensions. |
||||||
|
|
||||||
cd build |
:: load configuration |
||||||
%CMAKE_EXE% -C ../CMakeCache.android.initial.cmake -G"Unix Makefiles" -DCMAKE_TOOLCHAIN_FILE=..\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=%MAKE_EXE% ..\.. |
PUSHD %~dp0 |
||||||
|
IF NOT EXIST .\wincfg.cmd GOTO nocfg |
||||||
|
CALL .\wincfg.cmd |
||||||
|
SET OPENCV_BUILD_DIR="%cd%"\..\%BUILD_DIR% |
||||||
|
POPD |
||||||
|
|
||||||
|
:: path to project root |
||||||
|
SET SOURCE_DIR="%cd%" |
||||||
|
|
||||||
|
:: create build dir |
||||||
|
::rmdir /S /Q %BUILD_DIR% &:: uncomment this line to rebuild instead of build |
||||||
|
MKDIR %BUILD_DIR% 2>NUL |
||||||
|
PUSHD %BUILD_DIR% |
||||||
|
|
||||||
|
:: run cmake |
||||||
|
ECHO. |
||||||
|
ECHO Runnning cmake... |
||||||
|
ECHO ARM_TARGET=%ARM_TARGET% |
||||||
|
ECHO. |
||||||
|
IF NOT EXIST %SOURCE_DIR%\CMakeCache.android.initial.cmake GOTO other-cmake |
||||||
|
:opencv-cmake |
||||||
|
%CMAKE_EXE% -G"MinGW Makefiles" -DARM_TARGET="%ARM_TARGET%" -C %SOURCE_DIR%\CMakeCache.android.initial.cmake -DCMAKE_TOOLCHAIN_FILE=%SOURCE_DIR%\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM="%MAKE_EXE%" %SOURCE_DIR%\.. |
||||||
|
IF ERRORLEVEL 1 GOTO cmakefails |
||||||
|
GOTO cmakefin |
||||||
|
:other-cmake |
||||||
|
%CMAKE_EXE% -G"MinGW Makefiles" -DARM_TARGET="%ARM_TARGET%" -DOpenCV_DIR=%OPENCV_BUILD_DIR% -DCMAKE_PROGRAM_PATH=%SWIG_DIR% -DCMAKE_TOOLCHAIN_FILE=%OPENCV_BUILD_DIR%\..\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM="%MAKE_EXE%" %SOURCE_DIR% |
||||||
|
IF ERRORLEVEL 1 GOTO cmakefails |
||||||
|
GOTO cmakefin |
||||||
|
:cmakefin |
||||||
|
|
||||||
|
:: run make |
||||||
|
ECHO. |
||||||
|
ECHO Building native libs... |
||||||
|
%MAKE_EXE% -j %NUMBER_OF_PROCESSORS% &:: VERBOSE=1 |
||||||
|
IF ERRORLEVEL 1 GOTO makefail |
||||||
|
|
||||||
|
IF NOT EXIST ..\jni GOTO fin |
||||||
|
|
||||||
|
:: configure java part |
||||||
|
POPD |
||||||
|
PUSHD . |
||||||
|
ECHO. |
||||||
|
ECHO Updating Android project... |
||||||
|
CALL %ANDROID_SDK%\tools\android update project --name %PROJECT_NAME% --path . |
||||||
|
IF ERRORLEVEL 1 GOTO androidfail |
||||||
|
|
||||||
|
:: compile java part |
||||||
|
ECHO. |
||||||
|
ECHO Compiling Android project... |
||||||
|
CALL %ANT_DIR%\bin\ant compile |
||||||
|
IF ERRORLEVEL 1 GOTO antfail |
||||||
|
|
||||||
|
GOTO fin |
||||||
|
|
||||||
|
:nocfg |
||||||
|
ECHO. |
||||||
|
ECHO Could not find wincfg.cmd file. |
||||||
|
ECHO. |
||||||
|
ECHO You should create opencv\android\scripts\wincfg.cmd |
||||||
|
ECHO from template opencv\android\scripts\wincfg.cmd.tmpl |
||||||
|
GOTO fin |
||||||
|
|
||||||
|
:antfail |
||||||
|
ECHO. |
||||||
|
ECHO failed to compile android project |
||||||
|
GOTO fin |
||||||
|
|
||||||
|
:androidfail |
||||||
|
ECHO. |
||||||
|
ECHO failed to update android project |
||||||
|
GOTO fin |
||||||
|
|
||||||
|
:makefail |
||||||
|
ECHO. |
||||||
|
ECHO make failed |
||||||
|
GOTO fin |
||||||
|
|
||||||
|
:cmakefail |
||||||
|
ECHO. |
||||||
|
ECHO cmake failed |
||||||
|
GOTO fin |
||||||
|
|
||||||
|
:fin |
||||||
|
POPD |
||||||
|
ENDLOCAL |
@ -1,11 +0,0 @@ |
|||||||
cd %~dp0\.. |
|
||||||
|
|
||||||
::rmdir /S /Q build |
|
||||||
mkdir build 2>nul |
|
||||||
|
|
||||||
SET ANDROID_NDK=C:\apps\android-ndk-r5b |
|
||||||
SET CMAKE_EXE=C:\apps\cmake\bin\cmake.exe |
|
||||||
SET MAKE_EXE=C:\apps\gnuport\make.exe |
|
||||||
|
|
||||||
cd build |
|
||||||
%CMAKE_EXE% -C ../CMakeCache.android.initial.cmake -G"Unix Makefiles" -DARM_TARGET=armeabi -DCMAKE_TOOLCHAIN_FILE=..\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=%MAKE_EXE% ..\.. |
|
@ -1,11 +0,0 @@ |
|||||||
cd %~dp0\.. |
|
||||||
|
|
||||||
::rmdir /S /Q build |
|
||||||
mkdir build 2>nul |
|
||||||
|
|
||||||
SET ANDROID_NDK=C:\apps\android-ndk-r5b |
|
||||||
SET CMAKE_EXE=C:\apps\cmake\bin\cmake.exe |
|
||||||
SET MAKE_EXE=C:\apps\gnuport\make.exe |
|
||||||
|
|
||||||
cd build |
|
||||||
%CMAKE_EXE% -C ../CMakeCache.android.initial.cmake -G"Unix Makefiles" -DARM_TARGET="armeabi-v7a with NEON" -DCMAKE_TOOLCHAIN_FILE=..\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=%MAKE_EXE% ..\.. |
|
@ -0,0 +1,26 @@ |
|||||||
|
:: variables required for OpenCV build :: |
||||||
|
SET ANDROID_NDK=C:\full\path\to\your\copy\of\android\NDK\android-ndk-r5b |
||||||
|
SET CMAKE_EXE=C:\full\path\to\cmake\utility\cmake.exe |
||||||
|
SET MAKE_EXE=C:\full\path\to\native\port\of\make\utility\make.exe |
||||||
|
|
||||||
|
:: variables required for android-opencv build :: |
||||||
|
SET SWIG_DIR=C:\full\path\to\SWIG\directory\swigwin-2.0.3 |
||||||
|
SET ANDROID_SDK=C:\full\path\to\your\copy\of\android\SDK\android-sdk-windows |
||||||
|
SET ANT_DIR=C:\full\path\to\ant\directory\apache-ant-1.8.2 |
||||||
|
SET JAVA_HOME=C:\full\path\to\JDK\jdk1.6.0_25 |
||||||
|
|
||||||
|
:: configuration options :: |
||||||
|
:::: general ARM-V7 settings |
||||||
|
SET ARM_TARGET=armeabi-v7a |
||||||
|
SET BUILD_DIR=build |
||||||
|
|
||||||
|
:::: uncomment following lines to compile for emulator or old device |
||||||
|
::SET ARM_TARGET=armeabi |
||||||
|
::SET BUILD_DIR=build_armeabi |
||||||
|
|
||||||
|
:::: uncomment following lines to compile for ARM-V7 with NEON support |
||||||
|
::SET ARM_TARGET="armeabi-v7a with NEON" |
||||||
|
::SET BUILD_DIR=build_neon |
||||||
|
|
||||||
|
:::: other options |
||||||
|
::SET ANDROID_API_LEVEL=8 &:: android-3 is enough for OpenCV but android-8 is recommended |
Loading…
Reference in new issue