Beispiel #1
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)
      )
Beispiel #2
0
def _print_gcc_extensions(platform, lang, p):
    gcc = config_call('fbuild.config.c.gnu.extensions', platform, lang.static)

    have_gnu_x86 = gcc.named_registers_x86 and not gcc.named_registers_x86_64

    p('HAVE_CGOTO',              gcc.computed_gotos)
    p('HAVE_ASM_LABELS',         gcc.asm_labels)
    p('HAVE_GNU_BUILTIN_EXPECT', bool(gcc.builtin_expect))

    hash_map = config_call('fbuild.config.cxx.gnu.gcc_cxx_hash_map',
        platform, lang.static)
    p('HAVE_STL_GNU_CXX', hash_map.header)
Beispiel #3
0
def _print_gcc_extensions(platform, lang, p):
    gcc = config_call('fbuild.config.c.gnu.extensions', platform, lang.static)

    have_gnu_x86 = gcc.named_registers_x86 and not gcc.named_registers_x86_64

    p('HAVE_CGOTO', gcc.computed_gotos)
    p('HAVE_ASM_LABELS', gcc.asm_labels)
    p('HAVE_GNU_BUILTIN_EXPECT', bool(gcc.builtin_expect))

    hash_map = config_call('fbuild.config.cxx.gnu.gcc_cxx_hash_map', platform,
                           lang.static)
    p('HAVE_STL_GNU_CXX', hash_map.header)
Beispiel #4
0
def _print_openmp_support(ctx, platform, lang, p):
    try:
        static = config_call("fbuild.builders.c.openmp.config", platform, ctx, lang.static)
    except ConfigFailed:
        static = {}

    try:
        shared = config_call("fbuild.builders.c.openmp.config", platform, ctx, lang.shared)
    except ConfigFailed:
        shared = {}

    p("HAVE_OPENMP", bool(static) or bool(shared))
    p("HAVE_STATIC_OPENMP", bool(static))
    p("HAVE_SHARED_OPENMP", bool(shared))
Beispiel #5
0
def _print_gcc_extensions(platform, lang, p):
    gcc = config_call("fbuild.config.c.gnu.extensions", platform, lang.static)

    have_gnu_x86 = gcc.named_registers_x86 and not gcc.named_registers_x86_64

    p("HAVE_GNU_X86", have_gnu_x86)
    p("HAVE_GNU_X86_64", gcc.named_registers_x86_64)
    p("HAVE_CGOTO", gcc.computed_gotos)
    p("HAVE_ASM_LABELS", gcc.asm_labels)
    p("HAVE_GNU_BUILTIN_EXPECT", bool(gcc.builtin_expect))
    p("USE_REGPARM3", have_gnu_x86)

    hash_map = config_call("fbuild.config.cxx.gnu.gcc_cxx_hash_map", platform, lang.static)
    p("HAVE_STL_GNU_CXX", hash_map.header)
Beispiel #6
0
def _print_posix_support(platform, lang, p):
    # print out information about the posix libraries
    dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h',
        platform, lang.static, lang.shared)

    if dlfcn_h.dlopen:
        p('HAVE_DLOPEN', True)
        p('SUPPORT_DYNAMIC_LOADING', True)
        switch = list(dlfcn_h.flags)
        p('DYNAMIC_LOADING_CFLAGS', ' '.join(switch))
        switch=list('-L' + p for p in dlfcn_h.libpaths)
        switch.extend('-l' + l for l in dlfcn_h.libs)
        switch.extend('-l' + l for l in dlfcn_h.external_libs)
        p('DYNAMIC_LOADING_LIBS', ' '.join(switch))
    else:
        p('HAVE_DLOPEN', False)

    socket_h = config_call('fbuild.config.c.posix.sys_socket_h',
        platform, lang.static)
    if socket_h.accept:
        # We strip off the trailing '*' from the socklen_t type.
        p('FLX_SOCKLEN_T', socket_h.accept.args[-1][:-1])

    pthread_h = config_call('fbuild.config.c.posix.pthread_h',
        platform, lang.static)
    if pthread_h.pthread_create:
        p('HAVE_PTHREADS', True)
        switch = list(pthread_h.flags)
        p('PTHREAD_CFLAGS', ' '.join(switch))
        switch=list('-L' + p for p in pthread_h.libpaths)
        switch.extend('-l' + l for l in pthread_h.libs)
        switch.extend('-l' + l for l in pthread_h.external_libs)
        p('PTHREAD_LIBS', ' '.join(switch))
    else:
        p('HAVE_PTHREADS', False)

    poll_h = config_call('fbuild.config.c.posix.poll_h',
        platform, lang.static)
    p('HAVE_POLL', bool(poll_h.header))

    mman_h = config_call('fbuild.config.c.posix.sys_mman_h',
        platform, lang.static)

    p('HAVE_MMAP', bool(mman_h.header))
    for name, macro in mman_h.macros():
        p('HAVE_' + name, bool(macro))

    event_h = config_call('fbuild.config.c.bsd.sys_event_h',
        platform, lang.static)
    p('HAVE_KQUEUE_DEMUXER', bool(event_h.kqueue))

    epoll_h = config_call('fbuild.config.c.linux.sys_epoll_h',
        platform, lang.static)
    p('HAVE_EPOLL', bool(epoll_h.epoll_create))

    port_h = config_call('fbuild.config.c.solaris.port_h',
        platform, lang.static)
    p('HAVE_EVTPORTS', bool(port_h.port_create))
Beispiel #7
0
def _print_openmp_support(ctx, platform, lang, p):
    try:
        static = config_call('fbuild.builders.c.openmp.config', platform, ctx,
                             lang.static)
    except ConfigFailed:
        static = {}

    try:
        shared = config_call('fbuild.builders.c.openmp.config', platform, ctx,
                             lang.shared)
    except ConfigFailed:
        shared = {}

    p('HAVE_OPENMP', bool(static) or bool(shared))
    p('HAVE_STATIC_OPENMP', bool(static))
    p('HAVE_SHARED_OPENMP', bool(shared))
Beispiel #8
0
def _print_posix_support(platform, lang, p):
    # print out information about the posix libraries
    dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h', platform,
                          lang.static, lang.shared)

    if dlfcn_h.dlopen:
        p('HAVE_DLOPEN', True)
        p('SUPPORT_DYNAMIC_LOADING', True)
        switch = list(dlfcn_h.flags)
        p('DYNAMIC_LOADING_CFLAGS', ' '.join(switch))
        switch = list('-L' + p for p in dlfcn_h.libpaths)
        switch.extend('-l' + l for l in dlfcn_h.libs)
        switch.extend('-l' + l for l in dlfcn_h.external_libs)
        p('DYNAMIC_LOADING_LIBS', ' '.join(switch))
    else:
        p('HAVE_DLOPEN', False)

    socket_h = config_call('fbuild.config.c.posix.sys_socket_h', platform,
                           lang.static)
    if socket_h.accept:
        # We strip off the trailing '*' from the socklen_t type.
        p('FLX_SOCKLEN_T', socket_h.accept.args[-1][:-1])

    pthread_h = config_call('fbuild.config.c.posix.pthread_h', platform,
                            lang.static)
    if pthread_h.pthread_create:
        p('HAVE_PTHREADS', True)
        switch = list(pthread_h.flags)
        p('PTHREAD_CFLAGS', ' '.join(switch))
        switch = list('-L' + p for p in pthread_h.libpaths)
        switch.extend('-l' + l for l in pthread_h.libs)
        switch.extend('-l' + l for l in pthread_h.external_libs)
        p('PTHREAD_LIBS', ' '.join(switch))
    else:
        p('HAVE_PTHREADS', False)

    poll_h = config_call('fbuild.config.c.posix.poll_h', platform, lang.static)
    p('HAVE_POLL', bool(poll_h.header))

    mman_h = config_call('fbuild.config.c.posix.sys_mman_h', platform,
                         lang.static)

    p('HAVE_MMAP', bool(mman_h.header))
    for name, macro in mman_h.macros():
        p('HAVE_' + name, bool(macro))

    event_h = config_call('fbuild.config.c.bsd.sys_event_h', platform,
                          lang.static)
    p('HAVE_KQUEUE_DEMUXER', bool(event_h.kqueue))

    epoll_h = config_call('fbuild.config.c.linux.sys_epoll_h', platform,
                          lang.static)
    p('HAVE_EPOLL', bool(epoll_h.epoll_create))

    port_h = config_call('fbuild.config.c.solaris.port_h', platform,
                         lang.static)
    p('HAVE_EVTPORTS', bool(port_h.port_create))
