Пример #1
0
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
Пример #2
0
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
Пример #3
0
 def get_dcc32(cls, relative_to=None):
     # XXX on cygwin invocation seems to fail sometimes with a rel path
     if io.platform_is_cygwin():
         relative_to = None
     return os.path.join(cls.get_basepath(cls.basepath_dcc_rel,
                                          relative_to=relative_to),
                         'bin', cls.dcc32_binary)
Пример #4
0
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
Пример #5
0
 def _prepare_path(self, fp):
     if io.platform_is_cygwin():
         fp = io.convert_path(fp)
     fp = fp.lower()
     return fp
Пример #6
0
 def get_txl_grammar_path(cls, relative_to=None):
     # XXX on cygwin invocation seems to fail sometimes with a rel path
     if io.platform_is_cygwin():
         relative_to = None
     return cls.get_basepath(cls.basepath_txlgram_rel,
                             relative_to=relative_to)