Example #1
0
def speed(ctx):
    """Run the Felix performance tests."""

    # Make sure we're built.
    phases, iscr, felix = build(ctx)

    call('buildsystem.speed.run_tests', phases.target, felix)
Example #2
0
def build_runtime(host_phase,target_phase):
    path = Path ('src/flx_async')
    buildsystem.copy_hpps_to_rtl(target_phase.ctx,
        path / 'flx_async.hpp',
    )

    dst = 'host/lib/rtl/flx_async'
    suffix = '.so'
    srcs = [copy(ctx=target_phase.ctx, src=f, dst=target_phase.ctx.buildroot / f) for f in ['src/flx_async/flx_async.cpp']]
    includes = [
        target_phase.ctx.buildroot / 'host/lib/rtl',
        target_phase.ctx.buildroot / 'share/lib/rtl'
    ]
    macros = ['BUILD_ASYNC']
    libs = [
        call('buildsystem.flx_pthread.build_runtime', target_phase),
        call('buildsystem.flx_gc.build_runtime', host_phase,target_phase),
    ]

    return Record(
        static=buildsystem.build_cxx_static_lib(target_phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.static for lib in libs]),
        shared=buildsystem.build_cxx_shared_lib(target_phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.shared for lib in libs]))
Example #3
0
def config_host(ctx, build):
    ctx.logger.log('configuring host phase', color='cyan')

    platform = call('fbuild.builders.platform.guess_platform', ctx,
        ctx.options.build_platform)

    if platform == build.platform:
        ctx.logger.log("using build's c and cxx compiler", color='cyan')
        phase = build
    else:
        phase = Record(
            ctx=ctx,
            platform=platform,
            c=make_c_builder(ctx, exe=fbuild.builders.host_cc,
                platform=platform,
                debug=ctx.options.debug or ctx.options.host_c_debug,
                optimize=not (ctx.options.debug or ctx.options.host_c_debug),
                includes=ctx.options.host_includes,
                libpaths=ctx.options.host_libpaths,
                flags=ctx.options.host_c_flags),
            cxx=make_cxx_builder(ctx, exe=fbuild.builders.host_cxx,
                platform=platform,
                debug=ctx.options.debug or ctx.options.host_c_debug,
                optimize=not (ctx.options.debug or ctx.options.host_c_debug),
                includes=ctx.options.host_includes,
                libpaths=ctx.options.host_libpaths,
                flags=ctx.options.host_cxx_flags))

    phase.ocaml = call('fbuild.builders.ocaml.Ocaml', ctx,
        debug=ctx.options.debug or ctx.options.host_ocaml_debug,
        ocamlc=ctx.options.host_ocamlc,
        ocamlopt=ctx.options.host_ocamlopt,
        flags=['-w', 'yzex', '-warn-error', 'FPSU'],
        linker=phase.c.static.lib_linker,
        requires_at_least_version=(3, 11))

    phase.ocamllex = call('fbuild.builders.ocaml.Ocamllex', ctx,
        ctx.options.host_ocamllex)

    # we prefer the native ocaml as it's much faster
    if hasattr(phase.ocaml, 'ocamlopt'):
        phase.ocaml = phase.ocaml.ocamlopt
    else:
        phase.ocaml = phase.ocaml.ocamlc

    # We optionally support llvm
    try:
        llvm_config = call('fbuild.builders.llvm.LlvmConfig', ctx,
            ctx.options.host_llvm_config,
            requires_at_least_version=(2, 7))
    except fbuild.ConfigFailed:
        phase.llvm_config = None
    else:
        if llvm_config.ocaml_libdir().exists():
            #phase.llvm_config = llvm_config
            phase.llvm_config = None
        else:
            phase.llvm_config = None

    return phase
Example #4
0
def make_cxx_builder(ctx, *args, includes=[], libpaths=[], flags=[], **kwargs):
    flags = list(chain(ctx.options.c_flags, flags))

    kwargs['platform_options'] = [
        # GRRR .. for clang++
        ({'darwin'}, {
            'warnings': ['all', 'fatal-errors', 
                'no-invalid-offsetof', 
                'no-logical-op-parentheses',
                'no-bitwise-op-parentheses',
                'no-parentheses-equality',
                'no-return-stack-address',
                'no-tautological-compare',
                'no-return-type-c-linkage',
                'no-unused-variable',
                ],
            'flags': ['-fno-common', '-fno-strict-aliasing', '-std=c++11'] + flags,
            'optimize_flags': ['-O1', '-fomit-frame-pointer']}),
        ({'posix'}, {
            'warnings': ['all', 'fatal-errors', 'no-invalid-offsetof'],
            'flags': ['-fno-common', '-fno-strict-aliasing'] + flags,
            'optimize_flags': ['-O2', '-fomit-frame-pointer']}),
        ({'windows'}, {
            'flags': ['/GR', '/MD', '/EHs', '/wd4291'] + flags,
            'optimize_flags': ['/Ox']}),
    ]
    kwargs['includes'] = list(chain(ctx.options.includes, includes))
    kwargs['libpaths'] = list(chain(ctx.options.libpaths, libpaths))

    return Record(
        static=call('fbuild.builders.cxx.guess_static', ctx, *args, **kwargs),
        shared=call('fbuild.builders.cxx.guess_shared', ctx, *args, **kwargs))
Example #5
0
def build_flx_drivers(ctx, phase):
    libs = [
        call('buildsystem.ocs.build_lib', phase),
        call('buildsystem.sex.build', phase),
        call('buildsystem.dypgen.build_lib', phase),
        build_flx_version(phase),
        build_flx_lex(phase),
        build_flx_parse(phase),
        build_flx_misc(phase),
        build_flx_file(phase),
        build_flx_core(phase),
        build_flx_desugar(phase),
        build_flx_bind(phase),
        build_flx_frontend(phase),
        build_flx_opt(phase),
        build_flx_lower(phase),
        build_flx_backend(phase),
        build_flx_cpp_backend(phase),
        build_flx_version_hook(phase),
        ]

    external_libs = ['nums', 'unix', 'str']

    flxg = phase.ocaml.build_exe('host/bin/flxg',
        Path.glob('src/compiler/flxg/*.ml{,i}'),
        libs=libs,
        external_libs=external_libs)

    return Record(
        flxg=flxg,
    )
Example #6
0
def make_cxx_builder(ctx, *args,
        includes=[],
        libpaths=[],
        flags=[],
        profile=False,
        **kwargs):
    flags = list(chain(ctx.options.c_flags, flags))

    # profiling is incompatible with -fomit-frame-pointer
    posix_optimize_flags = [ '-O3', '--inline']
    if not profile:
        posix_optimize_flags.append('-fomit-frame-pointer')

    kwargs['platform_options'] = [
        ({'posix'}, {
            'warnings': ['all', 'fatal-errors', 'no-invalid-offsetof'],
            'flags': ['-fno-common'] + flags,
            'optimize_flags': posix_optimize_flags}),
        ({'windows'}, {
            'flags': ['/GR', '/MD', '/EHs', '/wd4291'] + flags,
            'optimize_flags': ['/Ox']}),
    ]
    kwargs['includes'] = list(chain(ctx.options.includes, includes))
    kwargs['libpaths'] = list(chain(ctx.options.libpaths, libpaths))

    return Record(
        static=call('fbuild.builders.cxx.guess_static', ctx, *args, **kwargs),
        shared=call('fbuild.builders.cxx.guess_shared', ctx, *args, **kwargs))
Example #7
0
def make_c_builder(*args, **kwargs):
    static = call('fbuild.builders.c.guess_static', *args, **kwargs)
    shared = call('fbuild.builders.c.guess_shared', *args, **kwargs)

    return Record(
        static=static,
        shared=shared)
Example #8
0
def build_flx(phase, flx_builder):
    print('[fbuild] [flx] building flx')
    #dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h',
    #    phase.platform,
    #    phase.cxx.static,
    #    phase.cxx.shared)

    #if dlfcn_h.dlopen:
    #    external_libs = dlfcn_h.external_libs
    #    print("HAVE dlfcn.h, library=" + str (external_libs))
    #else:
    #    print("NO dlfcn.h available")
    #    external_libs = []

    external_libs = []

    #print("[fbuild:flx.py:build_flx] ********** BUILDING FLX ***********************************************")
    return flx_builder.build_exe(
        aasync=False,
        dst=Path('host') / 'bin' / 'bootflx',
        src=phase.ctx.buildroot / 'share' / 'src' / 'tools' / 'bootflx.flx',
        includes=[
            phase.ctx.buildroot / 'host' / 'lib',
            phase.ctx.buildroot / 'share' / 'lib',
        ],
        cxx_includes=[
            phase.ctx.buildroot / 'share' / 'lib' / 'rtl',
            phase.ctx.buildroot / 'host' / 'lib' / 'rtl'
        ],
        cxx_libs=[
            call('buildsystem.flx_rtl.build_runtime', phase).static,
            call('buildsystem.re2.build_runtime', phase).static,
        ] + external_libs,
    )