Beispiel #9
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))
Beispiel #10
0
def build_runtime(host_phase, target_phase):
    """
    Builds the judy runtime library, and returns the static and shared
    library versions.
    """

    path = Path('src/judy/src')

    # Copy the header into the runtime library.
    buildsystem.copy_to(target_phase.ctx,
        target_phase.ctx.buildroot / 'lib/rtl',
        [path / 'Judy.h',
         path / 'Judy1/Judy1.h',
         path / 'JudyL/JudyL.h'])

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

    if types.voidp.size == 8:
        macros = ['JU_64BIT']
    else:
        macros = ['JU_32BIT']

    if 'windows' in target_phase.platform:
        macros.append('BUILD_JUDY') #Apply this to all source files.

    srcs = [copy(target_phase.ctx, p, target_phase.ctx.buildroot / p) for p in [
        path / 'JudyCommon/JudyMalloc.c',
        path / 'JudySL/JudySL.c',
        path / 'JudyHS/JudyHS.c'] +
        (path / 'Judy1' / '*.c').glob() +
        (path / 'JudyL' / '*.c').glob()]
    
    # Copy all the common judy sources we need so people can rebuild the RTL without a source distro
    for p in ((path / 'JudyCommon' / '*.c').glob() + 
              (path / 'Judy*' / '*.h').glob()): 
        if p not in ('JudyMalloc.c', 'JudyPrintJP.c'):
            copy(target_phase.ctx, p, target_phase.ctx.buildroot / p)

    includes = [path, 
                path / 'JudyCommon', 
                path / 'JudyL', 
                path / 'Judy1']
    
    static = buildsystem.build_c_static_lib(target_phase, 'lib/rtl/judy',
        srcs=srcs,
        macros=macros,
        includes=includes)

    shared = buildsystem.build_c_shared_lib(target_phase, 'lib/rtl/judy',
        srcs=srcs,
        macros=macros,
        includes=includes)

    return Record(static=static, shared=shared)
Beispiel #11
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))
Beispiel #12
0
def _print_math_support(platform, lang, p):
    cmath = config_call("fbuild.config.cxx.cmath.cmath", platform, lang.static)
    math_h = config_call("fbuild.config.c.stdlib.math_h", platform, lang.static)
    ieeefp_h = config_call("fbuild.config.c.ieeefp_h.ieeefp_h", platform, lang.static)

    p("HAVE_CXX_ISNAN_IN_CMATH", bool(cmath.isnan))
    p("HAVE_CXX_ISINF_IN_CMATH", bool(cmath.isinf))
    p("HAVE_CXX_ISFINITE_IN_CMATH", bool(cmath.isfinite))
    p("HAVE_C99_ISFINITE_IN_MATH", bool(math_h.isfinite))
    p("HAVE_C99_ISINF_IN_MATH", bool(math_h.isinf))
    p("HAVE_C99_ISNAN_IN_MATH", bool(math_h.isnan))
    p("HAVE_BSD_FINITE_IN_MATH", bool(math_h.finite))
    p("HAVE_BSD_ISINF_IN_MATH", bool(math_h.isinf))
    p("HAVE_BSD_ISNAN_IN_MATH", bool(math_h.isnan))
    p("HAVE_BSD_FINITE_IN_IEEEFP", bool(ieeefp_h.finite))
    p("HAVE_BSD_ISINF_IN_IEEEFP", bool(ieeefp_h.isinf))
    p("HAVE_BSD_ISNAN_IN_IEEEFP", bool(ieeefp_h.isnan))
    p("HAVE_FINITE_IN_IEEEFP", bool(ieeefp_h.finite))
    p("HAVE_ISINF_IN_IEEEFP", bool(ieeefp_h.isinf))
    p("HAVE_ISNANF_IN_IEEEFP", bool(ieeefp_h.isnanf))
Beispiel #13
0
def build_runtime(host_phase, target_phase):
    """
    Builds the judy runtime library, and returns the static and shared
    library versions.
    """

    path = Path('src/judy/src')

    # Copy the header into the runtime library.
    buildsystem.copy_to(target_phase.ctx,
                        target_phase.ctx.buildroot / 'share/lib/rtl',
                        [path / 'Judy.h'])

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

    if types.voidp.size == 8:
        macros = ['JU_64BIT']
    else:
        macros = ['JU_32BIT']

    if 'windows' in target_phase.platform:
        macros.append('BUILD_JUDY')  #Apply this to all source files.

    srcs = [
        copy(target_phase.ctx, p, target_phase.ctx.buildroot / 'share' / p)
        for p in [
            path / 'JudyCommon/JudyMalloc.c', path / 'JudySL/JudySL.c', path /
            'JudyHS/JudyHS.c'
        ] + (path / 'Judy1' / '*.c').glob() + (path / 'JudyL' / '*.c').glob()
    ]

    # Copy all the common judy sources we need so people can rebuild the RTL without a source distro
    for p in ((path / 'JudyCommon' / '*.c').glob() +
              (path / 'Judy*' / '*.h').glob()):
        if p not in ('JudyMalloc.c', 'JudyPrintJP.c'):
            copy(target_phase.ctx, p, target_phase.ctx.buildroot / 'share' / p)

    includes = [path, path / 'JudyCommon', path / 'JudyL', path / 'Judy1']

    static = buildsystem.build_c_static_lib(target_phase,
                                            'host/lib/rtl/judy',
                                            srcs=srcs,
                                            macros=macros,
                                            includes=includes)

    shared = buildsystem.build_c_shared_lib(target_phase,
                                            'host/lib/rtl/judy',
                                            srcs=srcs,
                                            macros=macros,
                                            includes=includes)

    return Record(static=static, shared=shared)
Beispiel #14
0
def _print_math_support(platform, lang, p):
    cmath = config_call('fbuild.config.cxx.cmath.cmath', platform, lang.static)
    math_h = config_call('fbuild.config.c.stdlib.math_h', platform,
                         lang.static)
    ieeefp_h = config_call('fbuild.config.c.ieeefp_h.ieeefp_h', platform,
                           lang.static)

    p('HAVE_CXX_ISNAN_IN_CMATH', bool(cmath.isnan))
    p('HAVE_CXX_ISINF_IN_CMATH', bool(cmath.isinf))
    p('HAVE_CXX_ISFINITE_IN_CMATH', bool(cmath.isfinite))
    p('HAVE_C99_ISFINITE_IN_MATH', bool(math_h.isfinite))
    p('HAVE_C99_ISINF_IN_MATH', bool(math_h.isinf))
    p('HAVE_C99_ISNAN_IN_MATH', bool(math_h.isnan))
    p('HAVE_BSD_FINITE_IN_MATH', bool(math_h.finite))
    p('HAVE_BSD_ISINF_IN_MATH', bool(math_h.isinf))
    p('HAVE_BSD_ISNAN_IN_MATH', bool(math_h.isnan))
    p('HAVE_BSD_FINITE_IN_IEEEFP', bool(ieeefp_h.finite))
    p('HAVE_BSD_ISINF_IN_IEEEFP', bool(ieeefp_h.isinf))
    p('HAVE_BSD_ISNAN_IN_IEEEFP', bool(ieeefp_h.isnan))
    p('HAVE_FINITE_IN_IEEEFP', bool(ieeefp_h.finite))
    p('HAVE_ISINF_IN_IEEEFP', bool(ieeefp_h.isinf))
    p('HAVE_ISNANF_IN_IEEEFP', bool(ieeefp_h.isnanf))
Beispiel #15
0
def configure(ctx):
    """Configure Felix."""

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

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

    compiler = hack_toolchain_name(str(target.c.static))
    os = hack_os_name(target.platform)
    bits = hack_size(types.voidp.size)

    target_config(ctx, target, os, bits, compiler)
    return Record(build=build, host=host, target=target)
Beispiel #16
0
def build_runtime(host_phase, target_phase):
    """
    Builds the judy runtime library, and returns the static and shared
    library versions.
    """

    path = Path("src/judy/src")

    # Copy the header into the runtime library.
    buildsystem.copy_to(target_phase.ctx, target_phase.ctx.buildroot / "lib/rtl", [path / "Judy.h"])

    types = config_call("fbuild.config.c.c99.types", target_phase.platform, target_phase.c.static)

    if types.voidp.size == 8:
        macros = ["JU_64BIT"]
    else:
        macros = ["JU_32BIT"]

    srcs = [path / "JudyCommon/JudyMalloc.c", path / "JudySL/JudySL.c", path / "JudyHS/JudyHS.c"]

    static = buildsystem.build_c_static_lib(
        target_phase,
        "lib/rtl/judy",
        srcs=srcs,
        objs=_build_objs(host_phase, target_phase, target_phase.c.static, "Judy1")
        + _build_objs(host_phase, target_phase, target_phase.c.static, "JudyL"),
        macros=macros,
        includes=[path, path / "JudyCommon"],
    )

    shared = buildsystem.build_c_shared_lib(
        target_phase,
        "lib/rtl/judy",
        srcs=srcs,
        objs=_build_objs(host_phase, target_phase, target_phase.c.shared, "Judy1")
        + _build_objs(host_phase, target_phase, target_phase.c.shared, "JudyL"),
        macros=macros,
        includes=[path, path / "JudyCommon"],
    )

    return Record(static=static, shared=shared)
