Example #1
0
def _compile(sources, BuildDir, JAVA_FLAGS):
    args = ["javac", "-d", BuildDir] + JAVA_FLAGS + sources
    print " ".join(args)
    if subprocess.call(args) != 0:
        mem.fail()
    return [File(os.path.join(BuildDir, os.path.splitext(source)[0] + ".class"))
            for source in sources]
Example #2
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)]
Example #3
0
def always_command(cmd):
    """ Runs the specified command """
    print cmd
    (stat, out) = commands.getstatusoutput(cmd)
    if stat:
        mem.fail(cmd + ":" + out)

    return None
Example #4
0
    def _run_pdflatex(self, source_list, args):
        code,stderr,stdout = mem.util.run_return_output_no_print(
            "PDFLATEX", source_list, mem.util._open_pipe_, args)
        if code is not 0:
            print stderr
            mem.fail("PDFLatex failed!")

        return stderr, stdout
Example #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)
Example #6
0
def _compile(sources, JAVA_PACKAGE, JAVA_BUILD_DIR, JAVA_FLAGS):
    mem.add_deps([nodes.File(f) for f in sources])
    args = (["javac", "-d", JAVA_BUILD_DIR, "-cp", JAVA_BUILD_DIR] +
            JAVA_FLAGS + sources)
    print " ".join(args)
    if subprocess.call(args) != 0:
        mem.fail()

    def src_path_to_dest_file(p):
        return os.path.splitext(os.path.basename(p))[0] + ".class"

    return [File(os.path.join(JAVA_BUILD_DIR,
                              *(JAVA_PACKAGE.split(".") +
                                [src_path_to_dest_file(source)])))
            for source in sources]
Example #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)