Example #9
0
File: flx.py Project: DawidvC/felix
def build_flx( phase, flx_builder):
    print('[fbuild] [flx] building flx')
    #dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h',
    #    phase.platform,
    #    phase.cxx.static,
    #    phase.cxx.shared)

    #if dlfcn_h.dlopen:
    #    external_libs = dlfcn_h.external_libs
    #    print("HAVE dlfcn.h, library=" + str (external_libs))
    #else:
    #    print("NO dlfcn.h available")
    #    external_libs = []

    external_libs = []

    #print("[fbuild:flx.py:build_flx] ********** BUILDING FLX ***********************************************")
    return flx_builder.build_exe(
        async=False,
        dst=Path('host')/'bin'/'bootflx',
        src=phase.ctx.buildroot/'share'/'src'/'tools'/'bootflx.flx',
        includes=[
          phase.ctx.buildroot / 'host'/'lib',
          phase.ctx.buildroot / 'share'/'lib',
          ],
        cxx_includes=[ 
                      phase.ctx.buildroot / 'share'/'lib'/'rtl', 
                      phase.ctx.buildroot / 'host'/'lib'/'rtl'],
        cxx_libs=[
          call('buildsystem.flx_rtl.build_runtime',  phase).static,
          call('buildsystem.re2.build_runtime', phase).static,
          ]+external_libs,
    )
Example #10
0
def config_host(ctx, build):
    ctx.logger.log('configuring host phase', color='cyan')

    platform = call('fbuild.builders.platform.guess_platform', ctx,
        ctx.options.build_platform)

    if platform == build.platform:
        ctx.logger.log("using build's c and cxx compiler", color='cyan')
        phase = build
    else:
        phase = Record(
            ctx=ctx,
            platform=platform,
            c=make_c_builder(ctx, exe=fbuild.builders.host_cc,
                platform=platform,
                debug=ctx.options.debug or ctx.options.host_c_debug,
                optimize=not (ctx.options.debug or ctx.options.host_c_debug),
                includes=ctx.options.host_includes,
                libpaths=ctx.options.host_libpaths,
                flags=ctx.options.host_c_flags),
            cxx=make_cxx_builder(ctx, exe=fbuild.builders.host_cxx,
                platform=platform,
                debug=ctx.options.debug or ctx.options.host_c_debug,
                optimize=not (ctx.options.debug or ctx.options.host_c_debug),
                includes=ctx.options.host_includes,
                libpaths=ctx.options.host_libpaths,
                flags=ctx.options.host_cxx_flags))

    phase.ocaml = call('fbuild.builders.ocaml.Ocaml', ctx,
        debug=ctx.options.debug or ctx.options.host_ocaml_debug,
        ocamlc=ctx.options.host_ocamlc,
        ocamlopt=ctx.options.host_ocamlopt,
        flags=['-w', 'yzex', '-warn-error', 'FPSU'],
        linker=phase.c.static.lib_linker,
        requires_at_least_version=(3, 11))

    phase.ocamllex = call('fbuild.builders.ocaml.Ocamllex', ctx,
        ctx.options.host_ocamllex)

    # we prefer the native ocaml as it's much faster
    if hasattr(phase.ocaml, 'ocamlopt'):
        phase.ocaml = phase.ocaml.ocamlopt
    else:
        phase.ocaml = phase.ocaml.ocamlc

    # We optionally support llvm
    try:
        llvm_config = call('fbuild.builders.llvm.LlvmConfig', ctx,
            ctx.options.host_llvm_config,
            requires_at_least_version=(2, 7))
    except fbuild.ConfigFailed:
        phase.llvm_config = None
    else:
        if llvm_config.ocaml_libdir().exists():
            #phase.llvm_config = llvm_config
            phase.llvm_config = None
        else:
            phase.llvm_config = None

    return phase
Example #11
0
def make_c_builder(ctx, *args, includes=[], libpaths=[], flags=[], **kwargs):
    flags = list(chain(ctx.options.c_flags, flags))

    kwargs['platform_options'] = [
        # GRRR .. for clang
        ({'darwin'},
            {'warnings': ['all', 'fatal-errors',
                'no-constant-logical-operand',
                'no-array-bounds',
                ],
            'flags': ['-fno-common','-fvisibility=hidden'] + flags,
            'optimize_flags': ['-fomit-frame-pointer']}),
        ({'bsd'}, {
            'warnings': ['all', 'fatal-errors', 'no-constant-logical-operand', 'no-array-bounds', ],
            'flags': ['-std=c++11', '-fno-common','-fvisibility=hidden'] + flags,
            'link_flags' : ['-lpthread'],
            'link_flags-': ['-ldl'],
            'optimize_flags': ['-fomit-frame-pointer']}),
        ({'posix'},
            {'warnings': ['all', 'fatal-errors'],
            'flags': ['-std=gnu89', '-fno-common', '-fvisibility=hidden', '-fno-strict-aliasing'] + flags,
            'optimize_flags': ['-fomit-frame-pointer']}),
        ({'windows'}, {
            'link_flags' : ['/DEBUG'],
            'flags': ['/GR', '/MDd', '/EHs', '/Zi', '/wd4291'] + flags,
            'optimize_flags': ['/Ox']}),
    ]
    kwargs['includes'] = list(chain(ctx.options.includes, includes))
    kwargs['libpaths'] = list(chain(ctx.options.libpaths, libpaths))

    return Record(
        static=call('fbuild.builders.c.guess_static', ctx, *args, **kwargs),
        shared=call('fbuild.builders.c.guess_shared', ctx, *args, **kwargs))
Example #12
0
def build_flx_drivers(phase):
    path = Path('src/compiler/drivers')

    call('buildsystem.ocs.build_exe', phase)

    lib = phase.ocaml.build_lib(path / 'flx_driver',
        srcs=Path.glob(path / '*.ml{,i}'))

    return {
        'flxi': phase.ocaml.build_exe('bin/flxi',
            srcs=Path(path / 'flxi' / '*.ml{,i}').glob(),
            libs=[
                call('buildsystem.dypgen.build_lib', phase),
                call('buildsystem.ocs.build_lib', phase),
                lib,
                build_flx_misc(phase),
                build_flx_core(phase),
                build_flx_parse(phase),
                build_flx_bind(phase),
                build_flx_codegen(phase)],
            external_libs=[
                'batteries',
                'threads',
                'llvm',
                'llvm_analysis',
                'llvm_executionengine',
                'llvm_scalar_opts',
                'llvm_target'],
            flags=['-thread'],
            packages=['batteries'],
            cc=phase.cxx.static.compiler.gcc.exe) }
Example #13
0
def build_runtime(phase):
    dst = 'lib/rtl/flx_async'
    suffix = '.so'
    srcs = ['src/flx_async/flx_async.cpp']
    includes = [
        phase.ctx.buildroot / 'config/target',
        'src/exceptions',
        'src/demux',
        'src/faio',
        'src/gc',
        'src/pthread',
        'src/rtl',
    ]
    macros = ['BUILD_ASYNC']
    libs = [
        call('buildsystem.flx_pthread.build_runtime', phase),
        call('buildsystem.faio.build_runtime', phase),
        call('buildsystem.demux.build_runtime', phase),
    ]

    return Record(
        static=buildsystem.build_cxx_static_lib(phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.static for lib in libs]),
        shared=buildsystem.build_cxx_shared_lib(phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.shared for lib in libs]))
Example #14
0
def make_c_builder(ctx, *args, includes=[], libpaths=[], flags=[], **kwargs):
    flags = list(chain(ctx.options.c_flags, flags))

    kwargs['platform_options'] = [
        # GRRR .. for clang
        ({'darwin'},
            {'warnings': ['all', 'fatal-errors', 
                'no-constant-logical-operand',
                'no-array-bounds',
                ],
            'flags': ['-fno-common'] + flags,
            'optimize_flags': ['-O2', '-fomit-frame-pointer']}),
        ({'posix'},
            {'warnings': ['all', 'fatal-errors'],
            'flags': ['-fno-common'] + flags,
            'optimize_flags': ['-O2', '-fomit-frame-pointer']}),
        ({'windows'}, {
            'flags': ['/GR', '/MD', '/EHs', '/wd4291'] + flags,
            'optimize_flags': ['/Ox']}),
    ]
    kwargs['includes'] = list(chain(ctx.options.includes, includes))
    kwargs['libpaths'] = list(chain(ctx.options.libpaths, libpaths))

    return Record(
        static=call('fbuild.builders.c.guess_static', ctx, *args, **kwargs),
        shared=call('fbuild.builders.c.guess_shared', ctx, *args, **kwargs))
Example #15
0
def build_flx_drivers(ctx, phase):
    libs = [
        call('buildsystem.ocs.build_lib', phase),
        call('buildsystem.sex.build', phase),
        call('buildsystem.dypgen.build_lib', phase),
        build_flx_version(phase),
        build_flx_lex(phase),
        build_flx_parse(phase),
        build_flx_misc(phase),
        build_flx_file(phase),
        build_flx_core(phase),
        build_flx_desugar(phase),
        build_flx_bind(phase),
        build_flx_frontend(phase),
        build_flx_opt(phase),
        build_flx_lower(phase),
        build_flx_backend(phase),
        build_flx_cpp_backend(phase),
        build_flx_version_hook(phase),
    ]

    external_libs = ['unix', 'str']

    flxg = phase.ocaml.build_exe('host/bin/flxg',
                                 Path.glob('src/compiler/flxg/*.ml{,i}'),
                                 libs=libs,
                                 external_libs=external_libs)

    return Record(flxg=flxg, )