Beispiel #17
0
def _print_types(platform, lang, p):
    cxx_types = config_call('fbuild.config.cxx.cxx03.types', platform,
                            lang.static)

    def write(name, type_):
        if name == '_Bool':
            name = 'cbool'
        elif name == 'void*':
            name = 'VOIDP'

        name = name.replace(' ', '')
        alias = cxx_types.structural_alias(type_)
        if isinstance(type_, fbuild.config.c.IntType):
            p('ALIAS_' + name, alias)

        name = name.upper()
        p('SIZEOF_' + name, type_.size)
        p('ALIGNOF_' + name, type_.alignment)

    # standard language type info
    p('CHAR_IS_UNSIGNED', not cxx_types.char.signed)
    p('HAVE_BOOL', bool(cxx_types.bool))
    p('HAVE_LONGLONG', bool(cxx_types.long_long))
    p('HAVE_LONGDOUBLE', bool(cxx_types.long_double))

    max_align = 1
    aligns = {1: 'char'}
    for name, type_ in cxx_types.types():
        if type_ is None:
            continue

        aligns.setdefault(type_.alignment, name)
        max_align = max(max_align, type_.alignment)
        write(name, type_)
    p('MAX_ALIGN', max_align)
    p('flx_aligns', aligns)
    p('arith_conv', cxx_types.conversion_map())

    c99_types = config_call('fbuild.config.c.stdlib.types', platform,
                            lang.static)
    stddef_h = config_call('fbuild.config.c.stdlib.stddef_h', platform,
                           lang.static)
    complex_h = config_call('fbuild.config.c.stdlib.complex_h', platform,
                            lang.static)
    stdint_h = config_call('fbuild.config.c.stdlib.stdint_h', platform,
                           lang.static)
    sys_types_h = config_call('fbuild.config.c.posix.sys_types_h', platform,
                              lang.static)

    p('HAVE_STDINT', bool(stdint_h.header))
    p('HAVE_SYS_TYPES', bool(sys_types_h.header))

    # write out data for the types.
    for name, type_ in set(
            chain(cxx_types.types(), c99_types.types(), stddef_h.types(),
                  complex_h.types(), stdint_h.types(), sys_types_h.types())):
        if type_ is None:
            continue
        write(name, type_)

    if not stdint_h.header:
        if c99_types.long_long:
            p('ALIAS_intmax_t', 'long long')
            p('ALIAS_uintmax_t', 'unsigned long long')
        else:
            p('ALIAS_intmax_t', 'long')
            p('ALIAS_uintmax_t', 'unsigned long')

        visited = set()
        for name, type_ in cxx_types.int_types():
            if type_ is not None and type_ not in visited:
                visited.add(type_)
                if type_.signed:
                    p('ALIAS_int%s_t' % (type_.size * 8), name)
                else:
                    p('ALIAS_uint%s_t' % (type_.size * 8), name)

        p('ALIAS_intptr_t', cxx_types.structural_alias(cxx_types.voidp))
        p('ALIAS_uintptr_t',
          'unsigned ' + cxx_types.structural_alias(cxx_types.voidp))

    if not sys_types_h.ssize_t:
        if c99_types.long_long and \
                stddef_h.size_t.size == c99_types.long_long.size:
            p('ALIAS_ssize_t', 'long long')
        else:
            p('ALIAS_ssize_t', 'long')
Beispiel #18
0
def _print_compiler(ctx, lang, platform, p):
    # determine information about the compiler

    p('HAVE_PIC', '-fPIC' in lang.shared.compiler.flags)
    p('PIC', '-fPIC')

    static = lang.static
    shared = lang.shared

    if 'windows' in platform:
        p('SPEC_OBJ_FILENAME', '/Fo')
        p('SPEC_EXE_FILENAME', '/Fe')

        p(
            'CCOBJ_STATIC_FLX', '"' + str(static.compiler.cl.exe) +
            '" /nologo /c ' + ' '.join(static.compiler.flags) + ' ' +
            ' '.join('-I' + i for i in static.compiler.cl.includes))

        p(
            'CCLINK_STATIC_LIB', '"' + str(static.lib_linker.exe) + '" ' +
            ' '.join(i for i in static.lib_linker.flags))

        p(
            'CCOBJ_DYNAMIC_FLX', '"' + str(shared.compiler.cl.exe) +
            '" /nologo /c ' + ' '.join(shared.compiler.flags) + ' ' +
            ' '.join('-I' + i for i in static.compiler.cl.includes))

        p(
            'CCLINK_STATIC', '"' + str(static.compiler.cl.exe) + '" /nologo ' +
            ' '.join(shared.exe_linker.flags) + ' ' +
            ' '.join('-L' + i for i in static.exe_linker.libpaths))

        p(
            'CCLINK_DYNAMIC_FLX', '"' + str(shared.compiler.cl.exe) +
            '" /nologo ' + ' '.join(shared.lib_linker.flags) + ' ' +
            ' '.join('-L' + i for i in shared.lib_linker.libpaths))
    else:
        p('SPEC_OBJ_FILENAME', '-o ')
        p('SPEC_EXE_FILENAME', '-o ')

        static_arch = static.compiler.cc.arch
        p(
            'CCOBJ_STATIC_FLX',
            str(static.compiler.cc.exe) + ' -c ' +
            ' '.join(static.compiler.flags) + ' ' +
            ' '.join('-I' + i for i in static.compiler.cc.includes) + ' ' +
            ' '.join('-m' + i for i in static.compiler.cc.machine_flags) +
            ' ' + ('-arch ' + static_arch if static_arch else '') + ' ' +
            ' '.join('-W' + i for i in static.compiler.cc.warnings))

        p(
            'CCLINK_STATIC_LIB',
            str(static.lib_linker.exe) + ' ' +
            ' '.join(i for i in static.lib_linker.flags))

        p(
            'CCLINK_STATIC',
            str(static.exe_linker.cc.exe) + ' ' +
            ' '.join(shared.exe_linker.flags) + ' ' +
            ' '.join('-m' + i for i in static.compiler.cc.machine_flags) +
            ' ' + ('-arch ' + static_arch if static_arch else '') + ' ' +
            ' '.join('-L' + i for i in static.exe_linker.cc.libpaths))

        shared_arch = shared.compiler.cc.arch
        p(
            'CCOBJ_DYNAMIC_FLX',
            str(shared.compiler.cc.exe) + ' -c ' +
            ' '.join(shared.compiler.flags) + ' ' +
            ' '.join('-I' + i for i in shared.compiler.cc.includes) + ' ' +
            ('-arch ' + shared_arch if shared_arch else '') + ' ' +
            ' '.join('-m' + i for i in shared.compiler.cc.machine_flags) +
            ' ' + ' '.join('-W' + i for i in static.compiler.cc.warnings))

        p(
            'CCLINK_DYNAMIC_FLX',
            str(shared.lib_linker.cc.exe) + ' ' +
            ' '.join(shared.lib_linker.flags) + ' ' +
            ('-arch ' + shared_arch if shared_arch else '') + ' ' +
            ' '.join('-m' + i for i in shared.compiler.cc.machine_flags) +
            ' ' + ' '.join('-L' + i for i in shared.compiler.cc.libpaths))

    p('EXT_STATIC_OBJ', fbuild.builders.platform.static_obj_suffix(ctx))
    p('EXT_SHARED_OBJ', fbuild.builders.platform.shared_obj_suffix(ctx))
    p('EXT_LIB', fbuild.builders.platform.static_lib_suffix(ctx))
    p('EXT_SHLIB', fbuild.builders.platform.shared_lib_suffix(ctx))
    p('EXT_EXE', fbuild.builders.platform.exe_suffix(ctx))

    if 'windows' in platform:
        p('OPTIMISE', ' '.join(static.compiler.cl.optimize_flags))
        p('DEBUG_FLAGS', ' '.join(static.compiler.cl.debug_flags))
    else:
        p('OPTIMISE', ' '.join(static.compiler.cc.optimize_flags))
        p('DEBUG_FLAGS', ' '.join(static.compiler.cc.debug_flags))

    p(
        'LITTLE_ENDIAN',
        config_call('fbuild.config.c.platform.arch', platform,
                    static).little_endian)
