Ejemplo n.º 1
0
def _sun_cc_compiler(output, compiler_exe="cc"):
    try:
        _, out = detect_runner('%s -V' % compiler_exe)
        compiler = "sun-cc"
        installed_version = re.search("([0-9]+\.[0-9]+)", out).group()
        if installed_version:
            output.success("Found %s %s" % (compiler, installed_version))
            return compiler, installed_version
    except Exception:
        return None
Ejemplo n.º 2
0
def _detect_gcc_libcxx(executable, version, output, profile_name,
                       profile_path):
    # Assumes a working g++ executable
    new_abi_available = Version(version) >= Version("5.1")
    if not new_abi_available:
        return "libstdc++"

    if not get_env(CONAN_V2_MODE_ENVVAR, False):
        msg = textwrap.dedent("""
            Conan detected a GCC version > 5 but has adjusted the 'compiler.libcxx' setting to
            'libstdc++' for backwards compatibility.
            Your compiler is likely using the new CXX11 ABI by default (libstdc++11).

            If you want Conan to use the new ABI for the {profile} profile, run:

                $ conan profile update settings.compiler.libcxx=libstdc++11 {profile}

            Or edit '{profile_path}' and set compiler.libcxx=libstdc++11
            """.format(profile=profile_name, profile_path=profile_path))
        output.writeln(
            "\n************************* WARNING: GCC OLD ABI COMPATIBILITY "
            "***********************\n %s\n************************************"
            "************************************************\n\n\n" % msg,
            Color.BRIGHT_RED)
        return "libstdc++"

    main = textwrap.dedent("""
        #include <string>

        using namespace std;
        static_assert(sizeof(std::string) != sizeof(void*), "using libstdc++");
        int main(){}
        """)
    t = tempfile.mkdtemp()
    filename = os.path.join(t, "main.cpp")
    save(filename, main)
    old_path = os.getcwd()
    os.chdir(t)
    try:
        error, out_str = detect_runner("%s main.cpp -std=c++11" % executable)
        if error:
            if "using libstdc++" in out_str:
                output.info("gcc C++ standard library: libstdc++")
                return "libstdc++"
            # Other error, but can't know, lets keep libstdc++11
            output.warn("compiler.libcxx check error: %s" % out_str)
            output.warn(
                "Couldn't deduce compiler.libcxx for gcc>=5.1, assuming libstdc++11"
            )
        else:
            output.info("gcc C++ standard library: libstdc++11")
        return "libstdc++11"
    finally:
        os.chdir(old_path)
Ejemplo n.º 3
0
def _gcc_compiler(output, compiler_exe="gcc"):

    try:
        if platform.system() == "Darwin":
            # In Mac OS X check if gcc is a fronted using apple-clang
            _, out = detect_runner("%s --version" % compiler_exe)
            out = out.lower()
            if "clang" in out:
                return None

        ret, out = detect_runner('%s -dumpversion' % compiler_exe)
        if ret != 0:
            return None
        compiler = "gcc"
        installed_version = re.search("([0-9]+(\.[0-9])?)", out).group()
        # Since GCC 7.1, -dumpversion return the major version number
        # only ("7"). We must use -dumpfullversion to get the full version
        # number ("7.1.1").
        if installed_version:
            output.success("Found %s %s" % (compiler, installed_version))
            return compiler, installed_version
    except Exception:
        return None
Ejemplo n.º 4
0
def _clang_compiler(output, compiler_exe="clang"):
    try:
        ret, out = detect_runner('%s --version' % compiler_exe)
        if ret != 0:
            return None
        if "Apple" in out:
            compiler = "apple-clang"
        elif "clang version" in out:
            compiler = "clang"
        installed_version = re.search("([0-9]+\.[0-9])", out).group()
        if installed_version:
            output.success("Found %s %s" % (compiler, installed_version))
            return compiler, installed_version
    except Exception:
        return None