Example #16
0
def build_runtime(host_phase, target_phase):
    path = Path('src', 'rtl')

    buildsystem.copy_hpps_to_rtl(target_phase.ctx,
        path / 'flx_rtl.hpp',
        path / 'flx_rtl_shapes.hpp',
        path / 'flx_compiler_support_headers.hpp',
        path / 'flx_compiler_support_bodies.hpp',
        path / 'flx_dynlink.hpp',
        path / 'flx_i18n.hpp',
        path / 'flx_ioutil.hpp',
        path / 'flx_strutil.hpp',
        path / 'flx_executil.hpp',
        path / 'flx_sync.hpp',
        path / 'flx_world.hpp',
        path / 'flx_async_world.hpp',
        path / 'flx_world_config.hpp',
        path / 'plat_linux.hpp',
    )

    for f in Path.glob(path/"*.hpp"):
      print("Copying " + f + " --> " +target_phase.ctx.buildroot/f )
      copy(ctx=target_phase.ctx, src=f,dst=target_phase.ctx.buildroot/f)

    srcs = [copy(ctx=target_phase.ctx, src=f, dst=target_phase.ctx.buildroot / f) for f in Path.glob(path / '*.cpp')]
    includes = [
        target_phase.ctx.buildroot / 'host/lib/rtl',
        target_phase.ctx.buildroot / 'share/lib/rtl'
    ]
    macros = ['BUILD_RTL']
    libs = [
        call('buildsystem.flx_async.build_runtime', host_phase,target_phase),
        call('buildsystem.flx_exceptions.build_runtime', target_phase),
        call('buildsystem.flx_gc.build_runtime', host_phase, target_phase),
    ]

    dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h',
        target_phase.platform,
        target_phase.cxx.static,
        target_phase.cxx.shared)

    if dlfcn_h.dlopen:
        external_libs = dlfcn_h.external_libs
    else:
        external_libs = []

    dst = 'host/lib/rtl/flx'
    return Record(
        static=buildsystem.build_cxx_static_lib(target_phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.static for lib in libs],
            external_libs=external_libs),
        shared=buildsystem.build_cxx_shared_lib(target_phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.shared for lib in libs],
            external_libs=external_libs))
Example #17
0
def build_flx_core(phase):
    path = Path('src/compiler/flx_core')
    return phase.ocaml.build_lib(path / 'flx_core',
        srcs=Path.glob(path / '*.ml{,i}'),
        libs=[
            build_flx_misc(phase),
            call('buildsystem.dypgen.build_lib', phase),
            call('buildsystem.ocs.build_lib', phase)],
        external_libs=['nums'])
Example #18
0
def make_cxx_builder(ctx, *args, includes=[], libpaths=[], flags=[], **kwargs):
    flags = list(chain(ctx.options.cxx_flags, flags))

    kwargs['platform_options'] = [
        # GRRR .. for clang++
        ({'darwin'}, {
            'warnings': [
                'fatal-errors',
                'no-invalid-offsetof',
                'no-logical-op-parentheses',
                'no-bitwise-op-parentheses',
                'no-parentheses-equality',
                'no-parentheses',
                'no-return-stack-address',
                'no-tautological-compare',
                'no-return-type-c-linkage',
                'no-unused-variable',
                'no-unused-function',
                'no-c++11-narrowing',
                'no-missing-braces',
                'no-return-type-c-linkage',
            ],
            'flags': [
                '-w', '-fno-common', '-fno-strict-aliasing',
                '-fvisibility=hidden', '-std=c++11'
            ] + flags,
            'optimize_flags': ['-fomit-frame-pointer']
        }),
        #({'cygwin'}, {
        #    'warnings': ['fatal-errors', 'no-invalid-offsetof','no-parentheses'],
        #    'flags': ['-std=gnu++11', '-w',
        #     '-fno-common', '-fvisibility=hidden', '-fno-strict-aliasing'] + flags,
        #    'optimize_flags': ['-fomit-frame-pointer']}),
        ({'posix'}, {
            'warnings':
            ['fatal-errors', 'no-invalid-offsetof', 'no-parentheses'],
            'flags': [
                '-std=gnu++11', '-D_POSIX', '-w', '-fno-common',
                '-fvisibility=hidden', '-fno-strict-aliasing'
            ] + flags,
            'optimize_flags': ['-fomit-frame-pointer']
        }),
        ({'windows'}, {
            'link_flags': ['/DEBUG'],
            'flags':
            ['/GR', '/MDd', '/EHs', '/Zi', '/wd4291', '/wd4190'] + flags,
            'optimize_flags': ['/Ox']
        }),
    ]
    kwargs['includes'] = list(chain(ctx.options.includes, includes))
    kwargs['libpaths'] = list(chain(ctx.options.libpaths, libpaths))

    return Record(static=call('fbuild.builders.cxx.guess_static', ctx, *args,
                              **kwargs),
                  shared=call('fbuild.builders.cxx.guess_shared', ctx, *args,
                              **kwargs))
Example #19
0
def build(phase):
    path = Path('src', 'compiler', 'sex')
    dypgen = call('buildsystem.dypgen.build_exe', phase)
    return phase.ocaml.build_lib(path/'sex', Path.globall(
            path/'*.ml{,i}',
            dypgen(path/'sex_parse.dyp'),
            phase.ocamllex(path/'sex_lex.mll')),
        libs=[
            call('buildsystem.ocs.build_lib', phase),
            call('buildsystem.dypgen.build_lib', phase)])
Example #20
0
def build_flx_lex(phase):
    path = Path('src/compiler/flx_lex')
    dypgen = call('buildsystem.dypgen.build_exe', phase)
    return phase.ocaml.build_lib(path/'flx_lex',
        srcs=Path.globall(path / '*.ml{,i}'),
        libs=[
            call('buildsystem.dypgen.build_lib', phase),
            call('buildsystem.ocs.build_lib', phase),
            call('buildsystem.sex.build', phase),
            build_flx_version(phase)])
Example #21
0
def build_runtime(host_phase, target_phase):
    path = Path('src', 'rtl')

    buildsystem.copy_hpps_to_rtl(target_phase.ctx,
        target_phase.ctx.buildroot / 'config/target/flx_rtl_config.hpp',
        target_phase.ctx.buildroot / 'config/target/flx_meta.hpp',
        path / 'flx_rtl.hpp',
        path / 'flx_compiler_support_headers.hpp',
        path / 'flx_compiler_support_bodies.hpp',
        path / 'flx_dynlink.hpp',
        path / 'flx_i18n.hpp',
        path / 'flx_ioutil.hpp',
        path / 'flx_strutil.hpp',
        path / 'flx_executil.hpp',
    )

    dst = 'lib/rtl/flx'
    srcs = Path.glob(path / '*.cpp')
    includes = [
        target_phase.ctx.buildroot / 'config/target',
        'src/exceptions',
        'src/demux',
        'src/faio',
        'src/judy/src',
        'src/gc',
        'src/pthread',
    ]
    macros = ['BUILD_RTL']
    libs = [
        call('buildsystem.flx_async.build_runtime', target_phase),
        call('buildsystem.flx_exceptions.build_runtime', target_phase),
        call('buildsystem.flx_gc.build_runtime', host_phase, target_phase),
    ]

    dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h',
        target_phase.platform,
        target_phase.cxx.static,
        target_phase.cxx.shared)

    if dlfcn_h.dlopen:
        external_libs = dlfcn_h.external_libs
    else:
        external_libs = []

    return Record(
        static=buildsystem.build_cxx_static_lib(target_phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.static for lib in libs],
            external_libs=external_libs),
        shared=buildsystem.build_cxx_shared_lib(target_phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.shared for lib in libs],
            external_libs=external_libs))
Example #22
0
def build_runtime(host_phase, target_phase):
    path = Path('src/faio')

    buildsystem.copy_hpps_to_rtl(
        target_phase.ctx,
        path / 'faio_job.hpp',
        path / 'faio_timer.hpp',
        path / 'faio_posixio.hpp',
        path / 'faio_winio.hpp',
    )

    dst = 'host/lib/rtl/faio'
    srcs = [
        path / 'faio_job.cpp',
        path / 'faio_timer.cpp',
    ]
    includes = [
        target_phase.ctx.buildroot / 'host/lib/rtl',
        Path('src', 'flx_async'),
        Path('src', 'pthread'),
        Path('src', 'demux'),
        Path('src', 'rtl'),
        Path('src', 'exceptions'),
        Path('src', 'gc'),
        path,
    ]
    macros = ['BUILD_FAIO']
    libs = [
        call('buildsystem.flx_pthread.build_runtime', target_phase),
        call('buildsystem.flx_async.build_runtime', host_phase, target_phase),
        call('buildsystem.demux.build_runtime', target_phase),
    ]

    if 'win32' in target_phase.platform:
        srcs.append(path / 'faio_winio.cpp')
        includes.append(Path('src', 'demux', 'win'))

    if 'posix' in target_phase.platform:
        srcs.append(path / 'faio_posixio.cpp')
        includes.append(Path('src', 'demux', 'posix'))

    return Record(static=buildsystem.build_cxx_static_lib(
        target_phase,
        dst,
        srcs,
        includes=includes,
        macros=macros,
        libs=[lib.static for lib in libs]),
                  shared=buildsystem.build_cxx_shared_lib(
                      target_phase,
                      dst,
                      srcs,
                      includes=includes,
                      macros=macros,
                      libs=[lib.shared for lib in libs]))
Example #23
0
def build(phase):
    path = Path('src', 'compiler', 'sex')
    dypgen = call('buildsystem.dypgen.build_exe', phase)
    return phase.ocaml.build_lib(path/'sex', Path.globall(
            path/'*.ml{,i}',
            dypgen(path/'sex_parse.dyp'),
            phase.ocamllex(path/'sex_lex.mll'),
            exclude=path/'sex.ml'),
        libs=[
            call('buildsystem.ocs.build_lib', phase),
            call('buildsystem.dypgen.build_lib', phase)])