Beispiel #19
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')
Beispiel #20
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,
        ),
    )
Beispiel #21
0
def _print_cxx_bugs(ctx, platform, lang, p):
    compiler = config_call('fbuild.config.cxx.compiler.bugs',
        platform, lang.static)

    p('HAVE_INCLASS_MEMBER_INITIALIZATION',
        compiler.class_member_intialization)
Beispiel #22
0
def build_runtime(phase):
    path = Path('src/pthread')

    copy(ctx=phase.ctx, 
      src="src/config/target/flx_pthread_config.hpp",
      dst=phase.ctx.buildroot / 'host/lib/rtl/flx_pthread_config.hpp')

    buildsystem.copy_hpps_to_rtl(phase.ctx,

        # portable
        path / 'pthread_thread.hpp',
        path / 'pthread_mutex.hpp',
        path / 'pthread_counter.hpp',
        path / 'pthread_waitable_bool.hpp',
        path / 'pthread_condv.hpp',
        path / 'pthread_semaphore.hpp',
        path / 'pthread_monitor.hpp',

        # win32 and posix
        path / 'pthread_win_posix_condv_emul.hpp',
    )

    srcs = [copy(ctx=phase.ctx, src=f, dst=phase.ctx.buildroot / f) for f in [
        path / 'pthread_win_posix_condv_emul.cpp', # portability hackery
        path / 'pthread_mutex.cpp',
        path / 'pthread_condv.cpp',
        path / 'pthread_counter.cpp',
        path / 'pthread_waitable_bool.cpp',
        path / 'pthread_semaphore.cpp',
        path / 'pthread_monitor.cpp',
        path / 'pthread_thread_control.cpp',
        path / 'pthread_win_thread.cpp',
        path / 'pthread_posix_thread.cpp',
    ]]
    includes = [phase.ctx.buildroot / 'host/lib/rtl', phase.ctx.buildroot / 'share/lib/rtl', 'src/rtl',]
    macros = ['BUILD_PTHREAD']
    flags = []
    libs = []
    external_libs = []

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

    dst = 'host/lib/rtl/flx_pthread'
    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=buildsystem.build_cxx_static_lib(phase, dst, srcs,
            includes=includes,
            macros=macros,
            cflags=flags,
            libs=libs,
            external_libs=external_libs,
            lflags=flags),
        shared=buildsystem.build_cxx_shared_lib(phase, dst, srcs,
            includes=includes,
            macros=macros,
            cflags=flags,
            libs=libs,
            external_libs=external_libs,
            lflags=flags))
Beispiel #23
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")
Beispiel #24
0
def _print_types(platform, lang, p):
    cxx_types = config_call('fbuild.config.cxx.cxx03.types',
        platform, lang.static)

    def write(name, type_):
        if name == '_Bool':
            name = 'cbool'
        elif name == 'void*':
            name = 'VOIDP'

        name = name.replace(' ', '')
        alias = cxx_types.structural_alias(type_)
        if isinstance(type_, fbuild.config.c.IntType):
            p('ALIAS_' + name, alias)

        name = name.upper()
        p('SIZEOF_' + name,  type_.size)
        p('ALIGNOF_' + name, type_.alignment)

    # standard language type info
    p('CHAR_IS_UNSIGNED', not cxx_types.char.signed)
    p('HAVE_BOOL',        bool(cxx_types.bool))
    p('HAVE_LONGLONG',    bool(cxx_types.long_long))
    p('HAVE_LONGDOUBLE',  bool(cxx_types.long_double))

    max_align = 1
    aligns = {1: 'char'}
    for name, type_ in cxx_types.types():
        if type_ is None:
            continue

        aligns.setdefault(type_.alignment, name)
        max_align = max(max_align, type_.alignment)
        write(name, type_)
    p('MAX_ALIGN', max_align)
    p('flx_aligns', aligns)
    p('arith_conv', cxx_types.conversion_map())

    c99_types = config_call('fbuild.config.c.stdlib.types',
        platform, lang.static)
    stddef_h = config_call('fbuild.config.c.stdlib.stddef_h',
        platform, lang.static)
    complex_h = config_call('fbuild.config.c.stdlib.complex_h',
        platform, lang.static)
    stdint_h = config_call('fbuild.config.c.stdlib.stdint_h',
        platform, lang.static)
    sys_types_h = config_call('fbuild.config.c.posix.sys_types_h',
        platform, lang.static)

    p('HAVE_STDINT', bool(stdint_h.header))
    p('HAVE_SYS_TYPES', bool(sys_types_h.header))

    # write out data for the types.
    for name, type_ in set(chain(
            cxx_types.types(),
            c99_types.types(),
            stddef_h.types(),
            complex_h.types(),
            stdint_h.types(),
            sys_types_h.types())):
        if type_ is None:
            continue
        write(name, type_)

    if not stdint_h.header:
        if c99_types.long_long:
            p('ALIAS_intmax_t', 'long long')
            p('ALIAS_uintmax_t', 'unsigned long long')
        else:
            p('ALIAS_intmax_t', 'long')
            p('ALIAS_uintmax_t', 'unsigned long')

        visited = set()
        for name, type_ in cxx_types.int_types():
            if type_ is not None and type_ not in visited:
                visited.add(type_)
                if type_.signed:
                    p('ALIAS_int%s_t' % (type_.size * 8), name)
                else:
                    p('ALIAS_uint%s_t' % (type_.size * 8), name)

        p('ALIAS_intptr_t', cxx_types.structural_alias(cxx_types.voidp))
        p('ALIAS_uintptr_t',
            'unsigned ' + cxx_types.structural_alias(cxx_types.voidp))

    if not sys_types_h.ssize_t:
        if c99_types.long_long and \
                stddef_h.size_t.size == c99_types.long_long.size:
            p('ALIAS_ssize_t', 'long long')
        else:
            p('ALIAS_ssize_t', 'long')
Beispiel #25
0
def _print_compiler(ctx, lang, platform, p):
    # determine information about the compiler

    p('HAVE_PIC', '-fPIC' in lang.shared.compiler.flags)
    p('PIC', '-fPIC')

    static = lang.static
    shared = lang.shared

    if 'windows' in platform:
        p('SPEC_OBJ_FILENAME', '/Fo')
        p('SPEC_EXE_FILENAME', '/Fe')

        p('CCOBJ_STATIC_FLX', '"' + str(static.compiler.cl.exe) + '" /nologo /c ' +
            ' '.join(static.compiler.flags) + ' ' +
            ' '.join('-I' + i for i in static.compiler.cl.includes))

        p('CCLINK_STATIC_LIB', '"'+str(static.lib_linker.exe) + '" ' +
            ' '.join(i for i in static.lib_linker.flags))


        p('CCOBJ_DYNAMIC_FLX', '"' + str(shared.compiler.cl.exe) + '" /nologo /c ' +
            ' '.join(shared.compiler.flags) + ' ' +
            ' '.join('-I' + i for i in static.compiler.cl.includes))

        p('CCLINK_STATIC', '"' + str(static.compiler.cl.exe) + '" /nologo ' +
            ' '.join(shared.exe_linker.flags) + ' ' +
            ' '.join('-L' + i for i in static.exe_linker.libpaths))

        p('CCLINK_DYNAMIC_FLX', '"' + str(shared.compiler.cl.exe) + '" /nologo ' +
            ' '.join(shared.lib_linker.flags) + ' ' +
            ' '.join('-L' + i for i in shared.lib_linker.libpaths))
    else:
        p('SPEC_OBJ_FILENAME', '-o ')
        p('SPEC_EXE_FILENAME', '-o ')

        static_arch = static.compiler.cc.arch
        p('CCOBJ_STATIC_FLX', str(static.compiler.cc.exe) + ' -c ' +
            ' '.join(static.compiler.flags) + ' ' +
            ' '.join('-I' + i for i in static.compiler.cc.includes) + ' ' +
            ' '.join('-m' + i for i in static.compiler.cc.machine_flags) + ' ' +
            ('-arch ' + static_arch if static_arch else '') + ' ' +
            ' '.join('-W' + i for i in static.compiler.cc.warnings))

        p('CCLINK_STATIC_LIB', str(static.lib_linker.exe) + ' ' +
            ' '.join(i for i in static.lib_linker.flags))

        p('CCLINK_STATIC', str(static.exe_linker.cc.exe) + ' ' +
            ' '.join(shared.exe_linker.flags) + ' ' +
            ' '.join('-m' + i for i in static.compiler.cc.machine_flags) + ' ' +
            ('-arch ' + static_arch if static_arch else '') + ' ' +
            ' '.join('-L' + i for i in static.exe_linker.cc.libpaths))

        shared_arch = shared.compiler.cc.arch
        p('CCOBJ_DYNAMIC_FLX', str(shared.compiler.cc.exe) + ' -c ' +
            ' '.join(shared.compiler.flags) + ' ' +
            ' '.join('-I' + i for i in shared.compiler.cc.includes) + ' ' +
            ('-arch ' + shared_arch if shared_arch else '') + ' ' +
            ' '.join('-m' + i for i in shared.compiler.cc.machine_flags) + ' ' +
            ' '.join('-W' + i for i in static.compiler.cc.warnings)) 

        p('CCLINK_DYNAMIC_FLX', str(shared.lib_linker.cc.exe) + ' ' +
            ' '.join(shared.lib_linker.flags) + ' ' +
            ('-arch ' + shared_arch if shared_arch else '') + ' ' +
            ' '.join('-m' + i for i in shared.compiler.cc.machine_flags) + ' ' +
            ' '.join('-L' + i for i in shared.compiler.cc.libpaths))

    p('EXT_STATIC_OBJ', fbuild.builders.platform.static_obj_suffix(ctx))
    p('EXT_SHARED_OBJ', fbuild.builders.platform.shared_obj_suffix(ctx))
    p('EXT_LIB',        fbuild.builders.platform.static_lib_suffix(ctx))
    p('EXT_SHLIB',      fbuild.builders.platform.shared_lib_suffix(ctx))
    p('EXT_EXE',        fbuild.builders.platform.exe_suffix(ctx))

    if 'windows' in platform:
        p('OPTIMISE',       ' '.join(static.compiler.cl.optimize_flags))
        p('DEBUG_FLAGS',    ' '.join(static.compiler.cl.debug_flags))
    else:
        p('OPTIMISE',       ' '.join(static.compiler.cc.optimize_flags))
        p('DEBUG_FLAGS',    ' '.join(static.compiler.cc.debug_flags))

    p('LITTLE_ENDIAN', config_call('fbuild.config.c.platform.arch',
        platform, static).little_endian)
