Exemple #1
0
def _get_default_compiler(output):
    """
    find the default compiler on the build machine
    search order and priority:
    1. CC and CXX environment variables are always top priority
    2. Visual Studio detection (Windows only) via vswhere or registry or environment variables
    3. Apple Clang (Mac only)
    4. cc executable
    5. gcc executable
    6. clang executable
    """
    v2_mode = get_env(CONAN_V2_MODE_ENVVAR, False)
    cc = os.environ.get("CC", "")
    cxx = os.environ.get("CXX", "")
    if cc or cxx:  # Env defined, use them
        output.info("CC and CXX: %s, %s " % (cc or "None", cxx or "None"))
        command = cc or cxx
        if v2_mode:
            compiler = _get_compiler_and_version(output, command)
            if compiler:
                return compiler
        else:
            if "gcc" in command:
                gcc = _gcc_compiler(output, command)
                if platform.system() == "Darwin" and gcc is None:
                    output.error(
                        "%s detected as a frontend using apple-clang. "
                        "Compiler not supported" % command)
                return gcc
            if "clang" in command.lower():
                return _clang_compiler(output, command)
            if platform.system() == "SunOS" and command.lower() == "cc":
                return _sun_cc_compiler(output, command)
        # I am not able to find its version
        output.error("Not able to automatically detect '%s' version" % command)
        return None

    vs = cc = sun_cc = None
    if detected_os() == "Windows":
        version = latest_visual_studio_version_installed(output)
        vs = ('Visual Studio', version) if version else None

    if v2_mode:
        cc = _get_compiler_and_version(output, "cc")
        gcc = _get_compiler_and_version(output, "gcc")
        clang = _get_compiler_and_version(output, "clang")
    else:
        gcc = _gcc_compiler(output)
        clang = _clang_compiler(output)
        if platform.system() == "SunOS":
            sun_cc = _sun_cc_compiler(output)

    if detected_os() == "Windows":
        return vs or cc or gcc or clang
    elif platform.system() == "Darwin":
        return clang or cc or gcc
    elif platform.system() == "SunOS":
        return sun_cc or cc or gcc or clang
    else:
        return cc or gcc or clang
Exemple #2
0
def _detect_os_arch(result, output):
    architectures = {
        'i386': 'x86',
        'i686': 'x86',
        'i86pc': 'x86',
        'amd64': 'x86_64',
        'aarch64': 'armv8',
        'sun4v': 'sparc'
    }
    the_os = detected_os()
    result.append(("os", the_os))
    result.append(("os_build", the_os))

    platform_machine = platform.machine().lower()
    if platform_machine:
        arch = architectures.get(platform_machine, platform_machine)
        if arch.startswith('arm'):
            for a in ("armv6", "armv7hf", "armv7", "armv8"):
                if arch.startswith(a):
                    arch = a
                    break
            else:
                output.error(
                    "Your ARM '%s' architecture is probably not defined in settings.yml\n"
                    "Please check your conan.conf and settings.yml files" %
                    arch)
        elif arch.startswith('e2k'):
            arch = OSInfo.get_e2k_architecture() or arch
        elif OSInfo().is_aix:
            arch = OSInfo.get_aix_architecture() or arch

        result.append(("arch", arch))
        result.append(("arch_build", arch))
Exemple #3
0
def _detect_os_arch(result, output):
    from conans.client.conf import get_default_settings_yml
    from conans.model.settings import Settings

    the_os = detected_os()
    result.append(("os", the_os))
    result.append(("os_build", the_os))

    arch = detected_architecture()

    if arch:
        if arch.startswith('arm'):
            settings = Settings.loads(get_default_settings_yml())
            defined_architectures = settings.arch.values_range
            defined_arm_architectures = [
                v for v in defined_architectures if v.startswith("arm")
            ]

            for a in defined_arm_architectures:
                if arch.startswith(a):
                    arch = a
                    break
            else:
                output.error(
                    "Your ARM '%s' architecture is probably not defined in settings.yml\n"
                    "Please check your conan.conf and settings.yml files" %
                    arch)

        result.append(("arch", arch))
        result.append(("arch_build", arch))
Exemple #4
0
def _detect_os_arch(result, output):
    architectures = {'i386': 'x86',
                     'i686': 'x86',
                     'i86pc': 'x86',
                     'amd64': 'x86_64',
                     'aarch64': 'armv8',
                     'sun4v': 'sparc'}
    the_os = detected_os()
    result.append(("os", the_os))
    result.append(("os_build", the_os))

    platform_machine = platform.machine().lower()
    if platform_machine:
        arch = architectures.get(platform_machine, platform_machine)
        if arch.startswith('arm'):
            for a in ("armv6", "armv7hf", "armv7", "armv8"):
                if arch.startswith(a):
                    arch = a
                    break
            else:
                output.error("Your ARM '%s' architecture is probably not defined in settings.yml\n"
                             "Please check your conan.conf and settings.yml files" % arch)
        elif the_os == 'AIX':
            processor = platform.processor()
            if "powerpc" in processor:
                kernel_bitness = OSInfo().get_aix_conf("KERNEL_BITMODE")
                if kernel_bitness:
                    arch = "ppc64" if kernel_bitness == "64" else "ppc32"
            elif "rs6000" in processor:
                arch = "ppc32"

        result.append(("arch", arch))
        result.append(("arch_build", arch))
Exemple #5
0
def _get_default_compiler(output):
    cc = os.environ.get("CC", "")
    cxx = os.environ.get("CXX", "")
    if cc or cxx:  # Env defined, use them
        output.info("CC and CXX: %s, %s " % (cc or "None", cxx or "None"))
        command = cc or cxx
        if "gcc" in command:
            gcc = _gcc_compiler(output, command)
            if platform.system() == "Darwin" and gcc is None:
                output.error(
                    "%s detected as a frontend using apple-clang. Compiler not supported"
                    % command)
            return gcc
        if "clang" in command.lower():
            return _clang_compiler(output, command)
        if platform.system() == "SunOS" and command.lower() == "cc":
            return _sun_cc_compiler(output, command)
        # I am not able to find its version
        output.error("Not able to automatically detect '%s' version" % command)
        return None

    if detected_os() == "Windows":
        version = latest_visual_studio_version_installed(output)
        vs = ('Visual Studio', version) if version else None
    gcc = _gcc_compiler(output)
    clang = _clang_compiler(output)
    if platform.system() == "SunOS":
        sun_cc = _sun_cc_compiler(output)

    if detected_os() == "Windows":
        return vs or gcc or clang
    elif platform.system() == "Darwin":
        return clang or gcc
    elif platform.system() == "SunOS":
        return sun_cc or gcc or clang
    else:
        return gcc or clang