Example #24
0
def build(host_phase, target_phase):
    path = Path('src/flx_drivers')

    run_includes = [
        target_phase.ctx.buildroot / 'config/target',
        'src/exceptions',
        'src/gc',
        'src/judy/src',
        'src/pthread',
        'src/flx_async',
        'src/rtl',
    ]

    arun_includes = run_includes + [
        target_phase.ctx.buildroot / 'lib/rtl',
        'src/demux',
        'src/faio',
    ]

    flx_run_lib = target_phase.cxx.static.compile(
        dst='lib/rtl/flx_run',
        src=path / 'flx_run.cxx',
        includes=run_includes,
        macros=['FLX_STATIC_LINK'],
    )

    flx_run_exe = target_phase.cxx.shared.build_exe(
        dst='bin/flx_run',
        srcs=[path / 'flx_run.cxx'],
        includes=run_includes,
        libs=[call('buildsystem.flx_rtl.build_runtime', host_phase, target_phase).shared],
    )

    flx_arun_lib = target_phase.cxx.static.compile(
        dst='lib/rtl/flx_arun',
        src=path / 'flx_arun.cxx',
        includes=arun_includes,
        macros=['FLX_STATIC_LINK'],
    )

    flx_arun_exe = target_phase.cxx.shared.build_exe(
        dst='bin/flx_arun',
        srcs=[path / 'flx_arun.cxx'],
        includes=arun_includes,
        libs=[call('buildsystem.flx_rtl.build_runtime', host_phase, target_phase).shared],
    )

    return Record(
        flx_run_lib=flx_run_lib,
        flx_run_exe=flx_run_exe,
        flx_arun_lib=flx_arun_lib,
        flx_arun_exe=flx_arun_exe,
    )
Example #25
0
def build_flx_lex(phase):
    path = Path('src/compiler/flx_lex')
    dypgen = call('buildsystem.dypgen.build_exe', phase)
    return phase.ocaml.build_lib(path / 'flx_lex',
                                 srcs=Path.globall(path / '*.ml{,i}'),
                                 libs=[
                                     call('buildsystem.dypgen.build_lib',
                                          phase),
                                     call('buildsystem.ocs.build_lib', phase),
                                     call('buildsystem.sex.build', phase),
                                     build_flx_version(phase)
                                 ])
Example #26
0
def build_flx_core(phase):
    path = Path('src/compiler/flx_core')
    return phase.ocaml.build_lib(path / 'flx_core',
                                 srcs=Path.glob(path / '*.ml{,i}'),
                                 libs=[
                                     call('buildsystem.dypgen.build_lib',
                                          phase),
                                     call('buildsystem.ocs.build_lib', phase),
                                     build_flx_lex(phase),
                                     build_flx_parse(phase),
                                     build_flx_misc(phase),
                                 ],
                                 external_libs=[])
Example #27
0
def build_flx_parse(phase):
    path = Path('src/compiler/flx_parse')
    dypgen = call('buildsystem.dypgen.build_exe', phase)
    return phase.ocaml.build_lib(path/'flx_parse',
        srcs=Path.globall(
            path / '*.ml{,i}',
            dypgen(path / 'flx_parse.dyp',
                flags=['--no-undef-nt', '--pv-obj', '--noemit-token-type'])),
        libs=[
            call('buildsystem.dypgen.build_lib', phase),
            call('buildsystem.ocs.build_lib', phase),
            call('buildsystem.sex.build', phase),
            build_flx_version(phase),
            build_flx_lex(phase)])
Example #28
0
def build_runtime(phase):
    path = Path('src/faio')

    buildsystem.copy_hpps_to_rtl(phase.ctx,
        phase.ctx.buildroot / 'config/target/flx_faio_config.hpp',
        path / 'faio_asyncio.hpp',
        path / 'faio_job.hpp',
        path / 'faio_timer.hpp',
        path / 'faio_posixio.hpp',
        path / 'faio_winio.hpp',
    )

    dst = 'lib/rtl/faio'
    srcs = [
        path / 'faio_asyncio.cpp',
        path / 'faio_job.cpp',
        path / 'faio_timer.cpp',
    ]
    includes = [
        phase.ctx.buildroot / 'config/target',
        Path('src', 'pthread'),
        Path('src', 'demux'),
        Path('src', 'rtl'),
        Path('src', 'exceptions'),
        Path('src', 'gc'),
        path,
    ]
    macros = ['BUILD_FAIO']
    libs=[
        call('buildsystem.flx_pthread.build_runtime', phase),
        call('buildsystem.demux.build_runtime', phase),
    ]

    if 'win32' in phase.platform:
        srcs.append(path / 'faio_winio.cpp')
        includes.append(Path('src', 'demux', 'win'))

    if 'posix' in phase.platform:
        srcs.append(path / 'faio_posixio.cpp')
        includes.append(Path('src', 'demux', 'posix'))

    return Record(
        static=buildsystem.build_cxx_static_lib(phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.static for lib in libs]),
        shared=buildsystem.build_cxx_shared_lib(phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.shared for lib in libs]))
Example #29
0
def build_flx_desugar(phase):
    path = Path('src/compiler/flx_desugar')

    return phase.ocaml.build_lib(path / 'flx_desugar',
        srcs=Path.glob(path / '*.ml{,i}'),
        libs=[
            call('buildsystem.dypgen.build_lib', phase),
            call('buildsystem.ocs.build_lib', phase),
            call('buildsystem.sex.build', phase),
            build_flx_misc(phase),
            build_flx_core(phase),
            build_flx_version(phase),
            build_flx_lex(phase),
            build_flx_parse(phase)],
        external_libs=['nums', 'unix'])
Example #30
0
def make_cxx_builder(*args, **kwargs):
    static = call('fbuild.builders.cxx.guess_static', *args,
        platform_options=[
            ({'windows'}, {'flags': ['/EHsc']}),
        ],
        **kwargs)
    shared = call('fbuild.builders.cxx.guess_shared', *args,
        platform_options=[
            ({'windows'}, {'flags': ['/EHsc']}),
        ],
        **kwargs)

    return Record(
        static=static,
        shared=shared)
Example #31
0
def build_flx_drivers(ctx, phase):
    libs = [
        call('buildsystem.ocs.build_lib', phase),
        call('buildsystem.sex.build', phase),
        call('buildsystem.dypgen.build_lib', phase),
        build_flx_version(phase),
        build_flx_misc(phase),
        build_flx_core(phase),
        build_flx_lex(phase),
        build_flx_parse(phase),
        build_flx_desugar(phase),
        build_flx_bind(phase),
        build_flx_why(phase),
        build_flx_frontend(phase),
        build_flx_opt(phase),
        build_flx_lower(phase),
        build_flx_backend(phase),
        build_flx_cpp_backend(phase),
        build_flx_version_hook(phase),
        ]

    external_libs = ['nums', 'unix', 'str']

    flxg = phase.ocaml.build_exe('bin/flxg',
        Path.glob('src/compiler/flxg/*.ml{,i}'),
        libs=libs,
        external_libs=external_libs)

    # Don't compile flxc if llvm isn't installed
    if phase.llvm_config:
        flxc = phase.ocaml.build_exe('bin/flxc',
            Path('src/compiler/flxc/*.ml{,i}').glob(),
            includes=[phase.llvm_config.ocaml_libdir()],
            libs=libs + [build_flx_llvm_backend(phase)],
            external_libs=external_libs + [
                'llvm',
                'llvm_analysis',
                'llvm_executionengine',
                'llvm_scalar_opts',
                'llvm_target'],
            cc=phase.cxx.static.compiler.gcc.exe)
    else:
        flxc = None

    return Record(
        flxg=flxg,
        flxc=flxc,
    )
Example #32
0
    def __init__(self, ctx, exe=None):
        super().__init__(ctx)

        if exe is None:
            exe = call('fbuildroot.src_dir', ctx) / 'buildsystem/interscript/bin/iscr.py'

        self.exe = Path(exe)
Example #33
0
def build_flx(host_phase, target_phase, flx_builder):
    return flx_builder.build_exe(
        async=False,
        dst=Path("bin") / "flx",
        src=Path("src") / "flx" / "flx.flx",
        includes=[target_phase.ctx.buildroot / "lib"],
        cxx_includes=[
            Path("src") / "flx",
            target_phase.ctx.buildroot / "lib" / "rtl",
            target_phase.ctx.buildroot / "config" / "target",
        ],
        cxx_libs=[
            call("buildsystem.flx_rtl.build_runtime", host_phase, target_phase).static,
            call("buildsystem.re2.build_runtime", host_phase).static,
        ],
    )
Example #34
0
def config_build(ctx):
    ctx.logger.log('configuring build phase', color='cyan')

    platform = call('fbuild.builders.platform.platform', ctx,
        ctx.options.build_platform)

    return Record(
        ctx=ctx,
        platform=platform,
        c=make_c_builder(ctx, ctx.options.build_cc,
            platform=platform,
            debug=ctx.options.debug or ctx.options.build_c_debug,
            profile=ctx.options.profile or ctx.options.build_c_profile,
            optimize=ctx.options.optimize or ctx.options.build_c_optimize,
            includes=ctx.options.build_includes,
            libpaths=ctx.options.build_libpaths,
            flags=ctx.options.build_c_flags),
        cxx=make_cxx_builder(ctx, ctx.options.build_cxx,
            platform=platform,
            debug=ctx.options.debug or ctx.options.build_c_debug,
            profile=ctx.options.profile or ctx.options.build_c_profile,
            optimize=ctx.options.optimize or ctx.options.build_c_optimize,
            includes=ctx.options.build_includes,
            libpaths=ctx.options.build_libpaths,
            flags=ctx.options.build_c_flags))