Beispiel #26
0
def _print_types(platform, lang, p):
    cxx_types = config_call("fbuild.config.cxx.cxx03.types", platform, lang.static)

    def write(name, type_):
        if name == "_Bool":
            name = "cbool"
        elif name == "void*":
            name = "VOIDP"

        name = name.replace(" ", "")
        alias = cxx_types.structural_alias(type_)
        if isinstance(type_, fbuild.config.c.IntType):
            p("ALIAS_" + name, alias)

        name = name.upper()
        p("SIZEOF_" + name, type_.size)
        p("ALIGNOF_" + name, type_.alignment)

    # standard language type info
    p("CHAR_IS_UNSIGNED", not cxx_types.char.signed)
    p("HAVE_BOOL", bool(cxx_types.bool))
    p("HAVE_LONGLONG", bool(cxx_types.long_long))
    p("HAVE_LONGDOUBLE", bool(cxx_types.long_double))

    max_align = 1
    aligns = {1: "char"}
    for name, type_ in cxx_types.types():
        if type_ is None:
            continue

        aligns.setdefault(type_.alignment, name)
        max_align = max(max_align, type_.alignment)
        write(name, type_)
    p("MAX_ALIGN", max_align)
    p("flx_aligns", aligns)
    p("arith_conv", cxx_types.conversion_map())

    c99_types = config_call("fbuild.config.c.stdlib.types", platform, lang.static)
    stddef_h = config_call("fbuild.config.c.stdlib.stddef_h", platform, lang.static)
    complex_h = config_call("fbuild.config.c.stdlib.complex_h", platform, lang.static)
    stdint_h = config_call("fbuild.config.c.stdlib.stdint_h", platform, lang.static)
    sys_types_h = config_call("fbuild.config.c.posix.sys_types_h", platform, lang.static)

    p("HAVE_STDINT", bool(stdint_h.header))
    p("HAVE_SYS_TYPES", bool(sys_types_h.header))

    # write out data for the types.
    for name, type_ in set(
        chain(
            cxx_types.types(),
            c99_types.types(),
            stddef_h.types(),
            complex_h.types(),
            stdint_h.types(),
            sys_types_h.types(),
        )
    ):
        if type_ is None:
            continue
        write(name, type_)

    if not stdint_h.header:
        if c99_types.long_long:
            p("ALIAS_intmax_t", "long long")
            p("ALIAS_uintmax_t", "unsigned long long")
        else:
            p("ALIAS_intmax_t", "long")
            p("ALIAS_uintmax_t", "unsigned long")

        visited = set()
        for name, type_ in cxx_types.int_types():
            if type_ is not None and type_ not in visited:
                visited.add(type_)
                if type_.signed:
                    p("ALIAS_int%s_t" % (type_.size * 8), name)
                else:
                    p("ALIAS_uint%s_t" % (type_.size * 8), name)

        p("ALIAS_intptr_t", cxx_types.structural_alias(cxx_types.voidp))
        p("ALIAS_uintptr_t", "unsigned " + cxx_types.structural_alias(cxx_types.voidp))

    if not sys_types_h.ssize_t:
        if c99_types.long_long and stddef_h.size_t.size == c99_types.long_long.size:
            p("ALIAS_ssize_t", "long long")
        else:
            p("ALIAS_ssize_t", "long")
Beispiel #27
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))
Beispiel #28
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))
Beispiel #29
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
Beispiel #30
0
def _print_cxx_bugs(ctx, platform, lang, p):
    compiler = config_call('fbuild.config.cxx.compiler.bugs', platform,
                           lang.static)

    p('HAVE_INCLASS_MEMBER_INITIALIZATION',
      compiler.class_member_intialization)
Beispiel #31
0
def _print_c99_support(platform, lang, p):
    stdio_h = config_call('fbuild.config.c.stdlib.stdio_h', platform,
                          lang.static)
    p('HAVE_VSNPRINTF', bool(stdio_h.vsnprintf))
Beispiel #32
0
def _print_compiler(ctx, lang, platform, p):
    # determine information about the compiler

    p("HAVE_PIC", "-fPIC" in lang.shared.compiler.flags)
    p("PIC", "-fPIC")

    static = lang.static
    shared = lang.shared

    if "windows" in platform:
        p("SPEC_OBJ_FILENAME", "/Fo")
        p("SPEC_EXE_FILENAME", "/Fe")

        p(
            "CCOBJ_STATIC_FLX",
            '"'
            + str(static.compiler.cl.exe)
            + '" /nologo /c '
            + " ".join(static.compiler.flags)
            + " "
            + " ".join("-I" + i for i in static.compiler.cl.includes),
        )

        p(
            "CCOBJ_DYNAMIC_FLX",
            '"'
            + str(shared.compiler.cl.exe)
            + '" /nologo /c '
            + " ".join(shared.compiler.flags)
            + " "
            + " ".join("-I" + i for i in static.compiler.cl.includes),
        )

        p(
            "CCLINK_STATIC",
            '"'
            + str(static.compiler.cl.exe)
            + '" /nologo '
            + " ".join(shared.exe_linker.flags)
            + " "
            + " ".join("-L" + i for i in static.exe_linker.libpaths),
        )

        p(
            "CCLINK_DYNAMIC_FLX",
            '"'
            + str(shared.compiler.cl.exe)
            + '" /nologo '
            + " ".join(shared.lib_linker.flags)
            + " "
            + " ".join("-L" + i for i in shared.lib_linker.libpaths),
        )
    else:
        p("SPEC_OBJ_FILENAME", "-o ")
        p("SPEC_EXE_FILENAME", "-o ")

        static_arch = static.compiler.cc.arch
        p(
            "CCOBJ_STATIC_FLX",
            str(static.compiler.cc.exe)
            + " -c "
            + " ".join(static.compiler.flags)
            + " "
            + " ".join("-I" + i for i in static.compiler.cc.includes)
            + " "
            + " ".join("-m" + i for i in static.compiler.cc.machine_flags)
            + " "
            + ("-arch " + static_arch if static_arch else "")
            + " "
            + " ".join("-W" + i for i in static.compiler.cc.warnings),
        )

        p(
            "CCLINK_STATIC",
            str(static.exe_linker.cc.exe)
            + " "
            + " ".join(shared.exe_linker.flags)
            + " "
            + " ".join("-m" + i for i in static.compiler.cc.machine_flags)
            + " "
            + ("-arch " + static_arch if static_arch else "")
            + " "
            + " ".join("-L" + i for i in static.exe_linker.cc.libpaths),
        )

        shared_arch = shared.compiler.cc.arch
        p(
            "CCOBJ_DYNAMIC_FLX",
            str(shared.compiler.cc.exe)
            + " -c "
            + " ".join(shared.compiler.flags)
            + " "
            + " ".join("-I" + i for i in shared.compiler.cc.includes)
            + " "
            + ("-arch " + shared_arch if shared_arch else "")
            + " "
            + " ".join("-m" + i for i in shared.compiler.cc.machine_flags)
            + " "
            + " ".join("-W" + i for i in static.compiler.cc.warnings),
        )

        p(
            "CCLINK_DYNAMIC_FLX",
            str(shared.lib_linker.cc.exe)
            + " "
            + " ".join(shared.lib_linker.flags)
            + " "
            + ("-arch " + shared_arch if shared_arch else "")
            + " "
            + " ".join("-m" + i for i in shared.compiler.cc.machine_flags)
            + " "
            + " ".join("-L" + i for i in shared.compiler.cc.libpaths),
        )

    p("EXT_STATIC_OBJ", fbuild.builders.platform.static_obj_suffix(ctx))
    p("EXT_SHARED_OBJ", fbuild.builders.platform.shared_obj_suffix(ctx))
    p("EXT_LIB", fbuild.builders.platform.static_lib_suffix(ctx))
    p("EXT_SHLIB", fbuild.builders.platform.shared_lib_suffix(ctx))
    p("EXT_EXE", fbuild.builders.platform.exe_suffix(ctx))

    if "windows" in platform:
        p("OPTIMISE", " ".join(static.compiler.cl.optimize_flags))
        p("DEBUG_FLAGS", " ".join(static.compiler.cl.debug_flags))
    else:
        p("OPTIMISE", " ".join(static.compiler.cc.optimize_flags))
        p("DEBUG_FLAGS", " ".join(static.compiler.cc.debug_flags))

    p("LITTLE_ENDIAN", config_call("fbuild.config.c.platform.arch", platform, static).little_endian)
