Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
8991d323
Commit
8991d323
authored
13 years ago
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Java wrapper build scripts.
Improved Android SDK search, fixed some bugs.
parent
cec8f719
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
173 additions
and
54 deletions
+173
-54
CMakeLists.txt
CMakeLists.txt
+2
-2
OpenCVDetectAndroidSDK.cmake
cmake/OpenCVDetectAndroidSDK.cmake
+117
-25
OpenCVModule.cmake
cmake/OpenCVModule.cmake
+3
-0
OpenCVUtils.cmake
cmake/OpenCVUtils.cmake
+37
-0
CMakeLists.txt
modules/java/CMakeLists.txt
+0
-0
default.properties
modules/java/android/default.properties
+0
-12
project.properties
modules/java/android/project.properties
+0
-12
AndroidManifest.xml
modules/java/android_test/AndroidManifest.xml
+14
-3
No files found.
CMakeLists.txt
View file @
8991d323
...
...
@@ -847,8 +847,8 @@ endif()
# samples and tests
status
(
""
)
status
(
" Tests and samples:"
)
status
(
" Tests:"
BUILD_TESTS THEN YES ELSE NO
)
status
(
" Performance tests:"
BUILD_PERF_TESTS THEN YES ELSE NO
)
status
(
" Tests:"
BUILD_TESTS
AND HAVE_opencv_ts
THEN YES ELSE NO
)
status
(
" Performance tests:"
BUILD_PERF_TESTS
AND HAVE_opencv_ts
THEN YES ELSE NO
)
status
(
" Examples:"
BUILD_EXAMPLES THEN YES ELSE NO
)
if
(
ANDROID
)
...
...
This diff is collapsed.
Click to expand it.
cmake/OpenCVDetectAndroidSDK.cmake
View file @
8991d323
if
(
EXISTS
"
${
ANDROID_EXECUTABLE
}
"
)
set
(
ANDROID_SDK_DETECT_QUIET TRUE
)
endif
()
file
(
TO_CMAKE_PATH
"$ENV{ProgramFiles}"
ProgramFiles_ENV_PATH
)
file
(
TO_CMAKE_PATH
"$ENV{ANDROID_SDK}"
ANDROID_SDK_ENV_PATH
)
file
(
TO_CMAKE_PATH
"$ENV{HOME}"
HOME_ENV_PATH
)
#find android SDK
if
(
CMAKE_HOST_WIN32
)
set
(
ANDROID_SDK_OS windows
)
elseif
(
CMAKE_HOST_APPLE
)
set
(
ANDROID_SDK_OS mac
)
else
()
set
(
ANDROID_SDK_OS linux
)
endif
()
#find android SDK: search in ANDROID_SDK first
find_host_program
(
ANDROID_EXECUTABLE
NAMES android.bat android
PATH_SUFFIXES tools
PATHS
ENV ANDROID_SDK
DOC
"Android SDK location"
NO_DEFAULT_PATH
)
# Now search default paths
find_host_program
(
ANDROID_EXECUTABLE
NAMES android.bat android
PATHS
"
${
ANDROID_SDK_ENV_PATH
}
/tools/"
"
${
ProgramFiles_ENV_PATH
}
/Android/android-sdk/tools/"
"
${
ProgramFiles_ENV_PATH
}
/Android/android-sdk-windows/tools/"
"/opt/android-sdk-linux/tools/"
"/opt/android-sdk-linux_x86/tools/"
"/opt/android-sdk-linux_86/tools/"
"/opt/android-sdk-mac/tools/"
"/opt/android-sdk-mac_x86/tools/"
"/opt/android-sdk-mac_86/tools/"
"/opt/android-sdk/tools/"
"
${
HOME_ENV_PATH
}
/NVPACK/android-sdk-linux_x86/tools/"
"
${
HOME_ENV_PATH
}
/NVPACK/android-sdk-linux_86/tools/"
"
${
HOME_ENV_PATH
}
/NVPACK/android-sdk-linux/tools/"
"
${
HOME_ENV_PATH
}
/NVPACK/android-sdk-mac_x86/tools/"
"
${
HOME_ENV_PATH
}
/NVPACK/android-sdk-mac_86/tools/"
"
${
HOME_ENV_PATH
}
/NVPACK/android-sdk-mac/tools/"
"$ENV{SystemDrive}/NVPACK/android-sdk-windows/tools/"
PATH_SUFFIXES android-sdk-
${
ANDROID_SDK_OS
}
/tools
android-sdk-
${
ANDROID_SDK_OS
}
_x86/tools
android-sdk-
${
ANDROID_SDK_OS
}
_86/tools
android-sdk/tools
PATHS /opt
"
${
HOME_ENV_PATH
}
/NVPACK"
"$ENV{SystemDrive}/NVPACK"
"
${
ProgramFiles_ENV_PATH
}
/Android"
DOC
"Android SDK location"
)
if
(
ANDROID_EXECUTABLE
)
if
(
NOT ANDROID_SDK_DETECT_QUIET
)
message
(
STATUS
" Found android tool:
${
ANDROID_EXECUTABLE
}
"
)
endif
()
get_filename_component
(
ANDROID_SDK_TOOLS_PATH
"
${
ANDROID_EXECUTABLE
}
"
PATH
)
#read source.properties
...
...
@@ -42,20 +58,46 @@ if(ANDROID_EXECUTABLE)
endforeach
()
endif
()
#fix missing revision (SDK tools before r9 don't set revision number correctly)
if
(
NOT ANDROID_TOOLS_Pkg_Revision
)
SET
(
ANDROID_TOOLS_Pkg_Revision
"Unknown"
CACHE INTERNAL
""
)
MARK_AS_ADVANCED
(
ANDROID_TOOLS_Pkg_Revision
)
endif
()
#fix missing description
if
(
NOT ANDROID_TOOLS_Pkg_Desc
)
SET
(
ANDROID_TOOLS_Pkg_Desc
"Android SDK Tools, revision
${
ANDROID_TOOLS_Pkg_Revision
}
."
CACHE INTERNAL
""
)
if
(
NOT ANDROID_TOOLS_Pkg_Revision GREATER 11
)
SET
(
ANDROID_TOOLS_Pkg_Desc
"
${
ANDROID_TOOLS_Pkg_Desc
}
It is recommended to update your SDK tools to revision 12 or newer."
CACHE INTERNAL
""
)
endif
()
MARK_AS_ADVANCED
(
ANDROID_TOOLS_Pkg_Desc
)
endif
()
#warn about outdated SDK
if
(
NOT ANDROID_TOOLS_Pkg_Revision GREATER 13
)
SET
(
ANDROID_TOOLS_Pkg_Desc
"
${
ANDROID_TOOLS_Pkg_Desc
}
It is recommended to update your SDK tools to revision 14 or newer."
CACHE INTERNAL
""
)
endif
()
if
(
ANDROID_TOOLS_Pkg_Revision GREATER 13
)
SET
(
ANDROID_PROJECT_PROPERTIES_FILE project.properties
)
SET
(
ANDROID_ANT_PROPERTIES_FILE ant.properties
)
else
()
SET
(
ANDROID_PROJECT_PROPERTIES_FILE default.properties
)
SET
(
ANDROID_ANT_PROPERTIES_FILE build.properties
)
endif
()
set
(
ANDROID_MANIFEST_FILE AndroidManifest.xml
)
set
(
ANDROID_LIB_PROJECT_FILES build.xml local.properties proguard-project.txt
${
ANDROID_PROJECT_PROPERTIES_FILE
}
)
set
(
ANDROID_PROJECT_FILES
${
ANDROID_ANT_PROPERTIES_FILE
}
${
ANDROID_LIB_PROJECT_FILES
}
)
#get installed targets
if
(
ANDROID_TOOLS_Pkg_Revision GREATER 11
)
execute_process
(
COMMAND
${
ANDROID_EXECUTABLE
}
list target -c
RESULT_VARIABLE ANDROID_PROCESS
OUTPUT_VARIABLE ANDROID_SDK_TARGETS
ERROR_VARIABLE ANDROID_PROCESS_ERRORS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string
(
REGEX MATCHALL
"[^
\n
]+"
ANDROID_SDK_TARGETS
"
${
ANDROID_SDK_TARGETS
}
"
)
else
()
#old SDKs (r11 and older) don't provide compact list
execute_process
(
COMMAND
${
ANDROID_EXECUTABLE
}
list target
RESULT_VARIABLE ANDROID_PROCESS
OUTPUT_VARIABLE ANDROID_SDK_TARGETS_FULL
...
...
@@ -71,8 +113,15 @@ if(ANDROID_EXECUTABLE)
list
(
APPEND ANDROID_SDK_TARGETS
"
${
line
}
"
)
endforeach
()
endif
()
endif
()
if
(
NOT ANDROID_PROCESS EQUAL 0
)
message
(
ERROR
"Failed to get list of installed Android targets."
)
set
(
ANDROID_EXECUTABLE
"ANDROID_EXECUTABLE-NOTFOUND"
)
endif
()
# detect ANDROID_SDK_TARGET if no target is provided by user
#TODO: remove this block
if
(
NOT ANDROID_SDK_TARGET
)
set
(
desired_android_target_level
${
ANDROID_NATIVE_API_LEVEL
}
)
if
(
desired_android_target_level LESS 11
)
...
...
@@ -95,8 +144,51 @@ if(ANDROID_EXECUTABLE)
endif
(
NOT ANDROID_SDK_TARGET
)
SET
(
ANDROID_SDK_TARGET
"
${
ANDROID_SDK_TARGET
}
"
CACHE STRING
"SDK target for Android tests and samples"
)
if
(
ANDROID_PROCESS EQUAL 0 AND CMAKE_VERSION VERSION_GREATER
"2.8"
)
set_property
(
CACHE ANDROID_SDK_TARGET PROPERTY STRINGS
${
ANDROID_SDK_TARGETS
}
)
endif
()
string
(
REGEX MATCH
"[0-9]+$"
ANDROID_SDK_TARGET_LEVEL
"
${
ANDROID_SDK_TARGET
}
"
)
endif
(
ANDROID_EXECUTABLE
)
# finds minimal installed SDK target compatible with provided names or API levels
# usage:
# get_compatible_android_api_level(VARIABLE [level1] [level2] ...)
macro
(
android_get_compatible_target VAR
)
set
(
${
VAR
}
"
${
VAR
}
-NOTFOUND"
)
if
(
ANDROID_SDK_TARGETS
)
list
(
GET ANDROID_SDK_TARGETS 1 __lvl
)
string
(
REGEX MATCH
"[0-9]+$"
__lvl
"
${
__lvl
}
"
)
#find minimal level mathing to all provided levels
foreach
(
lvl
${
ARGN
}
)
string
(
REGEX MATCH
"[0-9]+$"
__level
"
${
lvl
}
"
)
if
(
__level GREATER __lvl
)
set
(
__lvl
${
__level
}
)
endif
()
endforeach
()
#search for compatible levels
foreach
(
lvl
${
ANDROID_SDK_TARGETS
}
)
string
(
REGEX MATCH
"[0-9]+$"
__level
"
${
lvl
}
"
)
if
(
__level EQUAL __lvl
)
#look for exact match
foreach
(
usrlvl
${
ARGN
}
)
if
(
"
${
usrlvl
}
"
STREQUAL
"
${
lvl
}
"
)
set
(
${
VAR
}
"
${
lvl
}
"
)
break
()
endif
()
endforeach
()
if
(
"
${${
VAR
}}
"
STREQUAL
"
${
lvl
}
"
)
break
()
#exact match was found
elseif
(
NOT
${
VAR
}
)
set
(
${
VAR
}
"
${
lvl
}
"
)
endif
()
elseif
(
__level GREATER __lvl
)
if
(
NOT
${
VAR
}
)
set
(
${
VAR
}
"
${
lvl
}
"
)
endif
()
break
()
endif
()
endforeach
()
unset
(
__lvl
)
unset
(
__level
)
endif
()
endmacro
()
This diff is collapsed.
Click to expand it.
cmake/OpenCVModule.cmake
View file @
8991d323
...
...
@@ -387,6 +387,9 @@ macro(ocv_set_module_sources)
ocv_get_module_external_sources
()
endif
()
# use full paths for module to be independent from the module location
ocv_to_full_paths
(
OPENCV_MODULE_
${
the_module
}
_HEADERS
)
set
(
OPENCV_MODULE_
${
the_module
}
_HEADERS
${
OPENCV_MODULE_
${
the_module
}
_HEADERS
}
CACHE INTERNAL
"List of header files for
${
the_module
}
"
)
set
(
OPENCV_MODULE_
${
the_module
}
_SOURCES
${
OPENCV_MODULE_
${
the_module
}
_SOURCES
}
CACHE INTERNAL
"List of source files for
${
the_module
}
"
)
endmacro
()
...
...
This diff is collapsed.
Click to expand it.
cmake/OpenCVUtils.cmake
View file @
8991d323
...
...
@@ -216,6 +216,28 @@ macro(ocv_list_sort __lst)
endmacro
()
# add prefix to each item in the list
macro
(
ocv_list_add_prefix LST PREFIX
)
set
(
__tmp
""
)
foreach
(
item
${${
LST
}}
)
list
(
APPEND __tmp
"
${
PREFIX
}${
item
}
"
)
endforeach
()
set
(
${
LST
}
${
__tmp
}
)
unset
(
__tmp
)
endmacro
()
# add suffix to each item in the list
macro
(
ocv_list_add_suffix LST SUFFIX
)
set
(
__tmp
""
)
foreach
(
item
${${
LST
}}
)
list
(
APPEND __tmp
"
${
item
}${
SUFFIX
}
"
)
endforeach
()
set
(
${
LST
}
${
__tmp
}
)
unset
(
__tmp
)
endmacro
()
# simple regex escaping routine (does not cover all cases!!!)
macro
(
ocv_regex_escape var regex
)
string
(
REGEX REPLACE
"([+.*^$])"
"
\\\\
1"
${
var
}
"
${
regex
}
"
)
...
...
@@ -230,3 +252,17 @@ macro(ocv_get_real_path VAR PATHSTR)
get_filename_component
(
${
VAR
}
"
${
PATHSTR
}
"
REALPATH
)
endif
()
endmacro
()
# convert list of paths to full paths
macro
(
ocv_to_full_paths VAR
)
if
(
${
VAR
}
)
set
(
__tmp
""
)
foreach
(
path
${${
VAR
}}
)
get_filename_component
(
${
VAR
}
"
${
path
}
"
ABSOLUTE
)
list
(
APPEND __tmp
"
${${
VAR
}}
"
)
endforeach
()
set
(
${
VAR
}
${
__tmp
}
)
unset
(
__tmp
)
endif
()
endmacro
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
modules/java/CMakeLists.txt
View file @
8991d323
This diff is collapsed.
Click to expand it.
modules/java/android/default.properties
deleted
100644 → 0
View file @
cec8f719
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
android.library
=
true
# Project target.
target
=
android-8
This diff is collapsed.
Click to expand it.
modules/java/android/project.properties
deleted
100644 → 0
View file @
cec8f719
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.
android.library
=
true
# Project target.
target
=
android-8
This diff is collapsed.
Click to expand it.
modules/java/android_test/AndroidManifest.xml
View file @
8991d323
...
...
@@ -5,14 +5,24 @@
android:versionName=
"1.0"
>
<uses-sdk
android:minSdkVersion=
"8"
/>
<instrumentation
android:targetPackage=
"org.opencv.test"
android:name=
"OpenCVTestRunner"
></instrumentation>
<application
android:icon=
"@drawable/icon"
android:label=
"@string/app_name"
>
<!-- We add an application tag here just so that we can indicate that
this package needs to link against the android.test library,
which is needed when building test cases. -->
<application>
<uses-library
android:name=
"android.test.runner"
/>
</application>
<!--
This declares that this application uses the instrumentation test runner targeting
the package of org.opencv. To run the tests use the command:
"adb shell am instrument -w org.opencv.test/android.test.InstrumentationTestRunner"
-->
<instrumentation
android:name=
"android.test.InstrumentationTestRunner"
android:targetPackage=
"org.opencv"
android:label=
"Tests for org.opencv"
/>
<uses-permission
android:name=
"android.permission.CAMERA"
/>
<uses-feature
android:name=
"android.hardware.camera"
/>
<uses-feature
android:name=
"android.hardware.camera.autofocus"
/>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
></uses-permission
>
<uses-permission
android:name=
"android.permission.WRITE_EXTERNAL_STORAGE"
/
>
</manifest>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment