예제 #1
0
파일: bison.py 프로젝트: felix-lang/fbuild
    def __call__(self, src:fbuild.db.SRC, dst=None, *,
            suffix=None,
            verbose=False,
            name_prefix=None,
            defines=False,
            flags=[],
            buildroot=None) -> fbuild.db.DST:
        buildroot = buildroot or self.ctx.buildroot
        suffix = suffix or self.suffix
        dst = Path.addroot(dst or src, buildroot).replaceext(suffix)
        dst.parent.makedirs()

        cmd = [self.exe]

        if verbose:
            cmd.append('-v')

        if name_prefix is not None:
            cmd.extend(('-p', name_prefix))

        if defines:
            cmd.append('-d')

        cmd.extend(self.flags)
        cmd.extend(flags)
        cmd.extend(('-o', dst))
        cmd.append(src)

        self.ctx.execute(cmd, self.exe, '%s -> %s' % (src, dst), color='yellow')

        return dst
예제 #2
0
    def __call__(self, src: fbuild.db.SRC, header, dst=None) -> fbuild.db.DSTS:
        dst = Path.addroot(dst or src, self.ctx.buildroot).replaceext(self.suffix)
        dst.parent.makedirs()
        header = Path.addroot(header, self.ctx.buildroot)
        header.parent.makedirs()

        cmd = [self.exe]
        cmd.extend(self.flags)
        if self.debug: cmd.append('-d')
        cmd.extend(('-o', dst))
        cmd.append('--header='+header)
        cmd.append(src)

        self.ctx.execute(cmd, self.exe, '%s -> %s %s' % (src, dst, header),
            color='yellow')

        return [dst, header]
예제 #3
0
 def translate(self, src: fbuild.db.SRC, dst) -> fbuild.db.DST:
     dst = Path.addroot(dst, self.ctx.buildroot)
     dst.parent.makedirs()
     cmd = [self.exe, 'dynasm/dynasm.lua']
     for d in self.defs:
         cmd.extend(('-D', d))
     cmd.extend(('-o', dst))
     cmd.append(src)
     self.ctx.execute(cmd, 'dynasm', '%s -> %s' % (src, dst), color='yellow')
     return dst
예제 #4
0
파일: fbuildroot.py 프로젝트: S-YOU/rejit
 def translate(self, src: fbuild.db.SRC, dst) -> fbuild.db.DST:
     dst = Path.addroot(dst, self.ctx.buildroot)
     dst.parent.makedirs()
     cmd = [self.exe, 'dynasm/dynasm.lua']
     for d in self.defs:
         cmd.extend(('-D', d))
     cmd.extend(('-o', dst))
     cmd.append(src)
     self.ctx.execute(cmd, 'dynasm', '%s -> %s' % (src, dst), color='yellow')
     return dst
예제 #5
0
    def __call__(self, src: fbuild.db.SRC, header, dst=None) -> fbuild.db.DSTS:
        dst = Path.addroot(dst or src,
                           self.ctx.buildroot).replaceext(self.suffix)
        dst.parent.makedirs()
        header = Path.addroot(header, self.ctx.buildroot)
        header.parent.makedirs()

        cmd = [self.exe]
        cmd.extend(self.flags)
        if self.debug: cmd.append('-d')
        cmd.extend(('-o', dst))
        cmd.append('--header=' + header)
        cmd.append(src)

        self.ctx.execute(cmd,
                         self.exe,
                         '%s -> %s %s' % (src, dst, header),
                         color='yellow')

        return [dst, header]
예제 #6
0
def foo(ctx, src:fbuild.db.SRC, dst, *, buildroot=None) -> fbuild.db.DST:
    dst = Path.addroot(dst, buildroot or ctx.buildroot)

    ctx.logger.log(' * foo: %s %s' % (src, dst), color='cyan')

    with open(src) as f:
        x = f.read().strip()

    with open(dst, 'w') as f:
        print(src, dst, x, file=f)

    return dst
예제 #7
0
    def __call__(self, src, dst, *, buildroot=None):
        buildroot = buildroot or self.ctx.buildroot
        dst = Path.addroot(dst, buildroot).addprefix(self.prefix) + self.suffix

        self.ctx.logger.log(' * Builder.__call__: %s %s' % (src, dst),
            color='cyan')

        with open(src) as f:
            x = f.read().strip()

        with open(dst, 'w') as f:
            print(src, dst, x, file=f)

        return dst
예제 #8
0
def check_fluid(linker):
    fluidsynth = Path(linker.prefix + 'fluidsynth' + linker.suffix)
    fluidsynth = fluidsynth.addroot(Path('fluidsynth') / 'fluidsynth' / 'src')

    message = textwrap.dedent('''
    You need to build Fluidsynth separately first!
    Try runnung 'cd fluidsynth/fluidsynth; cmake'.
    (See http://sourceforge.net/p/fluidsynth/wiki/BuildingWithCMake/ for info.)
    '''.rstrip().lstrip('\n')).replace('\n', ' ', 1)

    if not fluidsynth.exists():
        raise fbuild.ConfigFailed(message)

    return fluidsynth