Example #35
0
File: flx.py Project: DawidvC/felix
def build_flx_pkgconfig( phase, flx_builder):
    #print('[fbuild] [flx] building flx_pkgconfig')
    #dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h',
    #    phase.platform,
    #    phase.cxx.static,
    #    phase.cxx.shared)

    #if dlfcn_h.dlopen:
    #    external_libs = dlfcn_h.external_libs
    #else:
    #    external_libs = []

    external_libs = []

    return flx_builder.build_flx_pkgconfig_exe(
        dst=Path('host')/'bin'/'flx_pkgconfig',
        src=phase.ctx.buildroot/'share'/'src'/'tools'/'flx_pkgconfig.flx',
        includes=[
          phase.ctx.buildroot / 'host'/'lib',
          phase.ctx.buildroot / 'share'/'lib',
          ],
        cxx_includes=[ 
                      phase.ctx.buildroot / 'share'/'lib'/'rtl', 
                      phase.ctx.buildroot / 'host'/'lib'/'rtl'],
        cxx_libs=[call('buildsystem.flx_rtl.build_runtime',  phase).static]+external_libs,
    )
Example #36
0
def build(phase):
    pthread_h = config_call('fbuild.config.c.posix.pthread_h',
        phase.platform,
        phase.cxx.shared)

    dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h',
        phase.platform,
        phase.cxx.static,
        phase.cxx.shared)

    flags = []
    libs=[call('buildsystem.sqlite3.build_runtime', phase, phase).static]
    external_libs = []
    path = Path('src/tools')
    dst = phase.ctx.buildroot / 'bin/flx_sqlite3'
    srcs = [path / 'flx_sqlite3.c'] 
    includes = [ phase.ctx.buildroot / 'lib/rtl', phase.ctx.buildroot / 'config/target' ]

    if dlfcn_h.dlopen:
        external_libs.extend ( dlfcn_h.external_libs)

    if pthread_h.pthread_create:
        flags.extend(pthread_h.flags)
        libs.extend(pthread_h.libs)
        external_libs.extend(pthread_h.external_libs)

    return Record (
        static = phase.c.static.build_exe(dst, srcs, 
          includes=includes, 
          cflags=flags, 
          libs=libs, 
          external_libs=external_libs)
      )
Example #37
0
def build_flx_pkgconfig(phase, flx_builder):
    #print('[fbuild] [flx] building flx_pkgconfig')
    #dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h',
    #    phase.platform,
    #    phase.cxx.static,
    #    phase.cxx.shared)

    #if dlfcn_h.dlopen:
    #    external_libs = dlfcn_h.external_libs
    #else:
    #    external_libs = []

    external_libs = []

    return flx_builder.build_flx_pkgconfig_exe(
        dst=Path('host') / 'bin' / 'flx_pkgconfig',
        src=phase.ctx.buildroot / 'share' / 'src' / 'tools' /
        'flx_pkgconfig.flx',
        includes=[
            phase.ctx.buildroot / 'host' / 'lib',
            phase.ctx.buildroot / 'share' / 'lib',
        ],
        cxx_includes=[
            phase.ctx.buildroot / 'share' / 'lib' / 'rtl',
            phase.ctx.buildroot / 'host' / 'lib' / 'rtl'
        ],
        cxx_libs=[call('buildsystem.flx_rtl.build_runtime', phase).static] +
        external_libs,
    )
Example #38
0
def config_build(ctx):
    ctx.logger.log('configuring build phase', color='cyan')

    platform = call('fbuild.builders.platform.guess_platform', ctx,
                    ctx.options.build_platform)
    return Record(
        ctx=ctx,
        platform=platform,
        c=make_c_builder(
            ctx,
            exe=ctx.options.build_cc,
            platform=platform,
            debug=ctx.options.debug or ctx.options.build_c_debug,
            optimize=not (ctx.options.debug or ctx.options.build_c_debug),
            includes=ctx.options.build_includes,
            libpaths=ctx.options.build_libpaths,
            flags=ctx.options.build_c_flags),
        cxx=make_cxx_builder(
            ctx,
            exe=ctx.options.build_cxx,
            platform=platform,
            debug=ctx.options.debug or ctx.options.build_c_debug,
            optimize=not (ctx.options.debug or ctx.options.build_c_debug),
            includes=ctx.options.build_includes,
            libpaths=ctx.options.build_libpaths,
            flags=ctx.options.build_cxx_flags))
Example #39
0
def build_runtime(host_phase, target_phase):
    path = Path('src/unixem')

    buildsystem.copy_hpps_to_rtl(target_phase.ctx,
        path / 'flx_glob.hpp',
    )

    dst = target_phase.ctx.buildroot / 'lib/rtl/flx_glob'
    srcs = []
    includes = [target_phase.ctx.buildroot / 'config/target']
    macros = ['BUILD_GLOB']
    libs = [call('buildsystem.flx_gc.build_runtime', host_phase, target_phase)]

    if 'win32' in target_phase.platform:
        srcs.extend((path / 'flx_glob.cpp', path / 'unixem_util.cpp'))

        return Record(
          static=buildsystem.build_cxx_static_lib(target_phase, dst, srcs,
              includes=includes,
              macros=macros,
              libs=[lib.static for lib in libs]),
          shared=buildsystem.build_cxx_shared_lib(target_phase, dst, srcs,
              includes=includes,
              macros=macros,
              libs=[lib.shared for lib in libs]))
    else:
        return Record()
Example #40
0
def dist(ctx):
    """Creates tarball and zip distribution files."""

    phases, iscr = configure(ctx)
    from buildsystem.version import flx_version

    # Find the git executable.
    git = fbuild.builders.find_program(ctx, ['git'])

    # Grab our revision name from git.
    flx_version = ctx.execute([git, 'describe'], quieter=1)[0].decode().strip()

    ctx.logger.log('Packing Source as Version: %s' % flx_version)

    call('buildsystem.dist.dist_tar', ctx, git, flx_version)
    call('buildsystem.dist.dist_zip', ctx, git, flx_version)
Example #41
0
def build_runtime(host_phase, target_phase):
    path = Path("src/faio")

    buildsystem.copy_hpps_to_rtl(
        target_phase.ctx,
        # target_phase.ctx.buildroot / 'config/target/flx_faio_config.hpp',
        path / "faio_job.hpp",
        path / "faio_timer.hpp",
        path / "faio_posixio.hpp",
        path / "faio_winio.hpp",
    )

    dst = "lib/rtl/faio"
    srcs = [path / "faio_job.cpp", path / "faio_timer.cpp"]
    includes = [
        target_phase.ctx.buildroot / "config/target",
        Path("src", "flx_async"),
        Path("src", "pthread"),
        Path("src", "demux"),
        Path("src", "rtl"),
        Path("src", "exceptions"),
        Path("src", "gc"),
        path,
    ]
    macros = ["BUILD_FAIO"]
    libs = [
        call("buildsystem.flx_pthread.build_runtime", target_phase),
        call("buildsystem.flx_async.build_runtime", host_phase, target_phase),
        call("buildsystem.demux.build_runtime", target_phase),
    ]

    if "win32" in target_phase.platform:
        srcs.append(path / "faio_winio.cpp")
        includes.append(Path("src", "demux", "win"))

    if "posix" in target_phase.platform:
        srcs.append(path / "faio_posixio.cpp")
        includes.append(Path("src", "demux", "posix"))

    return Record(
        static=buildsystem.build_cxx_static_lib(
            target_phase, dst, srcs, includes=includes, macros=macros, libs=[lib.static for lib in libs]
        ),
        shared=buildsystem.build_cxx_shared_lib(
            target_phase, dst, srcs, includes=includes, macros=macros, libs=[lib.shared for lib in libs]
        ),
    )
Example #42
0
def build_flx(host_phase, target_phase, flx_builder):
    return flx_builder.build_exe(
        async=False,
        dst=Path('host')/'bin'/'bootflx',
        src=Path('src')/'tools'/'bootflx.flx',
        includes=[
          target_phase.ctx.buildroot / 'host'/'lib',
          target_phase.ctx.buildroot / 'share'/'lib',
          ],
        cxx_includes=[Path('src')/'flx', 
                      target_phase.ctx.buildroot / 'share'/'lib'/'rtl', 
                      target_phase.ctx.buildroot / 'host'/'lib'/'rtl'],
        cxx_libs=[
          call('buildsystem.flx_rtl.build_runtime', host_phase, target_phase).static,
          call('buildsystem.re2.build_runtime', host_phase).static,
          ],
    )
Example #43
0
    def __init__(self, ctx, exe=None):
        super().__init__(ctx)

        if exe is None:
            exe = call('fbuildroot.src_dir',
                       ctx) / 'buildsystem/interscript/bin/iscr.py'

        self.exe = Path(exe)
Example #44
0
def config_build(ctx, *, platform, cc, cxx):
    ctx.logger.log('configuring build phase', color='cyan')

    return Record(
        platform=call('fbuild.builders.platform.guess_platform', ctx, platform),
        c=make_c_builder(ctx, exe=cc),
        cxx=make_cxx_builder(ctx, exe=cxx),
    )
