def tread_func(q): while True: fileName = q.get() if fileName is None: # EOF? return pth = os.path.join(prj_path, fileName) try: os.makedirs(pth) except OSError as e: if e.errno == errno.EEXIST: pass else: raise fname = os.path.join(mmps, fileName) fname = os.path.join("..", fname) fname = os.path.join("..", fname) # point to mmp file in mmp folder tmp = os.path.join(pth, "bld.inf") SafeWriteFile(tmp, prj_template %fname) cmd = subprocess.Popen('bldmake bldfiles', stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=pth, shell=True) out, err = cmd.communicate() print "err: %s\n\n" %err cmd = subprocess.Popen('abld build gcce urel', stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=pth, shell=True) out1, err1 = cmd.communicate() # I hope it correctly store logs in parallel tasks SafeWriteFile(build_log, out + out1, mode = 'a') SafeWriteFile(build_err, err + err1, mode = 'a')
def processModule_mk(dir, mmp_file): pth = os.path.join('..\..\..', dir) with open(os.path.join(pth, "module.mk")) as ff: f = ff.readlines() pth = os.path.join('..\..\..\..', dir) SafeWriteFile(mmp_file, "\nSOURCEPATH %s\n" % pth, 'a') src = [] addsrc = None for i in f: if "MODULE_OBJS :=" in i: print i addsrc = True if addsrc is None: addsrc = True elif len(i) == 1: addsrc = False elif "endif" in i: addsrc = False elif "ENABLE_" in i: t = i.split()[-1] if t in active_config: addsrc = True elif t in disabled_config: addsrc = False elif t not in disabled_config: SafeWriteFile(build_log, "New macro found: %s" % t) elif "USE_" in i: t = i.split()[-1] print "%s %s" % (dir, t) if "USE_ARM_SOUND_ASM" in i: # Special case, broken implementation. addsrc = False src += ["SOURCE rate.cpp"] elif t in active_config: print "active_config %s %s" % (dir, t) addsrc = True else: print "disabled_config %s %s" % (dir, t) addsrc = False if t not in disabled_config: SafeWriteFile(build_log, "New macro found: %s" % t) elif "DISABLE_" in i: t = i.split()[-1] if t in active_config: addsrc = True elif t not in disabled_config: SafeWriteFile(build_log, "New macro found: %s" % t) else: addsrc = False elif addsrc is True: tmp = i.strip() tmp = tmp.rstrip("\\") tmp = tmp.strip() tmp = exclude_special_cpp(tmp) if tmp.endswith(".o"): src += ["SOURCE %s.cpp" % tmp[:-2]] SafeWriteFile(mmp_file, src, 'a')
def parse_codecs(platform = "S60v3"): uids = get_UIDs(build) codecs_mmp = os.path.join(mmps, mmp_name) SafeWriteFile(codecs_mmp, mmp_template %platform) for i in range(len(uids)): idx = i+1 SafeWriteFile(codecs_mmp, "#define SCUMMVM_PT_%d\n" %idx, 'a') SafeWriteFile(codecs_mmp, "\n#include \"../mmp/macros.mmh\"\n", 'a') [processModule_mk(i, codecs_mmp) for i in src_dirs]
def processModule_mk(dir, mmp_file): pth = os.path.join('..\..\..', dir) with open(os.path.join(pth, "module.mk")) as ff: f = ff.readlines() pth = os.path.join('..\..\..\..', dir) SafeWriteFile(mmp_file, "\nSOURCEPATH %s\n" % pth, 'a') src = [] addsrc = None for i in f: if "MODULE_OBJS :=" in i: addsrc = True if addsrc is None: addsrc = True elif "endif" in i: addsrc = False elif "SDL_BACKEND" in i: addsrc = True elif "ENABLE_" in i: t = i.split()[-1] if t in active_config: addsrc = True else: addsrc = False if t not in disabled_config: print "New macro found: %s" % t elif "USE_" in i: t = i.split()[-1] if t in active_config: addsrc = True else: addsrc = False if t not in disabled_config: print "New macro found: %s" % t elif "DISABLE_" in i: t = i.split()[-1] if t in active_config: addsrc = True addsrc = False if t not in disabled_config: print "New macro found: %s" % t elif addsrc is True: tmp = i.strip() tmp = tmp.rstrip("\\") tmp = tmp.strip() tmp = exclude_special_cpp(tmp) if tmp.endswith(".o"): src += ["SOURCE %s.cpp" % tmp[:-2]] SafeWriteFile(mmp_file, src, 'a')
def build_apps(plats="S60v3"): cmd = subprocess.Popen('bldmake bldfiles', stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=plats, shell=True) out, err = cmd.communicate() cmd1 = subprocess.Popen('abld build gcce urel', stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=plats, shell=True) out1, err1 = cmd1.communicate() SafeWriteFile(build_log, out + out1, 'a') SafeWriteFile(build_err, err + err1, 'a')
def run(build, pkgs): log = "Build started at: %s\n" %datetime.now() SafeWriteFile(build_log, log) SafeWriteFile(build_err, '') create_mmps(build, pkgs) create_engine_mmps(build) log = "Build engines started at: %s\n" %datetime.now() SafeWriteFile(build_log, log, 'a') build_mmp() log = "Build engines ended at: %s\n" %datetime.now() SafeWriteFile(build_log, log, 'a') build_apps(pkgs) create_installers(pkgs)
def run(build, pkgs, only_begotten_engine=None): log = "Build started at: %s\n" % datetime.now() SafeWriteFile(build_log, log) SafeWriteFile(build_err, '') create_mmps(build, pkgs) create_engine_mmps(build) parse_codecs() parse_base() log = "Build engines started at: %s\n" % datetime.now() SafeWriteFile(build_log, log, 'a') if only_begotten_engine: minimal_whitelist(build_log) build_mmp(only_begotten_engine) log = "Build engines ended at: %s\n" % datetime.now() SafeWriteFile(build_log, log, 'a') build_apps(pkgs) create_installers(pkgs)
def build_mmp(try_fix=False): q = Queue.Queue() fileNames = os.listdir(mmps) fileNames = [x for x in fileNames if ".mmp" in x] if try_fix: with open(os.path.join(mmps, whitelist)) as ff: fileNames = ff.readlines() else: SafeWriteFile(os.path.join(mmps, whitelist), fileNames) for fileName in fileNames: q.put(fileName) print q.qsize() threads = [ threading.Thread(target=tread_func, args=(q, )) for i in range(mp.cpu_count()) ] for thread in threads: thread.start() q.put(None) # one EOF marker for each thread
def minimal_whitelist(engine): data = "#ifdef SCUMMVM_PT_1\nscummvm_base.mmp\nscummvm_codecs.mmp\n%s\n#endif // SCUMMVM_PT_%s\n" % engine SafeWriteFile(os.path.join(mmps, whitelist), data)
def makesis(pkg, path): t = "makesis -d%EPOCROOT% %s" %pkg cmd = subprocess.Popen(t, stdout=subprocess.PIPE, stderr=subprocess.PIPE, cwd=path, shell=True) out, err = cmd.communicate() SafeWriteFile(build_log, out) SafeWriteFile(build_err, err)
def parse_base(platform="S60v3"): uids = get_UIDs(build) codecs_mmp = os.path.join(mmps, mmp_name) SafeWriteFile(codecs_mmp, mmp_template % platform) [processModule_mk(i, codecs_mmp) for i in src_dirs]