2011-05-10 15:35:20 +02:00
|
|
|
@ECHO OFF
|
|
|
|
|
|
|
|
:: enable command extensions
|
|
|
|
VERIFY BADVALUE 2>NUL
|
|
|
|
SETLOCAL ENABLEEXTENSIONS || (ECHO Unable to enable command extensions. & EXIT \B)
|
|
|
|
|
|
|
|
:: build environment
|
|
|
|
SET SOURCE_DIR=%cd%
|
2012-02-06 12:30:59 +01:00
|
|
|
IF EXIST .\android.toolchain.cmake (SET BUILD_OPENCV=1) ELSE (SET BUILD_OPENCV=0)
|
2011-05-10 15:35:20 +02:00
|
|
|
IF EXIST .\jni\nul (SET BUILD_JAVA_PART=1) ELSE (SET BUILD_JAVA_PART=0)
|
|
|
|
|
|
|
|
:: load configuration
|
|
|
|
PUSHD %~dp0
|
|
|
|
SET SCRIPTS_DIR=%cd%
|
|
|
|
IF EXIST .\wincfg.cmd CALL .\wincfg.cmd
|
|
|
|
POPD
|
|
|
|
|
|
|
|
:: defaults
|
|
|
|
IF NOT DEFINED BUILD_DIR SET BUILD_DIR=build
|
2011-11-16 15:32:10 +01:00
|
|
|
IF NOT DEFINED ANDROID_ABI SET ANDROID_ABI=armeabi-v7a
|
2011-05-10 15:35:20 +02:00
|
|
|
SET OPENCV_BUILD_DIR=%SCRIPTS_DIR%\..\%BUILD_DIR%
|
|
|
|
|
|
|
|
:: check that all required variables defined
|
|
|
|
PUSHD .
|
|
|
|
IF NOT DEFINED ANDROID_NDK (ECHO. & ECHO You should set an environment variable ANDROID_NDK to the full path to your copy of Android NDK & GOTO end)
|
|
|
|
(CD "%ANDROID_NDK%") || (ECHO. & ECHO Directory "%ANDROID_NDK%" specified by ANDROID_NDK variable does not exist & GOTO end)
|
|
|
|
|
|
|
|
IF NOT EXIST "%CMAKE_EXE%" (ECHO. & ECHO You should set an environment variable CMAKE_EXE to the full path to cmake executable & GOTO end)
|
|
|
|
IF NOT EXIST "%MAKE_EXE%" (ECHO. & ECHO You should set an environment variable MAKE_EXE to the full path to native port of make executable & GOTO end)
|
|
|
|
|
|
|
|
IF NOT %BUILD_JAVA_PART%==1 GOTO required_variables_checked
|
|
|
|
|
|
|
|
IF NOT DEFINED ANDROID_SDK (ECHO. & ECHO You should set an environment variable ANDROID_SDK to the full path to your copy of Android SDK & GOTO end)
|
|
|
|
(CD "%ANDROID_SDK%" 2>NUL) || (ECHO. & ECHO Directory "%ANDROID_SDK%" specified by ANDROID_SDK variable does not exist & GOTO end)
|
|
|
|
|
|
|
|
IF NOT DEFINED ANT_DIR (ECHO. & ECHO You should set an environment variable ANT_DIR to the full path to Apache Ant root & GOTO end)
|
|
|
|
(CD "%ANT_DIR%" 2>NUL) || (ECHO. & ECHO Directory "%ANT_DIR%" specified by ANT_DIR variable does not exist & GOTO end)
|
|
|
|
|
|
|
|
IF NOT DEFINED JAVA_HOME (ECHO. & ECHO You should set an environment variable JAVA_HOME to the full path to JDK & GOTO end)
|
|
|
|
(CD "%JAVA_HOME%" 2>NUL) || (ECHO. & ECHO Directory "%JAVA_HOME%" specified by JAVA_HOME variable does not exist & GOTO end)
|
|
|
|
|
|
|
|
:required_variables_checked
|
|
|
|
POPD
|
|
|
|
|
|
|
|
:: create build dir
|
|
|
|
IF DEFINED REBUILD rmdir /S /Q "%BUILD_DIR%" 2>NUL
|
|
|
|
MKDIR "%BUILD_DIR%" 2>NUL
|
|
|
|
PUSHD "%BUILD_DIR%" || (ECHO. & ECHO Directory "%BUILD_DIR%" is not found & GOTO end)
|
|
|
|
|
|
|
|
:: run cmake
|
|
|
|
ECHO. & ECHO Runnning cmake...
|
2011-11-16 15:32:10 +01:00
|
|
|
ECHO ANDROID_ABI=%ANDROID_ABI%
|
2011-05-10 15:35:20 +02:00
|
|
|
ECHO.
|
|
|
|
IF NOT %BUILD_OPENCV%==1 GOTO other-cmake
|
|
|
|
:opencv-cmake
|
2012-02-06 12:30:59 +01:00
|
|
|
("%CMAKE_EXE%" -G"MinGW Makefiles" -DANDROID_ABI="%ANDROID_ABI%" -DCMAKE_TOOLCHAIN_FILE="%SOURCE_DIR%"\android.toolchain.cmake -DCMAKE_MAKE_PROGRAM="%MAKE_EXE%" %* "%SOURCE_DIR%\..") && GOTO cmakefin
|
2011-05-10 15:35:20 +02:00
|
|
|
ECHO. & ECHO cmake failed & GOTO end
|
|
|
|
:other-cmake
|
2011-11-17 21:43:14 +01:00
|
|
|
("%CMAKE_EXE%" -G"MinGW Makefiles" -DANDROID_ABI="%ANDROID_ABI%" -DOpenCV_DIR="%OPENCV_BUILD_DIR%" -DCMAKE_TOOLCHAIN_FILE="%OPENCV_BUILD_DIR%\..\android.toolchain.cmake" -DCMAKE_MAKE_PROGRAM="%MAKE_EXE%" %* "%SOURCE_DIR%") && GOTO cmakefin
|
2011-05-10 15:35:20 +02:00
|
|
|
ECHO. & ECHO cmake failed & GOTO end
|
|
|
|
:cmakefin
|
|
|
|
|
|
|
|
:: run make
|
|
|
|
ECHO. & ECHO Building native libs...
|
|
|
|
("%MAKE_EXE%" -j %NUMBER_OF_PROCESSORS% VERBOSE=%VERBOSE%) || (ECHO. & ECHO make failed & GOTO end)
|
|
|
|
|
|
|
|
IF NOT %BUILD_JAVA_PART%==1 GOTO end
|
|
|
|
POPD && PUSHD %SOURCE_DIR%
|
|
|
|
|
|
|
|
:: configure java part
|
|
|
|
ECHO. & ECHO Updating Android project...
|
|
|
|
(CALL "%ANDROID_SDK%\tools\android" update project --name %PROJECT_NAME% --path .) || (ECHO. & ECHO failed to update android project & GOTO end)
|
|
|
|
|
|
|
|
:: compile java part
|
|
|
|
ECHO. & ECHO Compiling Android project...
|
2012-02-24 10:39:28 +01:00
|
|
|
(CALL "%ANT_DIR%\bin\ant" debug) || (ECHO. & ECHO failed to compile android project & GOTO end)
|
2011-05-10 15:35:20 +02:00
|
|
|
|
|
|
|
:end
|
|
|
|
POPD
|
2011-11-16 15:32:10 +01:00
|
|
|
ENDLOCAL
|