opencv/platforms/osx/build_framework.py

48 lines
1.8 KiB
Python
Raw Normal View History

#!/usr/bin/env python
"""
2015-12-16 22:28:03 +08:00
The script builds OpenCV.framework for OSX.
"""
2015-12-16 22:28:03 +08:00
from __future__ import print_function
import os, os.path, sys, argparse, traceback, multiprocessing
2015-12-16 22:28:03 +08:00
# import common code
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from build_framework import Builder
2015-12-16 22:28:03 +08:00
class OSXBuilder(Builder):
2015-12-16 22:28:03 +08:00
def getToolchain(self, arch, target):
return None
def getBuildCommand(self, archs, target):
2015-12-16 22:28:03 +08:00
buildcmd = [
"xcodebuild",
"MACOSX_DEPLOYMENT_TARGET=10.9",
"ARCHS=%s" % archs[0],
2015-12-16 22:28:03 +08:00
"-sdk", target.lower(),
"-configuration", "Release",
"-parallelizeTargets",
2017-05-02 23:59:37 +08:00
"-jobs", str(multiprocessing.cpu_count())
2015-12-16 22:28:03 +08:00
]
return buildcmd
2015-12-16 22:28:03 +08:00
def getInfoPlist(self, builddirs):
return os.path.join(builddirs[0], "osx", "Info.plist")
if __name__ == "__main__":
2015-12-16 22:28:03 +08:00
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')
2015-12-16 22:28:03 +08:00
args = parser.parse_args()
b = OSXBuilder(args.opencv, args.contrib, False, False, args.without,
2015-12-16 22:28:03 +08:00
[
(["x86_64"], "MacOSX")
2015-12-16 22:28:03 +08:00
])
b.build(args.out)