Example #45
0
def build_flx_parse(phase):
    path = Path('src/compiler/flx_parse')
    dypgen = call('buildsystem.dypgen.build_exe', phase)
    return phase.ocaml.build_lib(
        path / 'flx_parse',
        srcs=Path.globall(
            path / '*.ml{,i}',
            dypgen(path / 'flx_parse.dyp',
                   flags=['--no-undef-nt', '--pv-obj',
                          '--noemit-token-type'])),
        libs=[
            call('buildsystem.dypgen.build_lib', phase),
            call('buildsystem.ocs.build_lib', phase),
            call('buildsystem.sex.build', phase),
            build_flx_version(phase),
            build_flx_lex(phase)
        ])
Example #46
0
def build_flx_desugar(phase):
    path = Path('src/compiler/flx_desugar')

    return phase.ocaml.build_lib(path / 'flx_desugar',
                                 srcs=Path.glob(path / '*.ml{,i}'),
                                 libs=[
                                     call('buildsystem.dypgen.build_lib',
                                          phase),
                                     call('buildsystem.ocs.build_lib', phase),
                                     call('buildsystem.sex.build', phase),
                                     build_flx_lex(phase),
                                     build_flx_parse(phase),
                                     build_flx_file(phase),
                                     build_flx_misc(phase),
                                     build_flx_core(phase),
                                     build_flx_version(phase),
                                 ],
                                 external_libs=['unix'])
Example #47
0
def config_target(ctx, host):
    ctx.logger.log('configuring target phase', color='cyan')

    platform = call('fbuild.builders.platform.guess_platform', ctx,
                    ctx.options.target_platform)

    if platform == host.platform:
        ctx.logger.log("using host's c and cxx compiler", color='cyan')
        phase = host
    else:
        phase = Record(
            ctx=ctx,
            platform=platform,
            c=make_c_builder(
                ctx,
                exe=ctx.options.target_cc,
                platform=platform,
                debug=ctx.options.debug or ctx.options.target_c_debug,
                optimize=not (ctx.options.debug or ctx.options.target_c_debug),
                includes=ctx.options.target_includes,
                libpaths=ctx.options.target_libpaths,
                flags=ctx.options.target_c_flags),
            cxx=make_cxx_builder(
                ctx,
                exe=ctx.options.target_cxx,
                platform=platform,
                debug=ctx.options.debug or ctx.options.target_c_debug,
                optimize=not (ctx.options.debug or ctx.options.target_c_debug),
                includes=ctx.options.target_includes,
                libpaths=ctx.options.target_libpaths,
                flags=ctx.options.target_cxx_flags))

    # We optionally support sdl
    try:
        phase.sdl_config = call('fbuild.builders.sdl.SDLConfig',
                                ctx,
                                ctx.options.target_sdl_config,
                                requires_at_least_version=(1, 3))
    except (fbuild.ConfigFailed, OSError):
        phase.sdl_config = None

    return phase
Example #48
0
def build_runtime(host_phase, target_phase):
    path = Path('src/gc')

    buildsystem.copy_hpps_to_rtl(target_phase.ctx,
        path / 'flx_gc.hpp',
        path / 'flx_judy_scanner.hpp',
        path / 'flx_serialisers.hpp',
        path / 'flx_collector.hpp',
        path / 'flx_gc_private.hpp',
        path / 'flx_ts_collector.hpp',
        path / 'pthread_bound_queue.hpp',
        path / 'pthread_work_fifo.hpp',
    )

    dst = 'host/lib/rtl/flx_gc'
    srcs = [copy(ctx=target_phase.ctx, src=f, dst=target_phase.ctx.buildroot / f) for f in Path.glob(path / '*.cpp')]
    includes = [
        target_phase.ctx.buildroot / 'host/lib/rtl',
        target_phase.ctx.buildroot / 'share/lib/rtl',
        'src/rtl',
        'src/pthread',
        'src/exceptions',
        'src/judy/src',
    ]
    macros = ['BUILD_FLX_GC']
    libs = [
        call('buildsystem.judy.build_runtime', host_phase, target_phase),
        call('buildsystem.flx_exceptions.build_runtime', target_phase),
        call('buildsystem.flx_pthread.build_runtime', target_phase),
    ]

    return Record(
        static=buildsystem.build_cxx_static_lib(target_phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.static for lib in libs]),
        shared=buildsystem.build_cxx_shared_lib(target_phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.shared for lib in libs]))
Example #49
0
def build_flx_pkgconfig(host_phase, target_phase, flx_builder):
    return flx_builder.build_flx_pkgconfig_exe(
        dst=Path('host')/'bin'/'flx_pkgconfig',
        src=Path('src')/'tools'/'flx_pkgconfig.flx',
        includes=[
          target_phase.ctx.buildroot / 'host'/'lib',
          target_phase.ctx.buildroot / 'share'/'lib',
          ],
        cxx_includes=[Path('src')/'flx_pkgconfig', 
                      target_phase.ctx.buildroot / 'share'/'lib'/'rtl', 
                      target_phase.ctx.buildroot / 'host'/'lib'/'rtl'],
        cxx_libs=[call('buildsystem.flx_rtl.build_runtime', host_phase, target_phase).static],
    )
Example #50
0
def config_target(ctx, host, *, platform, cc, cxx):
    ctx.logger.log('configuring target phase', color='cyan')

    platform = call('fbuild.builders.platform.platform', ctx, platform)

    if platform == host.platform:
        ctx.logger.log("using host's c and cxx compiler")
        phase = host
    else:
        phase = Record(platform=platform,
                       c=make_c_builder(ctx, exe=cc),
                       cxx=make_cxx_builder(ctx, exe=cxx))

    return phase
Example #51
0
def config_host(ctx, build, *,
        platform, cc, cxx, ocamlc, ocamlopt, ocamllex, ocamlyacc):
    ctx.logger.log('configuring host phase', color='cyan')

    platform = call('fbuild.builders.platform.guess_platform', ctx, platform)

    if platform == build.platform:
        ctx.logger.log("using build's c and cxx compiler")
        phase = build
    else:
        phase = Record(
            platform=platform,
            c=make_c_builder(ctx, exe=cc),
            cxx=make_cxx_builder(ctx, exe=cxx))

    phase.ocaml = call('fbuild.builders.ocaml.Ocaml', ctx,
        ocamlc=ocamlc,
        ocamlopt=ocamlopt,
    )
    phase.ocamllex = call('fbuild.builders.ocaml.Ocamllex', ctx, ocamllex)
    phase.ocamlyacc = call('fbuild.builders.ocaml.Ocamlyacc', ctx, ocamlyacc)

    return phase
Example #52
0
def build_runtime(host_phase, target_phase):
    path = Path('src/flx_async')
    buildsystem.copy_hpps_to_rtl(
        target_phase.ctx,
        path / 'flx_async.hpp',
    )

    dst = 'host/lib/rtl/flx_async'
    suffix = '.so'
    srcs = [
        copy(ctx=target_phase.ctx, src=f, dst=target_phase.ctx.buildroot / f)
        for f in ['src/flx_async/flx_async.cpp']
    ]
    includes = [
        target_phase.ctx.buildroot / 'host/lib/rtl',
        target_phase.ctx.buildroot / 'share/lib/rtl'
    ]
    macros = ['BUILD_ASYNC']
    libs = [
        call('buildsystem.flx_pthread.build_runtime', target_phase),
        call('buildsystem.flx_gc.build_runtime', host_phase, target_phase),
    ]

    return Record(static=buildsystem.build_cxx_static_lib(
        target_phase,
        dst,
        srcs,
        includes=includes,
        macros=macros,
        libs=[lib.static for lib in libs]),
                  shared=buildsystem.build_cxx_shared_lib(
                      target_phase,
                      dst,
                      srcs,
                      includes=includes,
                      macros=macros,
                      libs=[lib.shared for lib in libs]))
Example #53
0
def build(ctx):
    """Compile Felix."""

    set_version(ctx.buildroot)

    print("[fbuild] RUNNING PACKAGE MANAGER")
    tangle_packages(Path("src") / "packages", ctx.buildroot)

    print("[fbuild] CONFIGURING FELIX")
    # configure the phases
    phases, iscr = configure(ctx)

    # --------------------------------------------------------------------------
    # Compile the compiler.

    print("[fbuild] [ocaml] COMPILING COMPILER")
    compilers = call('buildsystem.flx_compiler.build_flx_drivers', ctx,
                     phases.host)
    print("[fbuild] COPYING REPOSITORY from current directory ..")
    buildsystem.copy_dir_to(ctx,
                            ctx.buildroot / 'share' / 'src',
                            'src',
                            pattern='*')

    print("[fbuild] INSTALLING FELIX LIBRARIES")
    buildsystem.copy_dir_to(ctx,
                            ctx.buildroot / 'share' / 'lib',
                            ctx.buildroot / 'share' / 'src' / 'lib',
                            pattern='*')

    print("[fbuild] RUNNING SYNTAX EXTRACTOR")
    find_grammar(ctx.buildroot)

    # --------------------------------------------------------------------------
    # Compile the runtime dependencies.

    print("[fbuild] [C++] COMPILING RUN TIME LIBRARY")
    call('buildsystem.judy.build_runtime', phases.target)
    call('buildsystem.re2.build_runtime', phases.target)

    # --------------------------------------------------------------------------
    # Build the standard library.

    print("[fbuild] [Felix] BUILDING STANDARD LIBRARY")
    # copy files into the library
    for module in ('flx_stdlib', ):
        call('buildsystem.' + module + '.build_flx', phases.target)

    # --------------------------------------------------------------------------
    # Compile the runtime drivers.

    print("[fbuild] [C++] COMPILING DRIVERS")
    drivers = call('buildsystem.flx_drivers.build', phases.target)

    # --------------------------------------------------------------------------
    # Compile the builder.

    print("[fbuild] [Felix] COMPILING TOOLS")
    flx_builder = call('buildsystem.flx.build', ctx, compilers.flxg,
                       phases.target.cxx.static, drivers)

    flx_pkgconfig = call('buildsystem.flx.build_flx_pkgconfig', phases.target,
                         flx_builder)
    flx = call('buildsystem.flx.build_flx', phases.target, flx_builder)

    # --------------------------------------------------------------------------
    # now, try building a file

    print("[fbuild] [Felix] TEST BUILD")
    felix = call('fbuild.builders.felix.Felix',
                 ctx,
                 exe=ctx.buildroot / 'host/bin/bootflx',
                 debug=ctx.options.debug,
                 flags=['--test=' + ctx.buildroot])

    print("[fbuild] [Felix] BUILDING PLUGINS")
    call('buildsystem.plugins.build', phases.target, felix)

    print("[fbuild] BUILD COMPLETE")
    return phases, iscr, felix
