Make xcframework output path argument explicit and required
* Make output path argument explicit and required
* Improve xcframework documentation
* Add TODOs for future breaking changes on build_framework.py scripts
parser.add_argument('out',metavar='OUTDIR',help='The directory where the xcframework will be created')
parser.add_argument('-o','--out',metavar='OUTDIR',help='<Required> The directory where the xcframework will be created',required=True)
parser.add_argument('--framework_name',default='opencv2',help='Name of OpenCV xcframework (default: opencv2, will change to OpenCV in future version)')
parser.add_argument('--framework_name',default='opencv2',help='Name of OpenCV xcframework (default: opencv2, will change to OpenCV in future version)')
parser.add_argument('--iphoneos_archs',default=None,help='select iPhoneOS target ARCHS. Default is "armv7,arm64"')
parser.add_argument('--iphoneos_archs',default=None,help='select iPhoneOS target ARCHS. Default is "armv7,arm64"')
parser.add_argument('--iphonesimulator_archs',default=None,help='select iPhoneSimulator target ARCHS. Default is "x86_64,arm64"')
parser.add_argument('--iphonesimulator_archs',default=None,help='select iPhoneSimulator target ARCHS. Default is "x86_64,arm64"')
Grab a coffee, because you'll be here for a while. By default this builds OpenCV for 8 architectures across 4 platforms:
Grab a coffee, because you'll be here for a while. By default this builds OpenCV for 8 architectures across 4 platforms:
@ -25,16 +25,32 @@ If everything's fine, you will eventually get `opencv2.xcframework` in the outpu
The script has some configuration options to exclude platforms and architectures you don't want to build for. Use the `--help` flag for more information.
The script has some configuration options to exclude platforms and architectures you don't want to build for. Use the `--help` flag for more information.
## How it Works
This script generates a fat `.framework` for each platform you specify, and stitches them together into a `.xcframework`. This file can be used to support the same architecture on different platforms, which fat `.framework`s don't allow. To build the intermediate `.framework`s, `build_xcframework.py` leverages the `build_framework.py` scripts in the ios and osx platform folders.
### Passthrough Arguments
Any arguments that aren't recognized by `build_xcframework.py` will be passed to the platform-specific `build_framework.py` scripts. The `--without` flag mentioned in the examples is an example of this in action. For more info, see the `--help` info for those scripts.
## Examples
## Examples
You may override the defaults by specifying a value for any of the `*_archs` flags. For example, if you want to build for arm64 on every platform, you can do this:
You may override the defaults by specifying a value for any of the `*_archs` flags. For example, if you want to build for arm64 on every platform, you can do this:
If you want to build only for certain platforms, you can supply the `--build_only_specified_archs` flag, which makes the script build only the archs you directly ask for. For example, to build only for Catalyst, you can do this:
If you want to build only for certain platforms, you can supply the `--build_only_specified_archs` flag, which makes the script build only the archs you directly ask for. For example, to build only for Catalyst, you can do this:
You can also build without OpenCV functionality you don't need. You can do this by using the `--without` flag, which you use once per item you want to go without. For example, if you wanted to compile without `video` or `objc`, you'd can do this:
```
python build_xcframework.py --out somedir --without video --without objc
```
```
(if you have issues with this, try using `=`, e.g. `--without=video --without=objc`, and file an issue on GitHub.)
parser=argparse.ArgumentParser(description='The script builds OpenCV.framework for iOS.')
parser=argparse.ArgumentParser(description='The script builds OpenCV.framework for iOS.')
# TODO: When we can make breaking changes, we should make the out argument explicit and required like in build_xcframework.py.
parser.add_argument('out',metavar='OUTDIR',help='folder to put built framework')
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('--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('--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('--without',metavar='MODULE',default=[],action='append',help='OpenCV modules to exclude from the framework. To exclude multiple, specify this flag again, e.g. "--without video --without objc"')
parser.add_argument('--disable',metavar='FEATURE',default=[],action='append',help='OpenCV features to disable (add WITH_*=OFF)')
parser.add_argument('--disable',metavar='FEATURE',default=[],action='append',help='OpenCV features to disable (add WITH_*=OFF). To disable multiple, specify this flag again, e.g. "--disable tbb --disable openmp"')
parser.add_argument('--dynamic',default=False,action='store_true',help='build dynamic framework (default is "False" - builds static framework)')
parser.add_argument('--dynamic',default=False,action='store_true',help='build dynamic framework (default is "False" - builds static framework)')
parser.add_argument('--disable-bitcode',default=False,dest='bitcodedisabled',action='store_true',help='disable bitcode (enabled by default)')
parser.add_argument('--disable-bitcode',default=False,dest='bitcodedisabled',action='store_true',help='disable bitcode (enabled by default)')
parser=argparse.ArgumentParser(description='The script builds OpenCV.framework for OSX.')
parser=argparse.ArgumentParser(description='The script builds OpenCV.framework for OSX.')
# TODO: When we can make breaking changes, we should make the out argument explicit and required like in build_xcframework.py.
parser.add_argument('out',metavar='OUTDIR',help='folder to put built framework')
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('--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('--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('--without',metavar='MODULE',default=[],action='append',help='OpenCV modules to exclude from the framework. To exclude multiple, specify this flag again, e.g. "--without video --without objc"')
parser.add_argument('--disable',metavar='FEATURE',default=[],action='append',help='OpenCV features to disable (add WITH_*=OFF)')
parser.add_argument('--disable',metavar='FEATURE',default=[],action='append',help='OpenCV features to disable (add WITH_*=OFF). To disable multiple, specify this flag again, e.g. "--disable tbb --disable openmp"')
parser.add_argument('--dynamic',default=False,action='store_true',help='build dynamic framework (default is "False" - builds static framework)')
parser.add_argument('--dynamic',default=False,action='store_true',help='build dynamic framework (default is "False" - builds static framework)')
parser.add_argument('--enable_nonfree',default=False,dest='enablenonfree',action='store_true',help='enable non-free modules (disabled by default)')
parser.add_argument('--enable_nonfree',default=False,dest='enablenonfree',action='store_true',help='enable non-free modules (disabled by default)')