Пример #1
0
 def _header_targets(self, name):
     if name not in self.__header_targets:
         include_dir = str(
             self.absolute_source_path('libs', name, 'include')
         )
         res = []
         for pat in ['*.h', '*.[hi]pp']:
             for h in tools.rglob(pat, include_dir):
                 res.append(self.build.fs.copy(
                     h,
                     dest = str(self.build_path(
                         'install',
                         'include',
                         path.relative(h, start = include_dir)
                     ))
                 ))
         self.__header_targets[name] = res
     return self.__header_targets[name]
Пример #2
0
def main(build):
    build_type = build.env.get('BUILD_TYPE', 'DEBUG')
    build.env.BUILD_TYPE = build_type
    status("Configuring project", build.env.NAME, '(%s)' % build.env.VERSION_NAME,
           'in', build.directory, '(%s)' % build_type)

    from configure.lang import cxx


    if build.env.BUILD_TYPE == 'DEBUG':
        defines = [
            'ETC_DEBUG',
            'CUBE_DEBUG',
            'CUBEAPP_DEBUG',
        ]
        optimization = cxx.compiler.Compiler.dont_optimize
    elif build.env.BUILD_TYPE == 'RELEASE':
        defines = ['NDEBUG']
        if platform.IS_WINDOWS:
            defines.append(('_SCL_SECURE', '0'))
        optimization = cxx.compiler.Compiler.optimize_fastest
    else:
        raise Exception("Unknown build type '%s'" % build_type)

    defines += ['BOOST_ALL_NO_LIB', 'GLEW_NO_GLU', 'GLM_FORCE_RADIANS', ]

    if platform.IS_WINDOWS:
        defines.extend([
            'NOMINMAX'
        #    ('_WIN32_WINNT', '0x0600'),
        #    ('WINVER', '0x0600'),
        ])
    #if platform.IS_LINUX:
    #    defines += ['CUBE_WITH_GLX']

    library_directories = [
        #'/home/hotgloupi/sandbox/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/libc/lib',
        #'/home/hotgloupi/sandbox/raspberry/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/arm-linux-gnueabihf/libc/lib/arm-linux-gnueabihf',
        #'/home/hotgloupi/sandbox/raspberry/root/usr/lib',
        #'/home/hotgloupi/sandbox/raspberry/root/usr/lib/arm-linux-gnueabihf',
    ]
    include_directories = [
        path.join(build.directory, 'src'),
#        '/home/hotgloupi/sandbox/raspberry/root/usr/include',
#        '/home/hotgloupi/sandbox/raspberry/root/usr/include/arm-linux-gnueabihf',
        path.absolute(build.project.directory, 'src'),
        path.absolute(build.project.directory, 'src/glew'),
    ]
    compiler = cxx.find_compiler(
        build,
        position_independent_code = True,
        standard = 'c++11',
        defines = defines,
        library_directories = library_directories,
        include_directories = include_directories,
        static_libstd = False,
        hidden_visibility = (build_type != 'DEBUG'),
        optimization = optimization,
        #force_architecture = True,
        #target_architecture = '32bit',
        forbidden_warnings = ['return-type',]
#        additional_link_flags = {
#            'gcc': ['-ldl', '-lpthread', '-lutil', '-lz', '-lX11', '-Xlinker', '-export-dynamic'],
#        }
    )

    c_compiler = c.find_compiler(
        build,
        force_architecture = False,
        optimization = optimization
    )

    status("Using %s as C++ compiler" % compiler)
    status("Using %s as C compiler" % c_compiler)

    freetype2 = build.add_dependency(
        c.libraries.FreetypeDependency,
        c_compiler,
        'deps/freetype2'
    )

    zlib = build.add_dependency(
        ZLibDependency,
        c_compiler,
        'deps/zlib-1.2.8'
    )

    bz2 = build.add_dependency(
        BZ2Dependency,
        c_compiler,
        'deps/bzip2-1.0.6',
    )

    if not platform.IS_WINDOWS:
        idn = build.add_dependency(
            IDNDependency,
            c_compiler,
            'deps/libidn-1.28',
        )
    else:
        idn = None

    curl = build.add_dependency(
        c.libraries.CURLDependency,
        c_compiler,
        "deps/curl-7.35.0",
        shared = False, #platform.IS_WINDOWS,
        with_ldap = False,
        with_ldaps = False,
        with_ftp = False,
        with_tftp = False,
        with_telnet = False,
        with_dict = False,
        with_file = False,
        with_cookies = True,
        idn = idn,
    )

    bullet_physics = build.add_dependency(
        BulletPhysics,
        compiler,
        "deps/bullet-2.82-r2704",
        shared = False, #platform.IS_WINDOWS,
    )

    librocket = build.add_dependency(
        LibRocketDependency,
        compiler,
        "deps/libRocket",
        c_compiler = c_compiler,
        freetype2 = freetype2,
        shared = False, #platform.IS_WINDOWS,
    )

    if platform.IS_WINDOWS:
        python = c.libraries.PythonLibrary(c_compiler, shared = True)
    else:
        python = build.add_dependency(
            c.libraries.PythonDependency,
            c_compiler,
            'deps/Python-v3.4.0',
            shared = False,
            version = (3, 4),
            pymalloc = False,
            with_valgrind_support = False,
            threads = False,
        )

    boost = build.add_dependency(
        cxx.libraries.BoostDependency,
        compiler,
        'deps/boost_1_57_0',
        version = (1, 57),
        python = python,
        export_python = True,
        components = [
            'format',
            'timer',
            'system',
            'filesystem',
            'python',
            'signals2',
            'thread',
            'coroutine',
            'context',
        ],
        #preferred_shared = False,
        #        python3_shared = True,
        #thread_shared = True,
    )

    glm = build.add_dependency(GLM, compiler, "deps/glm")

    # XXX needed ?
    compiler.include_directories.extend(tools.unique(
        sum((l.include_directories for l in boost.libraries),  [])
    ))

    assimp = build.add_dependency(
        Assimp,
        compiler,
        'deps/assimp',
        boost = boost,
        c_compiler = c_compiler,
        zlib = zlib,
        shared = False, #platform.IS_WINDOWS
    )

    if platform.IS_OSX and platform.OSX_VERSION_MAJOR <= 10 and platform.OSX_VERSION_MINOR <= 6:
         sdl = c.libraries.SDLLibrary(
             c_compiler,
             macosx_framework = True,
             search_macosx_framework_files = True
         )
    else:
        sdl = build.add_dependency(
            c.libraries.SDLDependency,
            c_compiler,
            'deps/SDL',
            shared = platform.IS_WINDOWS,
            audio = False,
            haptic = False, # Fails on windows
            dynamic_api = False,
        )
    sdl_image = build.add_dependency(
        c.libraries.SDLImageDependency, c_compiler, 'deps/SDL_image',
        sdl = sdl,
        shared = False
    )
    #sdl = c.libraries.SDLLibrary(
    #    compiler,
    #    components=['image'],
    #    shared=True
    #)

    opengl = c.libraries.OpenGLLibrary(
        compiler,
        system = True,
        shared = compiler.name != 'msvc'
    )

    graphic_libraries = (
        sdl.libraries +
        sdl_image.libraries +
        opengl.libraries +
        #assimp.libraries +
        freetype2.libraries +
        glm.libraries +
        bullet_physics.libraries +
        librocket.libraries
    )
    #if not platform.IS_WINDOWS:
    #    list(c.libraries.simple(s, compiler) for s in ['png', 'jpeg'])

    base_libraries = zlib.libraries + bz2.libraries
    if platform.IS_WINDOWS:
        base_libraries.extend(
            c.libraries.simple(name, compiler, system = True) for name in [
                'Shlwapi',
                'ws2_32',
                'Gdi32',
                'mswsock',
                'Dbghelp',
                'winmm',
                'version',
                'imm32',
                'Shell32',
                'User32',
                'Ole32',
                'OleAut32',
                'Advapi32',
                'Kernel32',
                'msvcrt',
                'msvcprt',
                #'libcmt'
            ]
        )
    else: # OSX and Linux
        if platform.IS_LINUX:
            base_libraries.extend(
                c.libraries.simple(name, compiler, system = True) for name in [
                    'rt',
                    'util',
                ]
            )
            # SDL audio disabled
            #base_libraries.extend(
            #    c.libraries.simple(name, compiler, system = True) for name in ['audio',]
            #)
        elif platform.IS_MACOSX:
            base_libraries.extend(
                c.libraries.simple(name, compiler, macosx_framework = True)
                for name in [
                    'ForceFeedback', 'IOKit', 'Cocoa', 'Carbon', 'CoreVideo'
                    # 'AudioUnit', 'CoreAudio', 'AudioToolbox', # SDL Audio disabled
                ]
            )

    libglew = compiler.link_static_library(
        'libglew',
        ['src/glew/glew.c'],
        directory = 'release/lib',
        libraries = opengl.libraries,
        defines = ['GLEW_NO_GLU', 'GLEW_STATIC'],
    )

    graphic_libraries.insert(0, libglew)


    precompiled_headers = []

    with_pch = False
    if with_pch:
        precompiled_headers.append(
            compiler.generate_precompiled_header(
                "src/wrappers/stl.hpp",
                force_include = True,
            )
        )

    base_libraries.extend([
        boost.component_library('filesystem'),
        boost.component_library('system'),
        boost.component_library('thread'),
        boost.component_library('coroutine'),
        boost.component_library('context'),
    ])
    libetc = compiler.link_library(
        'libetc',
        rglob("src/etc/*.cpp"),
        directory  = 'release/lib',
        libraries = base_libraries + curl.libraries,
        defines = ['ETC_BUILD_DYNAMIC_LIBRARY', ('CURL_STATICLIB', 1)],
        shared = True,
        precompiled_headers = precompiled_headers,
    )
    libetc_static = compiler.link_library(
        'libetc-static',
        rglob("src/etc/*.cpp"),
        directory  = 'release/lib',
        object_directory = 'etc-static',
        libraries = base_libraries + curl.libraries,
        defines = ['ETC_BUILD_STATIC_LIBRARY', ('CURL_STATICLIB', 1)],
        shared = False,
        position_independent_code = True,
        static_libstd = not platform.IS_MACOSX,
        precompiled_headers = precompiled_headers,
    )

