svn repository web references are replaced with links to git
This commit is contained in:
@@ -5,12 +5,12 @@ The built framework is universal, it can be used to build app and run it on eith
|
||||
|
||||
Usage:
|
||||
./build_framework.py <outputdir>
|
||||
|
||||
By cmake conventions (and especially if you work with OpenCV SVN repository),
|
||||
|
||||
By cmake conventions (and especially if you work with OpenCV repository),
|
||||
the output dir should not be a subdirectory of OpenCV source tree.
|
||||
|
||||
|
||||
Script will create <outputdir>, if it's missing, and a few its subdirectories:
|
||||
|
||||
|
||||
<outputdir>
|
||||
build/
|
||||
iPhoneOS/
|
||||
@@ -29,7 +29,7 @@ import glob, re, os, os.path, shutil, string, sys
|
||||
|
||||
def build_opencv(srcroot, buildroot, target):
|
||||
"builds OpenCV for device or simulator"
|
||||
|
||||
|
||||
builddir = os.path.join(buildroot, target)
|
||||
if not os.path.isdir(builddir):
|
||||
os.makedirs(builddir)
|
||||
@@ -46,23 +46,23 @@ def build_opencv(srcroot, buildroot, target):
|
||||
os.system("cmake %s ." % (cmakeargs,))
|
||||
else:
|
||||
os.system("cmake %s %s" % (cmakeargs, srcroot))
|
||||
|
||||
|
||||
for wlib in [builddir + "/modules/world/UninstalledProducts/libopencv_world.a",
|
||||
builddir + "/lib/Release/libopencv_world.a"]:
|
||||
if os.path.isfile(wlib):
|
||||
os.remove(wlib)
|
||||
|
||||
|
||||
os.system("xcodebuild -parallelizeTargets -jobs 8 -sdk %s -configuration Release -target ALL_BUILD" % target.lower())
|
||||
os.system("xcodebuild -sdk %s -configuration Release -target install install" % target.lower())
|
||||
os.chdir(currdir)
|
||||
|
||||
|
||||
def put_framework_together(srcroot, dstroot):
|
||||
"constructs the framework directory after all the targets are built"
|
||||
|
||||
|
||||
# find the list of targets (basically, ["iPhoneOS", "iPhoneSimulator"])
|
||||
targetlist = glob.glob(os.path.join(dstroot, "build", "*"))
|
||||
targetlist = [os.path.basename(t) for t in targetlist]
|
||||
|
||||
|
||||
# set the current dir to the dst root
|
||||
currdir = os.getcwd()
|
||||
framework_dir = dstroot + "/opencv2.framework"
|
||||
@@ -70,7 +70,7 @@ def put_framework_together(srcroot, dstroot):
|
||||
shutil.rmtree(framework_dir)
|
||||
os.makedirs(framework_dir)
|
||||
os.chdir(framework_dir)
|
||||
|
||||
|
||||
# determine OpenCV version (without subminor part)
|
||||
tdir0 = "../build/" + targetlist[0]
|
||||
cfg = open(tdir0 + "/cvconfig.h", "rt")
|
||||
@@ -79,18 +79,18 @@ def put_framework_together(srcroot, dstroot):
|
||||
opencv_version = l[l.find("\"")+1:l.rfind(".")]
|
||||
break
|
||||
cfg.close()
|
||||
|
||||
|
||||
# form the directory tree
|
||||
dstdir = "Versions/A"
|
||||
os.makedirs(dstdir + "/Resources")
|
||||
|
||||
# copy headers
|
||||
shutil.copytree(tdir0 + "/install/include/opencv2", dstdir + "/Headers")
|
||||
|
||||
|
||||
# make universal static lib
|
||||
wlist = " ".join(["../build/" + t + "/lib/Release/libopencv_world.a" for t in targetlist])
|
||||
os.system("lipo -create " + wlist + " -o " + dstdir + "/opencv2")
|
||||
|
||||
|
||||
# form Info.plist
|
||||
srcfile = open(srcroot + "/ios/Info.plist.in", "rt")
|
||||
dstfile = open(dstdir + "/Resources/Info.plist", "wt")
|
||||
@@ -98,29 +98,29 @@ def put_framework_together(srcroot, dstroot):
|
||||
dstfile.write(l.replace("${VERSION}", opencv_version))
|
||||
srcfile.close()
|
||||
dstfile.close()
|
||||
|
||||
|
||||
# copy cascades
|
||||
# TODO ...
|
||||
|
||||
|
||||
# make symbolic links
|
||||
os.symlink(dstdir + "/Headers", "Headers")
|
||||
os.symlink(dstdir + "/Resources", "Resources")
|
||||
os.symlink(dstdir + "/opencv2", "opencv2")
|
||||
os.symlink("A", "Versions/Current")
|
||||
|
||||
|
||||
|
||||
|
||||
def build_framework(srcroot, dstroot):
|
||||
"main function to do all the work"
|
||||
|
||||
|
||||
for target in ["iPhoneOS", "iPhoneSimulator"]:
|
||||
build_opencv(srcroot, os.path.join(dstroot, "build"), target)
|
||||
|
||||
|
||||
put_framework_together(srcroot, dstroot)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) != 2:
|
||||
print "Usage:\n\t./build_framework.py <outputdir>\n\n"
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
build_framework(os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")), os.path.abspath(sys.argv[1]))
|
||||
|
Reference in New Issue
Block a user