Пример #1
0
def mkspec_get_toolchain_paths(conf):
    """
    :return: the common paths where we may find the g++ binary
    """
    # The default path to search
    path_list = os.environ.get('PATH', '').split(os.pathsep)

    if conf.is_mkspec_platform('mac'):

        # If the compiler is installed using macports
        path_list += ['/opt/local/bin']

    if conf.is_mkspec_platform('android'):
        # If specified, the android_ndk_dir option overrides the OS path
        if conf.has_tool_option('android_ndk_dir'):
            ndk = conf.get_tool_option('android_ndk_dir')
            ndk = os.path.abspath(os.path.expanduser(ndk))
            ndk_path = [ndk, os.path.join(ndk, 'bin')]
            return ndk_path

    if conf.is_mkspec_platform('ios'):
        if conf.has_tool_option('ios_toolchain_dir'):
            toolchain = conf.get_tool_option('ios_toolchain_dir')
        else:
            toolchain = "/Applications/Xcode.app/Contents/Developer/" \
                        "Toolchains/XcodeDefault.xctoolchain/usr/bin/"
        toolchain = os.path.abspath(os.path.expanduser(toolchain))
        #toolchain_path = [toolchain, os.path.join(toolchain,'bin')]

        return toolchain

    return path_list
Пример #2
0
def mkspec_get_toolchain_paths(conf):
    """
    Return the common paths where the g++ binaries are located.

    :return: the common paths where we may find the g++ binary
    """
    # The default path to search
    path_list = os.environ.get('PATH', '').split(os.pathsep)

    if conf.is_mkspec_platform('mac'):

        # If the compiler is installed using macports
        path_list += ['/opt/local/bin']

    if conf.is_mkspec_platform('android'):
        # If specified, the android_ndk_dir option overrides the OS path
        if conf.has_tool_option('android_ndk_dir'):
            ndk = conf.get_tool_option('android_ndk_dir')
            ndk = os.path.abspath(os.path.expanduser(ndk))
            ndk_path = [ndk, os.path.join(ndk, 'bin')]
            return ndk_path

    if conf.is_mkspec_platform('ios'):
        if conf.has_tool_option('ios_toolchain_dir'):
            toolchain = conf.get_tool_option('ios_toolchain_dir')
        else:
            toolchain = "/Applications/Xcode.app/Contents/Developer/" \
                        "Toolchains/XcodeDefault.xctoolchain/usr/bin/"
        toolchain = os.path.abspath(os.path.expanduser(toolchain))

        return toolchain

    return path_list
Пример #3
0
def mkspec_get_gnu_binary_name(conf, base, major, minor, prefix=None):
    """
    :param base:    'gcc' or 'g++'
    :param major:   The major version number of the g++/gcc binary e.g. 4
    :param minor:   The minor version number of the g++/gcc binary e.g. 6
    :param prefix:  Prefix to compiler name, e.g. 'arm-linux-androideabi'
    :return:        A list with names of the g++ binary we are looking for,
                    e.g. ['g++-4.6', 'g++-mp-4.6'] for g++ version 4.6 on
                    mac/darwin
    """

    # First the default case
    binary = ['{0}-{1}.{2}'.format(base, major, minor)]

    if prefix:
        # Toolchains use a specific prefix
        return ['{0}-{1}'.format(prefix, base)]

    if conf.is_mkspec_platform('mac'):

        # If the compiler is installed using macports
        return binary + ['{0}-mp-{1}.{2}'.format(base, major, minor)]

    if conf.is_mkspec_platform('windows'):

        # On Windows, all binaries are named the same
        # for all g++ versions
        return [base]

    return binary
Пример #4
0
def mkspec_get_gnu_binary_name(conf, base, major, minor, prefix=None):
    """
    :param base:    'gcc' or 'g++'
    :param major:   The major version number of the g++/gcc binary e.g. 4
    :param minor:   The minor version number of the g++/gcc binary e.g. 6
    :param prefix:  Prefix to compiler name, e.g. 'arm-linux-androideabi'
    :return:        A list with names of the g++ binary we are looking for,
                    e.g. ['g++-4.6', 'g++-mp-4.6'] for g++ version 4.6 on
                    mac/darwin
    """

    # First the default case
    binary = ['{0}-{1}.{2}'.format(base, major, minor)]

    if prefix:
        # Toolchains use a specific prefix
        return ['{0}-{1}'.format(prefix, base)]

    if conf.is_mkspec_platform('mac'):

        # If the compiler is installed using macports
        return binary + ['{0}-mp-{1}.{2}'.format(base, major, minor)]

    if conf.is_mkspec_platform('windows'):

        # On Windows, all binaries are named the same
        # for all g++ versions
        return [base]

    return binary
Пример #5
0
def mkspec_get_toolchain_paths(conf):
    """
    :return: the common paths where we may find the g++ binary
    """
    # The default path to search
    path_list = os.environ.get("PATH", "").split(os.pathsep)

    if conf.is_mkspec_platform("mac"):

        # If the compiler is installed using macports
        path_list += ["/opt/local/bin"]

    if conf.is_mkspec_platform("android"):
        # If specified, the android_ndk_dir option overrides the OS path
        if conf.has_tool_option("android_ndk_dir"):
            ndk = conf.get_tool_option("android_ndk_dir")
            ndk = os.path.abspath(os.path.expanduser(ndk))
            ndk_path = [ndk, os.path.join(ndk, "bin")]
            return ndk_path

    if conf.is_mkspec_platform("ios"):
        if conf.has_tool_option("ios_toolchain_dir"):
            toolchain = conf.get_tool_option("ios_toolchain_dir")
        else:
            toolchain = "/Applications/Xcode.app/Contents/Developer/" "Toolchains/XcodeDefault.xctoolchain/usr/bin/"
        toolchain = os.path.abspath(os.path.expanduser(toolchain))
        # toolchain_path = [toolchain, os.path.join(toolchain,'bin')]

        return toolchain

    return path_list
Пример #6
0
def mkspec_set_clang_cxxflags(conf, force_debug=False):

    optflag = '-O2'
    # Use -Os (optimize for size) flag on iOS, because -O2 produces unstable
    # code on this platform
    if conf.get_mkspec_platform() == 'ios':
        optflag = '-Os'
    conf.env['CXXFLAGS'] += [optflag, '-Wextra', '-Wall']

    if conf.has_tool_option('cxx_debug') or force_debug:
        conf.env['CXXFLAGS'] += ['-g']
    elif not conf.get_mkspec_platform() in ['mac', 'ios']:
        conf.env['LINKFLAGS'] += ['-s']

    if conf.has_tool_option('cxx_nodebug'):
        conf.env['DEFINES'] += ['NDEBUG']

    # Use the more restrictive c++0x option for linux
    if conf.is_mkspec_platform('linux'):
        conf.env['CXXFLAGS'] += ['-std=c++0x']
    else:
        # Other platforms might need some non-standard functions
        # therefore we use gnu++0x
        # For Android see: http://stackoverflow.com/questions/9247151
        # For MinGW: http://stackoverflow.com/questions/6312151
        conf.env['CXXFLAGS'] += ['-std=gnu++0x']

    # To enable the latest standard on Mac OSX
    #conf.env['CXXFLAGS'] += ['-std=gnu++11']

    # Use clang's own C++ standard library on Mac OSX and iOS
    # Add other platforms when the library becomes stable there
    if conf.get_mkspec_platform() in ['mac', 'ios']:
        conf.env['CXXFLAGS'] += ['-stdlib=libc++']
        conf.env['LINKFLAGS'] += ['-lc++']
Пример #7
0
def mkspec_get_toolchain_paths(conf):
    """
    Return the common paths where the g++ binaries are located.

    :return: the common paths where we may find the g++ binary
    """
    # The default path to search
    path_list = os.environ.get("PATH", "").split(os.pathsep)

    if conf.is_mkspec_platform("mac"):

        # If the compiler is installed using macports
        path_list += ["/opt/local/bin"]

    if conf.is_mkspec_platform("android"):
        # If specified, the android_ndk_dir option overrides the OS path
        if conf.has_tool_option("android_ndk_dir"):
            ndk = conf.get_tool_option("android_ndk_dir")
            ndk = os.path.abspath(os.path.expanduser(ndk))
            ndk_path = [ndk, os.path.join(ndk, "bin")]
            return ndk_path

    if conf.is_mkspec_platform("ios"):
        if conf.has_tool_option("ios_toolchain_dir"):
            toolchain = conf.get_tool_option("ios_toolchain_dir")
        else:
            toolchain = ("/Applications/Xcode.app/Contents/Developer/"
                         "Toolchains/XcodeDefault.xctoolchain/usr/bin/")
        toolchain = os.path.abspath(os.path.expanduser(toolchain))

        return toolchain

    if conf.has_tool_option("poky_sdk_path"):
        sdk_path = conf.get_tool_option("poky_sdk_path")
        cross_compiler = os.path.join(
            sdk_path,
            "sysroots",
            "x86_64-pokysdk-linux",
            "usr",
            "bin",
            "arm-poky-linux-gnueabi",
        )

        path_list = [cross_compiler] + path_list

    return path_list
Пример #8
0
def cxx_msvc11_x64(conf):
    """
    Detect and setup the Microsoft Visual C++ 2012 compiler for 64-bit windows
    """
    if conf.is_mkspec_platform("windows"):
        conf.env.MSVC_TARGETS = ["x86_amd64"]
        conf.mkspec_msvc_configure("11.0")
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(conf.get_mkspec_platform()))
Пример #9
0
def cxx_apple_llvm130_x64(conf):
    """
    Detect and setup the 64-bit Apple LLVM 13.0 compiler
    """
    if conf.is_mkspec_platform("mac"):
        conf.mkspec_clang_configure(13, 0)
        conf.mkspec_add_common_flag("-m64")
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #10
0
def cxx_msvc12_x64(conf):
    """
    Detect and setup the Microsoft Visual C++ 2013 compiler for 64-bit windows
    """
    if conf.is_mkspec_platform("windows"):
        conf.env.MSVC_TARGETS = ["x86_amd64"]
        conf.mkspec_msvc_configure("12.0")
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #11
0
def cxx_msvc12_x64(conf):
    """
    Detect and setup the Microsoft Visual C++ 2013 compiler for 64-bit windows
    """
    if conf.is_mkspec_platform('windows'):
        conf.env.MSVC_TARGETS = ['x86_amd64']
        conf.mkspec_msvc_configure('12.0')
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #12
0
def cxx_msvc11_x64(conf):
    """
    Detect and setup the Microsoft Visual C++ 2012 compiler for 64-bit windows
    """
    if conf.is_mkspec_platform('windows'):
        conf.env.MSVC_TARGETS = ['x86_amd64']
        conf.mkspec_msvc_configure('11.0')
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #13
0
def cxx_apple_llvm50_x86(conf):
    """
    Detect and setup the 32-bit Apple llvm 5.0 compiler (clang 3.3)
    """
    if conf.is_mkspec_platform('mac'):
        conf.mkspec_clang_configure(5, 0)
        conf.mkspec_add_common_flag('-m32')
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #14
0
def cxx_apple_llvm100_x64(conf):
    """
    Detect and setup the 64-bit Apple LLVM 10.0 compiler
    """
    if conf.is_mkspec_platform('mac'):
        conf.mkspec_clang_configure(10, 0)
        conf.mkspec_add_common_flag('-m64')
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #15
0
def cxx_apple_llvm50_x86(conf):
    """
    Detect and setup the 32-bit Apple llvm 5.0 compiler (clang 3.3)
    """
    if conf.is_mkspec_platform('mac'):
        conf.mkspec_clang_configure(5, 0)
        conf.mkspec_add_common_flag('-m32')
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #16
0
def cxx_apple_llvm42_x64(conf):
    """
    Detect and setup the 64-bit Apple llvm 4.2 compiler (clang 3.2)
    """
    if conf.is_mkspec_platform('mac'):
        conf.mkspec_clang_configure(4, 2)
        conf.mkspec_add_common_flag('-m64')
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #17
0
def cxx_apple_llvm42_x64(conf):
    """
    Detect and setup the 64-bit Apple llvm 4.2 compiler (clang 3.2)
    """
    if conf.is_mkspec_platform('mac'):
        conf.mkspec_clang_configure(4, 2)
        conf.mkspec_add_common_flag('-m64')
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #18
0
def mkspec_get_toolchain_paths(conf):
    """
    Return the common paths where the g++ binaries are located.

    :return: the common paths where we may find the g++ binary
    """
    # The default path to search
    path_list = os.environ.get('PATH', '').split(os.pathsep)

    if conf.is_mkspec_platform('mac'):

        # If the compiler is installed using macports
        path_list += ['/opt/local/bin']

    if conf.is_mkspec_platform('android'):
        # If specified, the android_ndk_dir option overrides the OS path
        if conf.has_tool_option('android_ndk_dir'):
            ndk = conf.get_tool_option('android_ndk_dir')
            ndk = os.path.abspath(os.path.expanduser(ndk))
            ndk_path = [ndk, os.path.join(ndk, 'bin')]
            return ndk_path

    if conf.is_mkspec_platform('ios'):
        if conf.has_tool_option('ios_toolchain_dir'):
            toolchain = conf.get_tool_option('ios_toolchain_dir')
        else:
            toolchain = "/Applications/Xcode.app/Contents/Developer/" \
                        "Toolchains/XcodeDefault.xctoolchain/usr/bin/"
        toolchain = os.path.abspath(os.path.expanduser(toolchain))

        return toolchain

    if conf.has_tool_option('poky_sdk_path'):
        sdk_path = conf.get_tool_option('poky_sdk_path')
        cross_compiler = os.path.join(sdk_path, 'sysroots',
                                      'x86_64-pokysdk-linux', 'usr', 'bin',
                                      'arm-poky-linux-gnueabi')

        path_list = [cross_compiler] + path_list

    return path_list