################### libcube
    if with_pch:
        precompiled_headers.extend([
            compiler.generate_precompiled_header(
                "src/wrappers/boost/signals2.hpp",
                libraries = boost.libraries
            ),
        ])

    libcube_libs = base_libraries + [libetc] + assimp.libraries + graphic_libraries

    libcube = compiler.link_dynamic_library(
        'libcube',
        rglob("src/cube/*.cpp"),
        directory  = 'release/lib',
        libraries = libcube_libs,
        precompiled_headers = precompiled_headers,
        defines = ['CUBE_BUILD_DYNAMIC_LIBRARY', 'ROCKET_STATIC_LIB'],
    )


    if with_pch:
        precompiled_headers.extend([
            compiler.generate_precompiled_header(
                "src/wrappers/boost/python.hpp",
                libraries = boost.libraries + python.libraries,
            ),
        ])

    python_module_libraries = boost.libraries
    if platform.IS_WINDOWS:
        python_module_libraries.extend([libcube, libetc])
    for binding in rglob("cube/*.py++", dir='src'):
        t = compiler.link_dynamic_library(
            path.splitext(path.basename(binding))[0],
            [binding],
            ext = python.ext,
            directory = path.dirname("release/lib/python", binding[4:]),
            libraries = python_module_libraries + base_libraries,
            include_directories = glm.libraries[0].include_directories,
            precompiled_headers = precompiled_headers,
            allow_unresolved_symbols = True,
        )