예제 #9
0
    def uncached_compile(self,
                         src,
                         *,
                         static=None,
                         includes=[],
                         flags=[],
                         buildroot=None,
                         **kwargs):
        """Compile a felix file without caching the results.  This is needed
        when compiling temporary files."""
        print("Uncached compile " + src)
        src = Path(src)
        buildroot = buildroot or self.ctx.buildroot
        src_buildroot = src.addroot(buildroot)

        if static is None:
            static = self.static

        if static:
            dst = src_buildroot.replaceext(self.exe_suffix)
        else:
            dst = src_buildroot.replaceext(self.lib_suffix)

        if src != src_buildroot:
            src_buildroot.parent.makedirs()
            src.copy(src_buildroot)
            src = src_buildroot

        includes = set(includes)
        includes.update(self.includes)
        includes.add(src.parent)

        cmd_flags = ['-c']
        cmd_flags.extend(self.flags)
        cmd_flags.extend(flags)

        self.flx(src,
                 self.flx,
                 '%s -> %s' % (src, dst),
                 includes=includes,
                 static=static,
                 flags=cmd_flags,
                 color='compile',
                 **kwargs)

        return dst
예제 #10
0
파일: felix.py 프로젝트: alexkross/felix
    def uncached_compile(self, src, *,
            static=None,
            includes=[],
            flags=[],
            buildroot=None,
            **kwargs):
        """Compile a felix file without caching the results.  This is needed
        when compiling temporary files."""
        print("Uncached compile " + src)
        src = Path(src)
        buildroot = buildroot or self.ctx.buildroot
        src_buildroot = src.addroot(buildroot)

        if static is None:
            static = self.static

        if static:
            dst = src_buildroot.replaceext(self.exe_suffix)
        else:
            dst = src_buildroot.replaceext(self.lib_suffix)

        if src != src_buildroot:
            src_buildroot.parent.makedirs()
            src.copy(src_buildroot)
            src = src_buildroot

        includes = set(includes)
        includes.update(self.includes)
        includes.add(src.parent)

        cmd_flags = ['-c']
        cmd_flags.extend(self.flags)
        cmd_flags.extend(flags)

        self.flx(src, self.flx, '%s -> %s' % (src, dst),
            includes=includes,
            static=static,
            flags=cmd_flags,
            color='compile',
            **kwargs)

        return dst
예제 #11
0
파일: scala.py 프로젝트: rjeschmi/fbuild
    def __call__(self, src, *args, flags=[], buildroot=None, **kwargs):
        """Run a scala script."""

        src = Path(src)
        buildroot = buildroot or self.ctx.buildroot
        src_buildroot = src.addroot(buildroot)
        dst = src.replaceext('.jar')

        # We need to copy the src into the buildroot so we don't pollute our
        # tree.
        if src != src_buildroot:
            src_buildroot.parent.makedirs()
            src.copy(src_buildroot)
            src = src_buildroot

        # Always save the compilation results.
        flags = list(flags)
        flags.append('-savecompiled')

        stdout, stderr = self._run([src], *args, flags=flags, **kwargs)
        return dst, stdout, stderr
예제 #12
0
파일: bison.py 프로젝트: graydon/fbuild
    def __call__(self,
                 src: fbuild.db.SRC,
                 dst=None,
                 *,
                 suffix=None,
                 verbose=False,
                 name_prefix=None,
                 defines=False,
                 flags=[],
                 buildroot=None) -> fbuild.db.DST:
        buildroot = buildroot or self.ctx.buildroot
        suffix = suffix or self.suffix
        dst = Path.addroot(dst or src, buildroot).replaceext(suffix)
        dst.parent.makedirs()

        cmd = [self.exe]

        if verbose:
            cmd.append('-v')

        if name_prefix is not None:
            cmd.extend(('-p', name_prefix))

        if defines:
            cmd.append('-d')

        cmd.extend(self.flags)
        cmd.extend(flags)
        cmd.extend(('-o', dst))
        cmd.append(src)

        self.ctx.execute(cmd,
                         self.exe,
                         '%s -> %s' % (src, dst),
                         color='yellow')

        return dst
예제 #13
0
def find_font(ctx) -> fbuild.db.DST:
    ctx.logger.check('locating arial font')
    font = None

    if sys.platform == 'win32':
        font = Path(os.environ['SYSTEMROOT']) / 'Fonts' / 'Arial.ttf'
        if not font.exists():
            font = None
    elif sys.platform.startswith('linux'):
        # Check /etc/fonts/fonts.conf.
        font_dirs = []
        fonts = Path('/etc/fonts/fonts.conf')
        if not fonts.exists():
            ctx.logger.failed()
            raise fbuild.ConfigFailed('cannot locate fonts.conf')

        tree = etree.parse(str(fonts))
        for element in tree.findall('dir'):
            path = Path(element.text)
            if element.attrib.get('prefix') == 'xdg' and \
                'XDG_DATA_HOME' in os.environ:
                path = path.addroot(os.environ['XDG_DATA_HOME'])

            try:
                font = Path(next(path.find('Arial.ttf', include_dirs=False)))
            except StopIteration:
                pass
            else:
                break

    if font is None:
        ctx.logger.failed()
        raise fbuild.ConfigFailed('cannot locate arial font')
    else:
        ctx.logger.passed('ok %s' % font)
        return font
예제 #14
0
파일: ildroot.py 프로젝트: kirbyfan64/wit
def crystal(ctx, srcs: fbuild.db.SRCS, dst) -> fbuild.db.DST:
    dst = Path.addroot(dst, ctx.buildroot)
    ctx.execute(['crystal', 'build', '-o', dst, srcs[0]], 'crystal',
        '%s -> %s' % (' '.join(srcs), dst), color='yellow')
    return dst