Example #54
0
def _print_config(ctx, f, build, host, target):
    def p(msg, *args):
        if not args:
            print(msg, file=f)
        else:
            print(msg, '=', file=f, *(repr(a) for a in args))

    def pp(msg, *args):
        p('    ' + msg, *args)

    # --------------------------------------------------------------------------
    # version information

    p('flx_version = ' + repr(version.flx_version))
    p('flx_version_major = ' + repr(version.flx_version_major))
    p('flx_version_minor = ' + repr(version.flx_version_minor))
    p('flx_version_patch = ' + repr(version.flx_version_patch))
    p('flx_version_release = ' + repr(version.flx_version_release))

    # --------------------------------------------------------------------------
    # setup paths

    p('src_dir', str(call('fbuildroot.src_dir', ctx)))
    p('PREFIX', str(call('fbuildroot.prefix', ctx)))
    p('FLXCC_CPP', 'cpp ')

    # --------------------------------------------------------------------------
    # get all the platform information

    supported_platforms = set()
    for platforms in fbuild.builders.platform.archmap.values():
        supported_platforms |= platforms
    supported_platforms = sorted(supported_platforms)

    windows_h = config_call('fbuild.config.c.win32.windows_h', target.platform,
                            target.c.static)

    p('HAVE_MSVC', bool(windows_h.header))
    p('HAVE_GNU', 'windows' not in target.platform)

    # --------------------------------------------------------------------------
    # phases

    for phase_name, phase in (('build', build), ('host', host), ('target',
                                                                 target)):
        for lang in 'c', 'cxx':
            p('class ' + phase_name.upper() + '_' + lang.upper() + ':')
            p('  class options:')

            platform = phase.platform

            for name in supported_platforms:
                pp(name.upper(), name in platform)

            lang = phase[lang]

            _print_compiler(ctx, lang, platform, pp)
            _print_types(platform, lang, pp)
            _print_c99_support(platform, lang, pp)
            _print_posix_support(platform, lang, pp)
            _print_windows_support(platform, lang, pp)
            _print_math_support(platform, lang, pp)
            _print_openmp_support(ctx, platform, lang, pp)
            _print_cxx_bugs(ctx, platform, lang, pp)
            _print_gcc_extensions(platform, lang, pp)

    # --------------------------------------------------------------------------
    # expose target_cxx to the top level config

    for platform in supported_platforms:
        p(platform.upper() + '=TARGET_CXX.options.' + platform.upper())

    # --------------------------------------------------------------------------
    # figure out the global library loading scheme

    p('SUPPORT_STATIC_LINKAGE', True)
    p('SUPPORT_DYNAMIC_LOADING=TARGET_CXX.options.SUPPORT_DYNAMIC_LOADING')

    p('if SUPPORT_DYNAMIC_LOADING:')
    p('  DEFAULT_LINK_MODEL', 'dynamic')
    p('else:')
    p('  DEFAULT_LINK_MODEL', 'static')
Example #55
0
def configure(ctx):
    """Configure Felix."""

    build = config_build(ctx)
    host = config_host(ctx, build)
    target = config_target(ctx, host)

    # Make sure the config directories exist.
    #(ctx.buildroot / 'host/config').makedirs()

    # copy the config directory for initial config
    # this will be overwritten by subsequent steps if
    # necessary
    #
    buildsystem.copy_to(ctx, ctx.buildroot / 'host/config',
                        Path('src/config/*.fpc').glob())
    # most of these ones are actually platform independent
    # just do the windows EXTERN to dllexport mapping
    # which is controlled by compile time switches anyhow
    # should probably move these out of config directory
    # they're put in config in case there really are any
    # platform mods.
    buildsystem.copy_to(ctx, ctx.buildroot / 'host/lib/rtl',
                        Path('src/config/target/*.hpp').glob())
    buildsystem.copy_to(ctx, ctx.buildroot / 'host/lib/rtl',
                        Path('src/config/target/*.h').glob())

    types = config_call('fbuild.config.c.c99.types', target.platform,
                        target.c.static)

    # this is a hack: assume we're running on Unix.
    # later when Erick figures out how to fix this
    # we'd copy the win32 subdirectory entries instead
    if "posix" in target.platform:
        print("COPYING POSIX RESOURCE DATABASE")
        buildsystem.copy_to(ctx, ctx.buildroot / 'host/config',
                            Path('src/config/unix/*.fpc').glob())
        if types.voidp.size == 4:
            print("32 bit Unix")
            buildsystem.copy_to(ctx, ctx.buildroot / 'host/config',
                                Path('src/config/unix/unix32/*.fpc').glob())
        else:
            print("64 bit Unix")
            buildsystem.copy_to(ctx, ctx.buildroot / 'host/config',
                                Path('src/config/unix/unix64/*.fpc').glob())

    if "linux" in target.platform:
        print("COPYING LINUX RESOURCE DATABASE")
        buildsystem.copy_to(ctx, ctx.buildroot / 'host/config',
                            Path('src/config/linux/*.fpc').glob())

    # enable this on win32 **instead** of the above to copy fpc files
    if "windows" in target.platform:
        print("COPYING WIN32 RESOURCE DATABASE")
        buildsystem.copy_to(ctx, ctx.buildroot / 'host/config',
                            Path('src/config/win32/*.fpc').glob())

    # enable this on solaris to clobber any fpc files
    # where the generic unix ones are inadequate
    #buildsystem.copy_to(ctx,
    #    ctx.buildroot / 'config', Path('src/config/solaris/*.fpc').glob())

    # enable this on osx to clobber any fpc files
    # where the generic unix ones are inadequate
    if 'macosx' in target.platform:
        print("COPYING MACOSX RESOURCE DATABASE")
        buildsystem.copy_to(ctx, ctx.buildroot / 'host/config',
                            Path('src/config/macosx/*.fpc').glob())

    if 'cygwin' in target.platform:
        print("COPYING CYWGIN (POSIX) RESOURCE DATABASE")
        buildsystem.copy_to(ctx, ctx.buildroot / 'host/config',
                            Path('src/config/cygwin/*.fpc').glob())

    if 'msys' in target.platform:
        print("COPYING MSYS RESOURCE DATABASE")
        buildsystem.copy_to(ctx, ctx.buildroot / 'host/config',
                            Path('src/config/msys/*.fpc').glob())

    if 'solaris' in target.platform:
        print("COPYING SOLARIS RESOURCE DATABASE")
        buildsystem.copy_to(ctx, ctx.buildroot / 'host/config',
                            Path('src/config/solaris/*.fpc').glob())

    # extract the configuration
    iscr = call('buildsystem.iscr.Iscr', ctx)

    # convert the config into something iscr can use
    call('buildsystem.iscr.config_iscr_config', ctx, build, host, target)

    # re-extract packages if any of them changed
    ctx.scheduler.map(iscr, (src_dir(ctx) / 'lpsrc/*.pak').glob())

    # overwrite or add *.fpc files to the config directory
    call('buildsystem.post_config.copy_user_fpcs', ctx)

    # set the toolchain
    dst = ctx.buildroot / 'host/config/toolchain.fpc'
    if 'macosx' in target.platform:
        toolchain = "toolchain_" + hack_toolchain_name(str(
            target.c.static)) + "_osx"
    elif "windows" in target.platform:
        toolchain = "toolchain_msvc_win32"
    else:
        toolchain = "toolchain_" + hack_toolchain_name(str(
            target.c.static)) + "_linux"
    print("**********************************************")
    print("SETTING TOOLCHAIN " + toolchain)
    print("**********************************************")
    f = open(dst, "w")
    f.write("toolchain: " + toolchain + "\n")
    f.close()

    # make Felix representation of whole build config
    call('buildsystem.show_build_config.build', ctx)

    return Record(build=build, host=host, target=target), iscr