################### libcubeapp

    libcubeapp = compiler.link_dynamic_library(
        'libcubeapp',
        (src for src in rglob("src/cubeapp/*.cpp") if not src.endswith('main.cpp')),
        directory  = 'release/lib',
        libraries = [libetc, libcube] + boost.libraries + glm.libraries,
        precompiled_headers = precompiled_headers,
        defines = ['CUBEAPP_BUILD_DYNAMIC_LIBRARY'],
    )

    for binding in rglob("cubeapp/*.py++", dir='src'):
        compiler.link_dynamic_library(
            path.splitext(path.basename(binding))[0],
            [binding],
            ext = python.ext,
            directory = path.dirname("release/lib/python", binding[4:]),
            libraries=[libcubeapp, libcube, libetc] + graphic_libraries + boost.libraries + base_libraries,
            precompiled_headers = precompiled_headers,
        )


    infinit_cube_libraries = [
        libcubeapp,
        libcube,
        libetc,
    ] + graphic_libraries + boost.libraries + base_libraries

    cube_exe = compiler.link_executable(
        "8cube",
        ["src/cubeapp/main.cpp"],
        directory = "release/bin",
        libraries = infinit_cube_libraries,
        export_libraries = [boost.component_library('python')],
    )



    if platform.IS_WINDOWS:
        seen = set()
        for lib in infinit_cube_libraries + assimp.libraries:
            if not isinstance(lib, Target):
                #print("lib %s" % lib.files, lib.shared, lib.system)
                if lib.shared and not lib.system:
                    for f in lib.files:
                        if f not in seen:
                            seen.add(f)
                            build.fs.copy(f, dest_dir = 'release/bin')
            else:
                if lib.shared:
                    if lib.path not in seen:
                        seen.add(lib.path)
                        build.fs.copy(lib, dest_dir = 'release/bin')


    exts = ['py', 'bmp', 'ttf', 'rml']

    for ext in exts:
        for src in rglob("cube/*.%s" % ext, dir = 'src'):
            build.fs.copy(src, 'release/lib/python/' + src[4:])
        for src in rglob("cubeapp/*.%s" % ext, dir = 'src'):
            build.fs.copy(src, 'release/lib/python/' + src[4:])


    import os
    for ext in exts:
        for src in rglob(path.join('share/games/default', '*.%s' % ext)):
            build.fs.copy(src, "release/" + src[6:])


    # Default game launcher
    #
    # By default, it will launch the default game (named "default"). The
    # environment variable "GAME_ID" is used takes precedence over the default
    # game
    #
    compiler.link_executable(
        "launch",
        list(rglob("*.cpp", dir = "src/launch")),
        directory = 'release/bin',
        defines = [('GAME_ID', "default"), 'ETC_STATIC_LIBRARY'],
        static_libstd = not platform.IS_MACOSX and not platform.IS_WINDOWS,
        libraries =
            [libetc_static] +
            base_libraries +
            (
                not platform.IS_WINDOWS and
                [c.libraries.simple('pthread', compiler, system = True)] or
                []
            ) +
            curl.libraries
    )

    tests = [
        'simple_window', 'cube/gl/shader_generator',
    ]
