Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not muted exception and added new archs for triplet detection #3603

Merged
merged 1 commit into from Sep 24, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -84,11 +84,13 @@ def _get_host_build_target_flags(self):

try:
build = get_gnu_triplet(os_detected, arch_detected, self._compiler)
except ConanException:
except ConanException as exc:
self._conanfile.output.warn(str(exc))
build = None
try:
host = get_gnu_triplet(self._os, self._arch, self._compiler)
except ConanException:
except ConanException as exc:
self._conanfile.output.warn(str(exc))
host = None
return build, host, None

@@ -327,28 +327,43 @@ def get_cross_building_settings(settings, self_os=None, self_arch=None):
return build_os, build_arch, host_os, host_arch


def get_gnu_triplet(os, arch, compiler=None):
def get_gnu_triplet(os_, arch, compiler=None):
"""
Returns string with <machine>-<vendor>-<op_system> triplet (<vendor> can be omitted in practice)
:param os: os to be used to create the triplet
:param os_: os to be used to create the triplet
:param arch: arch to be used to create the triplet
:param compiler: compiler used to create the triplet (only needed fo windows)
"""

if os == "Windows" and compiler is None:
if os_ == "Windows" and compiler is None:
raise ConanException("'compiler' parameter for 'get_gnu_triplet()' is not specified and "
"needed for os=Windows")

# Calculate the arch
machine = {"x86": "i686" if os != "Linux" else "x86",
machine = {"x86": "i686" if os_ != "Linux" else "x86",
"x86_64": "x86_64",
"armv6": "arm",
"armv7": "arm",
"armv7s": "arm",
"armv7k": "arm",
"armv7hf": "arm",
"armv8": "aarch64"}.get(arch, None)

if not machine:
# https://wiki.debian.org/Multiarch/Tuples
if "arm" in arch:
machine = "arm"
elif "ppc64le" in arch:
machine = "powerpc64le"
elif "ppc64" in arch:
machine = "powerpc64"
elif "powerpc" in arch:
machine = "powerpc"
elif "mips64" in arch:
machine = "mips64"
elif "mips" in arch:
machine = "mips"
elif "sparcv9" in arch:
machine = "sparc64"
elif "sparc" in arch:
machine = "sparc"

if machine is None:
raise ConanException("Unknown '%s' machine, Conan doesn't know how to "
"translate it to the GNU triplet, please report at "
@@ -369,13 +384,13 @@ def get_gnu_triplet(os, arch, compiler=None):
"Macos": "apple-darwin",
"iOS": "apple-darwin",
"watchOS": "apple-darwin",
"tvOS": "apple-darwin"}.get(os, os.lower())
"tvOS": "apple-darwin"}.get(os_, os_.lower())

if os in ("Linux", "Android"):
if os_ in ("Linux", "Android"):
if "arm" in arch and arch != "armv8":
op_system += "eabi"

if arch == "armv7hf" and os == "Linux":
if arch == "armv7hf" and os_ == "Linux":
op_system += "hf"

return "%s-%s" % (machine, op_system)
@@ -47,6 +47,16 @@ def partial_build_test(self):
be.make()
self.assertIsNone(conan_file.command)

def warn_when_no_triplet_test(self):
conan_file = ConanFileMock()
deps_cpp_info = namedtuple("Deps", "libs, include_paths, lib_paths, defines, cflags, "
"cppflags, sharedlinkflags, exelinkflags, sysroot")
conan_file.deps_cpp_info = deps_cpp_info([], [], [], [], [], [], [], [], "")
conan_file.settings = MockSettings({"arch": "UNKNOWN_ARCH", "os": "Linux"})
AutoToolsBuildEnvironment(conan_file)
self.assertIn("Unknown 'UNKNOWN_ARCH' machine, Conan doesn't know "
"how to translate it to the GNU triplet", conan_file.output)

def test_cppstd(self):
options = MockOptions({})
# Valid one for GCC
@@ -982,6 +982,26 @@ def get_values(this_os, this_arch, setting_os, setting_arch, compiler=None):
host = tools.get_gnu_triplet(setting_os, setting_arch, compiler)
return build, host

build, host = get_values("Linux", "armv6", "Linux", "armv6")
self.assertEquals(build, "arm-linux-gnueabi")
self.assertEquals(host, "arm-linux-gnueabi")

build, host = get_values("Linux", "sparc", "Linux", "sparcv9")
self.assertEquals(build, "sparc-linux-gnu")
self.assertEquals(host, "sparc64-linux-gnu")

build, host = get_values("Linux", "mips", "Linux", "mips64")
self.assertEquals(build, "mips-linux-gnu")
self.assertEquals(host, "mips64-linux-gnu")

build, host = get_values("Linux", "ppc64le", "Linux", "ppc64")
self.assertEquals(build, "powerpc64le-linux-gnu")
self.assertEquals(host, "powerpc64-linux-gnu")

build, host = get_values("Linux", "armv5te", "Linux", "arm_whatever")
self.assertEquals(build, "arm-linux-gnueabi")
self.assertEquals(host, "arm-linux-gnueabi")

build, host = get_values("Linux", "x86_64", "Linux", "armv7hf")
self.assertEquals(build, "x86_64-linux-gnu")
self.assertEquals(host, "arm-linux-gnueabihf")
@@ -1074,18 +1094,18 @@ def get_values(this_os, this_arch, setting_os, setting_arch, compiler=None):
self.assertEquals(build, "x86_64-apple-darwin")
self.assertEquals(host, "aarch64-apple-darwin")

for os in ["Windows", "Linux"]:
for _os in ["Windows", "Linux"]:
for arch in ["x86_64", "x86"]:
triplet = tools.get_gnu_triplet(os, arch, "gcc")
triplet = tools.get_gnu_triplet(_os, arch, "gcc")

output = ""
if arch == "x86_64":
output += "x86_64"
else:
output += "i686" if os != "Linux" else "x86"
output += "i686" if _os != "Linux" else "x86"

output += "-"
if os == "Windows":
if _os == "Windows":
output += "w64-mingw32"
else:
output += "linux-gnu"
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.