def prepare_path(graph, use_abspath=None): searchpath = graph.searchpath # find all stdlib paths not in searchpath nodes = graph.rootnode.collect_nodes(lambda n: n != None) stdlibpath = util.iuniq(map(lambda n: n.path, nodes)) stdlibpath = util.setminus(stdlibpath, searchpath) # filter stdlibpath with respect to searchpath if io.platform_is_cygwin(): for path in stdlibpath: if io.path_cygwin_to_win(path) in searchpath: stdlibpath.remove(path) # filter for empties searchpath = filter(lambda p: p != "", searchpath) stdlibpath = filter(lambda p: p != "", stdlibpath) # make relative to given abspath if use_abspath: def rebase_path(path): oldcwd = os.getcwd() try: os.chdir(graph.abspath) path = os.path.abspath(path) finally: os.chdir(oldcwd) path = io.relpath(path, relative_to=use_abspath) return path searchpath = map(rebase_path, searchpath) stdlibpath = map(rebase_path, stdlibpath) # if cygwin make stdlibpath absolute if io.platform_is_cygwin(): abs = lambda p: io.path_join(graph.abspath, p) stdlibpath = map(abs, stdlibpath) # group include = searchpath + stdlibpath # if cygwin convert to winpaths if io.platform_is_cygwin(): include = map(lambda p: io.path_cygwin_to_win(p), include) # kill dupes include = util.iuniq(include) # join include_s = ";".join(include) return include_s
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 exec_txl(cls, txlprog, filepath, txlargs=None): directory, filename = os.path.split(filepath) directory = directory and directory or "." txlbin = DelphiCompiler.get_txl_binary(relative_to=directory) grammar_path = DelphiCompiler.get_txl_grammar_path(relative_to=directory) txlprog = os.path.join(grammar_path, txlprog) if not io.platform_is_linux(): txlprog = io.path_cygwin_to_win(txlprog) txlargs = txlargs and txlargs or [] return io.invoke([txlbin] + txlargs + [txlprog, filename], cwd=directory, return_all=True)
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