Пример #3
0
    def component_sources(self, component):
        if component in self.__component_sources:
            return self.__component_sources[component]

        srcs = None
        if component == 'thread':
            srcs = [
                'future.cpp',
            ]
            if not platform.IS_WINDOWS:
                srcs.extend([
                    'pthread/once.cpp',
                    'pthread/once_atomic.cpp',
                    'pthread/thread.cpp',
                ])
            else:
                srcs.extend([
                    'win32/thread.cpp',
                    'win32/tss_dll.cpp',
                    'win32/tss_pe.cpp',
                ])

        elif component == 'coroutine':
            srcs = [
                'exceptions.cpp',
                'detail/coroutine_context.cpp',
                #'detail/segmented_stack_allocator.cpp',
                (
                    platform.IS_WINDOWS and
                    'windows/stack_traits.cpp' or
                    'posix/stack_traits.cpp'
                ),
            ]
        elif component == 'context':
            all_srcs = [
                'asm/jump_arm_aapcs_elf_gas.S',
                'asm/jump_arm_aapcs_macho_gas.S',
                'asm/jump_arm_aapcs_pe_armasm.asm',
                'asm/jump_i386_ms_pe_masm.asm',
                'asm/jump_i386_sysv_elf_gas.S',
                'asm/jump_i386_sysv_macho_gas.S',
                'asm/jump_mips32_o32_elf_gas.S',
                'asm/jump_ppc32_sysv_elf_gas.S',
                'asm/jump_ppc64_sysv_elf_gas.S',
                'asm/jump_sparc64_sysv_elf_gas.S',
                'asm/jump_sparc_sysv_elf_gas.S',
                'asm/jump_x86_64_ms_pe_masm.asm',
                'asm/jump_x86_64_sysv_elf_gas.S',
                'asm/jump_x86_64_sysv_macho_gas.S',
                'asm/make_arm_aapcs_elf_gas.S',
                'asm/make_arm_aapcs_macho_gas.S',
                'asm/make_arm_aapcs_pe_armasm.asm',
                'asm/make_i386_ms_pe_masm.asm',
                'asm/make_i386_sysv_elf_gas.S',
                'asm/make_i386_sysv_macho_gas.S',
                'asm/make_mips32_o32_elf_gas.S',
                'asm/make_ppc32_sysv_elf_gas.S',
                'asm/make_ppc64_sysv_elf_gas.S',
                'asm/make_sparc64_sysv_elf_gas.S',
                'asm/make_sparc_sysv_elf_gas.S',
                'asm/make_x86_64_ms_pe_masm.asm',
                'asm/make_x86_64_sysv_elf_gas.S',
                'asm/make_x86_64_sysv_macho_gas.S',
            ]
            if platform.IS_WINDOWS:
                abi = 'ms'
            else:
                abi = 'sysv'
            processor = {
                'i386': 'i386',
                'i686': 'i386',
                'AMD64': 'i386',
                'x86_64': 'x86_64',
            }[platform.PROCESSOR]
            binary_format = platform.BINARY_FORMAT.lower()
            pattern = '_%s_%s_%s' % (processor, abi, binary_format)
            srcs = [s for s in all_srcs if pattern in s]
        elif component == 'serialization':
            srcs = [
                'basic_archive.cpp',
                'basic_iarchive.cpp',
                'basic_iserializer.cpp',
                'basic_oarchive.cpp',
                'basic_oserializer.cpp',
                'basic_pointer_iserializer.cpp',
                'basic_pointer_oserializer.cpp',
                'basic_serializer_map.cpp',
                'basic_text_iprimitive.cpp',
                'basic_text_oprimitive.cpp',
                'basic_xml_archive.cpp',
                'binary_iarchive.cpp',
                'binary_oarchive.cpp',
                'extended_type_info.cpp',
                'extended_type_info_typeid.cpp',
                'extended_type_info_no_rtti.cpp',
                'polymorphic_iarchive.cpp',
                'polymorphic_oarchive.cpp',
                'stl_port.cpp',
                'text_iarchive.cpp',
                'text_oarchive.cpp',
                'void_cast.cpp',
                'archive_exception.cpp',
                'xml_grammar.cpp',
                'xml_iarchive.cpp',
                'xml_oarchive.cpp',
                'xml_archive_exception.cpp',
            ]

        if srcs is not None:
            srcs = list(
                path.relative(
                    str(self.absolute_source_path('libs', component, 'src', src)),
                    start = self.project.directory
                ) for src in srcs
            )
        else:
            srcs = list(tools.rglob(
                '*.cpp',
                path.relative(
                    str(self.absolute_source_path('libs', component, 'src')),
                    start = self.project.directory
                )
            ))
        self.__component_sources[component] = srcs
        return srcs
Пример #4
0
def main(build):
    print("Configuring project", build.env.NAME, 'in', build.directory)
    for src in rglob('*.py', dir = 'src/'):
        build.fs.copy(src, src[4:])