Beispiel #33
0
def _print_c99_support(platform, lang, p):
    stdio_h = config_call('fbuild.config.c.stdlib.stdio_h',
        platform, lang.static)
    p('HAVE_VSNPRINTF', bool(stdio_h.vsnprintf))
Beispiel #34
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', True) #TARGET_CXX.options.SUPPORT_DYNAMIC_LOADING')

    p('if SUPPORT_DYNAMIC_LOADING:')
    p('  DEFAULT_LINK_MODEL', 'dynamic')
    p('else:')
    p('  DEFAULT_LINK_MODEL', 'static')
Beispiel #35
0
def _build_objs(host_phase, target_phase, builder, dstname):
    """
    Build the object files for Judy1 or JudyL. Unfortunately the judy build
    process is a little complicated because the same underlying code is used for
    bit arrays and word arrays. The only distinguishing feature is if the macro
    JUDY1 or JUDYL is defined. This function abstracts the handling of this
    distinction.
    """

    path = Path("src/judy/src")
    includes = [path, path / "JudyCommon", path / dstname]

    types = config_call("fbuild.config.c.c99.types", target_phase.platform, builder)

    macros = [dstname.upper()]
    if types.voidp.size == 8:
        macros.append("JU_64BIT")
    else:
        macros.append("JU_32BIT")

    kwargs = {}
    if "iphone" in target_phase.platform:
        kwargs["machine_flags"] = ["32"]

    # First, copy all the common files into the Judy* directory.
    srcs = []
    srcs.extend(
        copy_regex(
            target_phase.ctx,
            srcdir=path / "JudyCommon",
            dstdir=path / dstname,
            src_pattern=r"^Judy(.*\.c)",
            dst_pattern=r"%s\1" % dstname,
            exclude_pattern=r"("
            r"JudyMalloc.c|"
            r"JudyByCount.c|"
            r"JudyPrevNext.c|"
            r"JudyPrevNextEmpty.c|"
            r"JudyTables.c|"
            r"JudyPrintJP.c)",
        )
    )

    # Create the tablegen.
    tablegen = host_phase.c.static.build_exe(
        path / dstname / dstname + "TableGen",
        [copy(target_phase.ctx, src=path / "JudyCommon/JudyTables.c", dst=path / dstname / dstname + "TablesGen.c")],
        includes=includes,
        macros=macros,
        ckwargs=kwargs,
        lkwargs=kwargs,
    )

    # Create the table source.
    srcs.append(
        build_judytables(target_phase.ctx, tablegen, target_phase.ctx.buildroot / path / dstname / dstname + "Tables.c")
    )
    # Compile the objects.

    objs = []
    objs.extend(builder.build_objects(srcs, includes=includes, macros=macros))

    objs.extend(
        (
            builder.compile(
                path / "JudyCommon/JudyGet.c",
                dst=path / dstname / "j__udyGet.c",
                includes=includes,
                macros=macros + ["JUDYGETINLINE"],
            ),
            builder.compile(
                path / "JudyCommon/JudyPrevNext.c",
                dst=path / dstname / dstname + "Next.c",
                includes=includes,
                macros=macros + ["JUDYNEXT"],
            ),
            builder.compile(
                path / "JudyCommon/JudyPrevNextEmpty.c",
                dst=path / dstname / dstname + "NextEmpty.c",
                includes=includes,
                macros=macros + ["JUDYNEXT"],
            ),
            builder.compile(
                path / "JudyCommon/JudyPrevNext.c",
                dst=path / dstname / dstname + "Prev.c",
                includes=includes,
                macros=macros + ["JUDYPREV"],
            ),
            builder.compile(
                path / "JudyCommon/JudyPrevNextEmpty.c",
                dst=path / dstname / dstname + "PrevEmpty.c",
                includes=includes,
                macros=macros + ["JUDYPREV"],
            ),
            builder.compile(
                path / "JudyCommon/JudyByCount.c",
                path / dstname / dstname + "ByCount.c",
                includes=includes,
                macros=macros + ["NOSMARTJBB", "NOSMARTJBU", "NOSMARTJLB"],
            ),
        )
    )

    return objs
Beispiel #36
0
def build_runtime(phase):
    path = Path('src/demux')

    buildsystem.copy_hpps_to_rtl(phase.ctx,
        #phase.ctx.buildroot / 'config/target/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 = 'lib/rtl/demux'
    srcs = [path / '*.cpp']
    includes = [
        phase.ctx.buildroot / 'config/target',
        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))
