build_framework.py 1.7 KB
Newer Older
1 2
#!/usr/bin/env python
"""
3
The script builds OpenCV.framework for OSX.
4 5
"""

6 7
from __future__ import print_function
import os, os.path, sys, argparse, traceback
8

9 10 11
# import common code
sys.path.insert(0, os.path.abspath(os.path.abspath(os.path.dirname(__file__))+'/../ios'))
from build_framework import Builder
12

13
class OSXBuilder(Builder):
14

15 16
    def getToolchain(self, arch, target):
        return None
17

18 19 20 21 22 23 24 25 26 27
    def getBuildCommand(self, arch, target):
        buildcmd = [
            "xcodebuild",
            "ARCHS=%s" % arch,
            "-sdk", target.lower(),
            "-configuration", "Release",
            "-parallelizeTargets",
            "-jobs", "4"
        ]
        return buildcmd
28

29 30
    def getInfoPlist(self, builddirs):
        return os.path.join(builddirs[0], "osx", "Info.plist")
31 32 33


if __name__ == "__main__":
34 35 36 37 38
    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)')
39
    parser.add_argument('--without', metavar='MODULE', default=[], action='append', help='OpenCV modules to exclude from the framework')
40 41
    args = parser.parse_args()

42
    b = OSXBuilder(args.opencv, args.contrib, args.without,
43 44 45 46
        [
            ("x86_64", "MacOSX")
        ])
    b.build(args.out)