Esempio n. 1
0
def generate(BuildDir, source, SWIGFLAGS):
    mem.add_dep(mem.util.convert_to_file(source))
    mem.add_deps([mem.nodes.File(f) for f in make_depends(source, SWIGFLAGS)])

    # since we have no way to know all the files that swig will generate,
    # we have it generate into a temp directory, then we can see what
    # exact files were produced, and move them to their proper location.
    mem.util.ensure_file_dir(BuildDir)
    tmpdir = tempfile.mkdtemp(dir=BuildDir)

    if "-c++" in SWIGFLAGS:
        wrap_ext = ".cpp"
    else:
        wrap_ext = ".c"

    wrap = os.path.join(BuildDir, os.path.splitext(source)[0] + "_wrap" + wrap_ext)
    args = mem.util.convert_cmd(['swig', '-o', wrap, '-outdir', tmpdir] +
                                SWIGFLAGS + [source])

    if mem.util.run("SWIG", source, args) != 0:
        mem.fail()

    files = os.listdir(tmpdir)
    for file in files:
        shutil.move(os.path.join(tmpdir, file), os.path.join(BuildDir, file))

    os.rmdir(tmpdir)

    return [mem.nodes.File(os.path.join(BuildDir, file)) for file in files] + \
        [mem.nodes.File(wrap)]
Esempio n. 2
0
File: gcc.py Progetto: srp/mem
def t_cpp_obj(target, source_list, CXXFLAGS, CPPPATH):
    inc_dirs = set()
    if len(source_list) > 1:
        combine_opt=['-combine']
    else:
        combine_opt=[]

    for source in source_list:
        inc_dirs.add("-I" + os.path.dirname(source))
        if not os.path.exists(str(source)):
            Mem.instance().fail("%s does not exist" % source)

            mem.add_dep(util.convert_to_file(source))

    mem.add_deps([nodes.File(f) for f in
                  make_depends(target, source_list,
                               CFLAGS=CXXFLAGS, CPPPATH=CPPPATH,
                               inc_dirs = list(inc_dirs))])

    includes = ["-I" + path for path in CPPPATH]
    args = util.convert_cmd(["g++"] +  CXXFLAGS + includes +
                                target_inc_flag(target, source_list) +
                                list(inc_dirs) +
                                combine_opt +
                                ["-c", "-o", target] + source_list)

    util.ensure_file_dir(target)

    if util.run("Compiling", source_list, args) != 0:
        Mem.instance().fail()

    return nodes.File(target)
Esempio n. 3
0
    def build(self, mem, source, target=None, env=None,
              build_dir=None, **kwargs):
        BuildDir = mem.util.get_build_dir(env, build_dir)

        if not isinstance(source, (str,mem.nodes.File)):
            # TODO: or should this be a mem.fail
            raise RuntimeError("Only takes a single source tex file!")

        mem.add_dep(mem.util.convert_to_file(source))
        self._find_dependencies(open(source, "r").read())

        # Add all the recursively found dependencies
        for d in self._deps:
            mem.add_dep(mem.util.convert_to_file(d))

        args = mem.util.convert_cmd(['pdflatex', "-interaction=nonstopmode",
                    source])

        target = self._check_target(source, target)

        mem.util.ensure_file_dir(target)

        # Finally, run PDFLatex
        while 1:
            stderr, stdout = self._run_pdflatex(source, args)
            if not self._need_rerun(stderr):
                break

        return mem.nodes.File(target)
Esempio n. 4
0
File: gcc.py Progetto: srp/mem
def make_depends_single(target, source,
                        CC, CFLAGS, includes, target_inc, inc_dirs):
    mem.add_dep(util.convert_to_file(source))
    args = util.convert_cmd([CC] + CFLAGS +
                                includes +
                                target_inc +
                                inc_dirs +
                                ["-M", "-o", "-", source])
    return util.make_depends("GCC depends", source, args)
Esempio n. 5
0
def t_asciidoc(target, source, ASCIIDOC_FLAGS):
    """ Runs asciidoc compiler on specified files """
    mem.add_dep(mem.util.convert_to_file(source))
    scan(source)

    cmd = mem.util.convert_cmd(["asciidoc","-o",target]+ASCIIDOC_FLAGS+[source])

    print " ".join(cmd)

    mem.util.ensure_file_dir(target)
    if subprocess.call(cmd) != 0:
        mem.fail()

    return mem.nodes.File(target)
Esempio n. 6
0
def scan(file):
    path = os.path.dirname(file)
    f = open(file, "r")
    try:
        l = f.readline()
        incs = []
        while l != "":
            m = scanner_re.match(l)
            if m:
                incs.append(os.path.join(path, m.group(1)))
            l = f.readline()
        for inc in incs:
            mem.add_dep(mem.nodes.File(inc))
            scan(inc)
    finally:
        f.close()
Esempio n. 7
0
def install(source, DESTDIR):
    if DESTDIR is None:
        DESTDIR = Mem.instance().cwd
    mem.add_dep(source)

    target = os.path.join(DESTDIR, source.basename())
    source = mem.util.convert_cmd([source])[0]

    mem.util.ensure_dir(DESTDIR)

    def copier(*args, **kwargs):
        shutil.copy2(*args, **kwargs)
        return (0, "", "")


    if mem.util.run_return_output("Installing to %s" % DESTDIR,
                                  source,
                                  copier,
                                  source,
                                  target)[0]:
        mem.fail()

    return mem.nodes.File(target)