Ejemplo n.º 1
0
    def __call__(self, src:fbuild.db.SRC, *,
            flags=(),
            buildroot=None) -> fbuild.db.DSTS:
        buildroot = buildroot or self.ctx.buildroot
        # first, copy the src file into the buildroot
        src_buildroot = src.addroot(buildroot)
        dsts = (
            src_buildroot.replaceext('.ml'),
            src_buildroot.replaceext('.mli'),
        )

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

        cmd = [self.exe]
        cmd.extend(self.flags)
        cmd.extend(flags)
        cmd.append(src)

        self.ctx.execute(cmd, str(self), '%s -> %s' % (src, ' '.join(dsts)),
            color='yellow')

        return dsts
Ejemplo n.º 2
0
    def __call__(self, src:fbuild.db.SRC, *,
            flags=(),
            buildroot=None) -> fbuild.db.DSTS:
        buildroot = buildroot or self.ctx.buildroot
        # first, copy the src file into the buildroot
        src_buildroot = src.addroot(buildroot)
        dsts = (
            src_buildroot.replaceext('.ml'),
            src_buildroot.replaceext('.mli'),
        )

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

        cmd = [self.exe]
        cmd.extend(self.flags)
        cmd.extend(flags)
        cmd.append(src)

        self.ctx.execute(cmd, str(self), '%s -> %s' % (src, ' '.join(dsts)),
            color='yellow')

        return dsts
Ejemplo n.º 3
0
    def __call__(self,
                 src: fbuild.db.SRC,
                 *,
                 buildroot=None,
                 flags=[]) -> fbuild.db.DST:
        buildroot = buildroot or self.ctx.buildroot

        # first, copy the src file into the buildroot
        src_buildroot = src.addroot(buildroot)
        dst = src_buildroot.replaceext('.ml')

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

        cmd = [self.exe, '--no-mli']
        cmd.extend(flags)
        cmd.append(src)

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

        return dst
Ejemplo n.º 4
0
    def __call__(self, src:fbuild.db.SRC, *,
            buildroot=None,
            flags=[]) -> fbuild.db.DST:
        buildroot = buildroot or self.ctx.buildroot

        # first, copy the src file into the buildroot
        src_buildroot = src.addroot(buildroot)
        dst = src_buildroot.replaceext('.ml')

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

        cmd = [self.exe]
        cmd.extend(flags)
        cmd.append(src)

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

        return dst
Ejemplo n.º 5
0
    def _run_flxg(self, src:fbuild.db.SRC, *,
            includes=[],
            syntaxes=[],
            imports=[],
            flags=[],
            include_std=True,
            preparse=False,
            buildroot=None,
            **kwargs) -> fbuild.db.DST:
        buildroot = buildroot or self.ctx.buildroot

        src = Path(src)
        src_buildroot = src.addroot(buildroot)

        dst = src.addroot(buildroot)

        if preparse:
            dst = dst.replaceext('.par')
        else:
            dst = dst.replaceext('.cpp')

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

        dst.parent.makedirs()

        cmd = [self.flxg]

        if preparse:
            cmd.append('-c')

        includes = set(includes)
        includes.add(src.parent)
        includes.add(dst.parent)

        imports = list(imports)
        syntaxes = list(syntaxes)
        if include_std:
            imports.insert(0, 'plat/flx.flxh')
            syntaxes.insert(0, '@grammar/grammar.files')

        cmd.extend('-I' + i for i in sorted(includes) if Path.exists(i))
        cmd.extend('--syntax=' + i for i in syntaxes)
        cmd.extend('--import=' + i for i in imports)
        cmd.append('--output_dir=' + dst.parent)
        cmd.extend(flags)

        if include_std:
            cmd.append('std')

        if src.ext == '.flx':
            cmd.append(src.replaceext(''))
        else:
            cmd.append(src)

        self.ctx.execute(cmd, self.flxg.name, '%s -> %s' % (src, dst),
                color='yellow', **kwargs)

        return dst