mirror of https://github.com/opencv/opencv.git
Open Source Computer Vision Library
https://opencv.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.7 KiB
70 lines
2.7 KiB
12 years ago
|
#!/usr/bin/python
|
||
|
|
||
|
import os
|
||
|
import sys
|
||
|
import shutil
|
||
|
|
||
|
ScriptHome = os.path.split(sys.argv[0])[0]
|
||
|
ConfFile = open(os.path.join(ScriptHome, "camera_build.conf"), "rt")
|
||
|
HomeDir = os.getcwd()
|
||
|
for s in ConfFile.readlines():
|
||
12 years ago
|
s = s[0:s.find("#")]
|
||
|
if (not s):
|
||
12 years ago
|
continue
|
||
12 years ago
|
keys = s.split(";")
|
||
|
if (len(keys) < 4):
|
||
12 years ago
|
print("Error: invalid config line: \"%s\"" % s)
|
||
|
continue
|
||
12 years ago
|
MakeTarget = str.strip(keys[0])
|
||
|
Arch = str.strip(keys[1])
|
||
|
NativeApiLevel = str.strip(keys[2])
|
||
|
AndroidTreeRoot = str.strip(keys[3])
|
||
12 years ago
|
AndroidTreeRoot = str.strip(AndroidTreeRoot, "\n")
|
||
|
print("Building %s for %s" % (MakeTarget, Arch))
|
||
|
BuildDir = os.path.join(HomeDir, MakeTarget + "_" + Arch)
|
||
12 years ago
|
|
||
12 years ago
|
if (os.path.exists(BuildDir)):
|
||
12 years ago
|
shutil.rmtree(BuildDir)
|
||
|
|
||
12 years ago
|
try:
|
||
12 years ago
|
os.mkdir(BuildDir)
|
||
12 years ago
|
except:
|
||
12 years ago
|
print("Error: cannot create direcotry \"%s\"" % BuildDir)
|
||
|
continue
|
||
|
|
||
12 years ago
|
shutil.rmtree(os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"), ignore_errors=True)
|
||
12 years ago
|
|
||
|
LinkerLibs = os.path.join(AndroidTreeRoot, "bin_arm", "system")
|
||
12 years ago
|
if (Arch == "x86"):
|
||
12 years ago
|
LinkerLibs = os.path.join(AndroidTreeRoot, "bin_x86", "system")
|
||
12 years ago
|
elif (Arch == "mips"):
|
||
12 years ago
|
LinkerLibs = os.path.join(AndroidTreeRoot, "bin_mips", "system")
|
||
|
|
||
|
if (not os.path.exists(LinkerLibs)):
|
||
|
print("Error: Paltform libs for linker in path \"%s\" not found" % LinkerLibs)
|
||
|
print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch))
|
||
|
continue
|
||
|
|
||
|
shutil.copytree(LinkerLibs, os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
|
||
12 years ago
|
|
||
12 years ago
|
os.chdir(BuildDir)
|
||
|
BuildLog = os.path.join(BuildDir, "build.log")
|
||
12 years ago
|
CmakeCmdLine = "cmake -DCMAKE_TOOLCHAIN_FILE=../android/android.toolchain.cmake -DANDROID_SOURCE_TREE=\"%s\" -DANDROID_NATIVE_API_LEVEL=\"%s\" -DANDROID_ABI=\"%s\" -DANDROID_STL=stlport_static ../.. > \"%s\" 2>&1" % (AndroidTreeRoot, NativeApiLevel, Arch, BuildLog)
|
||
12 years ago
|
MakeCmdLine = "make %s >> \"%s\" 2>&1" % (MakeTarget, BuildLog);
|
||
12 years ago
|
#print(CmakeCmdLine)
|
||
12 years ago
|
os.system(CmakeCmdLine)
|
||
12 years ago
|
#print(MakeCmdLine)
|
||
12 years ago
|
os.system(MakeCmdLine)
|
||
12 years ago
|
os.chdir(HomeDir)
|
||
|
CameraLib = os.path.join(BuildDir, "lib", Arch, "lib" + MakeTarget + ".so")
|
||
|
if (os.path.exists(CameraLib)):
|
||
12 years ago
|
try:
|
||
12 years ago
|
shutil.copyfile(CameraLib, os.path.join("..", "3rdparty", "lib", Arch, "lib" + MakeTarget + ".so"))
|
||
12 years ago
|
print("Building %s for %s\t[\033[92mOK\033[0m]" % (MakeTarget, Arch));
|
||
|
except:
|
||
|
print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch));
|
||
12 years ago
|
else:
|
||
12 years ago
|
print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch));
|
||
12 years ago
|
|
||
12 years ago
|
ConfFile.close()
|