mirror of
https://github.com/opencv/opencv.git
synced 2024-12-20 20:58:00 +08:00
02385472b6
Objc binding * Initial work on Objective-C wrapper * Objective-C generator script; update manually generated wrappers * Add Mat tests * Core Tests * Imgproc wrapper generation and tests * Fixes for Imgcodecs wrapper * Miscellaneous fixes. Swift build support * Objective-C wrapper build/install * Add Swift wrappers for videoio/objdetect/feature2d * Framework build;iOS support * Fix toArray functions;Use enum types whenever possible * Use enum types where possible;prepare test build * Update test * Add test runner scripts for iOS and macOS * Add test scripts and samples * Build fixes * Fix build (cmake 3.17.x compatibility) * Fix warnings * Fix enum name conflicting handling * Add support for document generation with Jazzy * Swift/Native fast accessor functions * Add Objective-C wrapper for calib3d, dnn, ml, photo and video modules * Remove IntOut/FloatOut/DoubleOut classes * Fix iOS default test platform value * Fix samples * Revert default framework name to opencv2 * Add converter util functions * Fix failing test * Fix whitespace * Add handling for deprecated methods;fix warnings;define __OPENCV_BUILD * Suppress cmake warnings * Reduce severity of "jazzy not found" log message * Fix incorrect #include of compatibility header in ios.h * Use explicit returns in subscript/get implementation * Reduce minimum required cmake version to 3.15 for Objective-C/Swift binding
65 lines
3.4 KiB
Python
Executable File
65 lines
3.4 KiB
Python
Executable File
#!/usr/bin/env python
|
|
"""
|
|
The script builds OpenCV.framework for OSX.
|
|
"""
|
|
|
|
from __future__ import print_function
|
|
import os, os.path, sys, argparse, traceback, multiprocessing
|
|
|
|
# import common code
|
|
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
|
|
from build_framework import Builder
|
|
|
|
MACOSX_DEPLOYMENT_TARGET='10.12' # default, can be changed via command line options or environment variable
|
|
|
|
class OSXBuilder(Builder):
|
|
|
|
def getToolchain(self, arch, target):
|
|
return None
|
|
|
|
def getBuildCommand(self, archs, target):
|
|
buildcmd = [
|
|
"xcodebuild",
|
|
"MACOSX_DEPLOYMENT_TARGET=" + os.environ['MACOSX_DEPLOYMENT_TARGET'],
|
|
"ARCHS=%s" % archs[0],
|
|
"-sdk", target.lower(),
|
|
"-configuration", "Debug" if self.debug else "Release",
|
|
"-parallelizeTargets",
|
|
"-jobs", str(multiprocessing.cpu_count())
|
|
]
|
|
return buildcmd
|
|
|
|
def getInfoPlist(self, builddirs):
|
|
return os.path.join(builddirs[0], "osx", "Info.plist")
|
|
|
|
|
|
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 OSX.')
|
|
parser.add_argument('out', metavar='OUTDIR', help='folder to put built framework')
|
|
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)')
|
|
parser.add_argument('--without', metavar='MODULE', default=[], action='append', help='OpenCV modules to exclude from the framework')
|
|
parser.add_argument('--disable', metavar='FEATURE', default=[], action='append', help='OpenCV features to disable (add WITH_*=OFF)')
|
|
parser.add_argument('--enable_nonfree', default=False, dest='enablenonfree', action='store_true', help='enable non-free modules (disabled by default)')
|
|
parser.add_argument('--macosx_deployment_target', default=os.environ.get('MACOSX_DEPLOYMENT_TARGET', MACOSX_DEPLOYMENT_TARGET), help='specify MACOSX_DEPLOYMENT_TARGET')
|
|
parser.add_argument('--debug', action='store_true', help='Build "Debug" binaries (CMAKE_BUILD_TYPE=Debug)')
|
|
parser.add_argument('--debug_info', action='store_true', help='Build with debug information (useful for Release mode: BUILD_WITH_DEBUG_INFO=ON)')
|
|
parser.add_argument('--framework_name', default='opencv2', dest='framework_name', action='store_true', help='Name of OpenCV framework (default: opencv2, will change to OpenCV in future version)')
|
|
parser.add_argument('--legacy_build', default=False, dest='legacy_build', action='store_true', help='Build legacy framework (default: False, equivalent to "--framework_name=opencv2 --without=objc")')
|
|
|
|
args = parser.parse_args()
|
|
|
|
os.environ['MACOSX_DEPLOYMENT_TARGET'] = args.macosx_deployment_target
|
|
print('Using MACOSX_DEPLOYMENT_TARGET=' + os.environ['MACOSX_DEPLOYMENT_TARGET'])
|
|
if args.legacy_build:
|
|
args.framework_name = "opencv2"
|
|
if not "objc" in args.without:
|
|
args.without.append("objc")
|
|
|
|
b = OSXBuilder(args.opencv, args.contrib, False, False, args.without, args.disable, args.enablenonfree,
|
|
[
|
|
(["x86_64"], "MacOSX")
|
|
], args.debug, args.debug_info, args.framework_name)
|
|
b.build(args.out)
|