Example #56
0
def build_runtime(phase):
    path = Path('src/demux')

    buildsystem.copy_hpps_to_rtl(phase.ctx,
        #phase.ctx.buildroot / 'lib/rtl/flx_demux_config.hpp', # portable

        # portable
        path / 'flx_demux.hpp',
        path / 'demux_demuxer.hpp',
        path / 'demux_timer_queue.hpp',
        path / 'demux_quitter.hpp',

        # windows (monolithic)
        path / 'win/demux_iocp_demuxer.hpp',
        path / 'win/demux_overlapped.hpp',
        path / 'win/demux_win_timer_queue.hpp',
        path / 'win/demux_wself_piper.hpp',

        # posix
        path / 'posix/demux_posix_demuxer.hpp',
        path / 'posix/demux_posix_timer_queue.hpp',
        path / 'posix/demux_pfileio.hpp',
        path / 'posix/demux_select_demuxer.hpp',
        path / 'posix/demux_sockety.hpp',
        path / 'posix/demux_self_piper.hpp',
        path / 'posix/demux_ts_select_demuxer.hpp',

        # linux, osx 10.3 (select impl), 10.4 real.
        path / 'poll/demux_poll_demuxer.hpp',
        path / 'poll/demux_ts_poll_demuxer.hpp',

        # linux (>= 2.6)
        path / 'epoll/demux_epoll_demuxer.hpp',

        # osx (10.3 onwards)/bsd
        path / 'kqueue/demux_kqueue_demuxer.hpp',

        # solaris (9 onwards?)
        path / 'evtport/demux_evtport_demuxer.hpp',
    )

    dst = 'host/lib/rtl/demux'
    srcs = [path / '*.cpp']
    includes = [
        phase.ctx.buildroot / 'host/lib/rtl',
        Path('src', 'pthread'),
        Path('src', 'gc'),
        path,
    ]
    macros = ['BUILD_DEMUX']
    libs = [call('buildsystem.flx_pthread.build_runtime', phase)]
    extra_libs = []

    if 'win32' in phase.platform:
        print("DEMUX: providing WIN32 IO COMPLETION PORTS");
        srcs.extend((
            path / 'win/demux_iocp_demuxer.cpp',       # windows
            path / 'win/demux_overlapped.cpp',         # windows
            path / 'win/demux_wself_piper.cpp',        # windows
            path / 'win/demux_win_timer_queue.cpp',    # windows
        ))
        includes.append(path / 'win')
        extra_libs.extend(('ws2_32', 'mswsock'))

    if 'posix' in phase.platform:
        print("DEMUX: providing POSIX SELECT");
        srcs.extend((
            path / 'posix/demux_posix_demuxer.cpp',      # posix
            path / 'posix/demux_select_demuxer.cpp',     # posix
            path / 'posix/demux_posix_timer_queue.cpp',  # posix
            path / 'posix/demux_sockety.cpp',            # posix
            path / 'posix/demux_self_piper.cpp',         # posix
            path / 'posix/demux_pfileio.cpp',            # posix
            path / 'posix/demux_ts_select_demuxer.cpp',  # posix
        ))
        includes.append(path / 'posix')

    poll_h = config_call('fbuild.config.c.posix.poll_h', phase.platform, phase.cxx.shared)
    sys_epoll_h = config_call('fbuild.config.c.linux.sys_epoll_h', phase.platform, phase.cxx.shared)
    sys_event_h = config_call('fbuild.config.c.bsd.sys_event_h', phase.platform, phase.cxx.shared)
    port_h = config_call('fbuild.config.c.solaris.port_h', phase.platform, phase.cxx.shared)

    if poll_h.header:
        print("DEMUX: providing UNIX POLL");
        srcs.extend((
            # I've seen poll on linux and osx10.4 systems.
            # conditionally compiled and used.
            path / 'poll/demux_poll_demuxer.cpp',       # I've seen this on linux and osx10.4
            path / 'poll/demux_ts_poll_demuxer.cpp',    # ditto
        ))
        includes.append(path / 'poll')

    if sys_epoll_h.header:
        print("DEMUX: providing LINUX EPOLL");
        srcs.append(path / 'epoll/demux_epoll_demuxer.cpp')
        includes.append(path / 'epoll')

    if sys_event_h.header:
        print("DEMUX: providing OSX KQUEUE");
        srcs.append(path / 'kqueue/demux_kqueue_demuxer.cpp')
        includes.append(path / 'kqueue')

    if port_h.header:
        print("DEMUX: providingd SOLARIS EVENT PORTS");
        srcs.append(path / 'evtport/demux_evtport_demuxer.cpp')
        includes.append(path / 'evtport')

    srcs = Path.globall(srcs)

    lp = len (path)
    #print("demux: srcs = ", [str (src)[lp+1:] for src in srcs])
    #print("demux: include paths = ", [str(inc) for inc in includes])
    return Record(
        static=buildsystem.build_cxx_static_lib(phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.static for lib in libs],
            external_libs=extra_libs),
        shared=buildsystem.build_cxx_shared_lib(phase, dst, srcs,
            includes=includes,
            macros=macros,
            libs=[lib.shared for lib in libs],
            external_libs=extra_libs))
Example #57
0
def build(host_phase, target_phase):
    path = Path('src/flx_drivers')

    buildsystem.copy_to(target_phase.ctx,
                        target_phase.ctx.buildroot / "share/lib/rtl/", [
                            path / 'flx_run.hpp',
                        ])

    run_includes = [
        target_phase.ctx.buildroot / 'host/lib/rtl',
        'src/exceptions',
        'src/gc',
        'src/judy/src',
        'src/pthread',
        'src/flx_async',
        'src/rtl',
    ]

    arun_includes = run_includes + [
        target_phase.ctx.buildroot / 'host/lib/rtl',
        'src/demux',
        'src/faio',
    ] + ([], ['src/demux/win'])['win32' in target_phase.platform]

    flx_run_static_obj = target_phase.cxx.static.compile(
        dst='host/lib/rtl/flx_run_lib',
        src=path / 'flx_run_lib_static.cpp',
        includes=run_includes,
    )

    flx_run_static_main = target_phase.cxx.static.compile(
        dst='host/lib/rtl/flx_run_main',
        src=path / 'flx_run_main.cxx',
        includes=run_includes,
    )

    flx_run_exe = target_phase.cxx.shared.build_exe(
        dst='host/bin/flx_run',
        srcs=[path / 'flx_run_main.cxx', path / 'flx_run_lib_dynamic.cpp'],
        includes=run_includes,
        libs=[
            call('buildsystem.flx_rtl.build_runtime', host_phase,
                 target_phase).shared
        ],
    )

    flx_arun_static_obj = target_phase.cxx.static.compile(
        dst='host/lib/rtl/flx_arun_lib',
        src=path / 'flx_arun_lib_static.cpp',
        includes=arun_includes,
    )

    flx_arun_static_main = target_phase.cxx.static.compile(
        dst='host/lib/rtl/flx_arun_main',
        src=path / 'flx_arun_main.cxx',
        includes=arun_includes,
    )

    flx_arun_exe = target_phase.cxx.shared.build_exe(
        dst='host/bin/flx_arun',
        srcs=[path / 'flx_arun_main.cxx', path / 'flx_arun_lib_dynamic.cpp'],
        includes=arun_includes,
        libs=[
            call('buildsystem.flx_rtl.build_runtime', host_phase,
                 target_phase).shared,
            call('buildsystem.flx_pthread.build_runtime', target_phase).shared,
            call('buildsystem.flx_async.build_runtime', host_phase,
                 target_phase).shared,
            call('buildsystem.demux.build_runtime', target_phase).shared,
            call('buildsystem.faio.build_runtime', host_phase,
                 target_phase).shared
        ],
    )

    return Record(
        flx_run_lib=flx_run_static_obj,
        flx_run_main=flx_run_static_main,
        flx_run_exe=flx_run_exe,
        flx_arun_lib=flx_arun_static_obj,
        flx_arun_main=flx_arun_static_main,
        flx_arun_exe=flx_arun_exe,
    )
Example #58
0
def build_runtime(host_phase, target_phase):
    path = Path('src', 'rtl')

    buildsystem.copy_hpps_to_rtl(
        target_phase.ctx,
        path / 'flx_rtl.hpp',
        path / 'flx_rtl_shapes.hpp',
        path / 'flx_compiler_support_headers.hpp',
        path / 'flx_compiler_support_bodies.hpp',
        path / 'flx_dynlink.hpp',
        path / 'flx_i18n.hpp',
        path / 'flx_ioutil.hpp',
        path / 'flx_strutil.hpp',
        path / 'flx_executil.hpp',
        path / 'flx_sync.hpp',
        path / 'flx_world.hpp',
        path / 'flx_async_world.hpp',
        path / 'flx_world_config.hpp',
        path / 'plat_linux.hpp',
    )

    for f in Path.glob(path / "*.hpp"):
        print("Copying " + f + " --> " + target_phase.ctx.buildroot / f)
        copy(ctx=target_phase.ctx, src=f, dst=target_phase.ctx.buildroot / f)

    srcs = [
        copy(ctx=target_phase.ctx, src=f, dst=target_phase.ctx.buildroot / f)
        for f in Path.glob(path / '*.cpp')
    ]
    includes = [
        target_phase.ctx.buildroot / 'host/lib/rtl',
        target_phase.ctx.buildroot / 'share/lib/rtl'
    ]
    macros = ['BUILD_RTL']
    libs = [
        call('buildsystem.flx_async.build_runtime', host_phase, target_phase),
        call('buildsystem.flx_exceptions.build_runtime', target_phase),
        call('buildsystem.flx_gc.build_runtime', host_phase, target_phase),
    ]

    dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h',
                          target_phase.platform, target_phase.cxx.static,
                          target_phase.cxx.shared)

    if dlfcn_h.dlopen:
        external_libs = dlfcn_h.external_libs
    else:
        external_libs = []

    dst = 'host/lib/rtl/flx'
    return Record(static=buildsystem.build_cxx_static_lib(
        target_phase,
        dst,
        srcs,
        includes=includes,
        macros=macros,
        libs=[lib.static for lib in libs],
        external_libs=external_libs),
                  shared=buildsystem.build_cxx_shared_lib(
                      target_phase,
                      dst,
                      srcs,
                      includes=includes,
                      macros=macros,
                      libs=[lib.shared for lib in libs],
                      external_libs=external_libs))