raise Exception("Failed to parse Xcode version")
class Builder:
- def __init__(self, opencv, contrib, dynamic, bitcodedisabled, exclude, enablenonfree, targets):
+ def __init__(self, opencv, contrib, dynamic, bitcodedisabled, exclude, enablenonfree, targets, debug, debug_info):
self.opencv = os.path.abspath(opencv)
self.contrib = None
if contrib:
self.exclude = exclude
self.enablenonfree = enablenonfree
self.targets = targets
+ self.debug = debug
+ self.debug_info = debug_info
def getBD(self, parent, t):
def getToolchain(self, arch, target):
return None
+ def getConfiguration(self):
+ return "Debug" if self.debug else "Release"
+
def getCMakeArgs(self, arch, target):
args = [
"-GXcode",
"-DAPPLE_FRAMEWORK=ON",
"-DCMAKE_INSTALL_PREFIX=install",
- "-DCMAKE_BUILD_TYPE=Release",
+ "-DCMAKE_BUILD_TYPE=%s" % self.getConfiguration(),
] + ([
"-DBUILD_SHARED_LIBS=ON",
"-DCMAKE_MACOSX_BUNDLE=ON",
"-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=NO",
] if self.dynamic else []) + ([
"-DOPENCV_ENABLE_NONFREE=ON"
- ] if self.enablenonfree else [])
+ ] if self.enablenonfree else []) + ([
+ "-DBUILD_WITH_DEBUG_INFO=ON"
+ ] if self.debug_info else [])
if len(self.exclude) > 0:
args += ["-DBUILD_opencv_world=OFF"] if not self.dynamic else []
buildcmd += [
"-sdk", target.lower(),
- "-configuration", "Release",
+ "-configuration", self.getConfiguration(),
"-parallelizeTargets",
"-jobs", str(multiprocessing.cpu_count()),
] + (["-target","ALL_BUILD"] if self.dynamic else [])
shutil.rmtree(clean_dir)
buildcmd = self.getBuildCommand(arch, target)
execute(buildcmd + ["-target", "ALL_BUILD", "build"], cwd = builddir)
- execute(["cmake", "-P", "cmake_install.cmake"], cwd = builddir)
+ execute(["cmake", "-DBUILD_TYPE=%s" % self.getConfiguration(), "-P", "cmake_install.cmake"], cwd = builddir)
def mergeLibs(self, builddir):
- res = os.path.join(builddir, "lib", "Release", "libopencv_merged.a")
+ res = os.path.join(builddir, "lib", self.getConfiguration(), "libopencv_merged.a")
libs = glob.glob(os.path.join(builddir, "install", "lib", "*.a"))
libs3 = glob.glob(os.path.join(builddir, "install", "share", "OpenCV", "3rdparty", "lib", "*.a"))
print("Merging libraries:\n\t%s" % "\n\t".join(libs + libs3), file=sys.stderr)
shutil.copytree(os.path.join(builddirs[0], "install", "include", "opencv2"), os.path.join(dstdir, "Headers"))
# make universal static lib
- libs = [os.path.join(d, "lib", "Release", libname) for d in builddirs]
+ libs = [os.path.join(d, "lib", self.getConfiguration(), libname) for d in builddirs]
lipocmd = ["lipo", "-create"]
lipocmd.extend(libs)
lipocmd.extend(["-o", os.path.join(dstdir, name)])
parser.add_argument('--iphoneos_archs', default='armv7,armv7s,arm64', help='select iPhoneOS target ARCHS')
parser.add_argument('--iphonesimulator_archs', default='i386,x86_64', help='select iPhoneSimulator target ARCHS')
parser.add_argument('--enable_nonfree', default=False, dest='enablenonfree', action='store_true', help='enable non-free modules (disabled by default)')
+ parser.add_argument('--debug', default=False, dest='debug', action='store_true', help='Build "Debug" binaries (disabled by default)')
+ parser.add_argument('--debug_info', default=False, dest='debug_info', action='store_true', help='Build with debug information (useful for Release mode: BUILD_WITH_DEBUG_INFO=ON)')
args = parser.parse_args()
os.environ['IPHONEOS_DEPLOYMENT_TARGET'] = args.iphoneos_deployment_target
[
(iphoneos_archs, "iPhoneOS"),
(iphonesimulator_archs, "iPhoneSimulator"),
- ])
+ ], args.debug, args.debug_info)
b.build(args.out)
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):
def getBuildCommand(self, archs, target):
buildcmd = [
"xcodebuild",
- "MACOSX_DEPLOYMENT_TARGET=10.9",
+ "MACOSX_DEPLOYMENT_TARGET=" + os.environ['MACOSX_DEPLOYMENT_TARGET'],
"ARCHS=%s" % archs[0],
"-sdk", target.lower(),
- "-configuration", "Release",
+ "-configuration", "Debug" if self.debug else "Release",
"-parallelizeTargets",
"-jobs", str(multiprocessing.cpu_count())
]
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('--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)')
+
args = parser.parse_args()
+ os.environ['MACOSX_DEPLOYMENT_TARGET'] = args.macosx_deployment_target
+ print('Using MACOSX_DEPLOYMENT_TARGET=' + os.environ['MACOSX_DEPLOYMENT_TARGET'])
+
b = OSXBuilder(args.opencv, args.contrib, False, False, args.without, args.enablenonfree,
[
(["x86_64"], "MacOSX")
- ])
+ ], args.debug, args.debug_info)
b.build(args.out)