2012-09-07 15:22:11 +02:00
|
|
|
#!/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():
|
2012-09-11 15:40:44 +02:00
|
|
|
s = s[0:s.find("#")]
|
|
|
|
if (not s):
|
2012-10-30 16:01:06 +01:00
|
|
|
continue
|
2012-09-07 15:22:11 +02:00
|
|
|
keys = s.split(";")
|
|
|
|
if (len(keys) < 4):
|
2012-10-30 16:01:06 +01:00
|
|
|
print("Error: invalid config line: \"%s\"" % s)
|
|
|
|
continue
|
2012-09-11 15:40:44 +02:00
|
|
|
MakeTarget = str.strip(keys[0])
|
|
|
|
Arch = str.strip(keys[1])
|
|
|
|
NativeApiLevel = str.strip(keys[2])
|
|
|
|
AndroidTreeRoot = str.strip(keys[3])
|
2012-09-07 15:22:11 +02:00
|
|
|
AndroidTreeRoot = str.strip(AndroidTreeRoot, "\n")
|
|
|
|
print("Building %s for %s" % (MakeTarget, Arch))
|
|
|
|
BuildDir = os.path.join(HomeDir, MakeTarget + "_" + Arch)
|
2012-10-30 16:01:06 +01:00
|
|
|
|
2012-09-07 15:22:11 +02:00
|
|
|
if (os.path.exists(BuildDir)):
|
2012-10-30 16:01:06 +01:00
|
|
|
shutil.rmtree(BuildDir)
|
|
|
|
|
2012-09-07 15:22:11 +02:00
|
|
|
try:
|
2012-10-30 16:01:06 +01:00
|
|
|
os.mkdir(BuildDir)
|
2012-09-07 15:22:11 +02:00
|
|
|
except:
|
2012-10-30 16:01:06 +01:00
|
|
|
print("Error: cannot create direcotry \"%s\"" % BuildDir)
|
|
|
|
continue
|
|
|
|
|
2012-09-07 15:22:11 +02:00
|
|
|
shutil.rmtree(os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"), ignore_errors=True)
|
|
|
|
if (Arch == "x86"):
|
2012-10-30 16:01:06 +01:00
|
|
|
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_x86", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
|
2012-10-02 12:55:51 +02:00
|
|
|
elif (Arch == "mips"):
|
2012-10-30 16:01:06 +01:00
|
|
|
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_mips", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
|
2012-09-07 15:22:11 +02:00
|
|
|
else:
|
2012-10-30 16:01:06 +01:00
|
|
|
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_arm", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
|
|
|
|
|
2012-09-07 15:22:11 +02:00
|
|
|
os.chdir(BuildDir)
|
|
|
|
BuildLog = os.path.join(BuildDir, "build.log")
|
2012-10-30 16:01:06 +01:00
|
|
|
CmakeCmdLine = "cmake -DCMAKE_TOOLCHAIN_FILE=../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)
|
2012-09-07 15:22:11 +02:00
|
|
|
MakeCmdLine = "make %s >> \"%s\" 2>&1" % (MakeTarget, BuildLog);
|
2012-10-30 16:01:06 +01:00
|
|
|
print(CmakeCmdLine)
|
2012-09-12 12:29:00 +02:00
|
|
|
os.system(CmakeCmdLine)
|
2012-10-30 16:01:06 +01:00
|
|
|
print(MakeCmdLine)
|
2012-09-12 12:29:00 +02:00
|
|
|
os.system(MakeCmdLine)
|
2012-09-07 15:22:11 +02:00
|
|
|
os.chdir(HomeDir)
|
|
|
|
CameraLib = os.path.join(BuildDir, "lib", Arch, "lib" + MakeTarget + ".so")
|
|
|
|
if (os.path.exists(CameraLib)):
|
2012-10-30 16:01:06 +01:00
|
|
|
try:
|
|
|
|
shutil.copyfile(CameraLib, os.path.join("..", "3rdparty", "lib", Arch, "lib" + MakeTarget + ".so"))
|
|
|
|
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));
|
2012-09-17 09:56:46 +02:00
|
|
|
else:
|
2012-10-30 16:01:06 +01:00
|
|
|
print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch));
|
2012-09-07 15:22:11 +02:00
|
|
|
|
2012-10-30 16:01:06 +01:00
|
|
|
ConfFile.close()
|