Пример #1
0
    def _run_flx_pkgconfig(self, src: fbuild.db.SRC) -> fbuild.db.DSTS:
        """
        Run flx_pkgconfig to generate the include files, normally done by flx
        command line harness but we're probably building it here.
        """

        flx_pkgconfig = self.ctx.buildroot / 'host' / 'bin' / 'flx_pkgconfig'
        resh = src.replaceext('.resh')
        includes = src.replaceext('.includes')

        cmd = [
            flx_pkgconfig, '--path+=' + self.ctx.buildroot / 'host' / 'config',
            '--field=includes', '@' + resh
        ]

        stdout, stderr = self.ctx.execute(cmd,
                                          flx_pkgconfig,
                                          '%s -> %s %s' %
                                          (src, resh, includes),
                                          color='yellow',
                                          stdout_quieter=1)

        with open(includes, 'w') as f:
            for include in stdout.decode('utf-8', 'ignore').strip().split(' '):
                print('#include %s' % include, file=f)

        return resh, includes
Пример #2
0
    def _run_flx_pkgconfig(self, src:fbuild.db.SRC) -> fbuild.db.DSTS:
        """
        Run flx_pkgconfig to generate the include files, normally done by flx
        command line harness but we're probably building it here.
        """

        flx_pkgconfig = self.ctx.buildroot / 'host'/'bin'/'flx_pkgconfig'
        resh = src.replaceext('.resh')
        includes = src.replaceext('.includes')

        cmd = [
            flx_pkgconfig,
            '--path+=' + self.ctx.buildroot / 'host'/'config',
            '--field=includes',
            '@' + resh]

        stdout, stderr = self.ctx.execute(
            cmd,
            flx_pkgconfig,
            '%s -> %s %s' % (src, resh, includes),
            color='yellow',
            stdout_quieter=1)

        with open(includes, 'w') as f:
            for include in stdout.decode('utf-8','ignore').strip().split(' '):
                print('#include %s' % include, file=f)

        return resh, includes
Пример #3
0
    def _run_flx_pkgconfig(self, src: fbuild.db.SRC) -> fbuild.db.DSTS:
        """
        Run flx_pkgconfig to generate the include files, normally done by flx
        command line harness but we're probably building it here.
        """

        flx_pkgconfig = self.ctx.buildroot / "bin" / "flx_pkgconfig"
        resh = src.replaceext(".resh")
        includes = src.replaceext(".includes")

        cmd = [flx_pkgconfig, "--path+=" + self.ctx.buildroot / "config", "--field=includes", "@" + resh]

        stdout, stderr = self.ctx.execute(
            cmd, flx_pkgconfig, "%s -> %s %s" % (src, resh, includes), color="yellow", stdout_quieter=1
        )

        with open(includes, "w") as f:
            for include in stdout.decode("utf-8", "ignore").strip().split(" "):
                print("#include %s" % include, file=f)

        return resh, includes
Пример #4
0
    def __call__(self, src:fbuild.db.SRC, *,
            flags=(),
            buildroot=None) -> fbuild.db.DST:
        buildroot = buildroot or self.ctx.buildroot
        dst = src.replaceext('.ml').addroot(buildroot)
        dst.parent.makedirs()

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

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

        return dst
Пример #5
0
    def __call__(self, src:fbuild.db.SRC, *,
            flags=(),
            buildroot=None) -> fbuild.db.DST:
        buildroot = buildroot or self.ctx.buildroot
        dst = src.replaceext('.ml').addroot(buildroot)
        dst.parent.makedirs()

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

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

        return dst
Пример #6
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)

        print("Buildroot        = " + buildroot)
        print("Src to flxg      = " + src)
        if preparse:
            dst = buildroot / "cache" / "binary" + _getcwd() / src
            dst = dst.replaceext('.par')
        else:
            dst = buildroot / "cache" / "text" + _getcwd() / src
            dst = dst.replaceext('.cpp')

        print("Expected flg dst = " + dst)
        #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')  # Unix filename correct here
            imports.insert(
                0,
                'concordance/concordance.flxh')  # Unix filename correct here
            syntaxes.insert(
                0, '@grammar/grammar.files')  # Unix filename correct here

        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=' + Path(buildroot) / "cache" / "text")
        cmd.append('--cache_dir=' + Path(buildroot) / "cache" / "binary")
        #cmd.append('--with-comments') # add lots of comments to generated C++ to help debugging
        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
Пример #7
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)

        print("Buildroot        = " + buildroot)
        print("Src to flxg      = " + src)
        if preparse:
            dst = buildroot /"cache"/"binary"+_getcwd()/src
            dst = dst.replaceext('.par')
        else:
            dst =buildroot /"cache"/"text"+_getcwd()/src
            dst = dst.replaceext('.cpp')

        print("Expected flg dst = " + dst)
        #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')               # Unix filename correct here
            syntaxes.insert(0, '@grammar/grammar.files')     # Unix filename correct here

        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=' + Path(buildroot)/"cache"/"text")
        cmd.append('--cache_dir=' + Path(buildroot)/"cache"/"binary")
        cmd.append('--with-comments') # add lots of comments to generated C++ to help debugging
        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
Пример #8
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)

        print("Buildroot        = " + buildroot)
        print("Src to flxg      = " + src)
        if preparse:
            dst = buildroot / "cache" / "binary" + _getcwd() / src
            dst = dst.replaceext(".par")
        else:
            dst = buildroot / "cache" / "text" + _getcwd() / src
            dst = dst.replaceext(".cpp")

        print("Expected flg dst = " + dst)
        # 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")  # Unix filename correct here
            syntaxes.insert(0, "@grammar/grammar.files")  # Unix filename correct here

        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=" + Path(buildroot) / "cache" / "text")
        cmd.append("--cache_dir=" + Path(buildroot) / "cache" / "binary")
        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
Пример #9
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