From cd7a71a33a06634b72ca330375a44a0fff73cb6a Mon Sep 17 00:00:00 2001 From: SSE4 Date: Mon, 9 Nov 2020 20:33:49 +0700 Subject: [PATCH] - add e2k (Elbrus 2000) and mcst-lcc Signed-off-by: SSE4 --- conans/client/build/compiler_flags.py | 9 +- conans/client/build/cppstd_flags.py | 36 +++++- conans/client/conf/__init__.py | 13 ++- conans/client/conf/compiler_id.py | 9 +- conans/client/conf/detect.py | 14 +++ conans/client/generators/cmake_common.py | 2 +- conans/client/migrations_settings.py | 107 +++++++++++++++++- conans/client/tools/oss.py | 20 ++++ .../client/build/compiler_flags_test.py | 13 +++ .../client/build/compiler_id_test.py | 10 +- .../client/build/cpp_std_flags_test.py | 52 +++++++++ .../util/detected_architecture_test.py | 20 +++- conans/test/unittests/util/tools_test.py | 8 +- 13 files changed, 300 insertions(+), 13 deletions(-) diff --git a/conans/client/build/compiler_flags.py b/conans/client/build/compiler_flags.py index a379abd78f2..215868f4653 100644 --- a/conans/client/build/compiler_flags.py +++ b/conans/client/build/compiler_flags.py @@ -63,6 +63,13 @@ def architecture_flag(settings): return "/Qm32" if str(compiler_base) == "Visual Studio" else "-m32" elif str(arch) == "x86_64": return "/Qm64" if str(compiler_base) == "Visual Studio" else "-m64" + elif str(compiler) == "mcst-lcc": + return {"e2k-v2": "-march=elbrus-v2", + "e2k-v3": "-march=elbrus-v3", + "e2k-v4": "-march=elbrus-v4", + "e2k-v5": "-march=elbrus-v5", + "e2k-v6": "-march=elbrus-v6", + "e2k-v7": "-march=elbrus-v7"}.get(str(arch), "") return "" @@ -145,7 +152,7 @@ def build_type_flags(settings): # Modules/Compiler/GNU.cmake # clang include the gnu (overriding some things, but not build type) and apple clang # overrides clang but it doesn't touch clang either - if str(compiler) in ["clang", "gcc", "apple-clang", "qcc"]: + if str(compiler) in ["clang", "gcc", "apple-clang", "qcc", "mcst-lcc"]: # FIXME: It is not clear that the "-s" is something related with the build type # cmake is not adjusting it # -s: Remove all symbol table and relocation information from the executable. diff --git a/conans/client/build/cppstd_flags.py b/conans/client/build/cppstd_flags.py index 6d2d9e27182..a1e58de92a6 100644 --- a/conans/client/build/cppstd_flags.py +++ b/conans/client/build/cppstd_flags.py @@ -32,7 +32,8 @@ def cppstd_flag(compiler, compiler_version, cppstd, compiler_base=None): "clang": _cppstd_clang, "apple-clang": _cppstd_apple_clang, "Visual Studio": _cppstd_visualstudio, - "intel": cppstd_intel}.get(str(compiler), None) + "intel": cppstd_intel, + "mcst-lcc": _cppstd_mcst_lcc}.get(str(compiler), None) flag = None if func: flag = func(str(compiler_version), str(cppstd)) @@ -62,7 +63,8 @@ def cppstd_default(settings): "clang": _clang_cppstd_default(compiler_version), "apple-clang": "gnu98", # Confirmed in apple-clang 9.1 with a simple "auto i=1;" "Visual Studio": _visual_cppstd_default(compiler_version), - "intel": intel_cppstd_default(compiler_version)}.get(str(compiler), None) + "intel": intel_cppstd_default(compiler_version), + "mcst-lcc": _mcst_lcc_cppstd_default(compiler_version)}.get(str(compiler), None) return default @@ -89,6 +91,10 @@ def _intel_gcc_cppstd_default(_): return "gnu98" +def _mcst_lcc_cppstd_default(compiler_version): + return "gnu14" if Version(compiler_version) >= "1.24" else "gnu98" + + def _cppstd_visualstudio(visual_version, cppstd): # https://docs.microsoft.com/en-us/cpp/build/reference/std-specify-language-standard-version v14 = None @@ -274,3 +280,29 @@ def _cppstd_intel_gcc(intel_version, cppstd): def _cppstd_intel_visualstudio(intel_version, cppstd): flag = _cppstd_intel_common(intel_version, cppstd, None, None) return "/Qstd=%s" % flag if flag else None + + +def _cppstd_mcst_lcc(mcst_lcc_version, cppstd): + v11 = vgnu11 = v14 = vgnu14 = v17 = vgnu17 = v20 = vgnu20 = None + + if Version(mcst_lcc_version) >= "1.21": + v11 = "c++11" + vgnu11 = "gnu++11" + v14 = "c++14" + vgnu14 = "gnu++14" + + if Version(mcst_lcc_version) >= "1.24": + v17 = "c++17" + vgnu17 = "gnu++17" + + if Version(mcst_lcc_version) >= "1.25": + v20 = "c++2a" + vgnu20 = "gnu++2a" + + flag = {"98": "c++98", "gnu98": "gnu++98", + "03": "c++03", "gnu03": "gnu++03", + "11": v11, "gnu11": vgnu11, + "14": v14, "gnu14": vgnu14, + "17": v17, "gnu17": vgnu17, + "20": v20, "gnu20": vgnu20}.get(cppstd) + return "-std=%s" % flag if flag else None diff --git a/conans/client/conf/__init__.py b/conans/client/conf/__init__.py index 6b7f78aee86..0cd53c7e270 100644 --- a/conans/client/conf/__init__.py +++ b/conans/client/conf/__init__.py @@ -16,12 +16,12 @@ _t_default_settings_yml = Template(textwrap.dedent(""" # Only for cross building, 'os_build/arch_build' is the system that runs Conan os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX] - arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le] + arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] # Only for building cross compilation tools, 'os_target/arch_target' is the system for # which the tools generate code os_target: [Windows, Linux, Macos, Android, iOS, watchOS, tvOS, FreeBSD, SunOS, AIX, Arduino, Neutrino] - arch_target: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le] + arch_target: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] # Rest of the settings are "host" settings: # - For native building/cross building: Where the library/program will run. @@ -53,7 +53,7 @@ Emscripten: Neutrino: version: ["6.4", "6.5", "6.6", "7.0", "7.1"] - arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le] + arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] compiler: sun-cc: version: ["5.10", "5.11", "5.12", "5.13", "5.14", "5.15"] @@ -106,6 +106,13 @@ version: ["4.4", "5.4", "8.3"] libcxx: [cxx, gpp, cpp, cpp-ne, accp, acpp-ne, ecpp, ecpp-ne] cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17] + mcst-lcc: + version: ["1.19", "1.20", "1.21", "1.22", "1.23", "1.24", "1.25"] + base: + gcc: + <<: *gcc + threads: [None] + exceptions: [None] build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel] diff --git a/conans/client/conf/compiler_id.py b/conans/client/conf/compiler_id.py index f384ea052bf..973cf0be0c8 100644 --- a/conans/client/conf/compiler_id.py +++ b/conans/client/conf/compiler_id.py @@ -14,6 +14,7 @@ MSVC = "Visual Studio" INTEL = "intel" QCC = "qcc" +MCST_LCC = "mcst-lcc" class CompilerId(object): @@ -102,7 +103,13 @@ def __ne__(self, other): def _parse_compiler_version(defines): try: - if '__INTEL_COMPILER' in defines: + if '__LCC__' in defines and '__e2k__' in defines: + compiler = MCST_LCC + version = int(defines['__LCC__']) + major = int(version / 100) + minor = int(version % 100) + patch = int(defines['__LCC_MINOR__']) + elif '__INTEL_COMPILER' in defines: compiler = INTEL version = int(defines['__INTEL_COMPILER']) major = int(version / 100) diff --git a/conans/client/conf/detect.py b/conans/client/conf/detect.py index 6ba079819c4..35717d4393c 100644 --- a/conans/client/conf/detect.py +++ b/conans/client/conf/detect.py @@ -244,6 +244,18 @@ def _detect_compiler_version(result, output, profile_path): result.append(("compiler.libcxx", "libstdc++")) elif compiler == "sun-cc": result.append(("compiler.libcxx", "libCstd")) + elif compiler == "mcst-lcc": + result.append(("compiler.base", "gcc")) # do the same for Intel? + result.append(("compiler.base.libcxx", "libstdc++")) + version = Version(version) + if version >= "1.24": + result.append(("compiler.base.version", "7.3")) + elif version >= "1.23": + result.append(("compiler.base.version", "5.5")) + elif version >= "1.21": + result.append(("compiler.base.version", "4.8")) + else: + result.append(("compiler.base.version", "4.4")) def _detect_os_arch(result, output): @@ -268,6 +280,8 @@ def _detect_os_arch(result, output): 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 diff --git a/conans/client/generators/cmake_common.py b/conans/client/generators/cmake_common.py index 6ab2dbe7830..cf3249d5e20 100644 --- a/conans/client/generators/cmake_common.py +++ b/conans/client/generators/cmake_common.py @@ -524,7 +524,7 @@ class CMakeCommonMacros: if(NOT ${_CHECK_VERSION} VERSION_EQUAL ${_CONAN_VERSION}) conan_error_compiler_version() endif() - elseif(CONAN_COMPILER STREQUAL "apple-clang" OR CONAN_COMPILER STREQUAL "sun-cc") + elseif(CONAN_COMPILER STREQUAL "apple-clang" OR CONAN_COMPILER STREQUAL "sun-cc" OR CONAN_COMPILER STREQUAL "mcst-lcc") conan_split_version(${CONAN_COMPILER_VERSION} CONAN_COMPILER_MAJOR CONAN_COMPILER_MINOR) if(NOT ${VERSION_MAJOR}.${VERSION_MINOR} VERSION_EQUAL ${CONAN_COMPILER_MAJOR}.${CONAN_COMPILER_MINOR}) conan_error_compiler_version() diff --git a/conans/client/migrations_settings.py b/conans/client/migrations_settings.py index 56e1df425d1..a3e10ae1ba6 100644 --- a/conans/client/migrations_settings.py +++ b/conans/client/migrations_settings.py @@ -1817,4 +1817,109 @@ settings_1_31_3 = settings_1_31_2 settings_1_31_4 = settings_1_31_3 -settings_1_32_0 = settings_1_31_4 +settings_1_32_0 = """ +# Only for cross building, 'os_build/arch_build' is the system that runs Conan +os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX] +arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] + +# Only for building cross compilation tools, 'os_target/arch_target' is the system for +# which the tools generate code +os_target: [Windows, Linux, Macos, Android, iOS, watchOS, tvOS, FreeBSD, SunOS, AIX, Arduino, Neutrino] +arch_target: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] + +# Rest of the settings are "host" settings: +# - For native building/cross building: Where the library/program will run. +# - For building cross compilation tools: Where the cross compiler will run. +os: + Windows: + subsystem: [None, cygwin, msys, msys2, wsl] + WindowsStore: + version: ["8.1", "10.0"] + WindowsCE: + platform: ANY + version: ["5.0", "6.0", "7.0", "8.0"] + Linux: + Macos: + version: [None, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0"] + Android: + api_level: ANY + iOS: + version: ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3", "11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", "13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6"] + watchOS: + version: ["4.0", "4.1", "4.2", "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1"] + tvOS: + version: ["11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", "13.0"] + FreeBSD: + SunOS: + AIX: + Arduino: + board: ANY + Emscripten: + Neutrino: + version: ["6.4", "6.5", "6.6", "7.0", "7.1"] +arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] +compiler: + sun-cc: + version: ["5.10", "5.11", "5.12", "5.13", "5.14", "5.15"] + threads: [None, posix] + libcxx: [libCstd, libstdcxx, libstlport, libstdc++] + gcc: &gcc + version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9", + "5", "5.1", "5.2", "5.3", "5.4", "5.5", + "6", "6.1", "6.2", "6.3", "6.4", "6.5", + "7", "7.1", "7.2", "7.3", "7.4", "7.5", + "8", "8.1", "8.2", "8.3", "8.4", + "9", "9.1", "9.2", "9.3", + "10", "10.1"] + libcxx: [libstdc++, libstdc++11] + threads: [None, posix, win32] # Windows MinGW + exception: [None, dwarf2, sjlj, seh] # Windows MinGW + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20] + Visual Studio: &visual_studio + runtime: [MD, MT, MTd, MDd] + version: ["8", "9", "10", "11", "12", "14", "15", "16"] + toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp, + v140, v140_xp, v140_clang_c2, LLVM-vs2012, LLVM-vs2012_xp, + LLVM-vs2013, LLVM-vs2013_xp, LLVM-vs2014, LLVM-vs2014_xp, + LLVM-vs2017, LLVM-vs2017_xp, v141, v141_xp, v141_clang_c2, v142, + llvm, ClangCL] + cppstd: [None, 14, 17, 20] + clang: + version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0", + "5.0", "6.0", "7.0", "7.1", + "8", "9", "10", "11"] + libcxx: [None, libstdc++, libstdc++11, libc++, c++_shared, c++_static] + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20] + runtime: [None, MD, MT, MTd, MDd] + apple-clang: &apple_clang + version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1", "10.0", "11.0", "12.0"] + libcxx: [libstdc++, libc++] + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20] + intel: + version: ["11", "12", "13", "14", "15", "16", "17", "18", "19", "19.1"] + base: + gcc: + <<: *gcc + threads: [None] + exception: [None] + Visual Studio: + <<: *visual_studio + apple-clang: + <<: *apple_clang + qcc: + version: ["4.4", "5.4", "8.3"] + libcxx: [cxx, gpp, cpp, cpp-ne, accp, acpp-ne, ecpp, ecpp-ne] + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17] + mcst-lcc: + version: ["1.19", "1.20", "1.21", "1.22", "1.23", "1.24", "1.25"] + base: + gcc: + <<: *gcc + threads: [None] + exceptions: [None] + +build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel] + + +cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20] # Deprecated, use compiler.cppstd +""" diff --git a/conans/client/tools/oss.py b/conans/client/tools/oss.py index 0a544402825..01deff0b879 100644 --- a/conans/client/tools/oss.py +++ b/conans/client/tools/oss.py @@ -109,6 +109,8 @@ def detected_architecture(): return "s390x" elif "s390" in machine: return "s390" + elif "e2k" in machine: + return OSInfo.get_e2k_architecture() return None @@ -342,6 +344,21 @@ def get_solaris_architecture(): elif "i386" in processor: return "x86_64" if kernel_bitness == "64bit" else "x86" + @staticmethod + def get_e2k_architecture(): + return { + "E1C+": "e2k-v4", # Elbrus 1C+ and Elbrus 1CK + "E2C+": "e2k-v2", # Elbrus 2CM + "E2C+DSP": "e2k-v2", # Elbrus 2C+ + "E2C3": "e2k-v6", # Elbrus 2C3 + "E2S": "e2k-v3", # Elbrus 2S (aka Elbrus 4C) + "E8C": "e2k-v4", # Elbrus 8C and Elbrus 8C1 + "E8C2": "e2k-v5", # Elbrus 8C2 (aka Elbrus 8CB) + "E12C": "e2k-v6", # Elbrus 12C + "E16C": "e2k-v6", # Elbrus 16C + "E32C": "e2k-v7", # Elbrus 32C + }.get(platform.processor()) + @staticmethod def get_freebsd_version(): return platform.release().split("-")[0] @@ -539,6 +556,9 @@ def get_gnu_triplet(os_, arch, compiler=None): machine = "s390-ibm" elif "sh4" in arch: machine = "sh4" + elif "e2k" in arch: + # https://lists.gnu.org/archive/html/config-patches/2015-03/msg00000.html + machine = "e2k-unknown" if machine is None: raise ConanException("Unknown '%s' machine, Conan doesn't know how to " diff --git a/conans/test/unittests/client/build/compiler_flags_test.py b/conans/test/unittests/client/build/compiler_flags_test.py index 0bbf4388439..7c25f275acd 100644 --- a/conans/test/unittests/client/build/compiler_flags_test.py +++ b/conans/test/unittests/client/build/compiler_flags_test.py @@ -52,6 +52,19 @@ def test_arch_flag_intel(self, base, arch, flag): "arch": arch}) self.assertEqual(architecture_flag(settings), flag) + @parameterized.expand([("e2k-v2", "-march=elbrus-v2"), + ("e2k-v3", "-march=elbrus-v3"), + ("e2k-v4", "-march=elbrus-v4"), + ("e2k-v5", "-march=elbrus-v5"), + ("e2k-v6", "-march=elbrus-v6"), + ("e2k-v7", "-march=elbrus-v7"), + ]) + def test_arch_flag_mcst_lcc(self, arch, flag): + settings = MockSettings({"compiler": "mcst-lcc", + "compiler.base": "gcc", + "arch": arch}) + self.assertEqual(architecture_flag(settings), flag) + @parameterized.expand([("gcc", "libstdc++", "_GLIBCXX_USE_CXX11_ABI=0"), ("gcc", "libstdc++11", "_GLIBCXX_USE_CXX11_ABI=1"), ("clang", "libstdc++", "_GLIBCXX_USE_CXX11_ABI=0"), diff --git a/conans/test/unittests/client/build/compiler_id_test.py b/conans/test/unittests/client/build/compiler_id_test.py index 2765481b019..a34c091a5f0 100644 --- a/conans/test/unittests/client/build/compiler_id_test.py +++ b/conans/test/unittests/client/build/compiler_id_test.py @@ -2,7 +2,7 @@ from parameterized import parameterized from conans.client.conf.compiler_id import detect_compiler_id, CompilerId, UNKNOWN_COMPILER, \ - GCC, LLVM_GCC, CLANG, APPLE_CLANG, SUNCC, MSVC, INTEL, QCC + GCC, LLVM_GCC, CLANG, APPLE_CLANG, SUNCC, MSVC, INTEL, QCC, MCST_LCC from conans.test.unittests.util.tools_test import RunnerMock @@ -127,3 +127,11 @@ def test_qcc(self): "#define __GNUC_PATCHLEVEL__ 4\n" compiler_id = detect_compiler_id("qcc", runner=runner) self.assertEqual(CompilerId(QCC, 4, 2, 4), compiler_id) + + def test_mcst_lcc(self): + runner = RunnerMock() + runner.output = "#define __LCC__ 125\n" \ + "#define __LCC_MINOR__ 6\n" \ + "#define __e2k__ 1\n" + compiler_id = detect_compiler_id("lcc", runner=runner) + self.assertEqual(CompilerId(MCST_LCC, 1, 25, 6), compiler_id) diff --git a/conans/test/unittests/client/build/cpp_std_flags_test.py b/conans/test/unittests/client/build/cpp_std_flags_test.py index 6ae000bfa0f..3ebd42eaccf 100644 --- a/conans/test/unittests/client/build/cpp_std_flags_test.py +++ b/conans/test/unittests/client/build/cpp_std_flags_test.py @@ -294,3 +294,55 @@ def test_intel_gcc_cppstd_flag(self): self.assertEqual(_make_cppstd_flag("intel", "11", "14", "gcc"), None) self.assertEqual(_make_cppstd_flag("intel", "11", "17", "gcc"), None) self.assertEqual(_make_cppstd_flag("intel", "11", "20", "gcc"), None) + + def test_mcst_lcc_cppstd_defaults(self): + self.assertEqual(_make_cppstd_default("mcst-lcc", "1.19", "gcc"), "gnu98") + self.assertEqual(_make_cppstd_default("mcst-lcc", "1.20", "gcc"), "gnu98") + self.assertEqual(_make_cppstd_default("mcst-lcc", "1.21", "gcc"), "gnu98") + self.assertEqual(_make_cppstd_default("mcst-lcc", "1.22", "gcc"), "gnu98") + self.assertEqual(_make_cppstd_default("mcst-lcc", "1.23", "gcc"), "gnu98") + self.assertEqual(_make_cppstd_default("mcst-lcc", "1.24", "gcc"), "gnu14") + self.assertEqual(_make_cppstd_default("mcst-lcc", "1.25", "gcc"), "gnu14") + + def test_mcst_lcc_cppstd_flag(self): + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.19", "98", "gcc"), "-std=c++98") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.19", "11", "gcc"), None) + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.19", "14", "gcc"), None) + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.19", "17", "gcc"), None) + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.19", "20", "gcc"), None) + + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.20", "98", "gcc"), "-std=c++98") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.20", "11", "gcc"), None) + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.20", "14", "gcc"), None) + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.20", "17", "gcc"), None) + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.20", "20", "gcc"), None) + + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.21", "98", "gcc"), "-std=c++98") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.21", "11", "gcc"), "-std=c++11") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.21", "14", "gcc"), "-std=c++14") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.21", "17", "gcc"), None) + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.21", "20", "gcc"), None) + + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.22", "98", "gcc"), "-std=c++98") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.22", "11", "gcc"), "-std=c++11") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.22", "14", "gcc"), "-std=c++14") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.22", "17", "gcc"), None) + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.22", "20", "gcc"), None) + + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.23", "98", "gcc"), "-std=c++98") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.23", "11", "gcc"), "-std=c++11") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.23", "14", "gcc"), "-std=c++14") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.23", "17", "gcc"), None) + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.23", "20", "gcc"), None) + + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.24", "98", "gcc"), "-std=c++98") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.24", "11", "gcc"), "-std=c++11") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.24", "14", "gcc"), "-std=c++14") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.24", "17", "gcc"), "-std=c++17") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.24", "20", "gcc"), None) + + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.25", "98", "gcc"), "-std=c++98") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.25", "11", "gcc"), "-std=c++11") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.25", "14", "gcc"), "-std=c++14") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.25", "17", "gcc"), "-std=c++17") + self.assertEqual(_make_cppstd_flag("mcst-lcc", "1.25", "20", "gcc"), "-std=c++2a") diff --git a/conans/test/unittests/util/detected_architecture_test.py b/conans/test/unittests/util/detected_architecture_test.py index db8c332aaed..8ff238d5572 100644 --- a/conans/test/unittests/util/detected_architecture_test.py +++ b/conans/test/unittests/util/detected_architecture_test.py @@ -10,6 +10,7 @@ from conans.client.tools.oss import detected_architecture + class DetectedArchitectureTest(unittest.TestCase): @parameterized.expand([ @@ -36,7 +37,6 @@ def test_various(self, mocked_machine, expected_arch): with mock.patch("platform.machine", mock.MagicMock(return_value=mocked_machine)): self.assertEqual(expected_arch, detected_architecture(), "given '%s' expected '%s'" % (mocked_machine, expected_arch)) - def test_aix(self): with mock.patch("platform.machine", mock.MagicMock(return_value='00FB91F44C00')),\ mock.patch("platform.processor", mock.MagicMock(return_value='powerpc')),\ @@ -52,7 +52,6 @@ def test_aix(self): mock.patch('subprocess.check_output', mock.MagicMock(return_value='7.1.0.0')): self.assertEqual('ppc64', detected_architecture()) - def test_solaris(self): with mock.patch("platform.machine", mock.MagicMock(return_value='sun4v')),\ mock.patch("platform.processor", mock.MagicMock(return_value='sparc')),\ @@ -67,3 +66,20 @@ def test_solaris(self): mock.patch("platform.architecture", mock.MagicMock(return_value=('64bit', 'ELF'))),\ mock.patch("platform.release", mock.MagicMock(return_value='5.11')): self.assertEqual('x86_64', detected_architecture()) + + @parameterized.expand([ + ["E1C+", "e2k-v4"], + ["E2C+", "e2k-v2"], + ["E2C+DSP", "e2k-v2"], + ["E2C3", "e2k-v6"], + ["E2S", "e2k-v3"], + ["E8C", "e2k-v4"], + ["E8C2", "e2k-v5"], + ["E12C", "e2k-v6"], + ["E16C", "e2k-v6"], + ["E32C", "e2k-v7"] + ]) + def test_e2k(self, processor, expected_arch): + with mock.patch("platform.machine", mock.MagicMock(return_value='e2k')), \ + mock.patch("platform.processor", mock.MagicMock(return_value=processor)): + self.assertEqual(expected_arch, detected_architecture()) diff --git a/conans/test/unittests/util/tools_test.py b/conans/test/unittests/util/tools_test.py index a9453ca828b..3b625618d0c 100644 --- a/conans/test/unittests/util/tools_test.py +++ b/conans/test/unittests/util/tools_test.py @@ -623,7 +623,13 @@ def get_forbidden(): ["Neutrino", "armv7", None, "arm-nto-qnx"], ["Neutrino", "armv8", None, "aarch64-nto-qnx"], ["Neutrino", "sh4le", None, "sh4-nto-qnx"], - ["Neutrino", "ppc32be", None, "powerpcbe-nto-qnx"] + ["Neutrino", "ppc32be", None, "powerpcbe-nto-qnx"], + ["Linux", "e2k-v2", None, "e2k-unknown-linux-gnu"], + ["Linux", "e2k-v3", None, "e2k-unknown-linux-gnu"], + ["Linux", "e2k-v4", None, "e2k-unknown-linux-gnu"], + ["Linux", "e2k-v5", None, "e2k-unknown-linux-gnu"], + ["Linux", "e2k-v6", None, "e2k-unknown-linux-gnu"], + ["Linux", "e2k-v7", None, "e2k-unknown-linux-gnu"], ]) def test_get_gnu_triplet(self, os, arch, compiler, expected_triplet): triplet = tools.get_gnu_triplet(os, arch, compiler)