<commit_before>#!/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():
    s = s[0:s.find("#")]
    if (not s):
	continue
    keys = s.split(";")
    if (len(keys) < 4):
	print("Error: invalid config line: \"%s\"" % s)
	continue
    MakeTarget = str.strip(keys[0])
    Arch = str.strip(keys[1])
    NativeApiLevel = str.strip(keys[2])
    AndroidTreeRoot = str.strip(keys[3])
    AndroidTreeRoot = str.strip(AndroidTreeRoot, "\n")
    print("Building %s for %s" % (MakeTarget, Arch))
    BuildDir = os.path.join(HomeDir, MakeTarget + "_" + Arch)
    if (os.path.exists(BuildDir)):
	shutil.rmtree(BuildDir)
    try:
	os.mkdir(BuildDir)
    except:
	print("Error: cannot create direcotry \"%s\"" % BuildDir)
	continue
    shutil.rmtree(os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"), ignore_errors=True)
    if (Arch == "x86"):
	shutil.copytree(os.path.join(AndroidTreeRoot, "bin_x86", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
    elif (Arch == "mips"):
	shutil.copytree(os.path.join(AndroidTreeRoot, "bin_mips", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
    else:
	shutil.copytree(os.path.join(AndroidTreeRoot, "bin_arm", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
    os.chdir(BuildDir)
    BuildLog = os.path.join(BuildDir, "build.log")
    CmakeCmdLine = "cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_SOURCE_TREE=\"%s\" -DANDROID_NATIVE_API_LEVEL=\"%s\" -DANDROID_ABI=\"%s\" -DANDROID_USE_STLPORT=ON ../../ > \"%s\" 2>&1" % (AndroidTreeRoot, NativeApiLevel, Arch, BuildLog)
    MakeCmdLine = "make %s >> \"%s\" 2>&1" % (MakeTarget, BuildLog);
    #print(CmakeCmdLine)
    os.system(CmakeCmdLine)
    #print(MakeCmdLine)
    os.system(MakeCmdLine)
    os.chdir(HomeDir)
    CameraLib = os.path.join(BuildDir, "lib", Arch, "lib" + MakeTarget + ".so")
    if (os.path.exists(CameraLib)):
	try:
	    shutil.copyfile(CameraLib, os.path.join("..", "3rdparty", "lib", Arch, "lib" + MakeTarget + ".so"))
	    print("Building %s for %s\t[OK]" % (MakeTarget, Arch));
	except:
	    print("Building %s for %s\t[FAILED]" % (MakeTarget, Arch));
    else:
	print("Building %s for %s\t[FAILED]" % (MakeTarget, Arch));
ConfFile.close()

<commit_msg>Native cameras build script output colorized.<commit_after>#!/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():
    s = s[0:s.find("#")]
    if (not s):
	continue
    keys = s.split(";")
    if (len(keys) < 4):
	print("Error: invalid config line: \"%s\"" % s)
	continue
    MakeTarget = str.strip(keys[0])
    Arch = str.strip(keys[1])
    NativeApiLevel = str.strip(keys[2])
    AndroidTreeRoot = str.strip(keys[3])
    AndroidTreeRoot = str.strip(AndroidTreeRoot, "\n")
    print("Building %s for %s" % (MakeTarget, Arch))
    BuildDir = os.path.join(HomeDir, MakeTarget + "_" + Arch)
    if (os.path.exists(BuildDir)):
	shutil.rmtree(BuildDir)
    try:
	os.mkdir(BuildDir)
    except:
	print("Error: cannot create direcotry \"%s\"" % BuildDir)
	continue
    shutil.rmtree(os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"), ignore_errors=True)
    if (Arch == "x86"):
	shutil.copytree(os.path.join(AndroidTreeRoot, "bin_x86", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
    elif (Arch == "mips"):
	shutil.copytree(os.path.join(AndroidTreeRoot, "bin_mips", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
    else:
	shutil.copytree(os.path.join(AndroidTreeRoot, "bin_arm", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
    os.chdir(BuildDir)
    BuildLog = os.path.join(BuildDir, "build.log")
    CmakeCmdLine = "cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_SOURCE_TREE=\"%s\" -DANDROID_NATIVE_API_LEVEL=\"%s\" -DANDROID_ABI=\"%s\" -DANDROID_USE_STLPORT=ON ../../ > \"%s\" 2>&1" % (AndroidTreeRoot, NativeApiLevel, Arch, BuildLog)
    MakeCmdLine = "make %s >> \"%s\" 2>&1" % (MakeTarget, BuildLog);
    #print(CmakeCmdLine)
    os.system(CmakeCmdLine)
    #print(MakeCmdLine)
    os.system(MakeCmdLine)
    os.chdir(HomeDir)
    CameraLib = os.path.join(BuildDir, "lib", Arch, "lib" + MakeTarget + ".so")
    if (os.path.exists(CameraLib)):
	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));
    else:
	print("Building %s for %s\t[\033[91mFAILED\033[0m]" % (MakeTarget, Arch));
ConfFile.close()


{'fraction_non_alphanumeric': 0.1961364084368224, 'fraction_numerical': 0.012024443130297654, 'mean_word_length': 4.415154749199573, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '517943', 'n_tokens_mistral': 1949, 'n_tokens_neox': 1902, 'n_words': 367}