Commit 8b554d3c authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

Merge pull request #5654 from mshabunin:ios-framework

parents b4112a58 e8bf4417
...@@ -40,6 +40,7 @@ source_group("Include" FILES ${lib_hdrs} ) ...@@ -40,6 +40,7 @@ source_group("Include" FILES ${lib_hdrs} )
source_group("Src" FILES ${lib_srcs}) source_group("Src" FILES ${lib_srcs})
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -Wmissing-declarations -Wuninitialized -Wswitch -Wparentheses -Warray-bounds -Wextra) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -Wmissing-declarations -Wuninitialized -Wswitch -Wparentheses -Warray-bounds -Wextra)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wdeprecated-declarations)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4245 /wd4305 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800) # vs2005 ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4245 /wd4305 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800) # vs2005
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4334) # vs2005 Win64 ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4334) # vs2005 Win64
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008 ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
......
...@@ -639,13 +639,13 @@ mark_as_advanced(CUDA_TARGET_OS_VARIANT) ...@@ -639,13 +639,13 @@ mark_as_advanced(CUDA_TARGET_OS_VARIANT)
# Target triplet # Target triplet
if(DEFINED CUDA_TARGET_TRIPLET) if(DEFINED CUDA_TARGET_TRIPLET)
set(_cuda_target_triplet_initial "${CUDA_TARGET_TRIPLET}") set(_cuda_target_triplet_initial "${CUDA_TARGET_TRIPLET}")
elseif(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND "${CUDA_TARGET_CPU_ARCH}" STREQUAL "ARM") elseif(CUDA_VERSION VERSION_GREATER "5.0" AND CMAKE_CROSSCOMPILING AND "x${CUDA_TARGET_CPU_ARCH}" STREQUAL "xARM")
if("${CUDA_TARGET_OS_VARIANT}" STREQUAL "Android" AND EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-androideabi") if("${CUDA_TARGET_OS_VARIANT}" STREQUAL "Android" AND EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-androideabi")
set(_cuda_target_triplet_initial "armv7-linux-androideabi") set(_cuda_target_triplet_initial "armv7-linux-androideabi")
elseif(EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf") elseif(EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/armv7-linux-gnueabihf")
set(_cuda_target_triplet_initial "armv7-linux-gnueabihf") set(_cuda_target_triplet_initial "armv7-linux-gnueabihf")
endif() endif()
elseif(CUDA_VERSION VERSION_GREATER "6.5" AND CMAKE_CROSSCOMPILING AND "${CUDA_TARGET_CPU_ARCH}" STREQUAL "AARCH64") elseif(CUDA_VERSION VERSION_GREATER "6.5" AND CMAKE_CROSSCOMPILING AND "x${CUDA_TARGET_CPU_ARCH}" STREQUAL "xAARCH64")
if("${CUDA_TARGET_OS_VARIANT}" STREQUAL "Android" AND EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux-androideabi") if("${CUDA_TARGET_OS_VARIANT}" STREQUAL "Android" AND EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux-androideabi")
set(_cuda_target_triplet_initial "aarch64-linux-androideabi") set(_cuda_target_triplet_initial "aarch64-linux-androideabi")
elseif(EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux-gnueabihf") elseif(EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/targets/aarch64-linux-gnueabihf")
......
...@@ -306,23 +306,17 @@ macro(add_android_project target path) ...@@ -306,23 +306,17 @@ macro(add_android_project target path)
# build java part # build java part
if(android_proj_IGNORE_JAVA) if(android_proj_IGNORE_JAVA)
add_custom_command( set(android_proj_extra_deps "")
OUTPUT "${android_proj_bin_dir}/bin/${target}-debug.apk"
COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug
COMMAND ${CMAKE_COMMAND} -E touch "${android_proj_bin_dir}/bin/${target}-debug.apk" # needed because ant does not update the timestamp of updated apk
WORKING_DIRECTORY "${android_proj_bin_dir}"
MAIN_DEPENDENCY "${android_proj_bin_dir}/${ANDROID_MANIFEST_FILE}"
DEPENDS ${android_proj_file_deps} ${JNI_LIB_NAME})
else() else()
list(APPEND android_proj_extra_deps "${OpenCV_BINARY_DIR}/bin/classes.jar.dephelper" opencv_java)
endif()
add_custom_command( add_custom_command(
OUTPUT "${android_proj_bin_dir}/bin/${target}-debug.apk" OUTPUT "${android_proj_bin_dir}/bin/${target}-debug.apk"
COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6
COMMAND ${CMAKE_COMMAND} -E touch "${android_proj_bin_dir}/bin/${target}-debug.apk" # needed because ant does not update the timestamp of updated apk COMMAND ${CMAKE_COMMAND} -E touch "${android_proj_bin_dir}/bin/${target}-debug.apk" # needed because ant does not update the timestamp of updated apk
WORKING_DIRECTORY "${android_proj_bin_dir}" WORKING_DIRECTORY "${android_proj_bin_dir}"
MAIN_DEPENDENCY "${android_proj_bin_dir}/${ANDROID_MANIFEST_FILE}" MAIN_DEPENDENCY "${android_proj_bin_dir}/${ANDROID_MANIFEST_FILE}"
DEPENDS "${OpenCV_BINARY_DIR}/bin/classes.jar.dephelper" opencv_java # as we are part of OpenCV we can just force this dependency DEPENDS ${android_proj_extra_deps} ${android_proj_file_deps} ${JNI_LIB_NAME})
DEPENDS ${android_proj_file_deps} ${JNI_LIB_NAME})
endif()
unset(JNI_LIB_NAME) unset(JNI_LIB_NAME)
......
...@@ -83,11 +83,6 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags) ...@@ -83,11 +83,6 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
endif() endif()
ENDFOREACH(item) ENDFOREACH(item)
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
GET_DIRECTORY_PROPERTY(_global_definitions DIRECTORY ${OpenCV_SOURCE_DIR} DEFINITIONS)
#MESSAGE("_directory_flags ${_directory_flags} ${_global_definitions}" )
LIST(APPEND ${_out_compile_flags} ${_directory_flags})
LIST(APPEND ${_out_compile_flags} ${_global_definitions})
LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS}) LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS})
SEPARATE_ARGUMENTS(${_out_compile_flags}) SEPARATE_ARGUMENTS(${_out_compile_flags})
......
...@@ -260,6 +260,8 @@ enum BorderTypes { ...@@ -260,6 +260,8 @@ enum BorderTypes {
# endif # endif
# if __has_extension(cxx_static_assert) # if __has_extension(cxx_static_assert)
# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition) # define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
# elif __has_extension(c_static_assert)
# define CV_StaticAssert(condition, reason) _Static_assert((condition), reason " " #condition)
# endif # endif
#elif defined(__GNUC__) #elif defined(__GNUC__)
# if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) # if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
......
...@@ -308,7 +308,7 @@ if(ANDROID) ...@@ -308,7 +308,7 @@ if(ANDROID)
# build the library project # build the library project
# normally we should do this after a native part, but for a library project we can build the java part first # normally we should do this after a native part, but for a library project we can build the java part first
add_custom_command(OUTPUT "${JAR_FILE}" "${JAR_FILE}.dephelper" add_custom_command(OUTPUT "${JAR_FILE}" "${JAR_FILE}.dephelper"
COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6
COMMAND ${CMAKE_COMMAND} -E touch "${JAR_FILE}.dephelper" # can not rely on classes.jar because different versions of SDK update timestamp at different times COMMAND ${CMAKE_COMMAND} -E touch "${JAR_FILE}.dephelper" # can not rely on classes.jar because different versions of SDK update timestamp at different times
WORKING_DIRECTORY "${OpenCV_BINARY_DIR}" WORKING_DIRECTORY "${OpenCV_BINARY_DIR}"
DEPENDS ${step3_depends} DEPENDS ${step3_depends}
......
...@@ -50,7 +50,7 @@ get_filename_component(java_name "${java_location}" NAME) ...@@ -50,7 +50,7 @@ get_filename_component(java_name "${java_location}" NAME)
add_custom_command( add_custom_command(
OUTPUT "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" OUTPUT "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${java_location}" "${opencv_test_java_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${java_name}" COMMAND ${CMAKE_COMMAND} -E copy_if_different "${java_location}" "${opencv_test_java_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${java_name}"
COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug COMMAND ${ANT_EXECUTABLE} -q -noinput -k debug -Djava.target=1.6 -Djava.source=1.6
COMMAND ${CMAKE_COMMAND} -E touch "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" # needed because ant does not update the timestamp of updated apk COMMAND ${CMAKE_COMMAND} -E touch "${opencv_test_java_bin_dir}/bin/OpenCVTest-debug.apk" # needed because ant does not update the timestamp of updated apk
WORKING_DIRECTORY "${opencv_test_java_bin_dir}" WORKING_DIRECTORY "${opencv_test_java_bin_dir}"
MAIN_DEPENDENCY "${opencv_test_java_bin_dir}/${ANDROID_MANIFEST_FILE}" MAIN_DEPENDENCY "${opencv_test_java_bin_dir}/${ANDROID_MANIFEST_FILE}"
......
...@@ -910,7 +910,7 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { ...@@ -910,7 +910,7 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() {
} }
AVAssetReaderTrackOutput * output = [mMovieReader.outputs objectAtIndex:0]; AVAssetReaderOutput * output = [mMovieReader.outputs objectAtIndex:0];
CMSampleBufferRef sampleBuffer = [output copyNextSampleBuffer]; CMSampleBufferRef sampleBuffer = [output copyNextSampleBuffer];
if (!sampleBuffer) { if (!sampleBuffer) {
[localpool drain]; [localpool drain];
......
...@@ -294,7 +294,7 @@ bool CvCaptureCAM::grabFrame(double timeOut) { ...@@ -294,7 +294,7 @@ bool CvCaptureCAM::grabFrame(double timeOut) {
// method exits immediately" // method exits immediately"
// using usleep() is not a good alternative, because it may block the GUI. // using usleep() is not a good alternative, because it may block the GUI.
// Create a dummy timer so that runUntilDate does not exit immediately: // Create a dummy timer so that runUntilDate does not exit immediately:
[NSTimer scheduledTimerWithTimeInterval:100 target:nil selector:@selector(doFireTimer:) userInfo:nil repeats:YES]; [NSTimer scheduledTimerWithTimeInterval:100 target:capture selector:@selector(doFireTimer:) userInfo:nil repeats:YES];
while (![capture updateImage] && (total += sleepTime)<=timeOut) { while (![capture updateImage] && (total += sleepTime)<=timeOut) {
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:sleepTime]]; [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:sleepTime]];
} }
......
...@@ -25,141 +25,165 @@ The script should handle minor OpenCV updates efficiently ...@@ -25,141 +25,165 @@ The script should handle minor OpenCV updates efficiently
However, opencv2.framework directory is erased and recreated on each run. However, opencv2.framework directory is erased and recreated on each run.
""" """
import glob, re, os, os.path, shutil, string, sys, exceptions, subprocess, argparse from __future__ import print_function
import glob, re, os, os.path, shutil, string, sys, argparse, traceback
opencv_contrib_path = None from subprocess import check_call, check_output, CalledProcessError
def execute(cmd): def execute(cmd, cwd = None):
try: print("Executing: %s in %s" % (cmd, cwd), file=sys.stderr)
print >>sys.stderr, "Executing:", cmd retcode = check_call(cmd, cwd = cwd)
retcode = subprocess.call(cmd, shell=True) if retcode != 0:
if retcode < 0:
raise Exception("Child was terminated by signal:", -retcode)
elif retcode > 0:
raise Exception("Child returned:", retcode) raise Exception("Child returned:", retcode)
except OSError as e:
raise Exception("Execution failed:", e)
def build_opencv(srcroot, buildroot, target, arch):
"builds OpenCV for device or simulator"
builddir = os.path.join(buildroot, target + '-' + arch)
if not os.path.isdir(builddir):
os.makedirs(builddir)
currdir = os.getcwd()
os.chdir(builddir)
# for some reason, if you do not specify CMAKE_BUILD_TYPE, it puts libs to "RELEASE" rather than "Release"
cmakeargs = ("-GXcode " +
"-DCMAKE_BUILD_TYPE=Release " +
"-DCMAKE_TOOLCHAIN_FILE=%s/platforms/ios/cmake/Toolchains/Toolchain-%s_Xcode.cmake " +
"-DCMAKE_C_FLAGS=\"-Wno-implicit-function-declaration\" " +
"-DCMAKE_INSTALL_PREFIX=install") % (srcroot, target)
if arch.startswith("armv"):
cmakeargs += " -DENABLE_NEON=ON"
if opencv_contrib_path is not None:
cmakeargs += " -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON -DOPENCV_EXTRA_MODULES_PATH=%s -DBUILD_opencv_contrib_world=ON" % opencv_contrib_path
build_target = "opencv_contrib_world"
libname = "libopencv_contrib_world.a"
else:
cmakeargs += " -DBUILD_opencv_world=ON"
build_target = "ALL_BUILD"
libname = "libopencv_world.a"
# if cmake cache exists, just rerun cmake to update OpenCV.xcodeproj if necessary def getXCodeMajor():
if os.path.isfile(os.path.join(builddir, "CMakeCache.txt")): ret = check_output(["xcodebuild", "-version"])
execute("cmake %s ." % (cmakeargs,)) m = re.match(r'XCode\s+(\d)\..*', ret, flags=re.IGNORECASE)
if m:
return int(m.group(1))
return 0
class Builder:
def __init__(self, opencv, contrib):
self.opencv = os.path.abspath(opencv)
self.contrib = None
if contrib:
modpath = os.path.join(contrib, "modules")
if os.path.isdir(modpath):
self.contrib = os.path.abspath(modpath)
else: else:
execute("cmake %s %s" % (cmakeargs, srcroot)) print("Note: contrib repository is bad - modules subfolder not found", file=sys.stderr)
self.targets = [
for wlib in [builddir + "/modules/world/UninstalledProducts/" + libname, ("armv7", "iPhoneOS"),
builddir + "/lib/Release/" + libname]: ("armv7s", "iPhoneOS"),
if os.path.isfile(wlib): ("arm64", "iPhoneOS"),
os.remove(wlib) ("i386", "iPhoneSimulator"),
("x86_64", "iPhoneSimulator")
execute("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 -parallelizeTargets ARCHS=%s -jobs 8 -sdk %s -configuration Release -target %s" % (arch, target.lower(), build_target)) ]
execute("xcodebuild IPHONEOS_DEPLOYMENT_TARGET=6.0 ARCHS=%s -sdk %s -configuration Release -target install install" % (arch, target.lower()))
os.chdir(currdir) def getBD(self, parent, t):
res = os.path.join(parent, '%s-%s' % t)
def put_framework_together(srcroot, dstroot): if not os.path.isdir(res):
"constructs the framework directory after all the targets are built" os.makedirs(res)
return os.path.abspath(res)
name = "opencv2" if opencv_contrib_path is None else "opencv2_contrib"
libname = "libopencv_world.a" if opencv_contrib_path is None else "libopencv_contrib_world.a" def build(self, outdir):
outdir = os.path.abspath(outdir)
# find the list of targets (basically, ["iPhoneOS", "iPhoneSimulator"]) if not os.path.isdir(outdir):
targetlist = glob.glob(os.path.join(dstroot, "build", "*")) os.makedirs(outdir)
targetlist = [os.path.basename(t) for t in targetlist] mainWD = os.path.join(outdir, "build")
dirs = []
xcode_ver = getXCodeMajor()
for t in self.targets:
mainBD = self.getBD(mainWD, t)
dirs.append(mainBD)
cmake_flags = []
if self.contrib:
cmake_flags.append("-DOPENCV_EXTRA_MODULES_PATH=%s" % self.contrib)
if xcode_ver >= 7 and not "Simulator" in t[1]:
cmake_flags.append("-DCMAKE_C_FLAGS=-fembed-bitcode")
cmake_flags.append("-DCMAKE_CXX_FLAGS=-fembed-bitcode")
self.buildOne(t[0], t[1], mainBD, cmake_flags)
self.mergeLibs(mainBD)
self.makeFramework(outdir, dirs)
def buildOne(self, arch, target, builddir, cmakeargs = []):
# Run cmake
toolchain = os.path.join(self.opencv, "platforms", "ios", "cmake", "Toolchains", "Toolchain-%s_Xcode.cmake" % target)
cmakecmd = [
"cmake",
"-GXcode",
"-DCMAKE_BUILD_TYPE=Release",
"-DCMAKE_TOOLCHAIN_FILE=%s" % toolchain,
"-DCMAKE_INSTALL_PREFIX=install",
]
if arch.startswith("armv"):
cmakecmd.append("-DENABLE_NEON=ON")
cmakecmd.append(self.opencv)
cmakecmd.extend(cmakeargs)
execute(cmakecmd, cwd = builddir)
# Clean and build
cleanlist = []
cleanlist.extend(glob.glob(os.path.join(builddir, "lib", "Release", "*.a")))
cleanlist.extend(glob.glob(os.path.join(builddir, "modules", "*", "UninstalledProducts", "*.a")))
print("Cleaning files:\n\t%s" % "\n\t".join(cleanlist), file=sys.stderr)
for f in cleanlist:
if os.path.isfile(f):
os.remove(f)
buildcmd = [
"xcodebuild",
"IPHONEOS_DEPLOYMENT_TARGET=6.0",
"ARCHS=%s" % arch,
"-sdk", target.lower(),
"-configuration", "Release",
"-parallelizeTargets",
"-jobs", "8",
]
execute(buildcmd + ["-target", "ALL_BUILD", "build"], cwd = builddir)
execute(buildcmd + ["-target", "install", "install"], cwd = builddir)
def mergeLibs(self, builddir):
res = os.path.join(builddir, "lib", "Release", "libopencv_merged.a")
libs = glob.glob(os.path.join(builddir, "lib", "Release", "*.a"))
libs3 = glob.glob(os.path.join(builddir, "3rdparty", "lib", "Release", "*.a"))
print("Merging libraries:\n\t%s" % "\n\t".join(libs + libs3), file=sys.stderr)
execute(["libtool", "-static", "-o", res] + libs + libs3)
def makeFramework(self, outdir, builddirs):
name = "opencv2"
libname = "libopencv_merged.a"
# set the current dir to the dst root # set the current dir to the dst root
currdir = os.getcwd() framework_dir = os.path.join(outdir, "%s.framework" % name)
framework_dir = dstroot + "/%s.framework" % name
if os.path.isdir(framework_dir): if os.path.isdir(framework_dir):
shutil.rmtree(framework_dir) shutil.rmtree(framework_dir)
os.makedirs(framework_dir) os.makedirs(framework_dir)
os.chdir(framework_dir)
# form the directory tree dstdir = os.path.join(framework_dir, "Versions", "A")
dstdir = "Versions/A"
os.makedirs(dstdir + "/Resources")
tdir0 = "../build/" + targetlist[0] # copy headers from one of build folders
# copy headers shutil.copytree(os.path.join(builddirs[0], "install", "include", "opencv2"), os.path.join(dstdir, "Headers"))
shutil.copytree(tdir0 + "/install/include/opencv2", dstdir + "/Headers")
# make universal static lib # make universal static lib
wlist = " ".join(["../build/" + t + "/lib/Release/" + libname for t in targetlist]) libs = [os.path.join(d, "lib", "Release", libname) for d in builddirs]
execute("lipo -create " + wlist + " -o " + dstdir + "/%s" % name) lipocmd = ["lipo", "-create"]
lipocmd.extend(libs)
lipocmd.extend(["-o", os.path.join(dstdir, name)])
print("Creating universal library from:\n\t%s" % "\n\t".join(libs), file=sys.stderr)
execute(lipocmd)
# copy Info.plist # copy Info.plist
shutil.copyfile(tdir0 + "/ios/Info.plist", dstdir + "/Resources/Info.plist") resdir = os.path.join(dstdir, "Resources")
os.makedirs(resdir)
shutil.copyfile(os.path.join(builddirs[0], "ios", "Info.plist"), os.path.join(resdir, "Info.plist"))
# make symbolic links # make symbolic links
os.symlink("A", "Versions/Current") links = [
os.symlink("Versions/Current/Headers", "Headers") (["A"], ["Versions", "Current"]),
os.symlink("Versions/Current/Resources", "Resources") (["Versions", "Current", "Headers"], ["Headers"]),
os.symlink("Versions/Current/%s" % name, name) (["Versions", "Current", "Resources"], ["Resources"]),
(["Versions", "Current", name], [name])
]
def build_framework(srcroot, dstroot): for l in links:
"main function to do all the work" s = os.path.join(*l[0])
d = os.path.join(framework_dir, *l[1])
targets = [("armv7", "iPhoneOS"), os.symlink(s, d)
("armv7s", "iPhoneOS"),
("arm64", "iPhoneOS"),
("i386", "iPhoneSimulator"),
("x86_64", "iPhoneSimulator")]
for t in targets:
build_opencv(srcroot, os.path.join(dstroot, "build"), t[1], t[0])
put_framework_together(srcroot, dstroot)
if __name__ == "__main__": if __name__ == "__main__":
folder = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../.."))
parser = argparse.ArgumentParser(description='The script builds OpenCV.framework for iOS.') parser = argparse.ArgumentParser(description='The script builds OpenCV.framework for iOS.')
parser.add_argument('outputdir', nargs=1, help='folder to put built framework') parser.add_argument('out', metavar='OUTDIR', help='folder to put built framework')
parser.add_argument('--contrib', help="folder with opencv_contrib repository") parser.add_argument('--opencv', metavar='DIR', default=folder, help='folder with opencv repository (default is "../.." relative to script location)')
parser.add_argument('--contrib', metavar='DIR', default=None, help='folder with opencv_contrib repository (default is "None" - build only main framework)')
args = parser.parse_args() args = parser.parse_args()
# path to OpenCV main repository - hardcoded ../.. b = Builder(args.opencv, args.contrib)
opencv_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "../.."))
print "OpenCV:", opencv_path
# path to OpenCV_contrib repository, can be empty - global variable
if hasattr(args, "contrib") and args.contrib is not None:
if os.path.isdir(args.contrib + "/modules"):
opencv_contrib_path = os.path.abspath(args.contrib + "/modules")
print "Contrib:", opencv_contrib_path
else:
print "Note: contrib repository is bad: modules subfolder not found"
# result path - folder where framework will be located
output_path = os.path.abspath(args.outputdir[0])
print "Output:", output_path
try: try:
build_framework(opencv_path, output_path) b.build(args.out)
except Exception as e: except Exception as e:
print >>sys.stderr, e print("="*60, file=sys.stderr)
print("ERROR: %s" % e, file=sys.stderr)
print("="*60, file=sys.stderr)
traceback.print_exc(file=sys.stderr)
sys.exit(1) sys.exit(1)
...@@ -40,8 +40,8 @@ set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}") ...@@ -40,8 +40,8 @@ set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
# Hidden visibilty is required for cxx on iOS # Hidden visibilty is required for cxx on iOS
set (no_warn "-Wno-unused-function -Wno-overloaded-virtual") set (no_warn "-Wno-unused-function -Wno-overloaded-virtual")
set (CMAKE_C_FLAGS "${no_warn}") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${no_warn}")
set (CMAKE_CXX_FLAGS "-stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden ${no_warn}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fvisibility=hidden -fvisibility-inlines-hidden ${no_warn}")
set (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fomit-frame-pointer -ffast-math") set (CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -O3 -fomit-frame-pointer -ffast-math")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment