def do_dfm_conversion(transform, graph): forms = find_forms(graph) for filepath_dfm in forms: directory = os.path.dirname(filepath_dfm) filepath_dfmbin = filepath_dfm + ".bin" filepath_dfmtxt = filepath_dfm + ".txt" filename_dfm = os.path.basename(filepath_dfm) filename_dfmbin = os.path.basename(filepath_dfmbin) dfmconvert = DelphiCompiler.get_dfmconvert(relative_to=directory) io.run_win32app( "Convert %s to binary dfm format" % filename_dfm, directory, [dfmconvert, "--to-binary", filename_dfm, "--output", filename_dfmbin], ) if os.path.exists(filepath_dfmbin): shutil.copymode(filepath_dfm, filepath_dfmbin) # make backup, file will be overwritten shutil.copyfile(filepath_dfm, filepath_dfmtxt) shutil.copymode(filepath_dfm, filepath_dfmtxt) # rewrite original filename os.unlink(filepath_dfm) os.rename(filepath_dfmbin, filepath_dfm) transform[filepath_dfm] = filepath_dfmtxt
def do_compile(transform, abspath, relpath, filename, includepath, target_dir=None): filepath = os.path.join(abspath, relpath, filename) directory = os.path.dirname(filepath) handle_cfg(transform, filepath) # keep codebase clean, write output to tempdir tmpdir = io.get_tmpdir() if io.platform_is_cygwin(): tmpdir = io.path_cygwin_to_win(tmpdir) target_dir = target_dir and target_dir or tmpdir outputdirs = [ '-E"%s"' % target_dir, # OutputDir '-N"%s"' % tmpdir, # UnitOutputDir '-LE"%s"' % tmpdir, # PackageDLLOutputDir '-LN"%s"' % tmpdir, # PackageDCPOutputDir ] dcc32 = DelphiCompiler.get_dcc32(relative_to=directory) exitcode = io.run_win32app( "Building %s" % filename, directory, [ dcc32, # '--depends', '-u"%s"' % includepath, ] + outputdirs + [filename], ) return exitcode
def do_preprocess(filelist, is_directive_on, dipp_conditionals): dipp_bin = get_dipp() for fp in filelist: filename = os.path.basename(fp) directory = os.path.dirname(fp) tmpfile = io.get_tmpfile(filename) if io.platform_is_cygwin(): tmpfile = io.path_cygwin_to_win(tmpfile) ### PASS 1 flags = ['-o', '-PD2006', '-li'] exitcode = io.run_win32app('Preprocessing includes in %s' % fp, directory, [dipp_bin, filename, tmpfile] + flags) if not exitcode: io.rename(tmpfile, fp) else: return exitcode ### PASS 1.5 prepare_to_preprocess(is_directive_on, fp) ### PASS 2 flags = ['-o', '-PD2006', '-c', '-h', dipp_conditionals] exitcode = io.run_win32app('Preprocessing conditionals in %s' % fp, directory, [dipp_bin, filename, tmpfile] + flags) if not exitcode: io.rename(tmpfile, fp) else: return exitcode ### PASS 2.5 do_after_preprocess(fp) return exitcode