Esempio n. 1
0
    def _get_host_build_target_flags(self):
        """Based on google search for build/host triplets, it could need a lot
        and complex verification"""

        arch_detected = detected_architecture() or platform.machine()
        os_detected = detected_os() or platform.system()

        if self._os_target and self._arch_target:
            try:
                target = get_gnu_triplet(self._os_target, self._arch_target,
                                         self._compiler)
            except ConanException as exc:
                self._conanfile.output.warn(str(exc))
                target = None
        else:
            target = None

        if os_detected is None or arch_detected is None or self._arch is None or self._os is None:
            return False, False, target
        if not cross_building(self._conanfile.settings, os_detected,
                              arch_detected):
            return False, False, target

        try:
            build = get_gnu_triplet(os_detected, arch_detected, self._compiler)
        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 as exc:
            self._conanfile.output.warn(str(exc))
            host = None
        return build, host, target
Esempio n. 2
0
 def _get_build_os_arch(self):
     if hasattr(self._conanfile, 'settings_build'):
         os_build, arch_build = get_build_os_arch(self._conanfile)
     else:
         # FIXME: Why not use 'os_build' and 'arch_build' from conanfile.settings?
         os_build = detected_os() or platform.system()
         arch_build = detected_architecture() or platform.machine()
     return arch_build, os_build
Esempio n. 3
0
 def build(self):
     autotools = AutoToolsBuildEnvironment(
         self, win_bash=detected_os() is "Windows")
     config_args = [
         "--target={}".format(self._arch_target_triple),
         "--enable-gold=yes",
         "--enable-ld=yes",
     ]
     autotools.configure(args=config_args,
                         configure_dir=os.path.join(self.source_folder,
                                                    self._source_subfolder))
     autotools.make()
Esempio n. 4
0
    def test_cross_platform_msg(self):
        # Explicit with os_build and os_arch settings
        message = "Cross-build from 'Linux:x86_64' to 'Windows:x86_64'"
        self._create("Hello0", "0.1", settings='"os_build", "os", "arch_build", "arch", "compiler"')
        self.client.run("install Hello0/0.1@lasote/stable -s os_build=Linux -s os=Windows",
                        assert_error=True)
        self.assertIn(message, self.client.out)

        # Implicit detection when not available (retrocompatibility)
        bad_os = "Linux" if platform.system() != "Linux" else "Macos"
        message = "Cross-build from '%s:x86_64' to '%s:x86_64'" % (detected_os(), bad_os)
        self._create("Hello0", "0.1")
        self.client.run("install Hello0/0.1@lasote/stable -s os=%s" % bad_os, assert_error=True)
        self.assertIn(message, self.client.out)
def test_cross_platform_msg(client):
    # Explicit with os_build and os_arch settings
    client.run(
        "install Hello0/0.1@lasote/stable -s os_build=Macos -s os=Windows",
        assert_error=True)
    assert "Cross-build from 'Macos:x86_64' to 'Windows:None'" in client.out
    assert "ERROR: Missing binary: Hello0" in client.out

    bad_os = "Windows" if platform.system() != "Windows" else "Macos"
    client.run("install Hello0/0.1@lasote/stable -s os={}".format(bad_os),
               assert_error=True)
    # Implicit detection when not available (retrocompatibility)
    message = "Cross-build from '{}:x86_64' to '{}:None'".format(
        detected_os(), bad_os)
    assert message in client.out
Esempio n. 6
0
 def test_solaris(self):
     with mock.patch("platform.system",
                     mock.MagicMock(return_value='SunOS')):
         self.assertEqual(detected_os(), "SunOS")
Esempio n. 7
0
 def test_freebsd(self):
     with mock.patch("platform.system",
                     mock.MagicMock(return_value='FreeBSD')):
         self.assertEqual(detected_os(), "FreeBSD")
Esempio n. 8
0
 def test_linux(self):
     with mock.patch("platform.system",
                     mock.MagicMock(return_value='Linux')):
         with mock.patch.object(OSInfo, '_get_linux_distro_info'):
             self.assertEqual(detected_os(), "Linux")
Esempio n. 9
0
 def test_darwin(self):
     with mock.patch("platform.system",
                     mock.MagicMock(return_value='Darwin')):
         self.assertEqual(detected_os(), "Macos")
Esempio n. 10
0
 def test_mingw64(self):
     with mock.patch("platform.system",
                     mock.MagicMock(return_value='MINGW64_NT-10.0')):
         self.assertEqual(detected_os(), "Windows")
Esempio n. 11
0
 def cross_compiling(self):
     return self.os != detected_os() or self.arch != detected_architecture()
Esempio n. 12
0
 def test_windows(self):
     with mock.patch("platform.system",
                     mock.MagicMock(return_value='Windows')):
         self.assertEqual(detected_os(), "Windows")
Esempio n. 13
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from conan.packager import ConanMultiPackager
from conans.client.tools.oss import detected_os
from conans.util.env_reader import get_env

if __name__ == "__main__":
    arch_str = get_env("ARCH", "x86,x86_64")
    archs = arch_str.split(",")

    builder = ConanMultiPackager(
        # docker_entry_script="pwd && ls",
    )
    for arch in archs:
        builder.add(settings={
            "arch_build": arch,
            "os_build": detected_os(),
        })
    builder.run()
Esempio n. 14
0
 def build_requirements(self):
     if detected_os() == "Windows":
         self.build_requires("msys2_installer/latest@bincrafters/stable")
Esempio n. 15
0
 def package(self):
     with tools.chdir(os.path.join(self.build_folder)):
         autotools = AutoToolsBuildEnvironment(
             self, win_bash=detected_os() is "Windows")
         autotools.install()
Esempio n. 16
0
#!/usr/bin/env python
#  -*- coding: utf-8 -*-

from bincrafters import build_template_installer
from conans.client.tools.oss import detected_os


if __name__ == "__main__":
    builder = build_template_installer.get_builder()


    for arch_target in ("x86", "x86_64", ):
        if detected_os() == "Linux":
            builder.add(settings={"arch_target": arch_target, "os_target": "Linux",})
        builder.add(settings={"arch_target": arch_target, "os_target": "Windows",})
    for os_target in ("Linux", "Arduino", ):
        builder.add(settings={"arch_target": "armv7", "os_target": os_target,})
        builder.add(settings={"arch_target": "armv8", "os_target": os_target,})
        builder.add(settings={"arch_target": "mips", "os_target": os_target,})
        builder.add(settings={"arch_target": "mips64", "os_target": os_target,})
    builder.add(settings={"arch_target": "avr", "os_target": "Arduino",})

    builder.run()
Esempio n. 17
0
 def test_cygwin(self):
     with mock.patch("platform.system",
                     mock.MagicMock(return_value='CYGWIN_NT-10.0')):
         self.assertEqual(detected_os(), "Windows")