def LoadDefaultValues(self, play_params): # Load the selected sourceport. if play_params[0] != -1: self.list_sourceports.SetSelection(play_params[0]) else: self.list_sourceports.SetSelection( const.ini_prop('play_sourceport', 0)) # Load the selected iwad if play_params[1] != -1: self.list_iwads.SetSelection(play_params[1]) else: self.list_iwads.SetSelection(const.ini_prop('play_iwad', 0)) # Load the specified map if len(play_params[2]) != 0: self.txt_ctrl_map.SetValue(play_params[2]) else: self.txt_ctrl_map.SetValue(const.ini_prop('play_map')) # Load the extra parameters if len(play_params[3]) != 0: self.txt_ctrl_params.SetValue(play_params[3]) else: self.txt_ctrl_params.SetValue(const.ini_prop('play_extraparams')) # And load the pwads. if len(play_params[4]) != 0: self.project_pwads = play_params[4] self.SetPWADList(play_params[4])
def run(self): exe_path = const.ini_prop(self.sourceport + '_path', '?') exe_path = utils.relativePath(exe_path) if exe_path == '?' or not os.path.isdir(exe_path): msg = "Could'nt find " + self.sourceport + ".exe" msg += "\nCheck the path in the project.ini, override " + self.sourceport + "_path, and try again." dlg = wx.MessageDialog(self.ui, msg, "Running error").ShowModal() return os.chdir(exe_path) pwadlist = [] for pwad in self.pwads: pwadlist.extend(["-file"] + [os.path.join(pwad[1], pwad[0])]) # -stdout fullcmd = [ self.sourceport + ".exe", "-iwad", self.iwad, '+map', self.test_map ] + pwadlist + self.ex_params.split() + ["-stdout"] """ fullcmd = ["zandronum.exe", "-iwad", "doom2.wad" , "-file", std_path] subprocess.call(fullcmd+ filelist + ['+map', map_test]) """ p = subprocess.Popen(fullcmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.DEVNULL) out, err = p.communicate() os.chdir(self.ui.rootdir) wx.PostEvent(self.ui, PlayResultEvent(out.decode("ansi")))
def __init__(self, name, rootdir): self.name = name self.rootdir = rootdir self.version = const.ini_prop("relase", "v0", name) self.filename = const.ini_prop("filename", name, name) self.acscomp = const.ini_prop("acscomp", section=name) self.sourcedir = const.ini_prop("sourcedir", "src", name) self.distdir = const.ini_prop("distdir", "dist", name) self.notxt = const.ini_prop("notxt", section=name) self.skip = False
def ReportResults(self, sucess): noacs = self.flags[0].GetValue() versioned = self.flags[1].GetValue() packed = self.flags[2].GetValue() play_it = self.flags[3].GetValue() snapshot = self.flags[4].GetValue() completed = sucess == thread.BUILD_SUCCESS failure = sucess == thread.BUILD_CANCELED or sucess == thread.BUILD_ERROR nopart = [] skip_a_part = False for part in self.projectparts: if part.skip: nopart.append(part.skip) skip_a_part = True result = "" title = "" if (not skip_a_part and not (noacs or versioned or packed or play_it)): if completed: title = "Full build completed." elif failure: title = "Full build interrupted." else: if (completed): title = "Build completed with the following flags." elif failure: title = "Build interrupted with the following flags." for part in self.projectparts: if part.skip: title += "\n -) " + part.name + " part skipped." if (noacs): title += "\n -) ACS compilation skipped." if (versioned): title += "\n -) Tagged to the respective versions." if (packed): zipfilename = "" zip_name = const.ini_prop('zip_name', 'project') zip_tag = const.ini_prop('zip_tag', 'v0') if (versioned): if (snapshot): zipfilename = zip_name + "_" + self.snapshot_tag else: zipfilename = zip_name + "_" + zip_tag + '.zip' else: zipfilename = zip_name + "_DEV.zip" title += "\n -) Packed-up in file: " + zipfilename if (sucess == thread.BUILD_SKIPPED): title = "Build Interrupted. \nAll the project parts are skipped, unmark the skip flags and try again." if (play_it): title += "\n -) The project will run once you close this window." title += "\nRead the log for more details." result += "\n------------------------------------------------------------" result += "\n\t==== Log Start ====" result += "\n------------------------------------------------------------\n" if len(self.log) == 0: result += "No log outputted.\n" else: for msg in self.log: result += msg + "\n" result += "------------------------------------------------------------" result += "\n\t==== Log End ====" result += "\n------------------------------------------------------------" return (title, result)
def acs_compile(builder, part): rootDir = part.rootdir sourceDir = part.sourcedir partname = part.name pathdir = os.path.join(rootDir, sourceDir) os.chdir(builder.ui.rootdir) tools_dir = os.path.join( utils.relativePath(const.ini_prop("acscomp_path", "..\\"))) src_dir = os.path.join(rootDir, sourceDir) acs_dir = os.path.join(pathdir, "acs") comp_path = os.path.join(tools_dir, const.COMPILER_EXE) if not os.path.isfile(comp_path): utils.process_msg( builder, "ACS compiler can't find " + const.COMPILER_EXE + "." + "Please configure the directory on the project.ini file." + "ACS Compilation skipped.") return 0 if not os.path.isdir(acs_dir): utils.process_msg( builder, "No ACS folder on {0} exists, creating it now.".format(partname)) os.mkdir(acs_dir) tmp_dir = os.path.join(tools_dir, "acscomp_tmp") if not os.path.exists(tmp_dir): os.mkdir(tmp_dir) else: rmtree(tmp_dir) os.mkdir(tmp_dir) # includes = ['-i'] + [tools_dir] """+ ['-i'] + [src_dir]""" includes = ['-i'] + [tools_dir] + ['-i'] + [tmp_dir] # print(includes); os.chdir(acs_dir) # Get rid of the old compiled files, for a clean build. utils.process_msg( builder, "Clearing old compiled ACS for {name}".format(name=partname)) current = 1 for root, dirs, files in os.walk(os.getcwd()): for file in files: if builder.abort: return -1 if file.endswith(".o"): os.remove(os.path.join(root, file)) utils.printProgress(builder, current, len(files), 'Cleared', '.o files. (' + file + ')') current += 1 utils.process_msg(builder, "{name} Old Compiled ACS cleared.".format(name=partname)) # Work-arround to hide the acc console. startupinfo = None if os.name == 'nt': startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW os.chdir(src_dir) outs = 0 while True: # Wait until the ACS Error dialog gives us an answer if outs == 1: if builder.ui.response == 0: # Sthap utils.process_msg(builder, "Aborting ACS Compilation.") builder.abort = True outs = ACSCOMP_FALLBACK elif builder.ui.response == 1: # Again # rmtree(tmp_dir) # Refresh the acs again! utils.process_msg(builder, "Retrying ACS Compilation.".format(file)) outs = ACSCOMP_RUNNING continue if (outs == ACSCOMP_FALLBACK): os.chdir(rootDir) rmtree(tmp_dir) return -1 if (outs == ACSCOMP_COMPLETED): utils.process_msg( builder, "{name} ACS Compiled Sucessfully.".format(name=partname)) break files_to_compile = [] try: files_to_compile = acs_update_compilable_files( builder, partname, src_dir, tmp_dir, True) except Exception as e: utils.process_msg( builder, "Something went really wrong. Skipping ACS Comp for {0}. ". format(partname)) utils.process_msg(builder, "Error msg: {0} ".format(str(e))) os.chdir(rootDir) return 0 # If user called to abort. if (files_to_compile == -1): return -1 # print(files_to_compile) # The stage is set! Let the compiling-fest begin! utils.process_msg(builder, "Compiling ACS for {name}".format(name=partname)) current = 0 for file in files_to_compile: if builder.abort: rmtree(tmp_dir) return -1 else: # If you have acs files, compile them like libnraries. f_target = os.path.join(tmp_dir, file) f_name = os.path.basename(f_target).split('.')[0] f_names = os.path.basename(f_target).split( '.')[0] + '.' + os.path.basename(f_target).split('.')[1] compcmd = [comp_path] + includes + [f_target] + [ os.path.join(acs_dir, f_name + '.o') ] subprocess.call(compcmd, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL, startupinfo=startupinfo) # acs_err = os.path.join(rootDir, 'acs.err') acs_err = f_target.replace(f_names, 'acs.err') # We got an error in the acs script? Stop it, and show the error ASAP. if os.path.isfile(acs_err): acs_err_dir = utils.get_file_dir(acs_err) os.chdir(acs_err_dir) # os.system('cls') with open('acs.err', 'rt') as errorlog: error = errorlog.read() builder.ui.AddToLog(error) # builder.ui.ACSErrorOutput(error) wx.CallAfter( builder.ui.ACSErrorOutput, error + "\n\nDo you wish to RETRY or ABORT the ACS Compilation?" ) errorlog.close() os.remove(os.path.join(acs_err_dir, 'acs.err')) utils.process_msg( builder, "The file contains some errors, compilation failed.") outs = ACSCOMP_PROMPT break # Actually instead of just bouncing you out, I prefer to just repeat the compilation of that file. # Also stop if the expected file was'nt created. if not os.path.isfile(os.path.join(acs_dir, f_name + '.o')): os.chdir(rootDir) # os.system('cls') if (os.path.isfile(acs_err)): os.remove(acs_err) wx.CallAfter(builder.ui.ACSErrorOutput, "Something blew up :/") utils.process_msg( builder, "The expected file was'nt created, compilation failed." ) outs = ACSCOMP_PROMPT break current += 1 utils.printProgress(builder, current, len(files_to_compile), 'Compiled', 'acs files. (' + f_names + ')') if outs == ACSCOMP_RUNNING: outs = ACSCOMP_COMPLETED # Job's done here, get back to the root directory and continue with the rest. os.chdir(rootDir) rmtree(tmp_dir) return 0
def SetUpPwads(self, parent, pwad_list): versioned = parent.flags[1].GetValue() snapshot = parent.flags[4].GetValue() snapshot_tag = parent.snapshot_tag snapshot_tag_last = parent.snapshot_tag_last # Read the INI file, and get the required pwads. pwads_before_ini = const.ini_prop('play_pwads_before') pwads_before = [] for path in pwads_before_ini: filepath = utils.relativePath(path) if os.path.isfile(filepath): pwads_before.append(filepath) pwads_after_ini = const.ini_prop('play_pwads_after') pwads_after = [] for path in pwads_after_ini: filepath = utils.relativePath(path) if os.path.isfile(filepath): pwads_after.append(filepath) if len(pwad_list) == 0: # If this is the first time on the play button. Load the INI PWADS and the project pwads for pwad in pwads_before: pwad_list.append( [utils.get_file_name(pwad), utils.get_file_dir(pwad)]) for p in parent.projectparts: pwad_list.append( p.GetExpectedPWADS(versioned, snapshot, snapshot_tag)) for pwad in pwads_after: pwad_list.append( [utils.get_file_name(pwad), utils.get_file_dir(pwad)]) else: # Else, update the project pwads. Depending on the versioned mark. index = 0 for pwadlist in pwad_list: for p in parent.projectparts: dev_ver = p.GetExpectedPWADS(False, False, "") relase_ver = p.GetExpectedPWADS(True, False, "") snap_ver = p.GetExpectedPWADS(True, True, snapshot_tag) snap_ver_last = p.GetExpectedPWADS(True, True, snapshot_tag_last) ''' print("Develop version: " + dev_ver[0]) print("Relase version: " + relase_ver[0]) print("Snap version expected: " + snap_ver[0]) print("Last Snap version expected: " + snap_ver_last[0]) print("Current set: " + pwadlist[0]) ''' if (versioned): if (snapshot): if pwadlist[0] == dev_ver[0] or pwadlist[ 0] == relase_ver[0] or pwadlist[ 0] == snap_ver_last[0]: pwad_list[index] = snap_ver else: if pwadlist[0] == dev_ver[0] or pwadlist[ 0] == snap_ver[0] or pwadlist[ 0] == snap_ver_last[0]: pwad_list[index] = relase_ver else: if pwadlist[0] == relase_ver[0] or pwadlist[ 0] == snap_ver[0] or pwadlist[ 0] == snap_ver_last[0]: pwad_list[index] = dev_ver index += 1 return pwad_list
def run(self): """Run Worker Thread.""" # First for all, check the main flags noacs = self.ui.flags[0].GetValue() versioned = self.ui.flags[1].GetValue() packed = self.ui.flags[2].GetValue() snapshot = self.ui.flags[4].GetValue() # Make sure you're on the working directory where you will start the build. rootdir = self.ui.rootdir # print("Root dir: " + rootdir) os.chdir(rootdir) parts = self.ui.projectparts current = 1 total = len(parts) for part in parts: if part.skip: total -= 1 if total == 0: wx.PostEvent(self.ui, BuildResultEvent(BUILD_SKIPPED)) return output = (0, []) files_to_pack = [] # Good, now start. for part in parts: output = part.BuildPart(self, versioned, noacs, snapshot, current, total) if not part.skip: current += 1 if output[0] != 0 or self.abort: wx.PostEvent(self.ui, BuildResultEvent(output[0])) return files_to_pack.extend(output[1]) # Files are built, now, we should pack them if flagged to do so. if packed: config = ConfigParser() config.read("project.ini") os.chdir(rootdir) distDir = const.ini_prop('zip_dir', 'dist\packed') filename = const.ini_prop('zip_name', 'project') if not os.path.exists(distDir): os.mkdir(distDir) self.ui.AddToLog( distDir + " directory created to allocate the packed projects.") if versioned: if snapshot: filename += "_" + self.ui.snapshot_tag + '.zip' else: filename += "_" + const.ini_prop('zip_tag', 'v0') + '.zip' else: filename += "_" + "DEV" + '.zip' destination = os.path.join(distDir, filename) distzip = zipfile.ZipFile(destination, "w", zipfile.ZIP_DEFLATED) current = 1 for file in files_to_pack: if self.abort: distzip.close() return None os.chdir(file[0]) distzip.write(file[1]) utils.printProgress(self, current, len(files_to_pack), 'Packed: ', 'files. (' + file[1] + ')') current += 1 distzip.close() self.ui.AddToLog("{0} Packed up Sucessfully".format(filename)) # print(file_list) os.chdir(rootdir) wx.PostEvent(self.ui, BuildResultEvent(BUILD_SUCCESS))