Beispiel #37
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
Beispiel #38
0
def build_runtime(phase):
    path = Path('src/tre/tre')

    alloca_h = config_call('fbuild.config.c.malloc.alloca_h', phase.platform, phase.c.static)
    dlfcn_h = config_call('fbuild.config.c.posix.dlfcn_h', phase.platform, phase.c.static, phase.c.shared)
    getopt_h = config_call('fbuild.config.c.gnu.getopt_h', phase.platform, phase.c.static)
    inttypes_h = config_call('fbuild.config.c.posix.inttypes_h', phase.platform, phase.c.static)
    libutf8_h = config_call('fbuild.config.c.libutf8.libutf8_h', phase.platform, phase.c.static)
    memory_h = config_call('fbuild.config.c.bsd.memory_h', phase.platform, phase.c.static)
    regex_h = config_call('fbuild.config.c.posix.regex_h', phase.platform, phase.c.static)
    stdint_h = config_call('fbuild.config.c.c99.stdint_h', phase.platform, phase.c.static)
    stdlib_h = config_call('fbuild.config.c.posix.stdlib_h', phase.platform, phase.c.static)
    string_h = config_call('fbuild.config.c.c99.string_h', phase.platform, phase.c.static)
    strings_h = config_call('fbuild.config.c.posix.strings_h', phase.platform, phase.c.static)
    sys_stat_h = config_call('fbuild.config.c.posix.sys_stat_h', phase.platform, phase.c.static)
    sys_types_h = config_call('fbuild.config.c.posix.sys_types_h', phase.platform, phase.c.static)
    unistd_h = config_call('fbuild.config.c.posix.unistd_h', phase.platform, phase.c.static)
    wchar_h = config_call('fbuild.config.c.posix.wchar_h', phase.platform, phase.c.static)
    wctype_h = config_call('fbuild.config.c.posix.wctype_h', phase.platform, phase.c.static)

    if 'win32' in phase.platform:
        inline = '__inline'
    else:
        inline = None

    patterns = {
        'CRAY_STACKSEG_END': None,
        'C_ALLOCA': None,
        'ENABLE_NLS': 0,
        'HAVE_ALLOCA': alloca_h.alloca is not None,
        'HAVE_WCSLEN': wchar_h.wcslen is not None,
        'NDEBUG': 1,
        'HAVE_ALLOCA_H': alloca_h.header is not None,
        'HAVE_CFLOCALECOPYCURRENT': None,
        'HAVE_CFPREFERENCESCOPYAPPVALUE': None,
        'HAVE_DCGETTEXT': None,
        'HAVE_DLFCN_H': dlfcn_h.header is not None,
        'HAVE_GETOPT_H': getopt_h.header is not None ,
        'HAVE_GETOPT_LONG': getopt_h.getopt_long is not None,
        'HAVE_GETTEXT': None,
        'HAVE_ICONV': None,
        'HAVE_INTTYPES_H': inttypes_h.header is not None,
        'HAVE_ISASCII': 1,
        'HAVE_ISBLANK': 1,
        'HAVE_ISWASCII': wctype_h.iswascii is not None,
        'HAVE_ISWBLANK': wctype_h.iswblank is not None,
        'HAVE_ISWCTYPE': wctype_h.iswctype is not None,
        'HAVE_ISWLOWER': wctype_h.iswlower is not None,
        'HAVE_ISWUPPER': wctype_h.iswupper is not None,
        'HAVE_LIBUTF8_H': libutf8_h.header is not None,
        'HAVE_MBRTOWC': wchar_h.mbrtowc is not None,
        'HAVE_MBSTATE_T': wchar_h.mbstate_t is not None,
        'HAVE_MBTOWC': stdlib_h.mbtowc is not None,
        'HAVE_MEMORY_H': memory_h.header is not None,
        'HAVE_REGEX_H': regex_h.header is not None,
        'HAVE_REG_ERRCODE_T': regex_h.reg_errcode_t is not None,
        'HAVE_STDINT_H': stdint_h.header is not None,
        'HAVE_STDLIB_H': stdlib_h.header is not None,
        'HAVE_STRINGS_H': strings_h.header is not None,
        'HAVE_STRING_H': string_h.header is not None,
        'HAVE_SYS_STAT_H': sys_stat_h.header is not None,
        'HAVE_SYS_TYPES_H': sys_types_h.header is not None,
        'HAVE_TOWLOWER': wctype_h.towlower is not None,
        'HAVE_TOWUPPER': wctype_h.towupper is not None,
        'HAVE_UNISTD_H': unistd_h.header is not None,
        'HAVE_WCHAR_H': wchar_h.header is not None,
        'HAVE_WCHAR_T': wchar_h.wchar_t is not None,
        'HAVE_WCSCHR': wchar_h.wcschr is not None,
        'HAVE_WCSCPY': wchar_h.wcscpy is not None,
        'HAVE_WCSNCPY': wchar_h.wcsncpy is not None,
        'HAVE_WCSRTOMBS': wchar_h.wcsrtombs is not None,
        'HAVE_WCSTOMBS': stdlib_h.wcstombs is not None,
        'HAVE_WCTYPE': wctype_h.wctype is not None,
        'HAVE_WCTYPE_H': wctype_h.header is not None,
        'HAVE_WINT_T': wctype_h.wint_t is not None,
        'NO_MINUS_C_MINUS_O': None,
        'PACKAGE': '"tre"',
        'PACKAGE_TARNAME': '"tre"',
        'PACKAGE_VERSION': '"0.8.0"',
        'STACK_DIRECTION': None,
        'VERSION': '"0.8.0"',
        'PACKAGE_BUGREPORT': '"*****@*****.**"',
        'PACKAGE_NAME': '"TRE"',
        'PACKAGE_STRING': '"TRE 0.8.0"',
        'PACKAGE_TARFILE': 'tre',
        'STDC_HEADERS': 1,
        'TRE_APPROX': 1,
        'TRE_DEBUG': None,
        'TRE_MULTIBYTE': wchar_h.header is not None,
        'TRE_REGEX_T_FIELD': 'value',
        'TRE_SYSTEM_REGEX_H_PATH': None,
        'TRE_USE_ALLOCA': alloca_h.alloca is not None,
        'TRE_USE_SYSTEM_REGEX_H': None,
        'TRE_VERSION': '"0.8.0"',
        'TRE_VERSION_1': '0',
        'TRE_VERSION_2': '8',
        'TRE_VERSION_3': '0',
        'TRE_WCHAR': wchar_h.header is not None,
        'WCHAR_MAX': None,
        'WCHAR_T_SIGNED': None,
        'WCHAR_T_UNSIGNED': None,
        '_FILE_OFFSET_BITS': None,
        '_GNU_SOURCE': 1,
        '_LARGE_FILES': None,
        '_REGCOMP_INTERNAL': None,
        'const': None,
        'inline': inline,
    }

    fbuild.builders.text.autoconf_config_header(phase.ctx,
        path / 'config.h',
        path / 'config.h.in',
        patterns)

    fbuild.builders.text.autoconf_config_header(phase.ctx,
        path / 'lib/tre-config.h',
        path / 'lib/tre-config.h.in',
        patterns)

    buildsystem.copy_to(phase.ctx, phase.ctx.buildroot / 'lib/rtl/tre', [
        path / 'lib/tre.h',
        phase.ctx.buildroot / path / 'lib/tre-config.h'])

    dst = 'lib/rtl/tre'
    srcs = Path.glob('src/tre/tre/lib/*.c')
    includes = [
        phase.ctx.buildroot / 'config/target',
        phase.ctx.buildroot / path,
        phase.ctx.buildroot / path / 'lib',
        path / 'gnulib/lib',
    ]
    macros = ['HAVE_CONFIG_H', 'BUILD_TRE']

    #Workaround link error : unresolved external symbol _snprintf
    #referenced in function _tre_version.

    if 'win32' in phase.platform:
        macros.append('snprintf=_snprintf')

    return Record(
        static=buildsystem.build_c_static_lib(phase, dst, srcs,
            includes=includes,
            macros=macros),
        shared=buildsystem.build_c_shared_lib(phase, dst, srcs,
            includes=includes,
            macros=macros))