Пример #19
0
def cxx_msvc15_x86(conf):
    """
    Configure the Visual Studio 2017 (version 15.x) compiler for 32-bit
    """
    if conf.is_mkspec_platform('windows'):
        # Use the native x86 toolchain when available, future versions of
        # Visual Studio might only provide amd64_x86, which is a 64-bit
        # compiler that cross-compiles to 32-bit
        conf.env.MSVC_TARGETS = ['x86', 'amd64_x86']
        version = conf.mkspec_find_installed_msvc_version(15)
        conf.mkspec_msvc_configure(version)
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #20
0
def cxx_msvc15_x86(conf):
    """
    Configure the Visual Studio 2017 (version 15.x) compiler for 32-bit
    """
    if conf.is_mkspec_platform("windows"):
        # Use the native x86 toolchain when available, future versions of
        # Visual Studio might only provide amd64_x86, which is a 64-bit
        # compiler that cross-compiles to 32-bit
        conf.env.MSVC_TARGETS = ["x86", "amd64_x86"]
        version = conf.mkspec_find_installed_msvc_version(15)
        conf.mkspec_msvc_configure(version)
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #21
0
def mkspec_get_clang_binary_name(conf, major, minor):
    """
    :param major:  The major version number of the clang binary e.g. 3
    :param minor:  The minor version number of the clang binary e.g. 4
    :return:       A list with names of the clang binary we are looking for,
                   e.g. ['clang34'] for clang 3.4 on Android
    """

    if conf.is_mkspec_platform('android'):
        # The numbered clang is the only real binary in the Android toolchain
        return ['clang{0}{1}'.format(major, minor)]

    # The default case works fine on all other platforms
    return ['clang']
Пример #22
0
def cxx_msvc15_x64(conf):
    """
    Configure the Visual Studio 2017 (version 15.x) compiler for 64-bit
    """
    if conf.is_mkspec_platform('windows'):
        # The x64 native toolchain is preferred over the x86_amd64 toolchain
        # which is a 32-bit compiler that cross-compiles to 64-bit (Visual
        # Studio 2017 Express only provides x86_amd64, but other versions
        # provide both options)
        conf.env.MSVC_TARGETS = ['x64', 'x86_amd64']
        version = conf.mkspec_find_installed_msvc_version(15)
        conf.mkspec_msvc_configure(version)
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #23
0
def cxx_msvc16_x64(conf):
    """
    Configure the Visual Studio 2019 (version 16.x) compiler for 64-bit
    """
    if conf.is_mkspec_platform("windows"):
        # The x64 native toolchain is preferred over the x86_amd64 toolchain
        # which is a 32-bit compiler that cross-compiles to 64-bit (Visual
        # Studio 2017 Express only provides x86_amd64, but other versions
        # provide both options)
        conf.env.MSVC_TARGETS = ["x64", "x86_amd64"]
        version = conf.mkspec_find_installed_msvc_version(16)
        conf.mkspec_msvc_configure(version)
    else:
        conf.fatal("This mkspec is not supported on {0}.".format(
            conf.get_mkspec_platform()))
Пример #24
0
def mkspec_set_gxx_cxxflags(conf):

    conf.env['CXXFLAGS'] += ['-O2', '-ftree-vectorize', '-Wextra', '-Wall']

    if conf.has_tool_option('cxx_debug'):
        conf.env['CXXFLAGS'] += ['-g']
    elif not conf.get_mkspec_platform() in ['mac', 'ios']:
        conf.env['LINKFLAGS'] += ['-s']

    if conf.has_tool_option('cxx_nodebug'):
        conf.env['DEFINES'] += ['NDEBUG']

    # Use the more restrictive c++0x option for linux
    if conf.is_mkspec_platform('linux'):
        conf.env['CXXFLAGS'] += ['-std=c++0x']
    else:
        # Other platforms might need some non-standard functions
        # therefore we use gnu++0x
        # For Android see: http://stackoverflow.com/questions/9247151
        # For MinGW: http://stackoverflow.com/questions/6312151
        conf.env['CXXFLAGS'] += ['-std=gnu++0x']
Пример #25
0
def mkspec_set_gxx_cxxflags(conf):

    conf.env['CXXFLAGS'] += ['-O2', '-ftree-vectorize', '-Wextra', '-Wall']

    if conf.has_tool_option('cxx_debug'):
        conf.env['CXXFLAGS'] += ['-g']
    elif not conf.get_mkspec_platform() in ['mac', 'ios']:
        conf.env['LINKFLAGS'] += ['-s']

    if conf.has_tool_option('cxx_nodebug'):
        conf.env['DEFINES'] += ['NDEBUG']

    # Use the more restrictive c++0x option for linux
    if conf.is_mkspec_platform('linux'):
        conf.env['CXXFLAGS'] += ['-std=c++0x']
    else:
        # Other platforms might need some non-standard functions
        # therefore we use gnu++0x
        # For Android see: http://stackoverflow.com/questions/9247151
        # For MinGW: http://stackoverflow.com/questions/6312151
        conf.env['CXXFLAGS'] += ['-std=gnu++0x']