Beispiel #39
0
def test(ctx):
    """Run the felix tests and other commands."""

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

    from buildsystem.flx import test_flx, compile_flx

    failed = []

    def test(src):
        try:
            passed = test_flx(phases.target, felix, src)
        except fbuild.ConfigFailed as e:
            ctx.logger.log(str(e))
            passed = False
        return src, passed

    def test_compile(src):
        try:
            passed = compile_flx(phases.target, felix, src)
        except fbuild.ConfigFailed as e:
            ctx.logger.log(str(e))
            passed = False
        return src, passed

    # Run the dynamic loading tests first
    ctx.logger.log("\nRunning dynamic loading tests\n", color='red')
    try:
        lib1 = felix.compile('test/regress/drt/lib1.flx', static=False)
        lib2 = felix.compile('test/regress/drt/lib2.flx', static=False)
        print("lib1="+lib1)
        print("lib2="+lib2)
    except fbuild.ExecutionError as e:
        ctx.logger.log(e, verbose=1)
    else:
        if not test_flx(phases.target, felix, 'test/regress/drt/main1.flx',
                env={'lib1': lib1, 'lib2': lib2}):
            failed.append('test/regress/drt/main1.flx')

    srcs = [
      # CORE
      ('regress_rt' , Path.globall('test/regress/rt/*.flx')),
      ('regress_nd' , Path.globall('test/regress/nd/*.flx')),
      ('regress_stl' , Path.globall('test/regress/stl/*.flx')),

      ('tut_embedding' , Path.globall('tut/embedding/*.flx')),
      ('tut_migration', Path.globall('tut/migration/*.flx')),
      ('tut_tutorial', Path.globall('tut/tutorial/*.flx')),

      ('collection' , Path.globall('test/collection/*.flx')),
      #('drivers' , Path.globall('test/drivers/*.flx')),
      ('glob' , Path.globall('test/glob/*.flx')),
      ('judy' , Path.globall('test/judy/*.flx')),
      ('sqlite3' , Path.globall('test/sqlite/*.flx')),
      ('pthread' , Path.globall('test/pthread/*.flx')),
      ('stdlib' , Path.globall('test/stdlib/*.flx')),
      ('tre' , Path.globall('test/tre/*.flx')),
      ('web' , Path.globall('test/web/*.flx',exclude=['test/web/xml2-*.flx'])),

      # ASYNC I/O
      ('faio',Path.globall('test/faio/*.flx',exclude=['test/faio/posix-*.flx','test/faio/win-*.flx'])),
      ]

    gmp_h = config_call(
        'fbuild.config.c.gmp.gmp_h', 
        phases.target.platform,
        phases.target.c.static).header
    if gmp_h: ctx.logger.log("gmp supported",color='green')
    else: ctx.logger.log("gmp NOT supported",color='red')

    mman_h = config_call(
        'fbuild.config.c.posix04.sys_mman_h', 
        phases.target.platform,
        phases.target.c.static).header
    if mman_h: ctx.logger.log("mmap supported",color='green')
    else: ctx.logger.log("mmap NOT supported",color='red')

    libxml2_libxml_xmlexports_h = config_call(
        'fbuild.config.c.xml2.libxml2_libxml_xmlexports_h', 
        phases.target.platform,
        phases.target.c.static).header
    if libxml2_libxml_xmlexports_h: ctx.logger.log("libxml2 supported",color='green')
    else: ctx.logger.log("libxml2 NOT supported",color='red')

    zmq_h = config_call(
        'fbuild.config.c.zmq.zmq_h', 
        phases.target.platform,
        phases.target.c.static).header
    if zmq_h: ctx.logger.log("zmq supported",color='green')
    else: ctx.logger.log("zmq NOT supported",color='red')

    osrcs = [
      # EXTERNAL LIBS
      ('windows' in phases.target.platform,'faio_win', Path.globall('test/faio/win-*.flx')),
      ('posix' in phases.target.platform, 'faio_posix', Path.globall('test/faio/posix-*.flx')),
      (gmp_h,'gmp', Path.globall('test/gmp/*.flx')),
      (mman_h,'mmap', Path.globall('test/mmap/*.flx')),
      (libxml2_libxml_xmlexports_h,'xml2', Path.globall('test/web/xml2-*flx')),
      ]

    osrcs_compileonly = [
      (zmq_h,'zmq', Path.globall('test/zmq/*.flx')),
    ]
    #--------------------------------
    ctx.logger.log("\nRunning core tests\n", color='cyan')
    for name,paths in srcs:
      failed_srcs = []
      ctx.logger.log("Running test "+name, color='cyan')
      for src, passed in phases.target.ctx.scheduler.map(
          test,
          sorted(paths, reverse=True)):
        if not passed:
          failed_srcs.append(src)
          failed.append(src)

      if failed_srcs:
        ctx.logger.log('\nOf '+str (len (paths))+' tests')
        ctx.logger.log('\nThe following tests failed:')
        for src in failed_srcs:
          ctx.logger.log('  %s' % src, color='yellow')
      else:
        ctx.logger.log('All ' + str (len (paths))+' tests passed', color='cyan')

    ctx.logger.log("\nRunning optional tests\n", color='cyan')
    for flag,name,paths in osrcs:
      if flag:
        failed_srcs = []
        ctx.logger.log("Running test "+name, color='cyan')
        for src, passed in phases.target.ctx.scheduler.map(
            test,
            sorted(paths, reverse=True)):
          if not passed:
            failed_srcs.append(src)
            failed.append(src)

        if failed_srcs:
          ctx.logger.log('\nOf '+str (len (paths))+' tests')
          ctx.logger.log('\nThe following tests failed:')
          for src in failed_srcs:
            ctx.logger.log('  %s' % src, color='yellow')
        else:
          ctx.logger.log('All ' + str (len (paths))+' tests passed', color='cyan')
      else:
        ctx.logger.log("SKIPPING test "+name+" resource not availabe", color='red')

    ctx.logger.log("\nRunning optional compiler only tests\n", color='cyan')
    for flag,name,paths in osrcs_compileonly:
      if flag:
        failed_srcs = []
        ctx.logger.log("Compiling test "+name, color='cyan')
        for src, passed in phases.target.ctx.scheduler.map(
            test_compile,
            sorted(paths, reverse=True)):
          if not passed:
            failed_srcs.append(src)
            failed.append(src)

        if failed_srcs:
          ctx.logger.log('\nOf '+str (len (paths))+' tests')
          ctx.logger.log('\nThe following tests failed:')
          for src in failed_srcs:
            ctx.logger.log('  %s' % src, color='yellow')
        else:
          ctx.logger.log('All ' + str (len (paths))+' tests passed', color='cyan')
      else:
        ctx.logger.log("SKIPPING test "+name+" resource not availabe", color='red')


    if failed:
        ctx.logger.log('\n======================================')
        ctx.logger.log('\nThe following tests failed:')
        for src in failed:
            ctx.logger.log('  %s' % src, color='yellow')
Beispiel #40
0
def build_runtime(phase):
    path = Path('src/pthread')

    copy(ctx=phase.ctx,
         src="src/config/target/flx_pthread_config.hpp",
         dst=phase.ctx.buildroot / 'host/lib/rtl/flx_pthread_config.hpp')

    buildsystem.copy_hpps_to_rtl(
        phase.ctx,

        # portable
        path / 'pthread_thread.hpp',
        path / 'pthread_mutex.hpp',
        path / 'pthread_counter.hpp',
        path / 'pthread_waitable_bool.hpp',
        path / 'pthread_condv.hpp',
        path / 'pthread_semaphore.hpp',
        path / 'pthread_monitor.hpp',

        # win32 and posix
        path / 'pthread_win_posix_condv_emul.hpp',
    )

    srcs = [
        copy(ctx=phase.ctx, src=f, dst=phase.ctx.buildroot / f) for f in [
            path / 'pthread_win_posix_condv_emul.cpp',  # portability hackery
            path / 'pthread_mutex.cpp',
            path / 'pthread_condv.cpp',
            path / 'pthread_counter.cpp',
            path / 'pthread_waitable_bool.cpp',
            path / 'pthread_semaphore.cpp',
            path / 'pthread_monitor.cpp',
            path / 'pthread_thread_control.cpp',
            path / 'pthread_win_thread.cpp',
            path / 'pthread_posix_thread.cpp',
        ]
    ]
    includes = [
        phase.ctx.buildroot / 'host/lib/rtl',
        phase.ctx.buildroot / 'share/lib/rtl',
        'src/rtl',
    ]
    macros = ['BUILD_PTHREAD']
    flags = []
    libs = []
    external_libs = []

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

    dst = 'host/lib/rtl/flx_pthread'
    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=buildsystem.build_cxx_static_lib(phase,
                                                dst,
                                                srcs,
                                                includes=includes,
                                                macros=macros,
                                                cflags=flags,
                                                libs=libs,
                                                external_libs=external_libs,
                                                lflags=flags),
        shared=buildsystem.build_cxx_shared_lib(phase,
                                                dst,
                                                srcs,
                                                includes=includes,
                                                macros=macros,
                                                cflags=flags,
                                                libs=libs,
                                                external_libs=external_libs,
                                                lflags=flags))
Beispiel #41
0
def build_runtime(phase):
    path = Path("src/pthread")

    buildsystem.copy_hpps_to_rtl(
        phase.ctx,
        phase.ctx.buildroot / "config/target/flx_pthread_config.hpp",
        # portable
        path / "pthread_thread.hpp",
        path / "pthread_mutex.hpp",
        path / "pthread_counter.hpp",
        path / "pthread_waitable_bool.hpp",
        path / "pthread_condv.hpp",
        path / "pthread_semaphore.hpp",
        path / "pthread_monitor.hpp",
        path / "pthread_sleep_queue.hpp",
        path / "pthread_work_fifo.hpp",
        # win32 and posix
        path / "pthread_win_posix_condv_emul.hpp",
    )

    dst = "lib/rtl/flx_pthread"
    srcs = [
        path / "pthread_win_posix_condv_emul.cpp",  # portability hackery
        path / "pthread_mutex.cpp",
        path / "pthread_condv.cpp",
        path / "pthread_counter.cpp",
        path / "pthread_waitable_bool.cpp",
        path / "pthread_semaphore.cpp",
        path / "pthread_monitor.cpp",
        path / "pthread_sleep_queue.cpp",
        path / "pthread_work_fifo.cpp",
        path / "pthread_thread_control.cpp",
    ]
    includes = [phase.ctx.buildroot / "config/target", "src/rtl"]
    macros = ["BUILD_PTHREAD"]
    flags = []
    libs = []
    external_libs = []

    if "win32" in phase.platform:
        srcs.append(path / "pthread_win_thread.cpp")

    if "posix" in phase.platform:
        srcs.append(path / "pthread_posix_thread.cpp")

    pthread_h = config_call("fbuild.config.c.posix.pthread_h", phase.platform, phase.cxx.shared)

    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=buildsystem.build_cxx_static_lib(
            phase,
            dst,
            srcs,
            includes=includes,
            macros=macros,
            cflags=flags,
            libs=libs,
            external_libs=external_libs,
            lflags=flags,
        ),
        shared=buildsystem.build_cxx_shared_lib(
            phase,
            dst,
            srcs,
            includes=includes,
            macros=macros,
            cflags=flags,
            libs=libs,
            external_libs=external_libs,
            lflags=flags,
        ),
    )