Beispiel #1
0
 def config_options(self):
     if self.version >= Version("2.8"):  # Means CMake version
         self.options.remove("version")
Beispiel #2
0
def _clang_cppstd_default(compiler_version):
    # Official docs are wrong, in 6.0 the default is gnu14 to follow gcc's choice
    return "gnu98" if Version(compiler_version) < "6" else "gnu14"
Beispiel #3
0
def _visual_cppstd_default(compiler_version):
    if Version(compiler_version) >= "14":  # VS 2015 update 3 only
        return "14"
    return None
Beispiel #4
0
    def _make_migrations(self, old_version):
        # ############### FILL THIS METHOD WITH THE REQUIRED ACTIONS ##############
        # VERSION 0.1
        if old_version is None:
            return

        if old_version < Version("0.25"):
            old_settings = """
os:
    Windows:
    Linux:
    Macos:
    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"]
    FreeBSD:
    SunOS:
arch: [x86, x86_64, ppc64le, ppc64, armv6, armv7, armv7hf, armv8, sparc, sparcv9, mips, mips64]
compiler:
    sun-cc:
       version: ["5.10", "5.11", "5.12", "5.13", "5.14"]
       threads: [None, posix]
       libcxx: [libCstd, libstdcxx, libstlport, libstdc++]
    gcc:
        version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9", "5.1", "5.2", "5.3", "5.4", "6.1", "6.2", "6.3", "7.1"]
        libcxx: [libstdc++, libstdc++11]
        threads: [None, posix, win32] #  Windows MinGW
        exception: [None, dwarf2, sjlj, seh] # Windows MinGW
    Visual Studio:
        runtime: [MD, MT, MTd, MDd]
        version: ["8", "9", "10", "11", "12", "14", "15"]
    clang:
        version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0"]
        libcxx: [libstdc++, libstdc++11, libc++]
    apple-clang:
        version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1"]
        libcxx: [libstdc++, libc++]

build_type: [None, Debug, Release]
"""
            self._update_settings_yml(old_settings)

        if old_version < Version("0.20"):
            conf_path = os.path.join(self.client_cache.conan_folder, CONAN_CONF)
            if conf_path:
                backup_path = conf_path + ".backup"
                save(backup_path, load(conf_path))
                os.unlink(conf_path)
                os.unlink(os.path.join(self.client_cache.conan_folder, CONAN_VERSION))
                self.out.warn("*" * 40)
                self.out.warn("Migration: Your Conan version was too old.")
                self.out.warn("Your old conan.conf file has been backup'd to: %s" % backup_path)
                self.out.warn("*" * 40)

        if old_version < Version("0.25"):
            from conans.paths import DEFAULT_PROFILE_NAME
            default_profile_path = os.path.join(self.client_cache.conan_folder, PROFILES_FOLDER,
                                                DEFAULT_PROFILE_NAME)
            if not os.path.exists(default_profile_path):
                self.out.warn("Migration: Moving default settings from %s file to %s"
                              % (CONAN_CONF, DEFAULT_PROFILE_NAME))
                conf_path = os.path.join(self.client_cache.conan_folder, CONAN_CONF)

                migrate_to_default_profile(conf_path, default_profile_path)

                self.out.warn("Migration: export_source cache new layout")
                migrate_c_src_export_source(self.client_cache, self.out)
    def test_docker(self):
        if not os.getenv("PYPI_PASSWORD", None):
            return
        self.deploy_pip()
        ci_manager = MockCIManager()
        unique_ref = "zlib/%s" % str(time.time())
        conanfile = """from conans import ConanFile
import os

class Pkg(ConanFile):
    settings = "os", "compiler", "build_type", "arch"

"""
        self.save_conanfile(conanfile)
        the_version = version.replace(
            "-", ".")  # Canonical name for artifactory repo
        pip = "--extra-index-url %s/simple conan-package-tools==%s " % (
            PYPI_TESTING_REPO, the_version)
        with tools.environment_append({
                "CONAN_USE_DOCKER":
                "1",
                "CONAN_DOCKER_USE_SUDO":
                "1",
                "CONAN_PIP_PACKAGE":
                pip,
                "CONAN_LOGIN_USERNAME":
                CONAN_LOGIN_UPLOAD,
                "CONAN_USERNAME":
                "******",
                "CONAN_UPLOAD":
                CONAN_UPLOAD_URL,
                "CONAN_PASSWORD":
                CONAN_UPLOAD_PASSWORD,
                "CONAN_CONFIG_URL":
                "https://conan.jfrog.io/conan/"
                "testing_files/empty_zip.zip"
        }):
            self.packager = ConanMultiPackager(channel="mychannel",
                                               gcc_versions=["6"],
                                               archs=["x86", "x86_64"],
                                               build_types=["Release"],
                                               reference=unique_ref,
                                               ci_manager=ci_manager)
            self.packager.add_common_builds()
            self.packager.run()

        search_pattern = "%s*" % unique_ref
        ref = ConanFileReference.loads("%s@lasote/mychannel" % unique_ref)

        # Remove from remote
        if Version(client_version) < Version("1.7"):
            results = self.api.search_recipes(
                search_pattern, remote="upload_repo")["results"][0]["items"]
            self.assertEquals(len(results), 1)
            packages = self.api.search_packages(
                ref,
                remote="upload_repo")["results"][0]["items"][0]["packages"]
            self.assertEquals(len(packages), 2)
            self.api.authenticate(name=CONAN_LOGIN_UPLOAD,
                                  password=CONAN_UPLOAD_PASSWORD,
                                  remote="upload_repo")
            self.api.remove(search_pattern, remote="upload_repo", force=True)
            self.assertEquals(
                self.api.search_recipes(search_pattern)["results"], [])
        else:
            results = self.api.search_recipes(
                search_pattern,
                remote_name="upload_repo")["results"][0]["items"]
            self.assertEquals(len(results), 1)
            packages = self.api.search_packages(
                ref, remote_name="upload_repo"
            )["results"][0]["items"][0]["packages"]
            self.assertEquals(len(packages), 2)
            self.api.authenticate(name=CONAN_LOGIN_UPLOAD,
                                  password=CONAN_UPLOAD_PASSWORD,
                                  remote_name="upload_repo")
            self.api.remove(search_pattern,
                            remote_name="upload_repo",
                            force=True)
            self.assertEquals(
                self.api.search_recipes(search_pattern)["results"], [])

        # Try upload only when stable, shouldn't upload anything
        with tools.environment_append({
                "CONAN_USE_DOCKER": "1",
                "CONAN_DOCKER_USE_SUDO": "1",
                "CONAN_PIP_PACKAGE": pip,
                "CONAN_LOGIN_USERNAME": CONAN_LOGIN_UPLOAD,
                "CONAN_USERNAME": "******",
                "CONAN_PASSWORD": CONAN_UPLOAD_PASSWORD,
                "CONAN_UPLOAD_ONLY_WHEN_STABLE": "1"
        }):
            self.packager = ConanMultiPackager(channel="mychannel",
                                               gcc_versions=["6"],
                                               archs=["x86", "x86_64"],
                                               build_types=["Release"],
                                               reference=unique_ref,
                                               upload=CONAN_UPLOAD_URL,
                                               ci_manager=ci_manager)
            self.packager.add_common_builds()
            self.packager.run()

        if Version(client_version) < Version("1.7"):
            results = self.api.search_recipes(search_pattern,
                                              remote="upload_repo")["results"]
            self.assertEquals(len(results), 0)
            self.api.remove(search_pattern, remote="upload_repo", force=True)
        else:
            results = self.api.search_recipes(
                search_pattern, remote_name="upload_repo")["results"]
            self.assertEquals(len(results), 0)
            self.api.remove(search_pattern,
                            remote_name="upload_repo",
                            force=True)
Beispiel #6
0
 def conan_set_std_branch():
     # Replicate logic from cmake_common definition of 'macro(conan_set_std)'
     cmake_version = CMakeBuildHelper.get_version()
     return cmake_version < Version("3.12")
    def run(self):
        client_version = get_client_version()

        if self._config_url:
            ConfigManager(self._conan_api,
                          self.printer).install(url=self._config_url,
                                                args=self._config_args)

        context = tools.no_op()
        compiler = self.settings.get("compiler", None)
        if not self._exclude_vcvars_precommand:
            if compiler == "Visual Studio" and "compiler.version" in self.settings:
                compiler_set = namedtuple("compiler", "version")(
                    self.settings["compiler.version"])
                mock_sets = namedtuple(
                    "mock_settings", "arch compiler get_safe")(
                        self.settings["arch"], compiler_set,
                        lambda x: self.settings.get(x, None))
                context = tools.vcvars(mock_sets)
        with context:
            self.printer.print_rule()
            self.printer.print_profile(tools.load(self._profile_abs_path))

            with self.printer.foldable_output("conan_create"):
                if client_version < Version("1.10.0"):
                    name, version, user, channel = self._reference
                else:
                    name, version, user, channel, _ = self._reference

                if self._build_policy:
                    self._build_policy = [] if self._build_policy == [
                        "all"
                    ] else self._build_policy
                # https://github.com/conan-io/conan-package-tools/issues/184
                with tools.environment_append({"_CONAN_CREATE_COMMAND_": "1"}):
                    params = {
                        "name": name,
                        "version": version,
                        "user": user,
                        "channel": channel,
                        "build_modes": self._build_policy,
                        "profile_name": self._profile_abs_path
                    }
                    self.printer.print_message("Calling 'conan create'")
                    self.printer.print_dict(params)
                    with tools.chdir(self._cwd):
                        if Version(client_version) >= "1.8.0":
                            from conans.errors import ConanInvalidConfiguration
                            exc_class = ConanInvalidConfiguration
                        else:
                            exc_class = None

                        try:
                            if client_version < Version("1.12.0"):
                                self._results = self._conan_api.create(
                                    self._conanfile,
                                    name=name,
                                    version=version,
                                    user=user,
                                    channel=channel,
                                    build_modes=self._build_policy,
                                    profile_name=self._profile_abs_path,
                                    test_folder=self._test_folder,
                                    not_export=self.skip_recipe_export,
                                    update=self._update_dependencies)
                            else:
                                self._results = self._conan_api.create(
                                    self._conanfile,
                                    name=name,
                                    version=version,
                                    user=user,
                                    channel=channel,
                                    build_modes=self._build_policy,
                                    profile_names=[self._profile_abs_path],
                                    test_folder=self._test_folder,
                                    not_export=self.skip_recipe_export,
                                    update=self._update_dependencies,
                                    lockfile=self._lockfile)
                        except exc_class as e:
                            self.printer.print_rule()
                            self.printer.print_message(
                                "Skipped configuration by the recipe: "
                                "%s" % str(e))
                            self.printer.print_rule()
                            return
                        for installed in self._results['installed']:
                            reference = installed["recipe"]["id"]
                            if client_version >= Version("1.10.0"):
                                reference = ConanFileReference.loads(reference)
                                reference = str(reference.copy_clear_rev())
                            if ((reference == str(self._reference)) or \
                               (reference in self._upload_dependencies) or \
                               ("all" in self._upload_dependencies)) and \
                               installed['packages']:
                                package_id = installed['packages'][0]['id']
                                if installed['packages'][0]["built"]:
                                    if "@" not in reference:
                                        reference += "@"
                                    if self._upload_only_recipe:
                                        self._uploader.upload_recipe(
                                            reference, self._upload)
                                    else:
                                        self._uploader.upload_packages(
                                            reference, self._upload,
                                            package_id)
                                else:
                                    self.printer.print_message(
                                        "Skipping upload for %s, "
                                        "it hasn't been built" % package_id)
Beispiel #8
0
class CygwinInstallerConan(ConanFile):
    name = "cygwin_installer"
    version = "2.9.0"
    license = "https://cygwin.com/COPYING"
    description = "Cygwin is a distribution of popular GNU and other Open Source tools running on Microsoft Windows"
    url = "https://github.com/bincrafters/conan-cygwin_installer"
    if conan_version < Version("0.99"):
        settings = {"os": ["Windows"], "arch": ["x86", "x86_64"]}
    else:
        settings = {"os_build": ["Windows"], "arch_build": ["x86", "x86_64"]}
    install_dir = 'cygwin-install'
    short_paths = True
    options = {"packages": "ANY",  # Comma separated, https://cygwin.com/packages/package_list.html
               "additional_packages": "ANY",  # Comma separated, https://cygwin.com/packages/package_list.html
               "exclude_files": "ANY", # Comma separated list of file patterns to exclude from the package
               "no_acl": [True, False],
               "cygwin": "ANY",  # https://cygwin.com/cygwin-ug-net/using-cygwinenv.html
               "db_enum": "ANY",  # https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nsswitch
               "db_home": "ANY",
               "db_shell": "ANY",
               "db_gecos": "ANY"}
    default_options = "packages=pkg-config,make,libtool,binutils,gcc-core,gcc-g++,autoconf,automake,gettext", \
                      "additional_packages=None", \
                      "exclude_files=None", \
                      "no_acl=False", \
                      "cygwin=None", \
                      "db_enum=None", \
                      "db_home=None", \
                      "db_shell=None", \
                      "db_gecos=None"

    @property
    def os(self):
        return self.settings.get_safe("os_build") or self.settings.get_safe("os")

    @property
    def arch(self):
        return self.settings.get_safe("arch_build") or self.settings.get_safe("arch")

    def build(self):
        filename = "setup-%s.exe" % self.arch
        url = "https://cygwin.com/%s" % filename
        tools.download(url, filename)

        if not os.path.isdir(self.install_dir):
            os.makedirs(self.install_dir)

        # https://cygwin.com/faq/faq.html#faq.setup.cli
        command = filename
        command += ' --arch %s' % self.arch
        # Disable creation of desktop and start menu shortcuts
        command += ' --no-shortcuts'
        # Do not check for and enforce running as Administrator
        command += ' --no-admin'
        # Unattended setup mode
        command += ' --quiet-mode'
        command += ' --root %s' % os.path.abspath(self.install_dir)
        # TODO : download and parse mirror list, probably also select the best one
        command += ' -s http://cygwin.mirror.constant.com'
        command += ' --local-package-dir %s' % tempfile.mkdtemp()
        packages = []
        if self.options.packages:
            packages.extend(str(self.options.packages).split(","))
        if self.options.additional_packages:
            packages.extend(str(self.options.additional_packages).split(","))
        if packages:
            command += ' --packages %s' % ','.join(packages)
        self.run(command)

        os.unlink(filename)

        # create /tmp dir in order to avoid
        # bash.exe: warning: could not find /tmp, please create!
        tmp_dir = os.path.join(self.install_dir, 'tmp')
        if not os.path.isdir(tmp_dir):
            os.makedirs(tmp_dir)
        tmp_name = os.path.join(tmp_dir, 'dummy')
        with open(tmp_name, 'a'):
            os.utime(tmp_name, None)

        def add_line(line):
            nsswitch_conf = os.path.join(self.install_dir, 'etc', 'nsswitch.conf')
            with open(nsswitch_conf, 'a') as f:
                f.write('%s\n' % line)

        if self.options.db_enum:
            add_line('db_enum: %s' % self.options.db_enum)
        if self.options.db_home:
            add_line('db_home: %s' % self.options.db_home)
        if self.options.db_shell:
            add_line('db_shell: %s' % self.options.db_shell)
        if self.options.db_gecos:
            add_line('db_gecos: %s' % self.options.db_gecos)

        if self.options.no_acl:
            fstab = os.path.join(self.install_dir, 'etc', 'fstab')
            tools.replace_in_file(fstab,
"""# This is default anyway:
none /cygdrive cygdrive binary,posix=0,user 0 0""",
"""none /cygdrive cygdrive noacl,binary,posix=0,user 0 0
{0}/bin /usr/bin ntfs binary,auto,noacl           0 0
{0}/lib /usr/lib ntfs binary,auto,noacl           0 0
{0}     /        ntfs override,binary,auto,noacl  0 0""".format(self.package_folder.replace('\\', '/')))

    def record_symlinks(self):
        symlinks = []
        root = os.path.join(self.build_folder, self.install_dir)
        try:
            output = subprocess.check_output(["attrib", "/S", "/D", os.path.join(root, '*')])
            lines = util.files.decode_text(output).split("\r\n")
        except (ValueError, FileNotFoundError, subprocess.CalledProcessError, UnicodeDecodeError) as e:
            raise errors.ConanException("attrib run error: %s" % str(e))
        attrib_re = re.compile(r'^([RASHOIXVPU ]+ )([A-Z]:.*)')
        for line in lines:
            match_obj = attrib_re.match(line)
            if match_obj:
                flags = match_obj.group(1)
                path = match_obj.group(2)
                if "S" in flags:
                    symlinks.append(os.path.relpath(path, root))
        symlinks_json = os.path.join(self.package_folder, "symlinks.json")
        tools.save(symlinks_json, json.dumps(symlinks))

    def package(self):
        self.record_symlinks()
        excludes = None
        if self.options.exclude_files:
            excludes = tuple(str(self.options.exclude_files).split(","))
        self.copy(pattern="*", dst=".", src=self.install_dir, excludes=excludes)

    def fix_symlinks(self):
        symlinks_json = os.path.join(self.package_folder, "symlinks.json")
        symlinks = json.loads(tools.load(symlinks_json))
        for path in symlinks:
            full_path = os.path.join(self.package_folder, path)
            self.run('attrib -R +S "%s"' % full_path)

    def package_info(self):
        # workaround for error "cannot execute binary file: Exec format error"
        # symbolic links must have system attribute in order to work properly
        self.fix_symlinks()

        cygwin_root = self.package_folder
        cygwin_bin = os.path.join(cygwin_root, "bin")

        self.output.info("Creating CYGWIN_ROOT env var : %s" % cygwin_root)
        self.env_info.CYGWIN_ROOT = cygwin_root

        self.output.info("Creating CYGWIN_BIN env var : %s" % cygwin_bin)
        self.env_info.CYGWIN_BIN = cygwin_bin

        self.output.info("Appending PATH env var with : " + cygwin_bin)
        self.env_info.path.append(cygwin_bin)

        if self.options.cygwin:
            self.output.info("Creating CYGWIN env var : %s" % self.options.cygwin)
            self.env_info.CYGWIN = str(self.options.cygwin)
Beispiel #9
0
def _clang_cppstd_default(compiler_version):
    return "gnu98" if Version(compiler_version) < "6.0" else "gnu14"
Beispiel #10
0
    def test_simple(self):
        v1 = Version("1.2.3")
        self.assertTrue(v1 == "1.2.3")
        self.assertTrue(v1 > "1.1")
        self.assertTrue(v1 > None)
        self.assertTrue(v1 < "1.11")
        self.assertTrue(v1 > "1.2")
        self.assertTrue(v1 > "1.2.2.2")
        self.assertTrue(v1 < "1.2.3.2")
        self.assertEqual(v1.major(), "1.Y.Z")  # 1.X.Y
        self.assertEqual(v1.minor(), "1.2.Z")  # 1.2.Y
        self.assertEqual(v1.patch(), "1.2.3")
        self.assertEqual(v1.pre(), "1.2.3")
        self.assertEqual(v1.build, "")
        self.assertTrue(v1.compatible("1.X"))
        self.assertTrue(v1.compatible("1.2.Y"))
        self.assertFalse(v1.compatible("0.X"))
        self.assertFalse(v1.compatible("1.2.2"))
        v2 = v1.minor()
        self.assertTrue(v2.compatible("1.X"))
        self.assertTrue(v2.compatible("1.2.3.4"))
        self.assertFalse(v2.compatible("1.3.3.4"))
        self.assertTrue(v2.major().compatible("1.3.3.4"))

        v1 = Version("1.2.rc1")
        self.assertTrue(v1 < "1.2.0")
        self.assertFalse(v1 < "1.1.9")

        self.assertTrue(Version("1.2.1-dev") < Version("1.2.1"))
        self.assertTrue(Version("1.2.1-dev") < Version("1.2.2"))
        self.assertTrue(Version("1.2.1-dev") < Version("1.3"))
        self.assertTrue(Version("1.2.1-dev") < Version("1.3-alpha"))
        self.assertTrue(Version("1.2.1-dev") > Version("1.2.0"))
        self.assertTrue(Version("1.2.1-dev") > Version("1.2"))
        self.assertTrue(Version("1.2.1-dev") > Version("1.2.alpha"))
        self.assertTrue(Version("1.2.1-dev") > Version("1.2-alpha"))

        self.assertFalse(Version("4") < Version("4.0.0"))
        self.assertFalse(Version("4") > Version("4.0.0"))
        self.assertFalse(Version("4") != Version("4.0.0"))
        self.assertTrue(Version("4") == Version("4.0.0"))
        self.assertTrue(Version("4") <= Version("4.0.0"))
        self.assertTrue(Version("4") >= Version("4.0.0"))
        self.assertTrue(Version("4.0") == Version("4.0.0"))

        self.assertTrue(Version("4.0.0") == Version("4.0.0"))
        self.assertTrue(Version("4.0.1") != "4")
        self.assertFalse(Version("4.0.0.1") == "4")
        self.assertTrue(Version("4.0.0.1") >= "4")
Beispiel #11
0
 def test_build(self):
     v1 = Version("0.2.3-alpha1+build2")
     self.assertEqual(v1.build, "build2")
     v2 = Version("0.2.3+b178")
     self.assertEqual(v2.build, "b178")
def get_client_version():
    from conans.model.version import Version
    from conans import __version__ as client_version
    # It is a mess comparing dev versions, lets assume that the -dev is the further release
    return Version(client_version.replace("-dev", ""))
Beispiel #13
0
class BitprimNodeCIntConan(ConanFile):
    name = "bitprim-node-cint"
    version = get_version()
    license = "http://www.boost.org/users/license.html"
    url = "https://github.com/bitprim/bitprim-node-cint"
    description = "Bitcoin Full Node Library with C interface"
    settings = "os", "compiler", "build_type", "arch"

    if conan_version < Version(get_conan_req_version()):
        raise Exception("Conan version should be greater or equal than %s" %
                        (get_conan_req_version(), ))

    options = {
        "shared": [True, False],
        "fPIC": [True, False],
        "with_tests": [True, False],
        "with_console": [True, False],
        "microarchitecture":
        "ANY",  #["x86_64", "haswell", "ivybridge", "sandybridge", "bulldozer", ...]
        "no_compilation": [True, False],
        "currency": ['BCH', 'BTC', 'LTC'],
        "verbose": [True, False],
    }
    # "with_litecoin": [True, False],

    #    "with_remote_blockchain": [True, False],
    #    "with_remote_database": [True, False],

    default_options = "shared=False", \
        "fPIC=True", \
        "with_tests=False", \
        "with_console=False",  \
        "microarchitecture=_DUMMY_",  \
        "no_compilation=False", \
        "currency=BCH", \
        "verbose=False"

    # "with_litecoin=False", \
    # "with_remote_blockchain=False", \
    # "with_remote_database=False", \

    generators = "cmake"
    exports = "conan_channel", "conan_version", "conan_req_version"
    exports_sources = "src/*", "CMakeLists.txt", "cmake/*", "bitprim-node-cintConfig.cmake.in", "bitprimbuildinfo.cmake", "include/*", "test/*", "console/*"
    package_files = "build/lbitprim-node-cint.so"
    build_policy = "missing"

    @property
    def msvc_mt_build(self):
        return "MT" in str(self.settings.compiler.runtime)

    @property
    def fPIC_enabled(self):
        if self.settings.compiler == "Visual Studio":
            return False
        else:
            return self.options.fPIC

    @property
    def is_shared(self):
        # if self.settings.compiler == "Visual Studio" and self.msvc_mt_build:
        #     return False
        # else:
        #     return self.options.shared
        return self.options.shared

    def requirements(self):
        if not self.options.no_compilation and self.settings.get_safe(
                "compiler") is not None:
            self.requires("boost/1.66.0@bitprim/stable")
            self.requires("bitprim-node/0.10.0@bitprim/%s" % get_channel())

    def config_options(self):
        # self.output.info('*-*-*-*-*-* def config_options(self):')
        if self.settings.compiler == "Visual Studio":
            self.options.remove("fPIC")

            #Note(fernando): too restrictive for the final user
            # if self.options.shared and self.msvc_mt_build:
            #     self.options.remove("shared")

    def configure(self):
        if self.options.no_compilation or (self.settings.compiler == None
                                           and self.settings.arch == 'x86_64'
                                           and self.settings.os
                                           in ('Linux', 'Windows', 'Macos')):
            self.settings.remove("compiler")
            self.settings.remove("build_type")

        if self.options.microarchitecture == "_DUMMY_":
            self.options.microarchitecture = get_cpu_microarchitecture()

            if get_cpuid() == None:
                march_from = 'default'
            else:
                march_from = 'taken from cpuid'

        else:
            march_from = 'user defined'

        self.options["*"].microarchitecture = self.options.microarchitecture
        self.output.info("Compiling for microarchitecture (%s): %s" %
                         (march_from, self.options.microarchitecture))

        self.options["*"].currency = self.options.currency
        self.output.info("Compiling for currency: %s" %
                         (self.options.currency, ))

    def package_id(self):
        # self.output.info('*-*-*-*-*-* def package_id(self):')

        self.info.options.with_tests = "ANY"
        self.info.options.with_console = "ANY"
        self.info.options.no_compilation = "ANY"
        self.info.options.verbose = "ANY"

        # self.info.requires.clear()
        # self.info.settings.compiler = "ANY"
        # self.info.settings.build_type = "ANY"

        #For Bitprim Packages libstdc++ and libstdc++11 are the same
        if self.settings.compiler == "gcc" or self.settings.compiler == "clang":
            if str(self.settings.compiler.libcxx) == "libstdc++" or str(
                    self.settings.compiler.libcxx) == "libstdc++11":
                self.info.settings.compiler.libcxx = "ANY"

    def build(self):
        cmake = CMake(self)

        cmake.definitions["USE_CONAN"] = option_on_off(True)
        cmake.definitions["NO_CONAN_AT_ALL"] = option_on_off(False)

        # cmake.definitions["CMAKE_VERBOSE_MAKEFILE"] = option_on_off(False)
        # cmake.verbose = False
        cmake.verbose = self.options.verbose

        # cmake.definitions["ENABLE_SHARED"] = option_on_off(self.options.shared)
        # cmake.definitions["ENABLE_SHARED_NODE_CINT"] = option_on_off(self.options.shared)
        # cmake.definitions["ENABLE_POSITION_INDEPENDENT_CODE"] = option_on_off(self.options.fPIC)

        cmake.definitions["ENABLE_SHARED"] = option_on_off(self.is_shared)
        cmake.definitions["ENABLE_SHARED_NODE_CINT"] = option_on_off(
            self.is_shared)
        cmake.definitions["ENABLE_POSITION_INDEPENDENT_CODE"] = option_on_off(
            self.fPIC_enabled)

        # cmake.definitions["WITH_REMOTE_BLOCKCHAIN"] = option_on_off(self.options.with_remote_blockchain)
        # cmake.definitions["WITH_REMOTE_DATABASE"] = option_on_off(self.options.with_remote_database)
        cmake.definitions["WITH_REMOTE_BLOCKCHAIN"] = option_on_off(False)
        cmake.definitions["WITH_REMOTE_DATABASE"] = option_on_off(False)

        cmake.definitions["WITH_TESTS"] = option_on_off(
            self.options.with_tests)
        cmake.definitions["WITH_CONSOLE"] = option_on_off(
            self.options.with_console)
        cmake.definitions["WITH_CONSOLE_NODE_CINT"] = option_on_off(
            self.options.with_console)

        # cmake.definitions["WITH_LITECOIN"] = option_on_off(self.options.with_litecoin)
        cmake.definitions["CURRENCY"] = self.options.currency
        cmake.definitions["MICROARCHITECTURE"] = self.options.microarchitecture

        if self.settings.compiler != "Visual Studio":
            # cmake.definitions["CONAN_CXX_FLAGS"] += " -Wno-deprecated-declarations"
            cmake.definitions["CONAN_CXX_FLAGS"] = cmake.definitions.get(
                "CONAN_CXX_FLAGS", "") + " -Wno-deprecated-declarations"

        if self.settings.compiler == "Visual Studio":
            cmake.definitions["CONAN_CXX_FLAGS"] = cmake.definitions.get(
                "CONAN_CXX_FLAGS",
                "") + " /DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE"

        if self.settings.compiler == "gcc":
            if float(str(self.settings.compiler.version)) >= 5:
                cmake.definitions["NOT_USE_CPP11_ABI"] = option_on_off(False)
            else:
                cmake.definitions["NOT_USE_CPP11_ABI"] = option_on_off(True)
        elif self.settings.compiler == "clang":
            if str(self.settings.compiler.libcxx) == "libstdc++" or str(
                    self.settings.compiler.libcxx) == "libstdc++11":
                cmake.definitions["NOT_USE_CPP11_ABI"] = option_on_off(False)

        cmake.definitions["BITPRIM_BUILD_NUMBER"] = os.getenv(
            'BITPRIM_BUILD_NUMBER', '-')
        cmake.configure(source_dir=self.source_folder)
        cmake.build()

        if self.options.with_tests:
            cmake.test()

    # def imports(self):
    # print('def imports')
    # self.copy("*.h", "", "include")
    # self.copy("*.h", dst="/Users/fernando/fertest", src="include")
    # self.copy("*.hpp", dst="/Users/fernando/fertest", src="include")
    # self.copy("*.a", dst="/Users/fernando/fertest", src="include")

    def package(self):
        # print('def package')
        self.copy("*.h", dst="include", src="include")
        self.copy("*.hpp", dst="include", src="include")
        self.copy("*.ipp", dst="include", src="include")
        self.copy("*.lib", dst="lib", keep_path=False)
        self.copy("*.dll", dst="bin", keep_path=False)
        self.copy("*.dylib*", dst="lib", keep_path=False)
        self.copy("*.so", dst="lib", keep_path=False)
        self.copy("*.a", dst="lib", keep_path=False)

    def package_info(self):
        self.cpp_info.includedirs = ['include']
        self.cpp_info.libs = ["bitprim-node-cint"]
Beispiel #14
0
    def run(self):

        if self._config_url:
            ConfigManager(self._conan_api,
                          self.printer).install(url=self._config_url)

        context = tools.no_op()
        compiler = self.settings.get("compiler", None)
        if not self._exclude_vcvars_precommand:
            if compiler == "Visual Studio" and "compiler.version" in self.settings:
                compiler_set = namedtuple("compiler", "version")(
                    self.settings["compiler.version"])
                mock_sets = namedtuple(
                    "mock_settings", "arch compiler get_safe")(
                        self.settings["arch"], compiler_set,
                        lambda x: self.settings.get(x, None))
                context = tools.vcvars(mock_sets)
        with context:
            self.printer.print_rule()
            self.printer.print_profile(tools.load(self._profile_abs_path))

            with self.printer.foldable_output("conan_create"):
                name, version, user, channel = self._reference
                if self._build_policy:
                    self._build_policy = [self._build_policy]
                # https://github.com/conan-io/conan-package-tools/issues/184
                with tools.environment_append({"_CONAN_CREATE_COMMAND_": "1"}):
                    params = {
                        "name": name,
                        "version": version,
                        "user": user,
                        "channel": channel,
                        "build_modes": self._build_policy,
                        "profile_name": self._profile_abs_path
                    }
                    self.printer.print_message("Calling 'conan create'")
                    self.printer.print_dict(params)
                    with tools.chdir(self._cwd):
                        if Version(client_version) >= "1.8.0":
                            from conans.errors import ConanInvalidConfiguration
                            exc_class = ConanInvalidConfiguration
                        else:
                            exc_class = None

                        try:
                            r = self._conan_api.create(
                                ".",
                                name=name,
                                version=version,
                                user=user,
                                channel=channel,
                                build_modes=self._build_policy,
                                profile_name=self._profile_abs_path,
                                test_folder=self._test_folder)
                        except exc_class as e:
                            self.printer.print_rule()
                            self.printer.print_message(
                                "Skipped configuration by the recipe: "
                                "%s" % str(e))
                            self.printer.print_rule()
                            return
                        for installed in r['installed']:
                            if installed["recipe"]["id"] == str(
                                    self._reference):
                                package_id = installed['packages'][0]['id']
                                if installed['packages'][0]["built"]:
                                    self._uploader.upload_packages(
                                        self._reference, self._upload,
                                        package_id)
                                else:
                                    self.printer.print_message(
                                        "Skipping upload for %s, "
                                        "it hasn't been built" % package_id)
    def test_docker(self):
        client_version = get_client_version()
        ci_manager = MockCIManager()
        unique_ref = "zlib/%s" % str(time.time())
        conanfile = """from conans import ConanFile
import os

class Pkg(ConanFile):
    settings = "os", "compiler", "build_type", "arch"

"""

        self.save_conanfile(conanfile)
        with tools.environment_append({"CONAN_DOCKER_RUN_OPTIONS": "--network=host -v{}:/tmp/cpt".format(self.root_project_folder),
                                       "CONAN_DOCKER_ENTRY_SCRIPT": "pip install -U /tmp/cpt",
                                       "CONAN_USE_DOCKER": "1",
                                       "CONAN_DOCKER_IMAGE_SKIP_UPDATE": "TRUE",
                                       "CONAN_LOGIN_USERNAME": "******",
                                       "CONAN_USERNAME": "******",
                                       "CONAN_UPLOAD": DockerTest.CONAN_SERVER_ADDRESS,
                                       "CONAN_PASSWORD": "******"}):

            self.packager = ConanMultiPackager(channel="mychannel",
                                               gcc_versions=["6"],
                                               archs=["x86", "x86_64"],
                                               build_types=["Release"],
                                               reference=unique_ref,
                                               ci_manager=ci_manager)
            self.packager.add_common_builds()
            self.packager.run()

        search_pattern = "%s*" % unique_ref
        ref = ConanFileReference.loads("%s@demo/mychannel" % unique_ref)

        # Remove from remote
        if Version(client_version) < Version("1.7"):
            results = self.api.search_recipes(search_pattern, remote="upload_repo")["results"][0]["items"]
            self.assertEquals(len(results), 1)
            packages = self.api.search_packages(ref, remote="upload_repo")["results"][0]["items"][0]["packages"]
            self.assertEquals(len(packages), 2)
            self.api.authenticate(name=CONAN_LOGIN_UPLOAD, password=CONAN_UPLOAD_PASSWORD,
                                  remote="upload_repo")
            self.api.remove(search_pattern, remote="upload_repo", force=True)
            self.assertEquals(self.api.search_recipes(search_pattern)["results"], [])
        else:
            results = self.api.search_recipes(search_pattern, remote_name="upload_repo")["results"][0]["items"]
            self.assertEquals(len(results), 1)
            if Version(client_version) >= Version("1.12.0"):
                ref = repr(ref)
            packages = self.api.search_packages(ref, remote_name="upload_repo")["results"][0]["items"][0]["packages"]
            self.assertEquals(len(packages), 2)
            self.api.authenticate(name="demo", password="******",
                                  remote_name="upload_repo")
            self.api.remove(search_pattern, remote_name="upload_repo", force=True)
            self.assertEquals(self.api.search_recipes(search_pattern)["results"], [])

        # Try upload only when stable, shouldn't upload anything
        with tools.environment_append({"CONAN_DOCKER_RUN_OPTIONS": "--network=host -v{}:/tmp/cpt".format(self.root_project_folder),
                                       "CONAN_DOCKER_ENTRY_SCRIPT": "pip install -U /tmp/cpt",
                                       "CONAN_USE_DOCKER": "1",
                                       "CONAN_LOGIN_USERNAME": "******",
                                       "CONAN_USERNAME": "******",
                                       "CONAN_PASSWORD": "******",
                                       "CONAN_DOCKER_IMAGE_SKIP_UPDATE": "TRUE",
                                       "CONAN_UPLOAD_ONLY_WHEN_STABLE": "1"}):
            self.packager = ConanMultiPackager(channel="mychannel",
                                               gcc_versions=["6"],
                                               archs=["x86", "x86_64"],
                                               build_types=["Release"],
                                               reference=unique_ref,
                                               upload=DockerTest.CONAN_SERVER_ADDRESS,
                                               ci_manager=ci_manager)
            self.packager.add_common_builds()
            self.packager.run()

        if Version(client_version) < Version("1.7"):
            results = self.api.search_recipes(search_pattern, remote="upload_repo")["results"]
            self.assertEquals(len(results), 0)
            self.api.remove(search_pattern, remote="upload_repo", force=True)
        else:
            results = self.api.search_recipes(search_pattern, remote_name="upload_repo")["results"]
            self.assertEquals(len(results), 0)
            self.api.remove(search_pattern, remote_name="upload_repo", force=True)
Beispiel #16
0
    def __init__(self, args=None, username=None, channel=None, runner=None,
                 gcc_versions=None, visual_versions=None, visual_runtimes=None,
                 apple_clang_versions=None, archs=None,
                 use_docker=None, curpage=None, total_pages=None,
                 docker_image=None, reference=None, password=None, remote=None,
                 remotes=None,
                 upload=None, stable_branch_pattern=None,
                 vs10_x86_64_enabled=False,
                 mingw_configurations=None,
                 stable_channel=None,
                 platform_info=None,
                 upload_retry=None,
                 clang_versions=None,
                 login_username=None,
                 upload_only_when_stable=False,
                 build_types=None,
                 skip_check_credentials=False,
                 allow_gcc_minors=False,
                 exclude_vcvars_precommand=False,
                 docker_image_skip_update=False,
                 docker_entry_script=None,
                 docker_32_images=None):

        self.sudo_command = ""
        if "CONAN_DOCKER_USE_SUDO" in os.environ:
            if get_bool_from_env("CONAN_DOCKER_USE_SUDO"):
                self.sudo_command = "sudo"
        elif platform.system() == "Linux":
            self.sudo_command = "sudo"

        self.exclude_vcvars_precommand = exclude_vcvars_precommand or os.getenv("CONAN_EXCLUDE_VCVARS_PRECOMMAND", False)
        self.docker_image_skip_update = docker_image_skip_update or os.getenv("CONAN_DOCKER_IMAGE_SKIP_UPDATE", False)
        self.allow_gcc_minors = allow_gcc_minors or os.getenv("CONAN_ALLOW_GCC_MINORS", False)
        self._builds = []
        self._named_builds = {}
        self._platform_info = platform_info or PlatformInfo()
        self.runner = runner or os.system
        self.output_runner = ConanOutputRunner()
        self.args = args or " ".join(sys.argv[1:])
        self.username = username or os.getenv("CONAN_USERNAME", None)
        self.login_username = login_username or os.getenv("CONAN_LOGIN_USERNAME",
                                                          None) or self.username
        if not self.username:
            raise Exception("Instance ConanMultiPackage with 'username' "
                            "parameter or use CONAN_USERNAME env variable")

        # Upload related variables
        self.upload_retry = upload_retry or os.getenv("CONAN_UPLOAD_RETRY", 3)
        self.reference = reference or os.getenv("CONAN_REFERENCE", None)
        self.password = password or os.getenv("CONAN_PASSWORD", None)
        self.remote = remote or os.getenv("CONAN_REMOTE", None)

        # User is already logged
        self._logged_user_in_remote = defaultdict(lambda: False)

        if self.remote:
            raise Exception('''
'remote' argument is deprecated. Use:
        - 'upload' argument to specify the remote URL to upload your packages (or None to disable
        upload)
        - 'remotes' argument to specify additional remote URLs, for example, different user
        repositories.
''')

        self.remotes = remotes or os.getenv("CONAN_REMOTES", [])
        self.upload = upload if upload is not None else os.getenv("CONAN_UPLOAD", None)
        # The username portion of the remote URLs must be all lowercase to work
        if self.remotes:
            if isinstance(self.remotes,list):
                self.remotes = [remote.lower() for remote in self.remotes]
            else:
                self.remotes = self.remotes.lower()
        if self.upload:
            self.upload = self.upload.lower()

        self.stable_branch_pattern = stable_branch_pattern or \
                                     os.getenv("CONAN_STABLE_BRANCH_PATTERN", None)
        default_channel = channel or os.getenv("CONAN_CHANNEL", "testing")
        self.stable_channel = stable_channel or os.getenv("CONAN_STABLE_CHANNEL", "stable")
        self.channel = self._get_channel(default_channel, self.stable_channel)

        if self.reference:
            self.reference = ConanFileReference.loads("%s@%s/%s" % (self.reference,
                                                                    self.username, self.channel))
        self.upload_only_when_stable = upload_only_when_stable or \
                                       os.getenv("CONAN_UPLOAD_ONLY_WHEN_STABLE", False)
        self.skip_check_credentials = skip_check_credentials or \
                                      os.getenv("CONAN_SKIP_CHECK_CREDENTIALS", False)

        self.docker_entry_script = docker_entry_script or \
                                      os.getenv("CONAN_DOCKER_ENTRY_SCRIPT", None)

        if self.upload:
            if self.upload in ("0", "None", "False"):
                self.upload = None
            elif self.upload == "1":
                raise Exception("WARNING! 'upload' argument has changed. Use 'upload' argument or "
                                "CONAN_UPLOAD environment variable to specify a remote URL to "
                                "upload your packages. e.j: "
                                "upload='https://api.bintray.com/conan/myuser/myconanrepo'")

        os.environ["CONAN_CHANNEL"] = self.channel

        self.clang_versions = clang_versions or split_colon_env("CONAN_CLANG_VERSIONS")
        self.gcc_versions = gcc_versions or split_colon_env("CONAN_GCC_VERSIONS")

        # If there are some GCC versions declared then we don't default the clang
        # versions
        if not self.clang_versions and not self.gcc_versions:
            self.clang_versions = self.default_clang_versions

        # If there are some CLANG versions declared then we don't default the gcc
        # versions
        if not self.gcc_versions and self.clang_versions == self.default_clang_versions:
            self.gcc_versions = self.default_gcc_versions

        if self.gcc_versions and not self.allow_gcc_minors:
            for a_version in self.gcc_versions:
                if Version(a_version) >= Version("5") and "." in a_version:
                    raise Exception("""
******************* DEPRECATED GCC MINOR VERSIONS! ***************************************

- The use of gcc versions >= 5 and specifying the minor version (e.j "5.4") is deprecated.
- The ABI of gcc >= 5 (5, 6, and 7) is compatible between minor versions (e.j 5.3 is compatible with 5.4)
- Specify only the major in your script:
   - CONAN_GCC_VERSIONS="5,6,7" if you are using environment variables.
   - gcc_versions=["5", "6", "7"] if you are using the constructor parameter.

You can still keep using the same docker images, or use the new "lasote/conangcc5", "lasote/conangcc6", "lasote/conangcc7"

If you still want to keep the old behavior, set the environment var CONAN_ALLOW_GCC_MINORS or pass the
"allow_gcc_minors=True" parameter. But it is not recommended, if your packages are public most users
won't be able to use them.

******************************************************************************************

""")

        if visual_versions is not None:
            self.visual_versions = visual_versions
        else:
            self.visual_versions = split_colon_env("CONAN_VISUAL_VERSIONS")
            if not self.visual_versions and not mingw_configurations and not get_mingw_config_from_env():
                self.visual_versions = self.default_visual_versions
            elif mingw_configurations or get_mingw_config_from_env():
                self.visual_versions = []

        self.visual_runtimes = visual_runtimes or split_colon_env("CONAN_VISUAL_RUNTIMES") or \
                               self.default_visual_runtimes

        self.apple_clang_versions = apple_clang_versions or \
                                    split_colon_env("CONAN_APPLE_CLANG_VERSIONS") or \
                                    self.default_apple_clang_versions

        self.mingw_configurations = mingw_configurations or get_mingw_config_from_env()
        env_ref = os.getenv("CONAN_MINGW_INSTALLER_REFERENCE")
        self.mingw_installer_reference = ConanFileReference.loads(env_ref or
                                                                  "mingw_installer/1.0"
                                                                  "@conan/stable")

        if not archs and not os.getenv("CONAN_ARCHS") and platform.system() == "Darwin":
            self.default_archs = ["x86_64"]  # No longer supported (by default) x86 macos

        self.archs = archs or split_colon_env("CONAN_ARCHS") or self.default_archs

        self.build_types = build_types or split_colon_env("CONAN_BUILD_TYPES") or \
                           self.default_build_types

        # If CONAN_DOCKER_IMAGE is speified, then use docker is True
        self.use_docker = use_docker or os.getenv("CONAN_USE_DOCKER", False) or \
                          (os.getenv("CONAN_DOCKER_IMAGE", None) is not None)

        if docker_32_images is not None:
            self.docker_32_images = docker_32_images
        else:
            self.docker_32_images = os.getenv("CONAN_DOCKER_32_IMAGES", False)

        self.curpage = curpage or os.getenv("CONAN_CURRENT_PAGE", 1)
        self.total_pages = total_pages or os.getenv("CONAN_TOTAL_PAGES", 1)
        self.docker_image = docker_image or os.getenv("CONAN_DOCKER_IMAGE", None)

        if self.password:
            self.password = self.password.replace('"', '\\"')

        self.conan_pip_package = os.getenv("CONAN_PIP_PACKAGE", "conan==%s" % client_version)
        self.vs10_x86_64_enabled = vs10_x86_64_enabled

        # Set the remotes
        if self.remotes:
            if not isinstance(self.remotes, list):
                self.remotes = [r.strip() for r in self.remotes.split(",") if r.strip()]
            for counter, remote in enumerate(reversed(self.remotes)):
                remote_name = "remote%s" % counter if remote != self.upload else "upload_repo"
                self.add_remote_safe(remote_name, remote, insert=True)
            self.runner("conan remote list")
        else:
            logger.info("Not additional remotes declared...")

        if self.upload and self.upload not in self.remotes:
            # If you specify the upload as a remote, put it first
            # this way we can cover all the possibilities
            self.add_remote_safe("upload_repo", self.upload, insert=False)

        _, client_cache, _ = Conan.factory()
        self.data_home = client_cache.store
        self.builds_in_current_page = []
Beispiel #17
0
 def get_aix_version():
     try:
         ret = check_output("oslevel").strip()
         return Version(ret)
     except Exception:
         return Version("%s.%s" % (platform.version(), platform.release()))
Beispiel #18
0
class BitprimPaymentChannelConan(ConanFile):
    name = "paych"
    version = get_version()
    license = "http://www.boost.org/users/license.html"
    url = "https://github.com/bitprim/bitprim-payment-channels"
    description = "Payment Channels Experiments"
    settings = "os", "compiler", "build_type", "arch"
    # settings = "os", "arch"

    if conan_version < Version(get_conan_req_version()):
        raise Exception("Conan version should be greater or equal than %s" %
                        (get_conan_req_version(), ))

    options = {
        "currency": ['BCH', 'BTC', 'LTC'],
        "microarchitecture": "ANY",
        "no_compilation": [True, False],
        "verbose": [True, False],
    }

    default_options = "currency=BCH", \
                      "microarchitecture=_DUMMY_",  \
                      "no_compilation=False",  \
                      "verbose=False"

    generators = "cmake"
    exports = "conan_channel", "conan_version", "conan_req_version"
    exports_sources = "CMakeLists.txt", "cmake/*", "src/*", "bitprimbuildinfo.cmake"
    build_policy = "missing"

    def requirements(self):
        if not self.options.no_compilation and self.settings.get_safe(
                "compiler") is not None:
            self.requires("bitprim-node/0.8@bitprim/%s" % get_channel())

    def configure(self):
        if self.options.no_compilation or (self.settings.compiler == None
                                           and self.settings.arch == 'x86_64'
                                           and self.settings.os
                                           in ('Linux', 'Windows', 'Macos')):
            self.settings.remove("compiler")
            self.settings.remove("build_type")

        if self.options.microarchitecture == "_DUMMY_":
            self.options.microarchitecture = get_cpu_microarchitecture()

            if get_cpuid() == None:
                march_from = 'default'
            else:
                march_from = 'taken from cpuid'

        else:
            march_from = 'user defined'

        self.options["*"].microarchitecture = self.options.microarchitecture
        self.output.info("Compiling for microarchitecture (%s): %s" %
                         (march_from, self.options.microarchitecture))

        self.options["*"].currency = self.options.currency
        self.output.info("Compiling for currency: %s" %
                         (self.options.currency, ))

    def package_id(self):
        self.info.requires.clear()
        self.info.settings.compiler = "ANY"
        self.info.settings.build_type = "ANY"
        self.info.options.no_compilation = "ANY"
        self.info.options.verbose = "ANY"

    def deploy(self):
        self.copy("bn.exe", src="bin")  # copy from current package
        self.copy("bn", src="bin")  # copy from current package
        # self.copy_deps("*.dll") # copy from dependencies

    def build(self):
        cmake = CMake(self)

        cmake.definitions["USE_CONAN"] = option_on_off(True)
        cmake.definitions["NO_CONAN_AT_ALL"] = option_on_off(False)
        cmake.verbose = self.options.verbose
        cmake.definitions["CURRENCY"] = self.options.currency
        cmake.definitions["MICROARCHITECTURE"] = self.options.microarchitecture

        if self.settings.compiler == "gcc":
            if float(str(self.settings.compiler.version)) >= 5:
                cmake.definitions["NOT_USE_CPP11_ABI"] = option_on_off(False)
            else:
                cmake.definitions["NOT_USE_CPP11_ABI"] = option_on_off(True)
        elif self.settings.compiler == "clang":
            if str(self.settings.compiler.libcxx) == "libstdc++" or str(
                    self.settings.compiler.libcxx) == "libstdc++11":
                cmake.definitions["NOT_USE_CPP11_ABI"] = option_on_off(False)

        cmake.definitions["BITPRIM_BUILD_NUMBER"] = os.getenv(
            'BITPRIM_BUILD_NUMBER', '-')
        cmake.configure(source_dir=self.source_folder)
        cmake.build()

    # def imports(self):
    #     self.copy("*.h", "", "include")

    def package(self):
        self.copy("pctest.exe", dst="bin", src="bin")  # Windows
        self.copy("pctest", dst="bin", src="bin")  # Linux / Macos
    def __init__(self,
                 profile_abs_path,
                 reference,
                 conan_api,
                 uploader,
                 exclude_vcvars_precommand=False,
                 build_policy=None,
                 runner=None,
                 cwd=None,
                 printer=None,
                 upload=False,
                 upload_only_recipe=None,
                 test_folder=None,
                 config_url=None,
                 config_args=None,
                 upload_dependencies=None,
                 conanfile=None,
                 skip_recipe_export=False,
                 update_dependencies=False,
                 lockfile=None):

        self.printer = printer or Printer()
        self._cwd = cwd or os.getcwd()
        self._uploader = uploader
        self._upload = upload
        self._conan_api = conan_api
        self._profile_abs_path = profile_abs_path
        self._reference = reference
        self._exclude_vcvars_precommand = exclude_vcvars_precommand
        self._build_policy = build_policy.split(",") if \
                             isinstance(build_policy, str) else \
                             build_policy
        self._runner = PrintRunner(runner or os.system, self.printer)
        self._test_folder = test_folder
        self._config_url = config_url
        self._config_args = config_args
        self._upload_only_recipe = upload_only_recipe
        self._conanfile = conanfile
        self._lockfile = lockfile
        self._upload_dependencies = upload_dependencies.split(",") if \
                                    isinstance(upload_dependencies, str) else \
                                    upload_dependencies
        self._upload_dependencies = self._upload_dependencies or []
        self.skip_recipe_export = skip_recipe_export
        self._update_dependencies = update_dependencies
        self._results = None

        patch_default_base_profile(conan_api, profile_abs_path)
        client_version = get_client_version()

        if client_version < Version("1.12.0"):
            cache = self._conan_api._client_cache
        elif client_version < Version("1.18.0"):
            cache = self._conan_api._cache
        else:
            if not conan_api.app:
                conan_api.create_app()
            cache = conan_api.app.cache

        self._profile = load_profile(profile_abs_path, cache)

        if isinstance(self._test_folder,
                      str) and self._test_folder.lower() == "false":
            self._test_folder = False
class MingwInstallerConan(ConanFile):
    name = "mingw_installer"
    version = "1.0"
    license = "http://www.mingw.org/license"
    url = "http://github.com/lasote/conan-mingw-installer"

    if conan_version < Version("0.99"):
        os_name = "os"
        arch_name = "arch"
    else:
        os_name = "os_build"
        arch_name = "arch_build"

    settings = {
        os_name: ["Windows"],
        arch_name: ["x86", "x86_64"],
        "compiler": {
            "gcc": {
                "version": None,
                "libcxx": ["libstdc++", "libstdc++11"],
                "threads": ["posix", "win32"],
                "exception": ["dwarf2", "sjlj", "seh"]
            }
        }
    }

    # update the file listing the available MinGW versions
    options = {"update_list": [True, False]}
    default_options = "update_list=False"

    # we provide a list of MinGW
    exports_sources = ['repository.txt']

    # the link below is the online list of available MinGW
    # useful for ensuring this recipe provides the same versions available through the official mingw64-installer
    repository_file = 'https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/repository.txt/download'

    build_policy = "missing"
    description = 'MinGW, a contraction of "Minimalist GNU for Windows", ' \
                  'is a minimalist development environment for native Microsoft' \
                  ' Windows applications.'
    build_requires = "7z_installer/1.0@conan/stable"

    @property
    def arch(self):
        return self.settings.get_safe("arch_build") or self.settings.get_safe(
            "arch")

    def update_repository(self):
        tools.download(self.repository_file, "repository.txt", overwrite=True)

    def build(self):

        if self.options.update_list:
            self.output.info("Updating MinGW List ... please wait.")
            self.update_repository()

        mingw_arch = 'x86_64' if self.arch == 'x86_64' else 'i686'

        mingw_list = MingwList()

        v = str(self.settings.compiler.version).split(".")
        if len(v) > 0:
            v_major = v[0]

        v_minor = v[1] if len(v) > 1 else "best"
        v_patch = v[2] if len(v) > 2 else "best"

        mingw_info, mingw_obj = mingw_list.get(
            mingw_arch, str(self.settings.compiler.threads),
            str(self.settings.compiler.exception), v_major, v_minor, v_patch)
        self.output.info(mingw_info)
        self.output.info("Found MinGW: %s" % mingw_obj.print_obj())

        self.output.info("Downloading: %s" % mingw_obj.url)
        tools.download(mingw_obj.url, "file.7z")
        self.run("7z x file.7z")

    def package(self):
        self.copy("*", dst="", src="mingw32")
        self.copy("*", dst="", src="mingw64")

    def package_id(self):
        # option to update the list of mingw available does not affect package's id
        self.info.options.update_list = "any"

    def package_info(self):
        self.env_info.path.append(os.path.join(self.package_folder, "bin"))
        self.env_info.MINGW_HOME = str(self.package_folder)
        self.env_info.CONAN_CMAKE_GENERATOR = "MinGW Makefiles"
        self.env_info.CXX = os.path.join(self.package_folder, "bin", "g++.exe")
        self.env_info.CC = os.path.join(self.package_folder, "bin", "gcc.exe")
Beispiel #21
0
 def configure(self):
     if self.settings.os == "Windows":
         if self.settings.compiler == "Visual Studio" and Version(self.settings.compiler.version.value) <= "12":
             raise ConanInvalidConfiguration("Google Test {} does not support Visual Studio <= 12".format(self.version))
Beispiel #22
0
 def package_id(self):
     v = Version(str(self.settings.compiler.version))
     if self.settings.compiler == "Visual Studio" and (v >= "14"):
         self.info.settings.compiler.version = "VS version >= VS2015"
Beispiel #23
0
class SVN(SCMBase):
    cmd_command = "svn"
    file_protocol = 'file:///' if platform.system() == "Windows" else 'file://'
    API_CHANGE_VERSION = Version("1.9")  # CLI changes in 1.9

    def __init__(self, folder=None, runner=None, *args, **kwargs):
        def runner_no_strip(command):
            return check_output(command)
        runner = runner or runner_no_strip
        super(SVN, self).__init__(folder=folder, runner=runner, *args, **kwargs)

    @staticmethod
    def get_version():
        try:
            out, _ = subprocess.Popen(["svn", "--version"], stdout=subprocess.PIPE).communicate()
            version_line = decode_text(out).split('\n', 1)[0]
            version_str = version_line.split(' ', 3)[2]
            return Version(version_str)
        except Exception as e:
            raise ConanException("Error retrieving SVN version: '{}'".format(e))

    @property
    def version(self):
        if not hasattr(self, '_version'):
            version = SVN.get_version()
            setattr(self, '_version', version)
        return getattr(self, '_version')

    def run(self, command):
        # Ensure we always pass some params
        extra_options = " --no-auth-cache --non-interactive"
        if not self._verify_ssl:
            if self.version >= SVN.API_CHANGE_VERSION:
                extra_options += " --trust-server-cert-failures=unknown-ca"
            else:
                extra_options += " --trust-server-cert"
        return super(SVN, self).run(command="{} {}".format(command, extra_options))

    def _show_item(self, item, target='.'):
        self.check_repo()
        if self.version >= SVN.API_CHANGE_VERSION:
            value = self.run("info --show-item {item} \"{target}\"".format(item=item, target=target))
            return value.strip()
        else:
            output = self.run("info --xml \"{target}\"".format(target=target))
            root = ET.fromstring(output)
            if item == 'revision':
                return root.findall("./entry")[0].get("revision")
            elif item == 'url':
                return root.findall("./entry/url")[0].text
            elif item == 'wc-root':
                return root.findall("./entry/wc-info/wcroot-abspath")[0].text
            elif item == 'last-changed-revision':
                return root.findall("./entry/commit")[0].get("revision")
            elif item == 'relative-url':
                root_url = root.findall("./entry/repository/root")[0].text
                url = self._show_item(item='url', target=target)
                if url.startswith(root_url):
                    return url[len(root_url):]
            raise ConanException("Retrieval of item '{}' not implemented for SVN<{}".format(
                item, SVN.API_CHANGE_VERSION))

    def checkout(self, url, revision="HEAD"):
        output = ""
        try:
            self.check_repo()
        except ConanException:
            output += self.run('co "{url}" .'.format(url=url))
        else:
            assert url.lower() == self.get_remote_url().lower(), \
                "%s != %s" % (url, self.get_remote_url())
            output += self.run("revert . --recursive")
        finally:
            output += self.update(revision=revision)
        return output

    def update(self, revision='HEAD'):
        self.check_repo()
        return self.run("update -r {rev}".format(rev=revision))

    def excluded_files(self):
        self.check_repo()
        excluded_list = []
        output = self.run("status --no-ignore")
        for it in output.splitlines():
            if it.startswith('I'):  # Only ignored files
                filepath = it[8:].strip()
                excluded_list.append(os.path.normpath(filepath))
        return excluded_list

    def get_remote_url(self, remove_credentials=False):
        url = self._show_item('url')
        if remove_credentials and not os.path.exists(url):  # only if not local
            url = self._remove_credentials_url(url)
        return url

    def get_qualified_remote_url(self, remove_credentials=False):
        # Return url with peg revision
        url = self.get_remote_url(remove_credentials=remove_credentials)
        revision = self.get_revision()
        return "{url}@{revision}".format(url=url, revision=revision)

    def is_local_repository(self):
        url = self.get_remote_url()
        return (url.startswith(self.file_protocol) and
                os.path.exists(unquote(url[len(self.file_protocol):])))

    def is_pristine(self):
        # Check if working copy is pristine/consistent
        if self.version >= SVN.API_CHANGE_VERSION:
            try:
                output = self.run("status -u -r {} --xml".format(self.get_revision()))
            except subprocess.CalledProcessError:
                return False
            else:
                root = ET.fromstring(output)

                pristine_item_list = ['external', 'ignored', 'none', 'normal']
                pristine_props_list = ['normal', 'none']
                for item in root.findall('.//wc-status'):
                    if item.get('item', 'none') not in pristine_item_list:
                        return False
                    if item.get('props', 'none') not in pristine_props_list:
                        return False

                for item in root.findall('.//repos-status'):
                    if item.get('item', 'none') not in pristine_item_list:
                        return False
                    if item.get('props', 'none') not in pristine_props_list:
                        return False
                return True
        else:
            if self._output:
                self._output.warn("SVN::is_pristine for SVN v{} (less than {}) is not implemented,"
                                  " it is returning not-pristine always because it cannot compare"
                                  " with checked out version.".format(self.version,
                                                                      SVN.API_CHANGE_VERSION))
            return False

    def get_revision(self):
        return self._show_item('revision')

    def get_revision_message(self):
        output = self.run("log -r COMMITTED").splitlines()
        return output[3] if len(output) > 2 else None

    def get_repo_root(self):
        return self._show_item('wc-root')

    def get_last_changed_revision(self, use_wc_root=True):
        if use_wc_root:
            return self._show_item(item='last-changed-revision', target=self.get_repo_root())
        else:
            return self._show_item(item='last-changed-revision')

    def get_branch(self):
        item = self._get_item("branches/[^/]+|trunk", "branch")
        return item.replace("branches/", "") if item else None

    def get_tag(self):
        item = self._get_item("tags/[^/]+", "tag")
        return item.replace("tags/", "") if item else None

    def _get_item(self, pattern, item_name):
        try:
            url = self._show_item('relative-url')
        except Exception as e:
            raise ConanException("Unable to get svn %s from %s: %s"
                                 % (item_name, self.folder, str(e)))
        item = re.search(pattern, url)
        return item.group(0) if item else None

    def check_repo(self):
        """ Check if it is a valid SVN repo """
        _check_repo(["svn", "info"], folder=self.folder)
Beispiel #24
0
 def build_requirements(self):
     # Ensure the package is build against a version of CMake from 3.16 onwards.
     if CMake.get_version() < Version("3.16"):
         self.build_requires("cmake/3.16.4")
    def __init__(self, reference, os_name, gcc_versions, apple_clang_versions, clang_versions,
                 visual_versions, visual_runtimes, visual_toolsets, vs10_x86_64_enabled,
                 mingw_configurations, archs, allow_gcc_minors, build_types, options, cppstds):

        self._visual_toolsets = visual_toolsets
        self._os_name = os_name
        self._reference = reference
        self._vs10_x86_64_enabled = vs10_x86_64_enabled
        self._allow_gcc_minors = allow_gcc_minors or os.getenv("CONAN_ALLOW_GCC_MINORS", False)

        self._clang_versions = clang_versions or split_colon_env("CONAN_CLANG_VERSIONS")
        self._gcc_versions = gcc_versions or split_colon_env("CONAN_GCC_VERSIONS")

        # If there are some GCC versions declared then we don't default the clang
        # versions
        if self._clang_versions is None:
            if not self._gcc_versions:
                self._clang_versions = default_clang_versions
            else:
                self._clang_versions = []

        # If there are some CLANG versions declared then we don't default the gcc
        # versions
        if self._gcc_versions is None:
            if self._clang_versions == default_clang_versions:
                self._gcc_versions = default_gcc_versions
            else:
                self._gcc_versions = []

        if self._gcc_versions and not self._allow_gcc_minors:
            for a_version in self._gcc_versions:
                if Version(str(a_version)) >= Version("5") and "." in str(a_version):
                    raise Exception("""
******************* DEPRECATED GCC MINOR VERSIONS! ***************************************

- The use of gcc versions >= 5 and specifying the minor version (e.j "5.4") is deprecated.
- The ABI of gcc >= 5 (5, 6, and 7) is compatible between minor versions (e.j 5.3 is compatible with 5.4)
- Specify only the major in your script:
   - CONAN_GCC_VERSIONS="5,6,7" if you are using environment variables.
   - gcc_versions=["5", "6", "7"] if you are using the constructor parameter.

You can still keep using the same docker images, or use the new "conanio/gcc5", "conanio/gcc6", "conanio/gcc7"

If you still want to keep the old behavior, set the environment var CONAN_ALLOW_GCC_MINORS or pass the
"allow_gcc_minors=True" parameter. But it is not recommended, if your packages are public most users
won't be able to use them.

******************************************************************************************

""")

        self._visual_versions = visual_versions or split_colon_env("CONAN_VISUAL_VERSIONS")
        if self._visual_versions is None:
            if not mingw_configurations and not get_mingw_config_from_env():
                self._visual_versions = default_visual_versions
            else:
                self._visual_versions = []
        elif mingw_configurations or get_mingw_config_from_env():
            self._visual_versions = []

        self._visual_runtimes = visual_runtimes or split_colon_env("CONAN_VISUAL_RUNTIMES")
        if self._visual_runtimes is None:
            self._visual_runtimes = default_visual_runtimes

        self._apple_clang_versions = apple_clang_versions or split_colon_env("CONAN_APPLE_CLANG_VERSIONS")

        if self._apple_clang_versions is None:
            self._apple_clang_versions = default_apple_clang_versions

        self._mingw_configurations = mingw_configurations or get_mingw_config_from_env()

        _default_archs = ["x86_64"] if self._os_name == "Darwin" else default_archs

        self._archs = archs or split_colon_env("CONAN_ARCHS")
        if self._archs is None:
            self._archs = _default_archs

        self._build_types = build_types or split_colon_env("CONAN_BUILD_TYPES")
        if self._build_types is None:
            self._build_types = default_build_types

        self._cppstds = cppstds or split_colon_env("CONAN_CPPSTDS")
        if self._cppstds is None:
            self._cppstds = default_cppstds

        options = options or split_colon_env("CONAN_OPTIONS")
        if options is None:
            options = []
        self._options = transform_list_options_to_dict(options)
Beispiel #26
0
def _mcst_lcc_cppstd_default(compiler_version):
    return "gnu14" if Version(compiler_version) >= "1.24" else "gnu98"
Beispiel #27
0
def _gcc_cppstd_default(compiler_version):
    return "gnu98" if Version(compiler_version) < "6" else "gnu14"
Beispiel #28
0
    def _make_migrations(self, old_version):
        # ############### FILL THIS METHOD WITH THE REQUIRED ACTIONS ##############
        # VERSION 0.1
        if old_version is None:
            return
        if old_version < Version("1.2.1"):
            old_settings = """
# Only for cross building, 'os_build/arch_build' is the system that runs Conan
os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS]
arch_build: [x86, x86_64, ppc64le, ppc64, armv6, armv7, armv7hf, armv8, sparc, sparcv9, mips, mips64, avr, armv7s, armv7k]

# 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, Arduino]
arch_target: [x86, x86_64, ppc64le, ppc64, armv6, armv7, armv7hf, armv8, sparc, sparcv9, mips, mips64, avr, armv7s, armv7k]

# 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"]
    Linux:
    Macos:
    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"]
    watchOS:
        version: ["4.0"]
    tvOS:
        version: ["11.0"]
    FreeBSD:
    SunOS:
    Arduino:
        board: ANY
arch: [x86, x86_64, ppc64le, ppc64, armv6, armv7, armv7hf, armv8, sparc, sparcv9, mips, mips64, avr, armv7s, armv7k]
compiler:
    sun-cc:
        version: ["5.10", "5.11", "5.12", "5.13", "5.14"]
        threads: [None, posix]
        libcxx: [libCstd, libstdcxx, libstlport, libstdc++]
    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",
                  "7", "7.1", "7.2", "7.3"]
        libcxx: [libstdc++, libstdc++11]
        threads: [None, posix, win32] #  Windows MinGW
        exception: [None, dwarf2, sjlj, seh] # Windows MinGW
    Visual Studio:
        runtime: [MD, MT, MTd, MDd]
        version: ["8", "9", "10", "11", "12", "14", "15"]
        toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp, v140, v140_xp, v140_clang_c2, LLVM-vs2014, LLVM-vs2014_xp, v141, v141_xp, v141_clang_c2]
    clang:
        version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0", "5.0", "6.0"]
        libcxx: [libstdc++, libstdc++11, libc++]
    apple-clang:
        version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0"]
        libcxx: [libstdc++, libc++]

build_type: [None, Debug, Release]
cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17]
"""
            self._update_settings_yml(old_settings)

        if old_version < Version("1.0"):
            _migrate_lock_files(self.client_cache, self.out)

        if old_version < Version("0.25"):
            from conans.paths import DEFAULT_PROFILE_NAME
            default_profile_path = os.path.join(self.client_cache.conan_folder, PROFILES_FOLDER,
                                                DEFAULT_PROFILE_NAME)
            if not os.path.exists(default_profile_path):
                self.out.warn("Migration: Moving default settings from %s file to %s"
                              % (CONAN_CONF, DEFAULT_PROFILE_NAME))
                conf_path = os.path.join(self.client_cache.conan_folder, CONAN_CONF)

                migrate_to_default_profile(conf_path, default_profile_path)

                self.out.warn("Migration: export_source cache new layout")
                migrate_c_src_export_source(self.client_cache, self.out)
Beispiel #29
0
    def _make_migrations(self, old_version):
        # ############### FILL THIS METHOD WITH THE REQUIRED ACTIONS ##############
        # VERSION 0.1
        if old_version is None:
            return
        if old_version < Version("0.3"):
            self.out.warn(
                "Migration: Reseting configuration and storage files...")
            if os.path.exists(self.conf_path):
                rmdir(self.conf_path)
            if os.path.exists(self.store_path):
                rmdir(self.store_path)
        elif old_version < Version("0.5"):
            self.out.warn(
                "Migration: Updating settings.yml with new gcc versions")
            default_settings = load(self.paths.settings_path)
            default_settings = default_settings.replace(
                'version: ["4.6", "4.7", "4.8", "4.9", "5.0"]',
                'version: ["4.6", "4.7", "4.8", "4.9", "5.1", "5.2", "5.3"]')
            save(self.paths.settings_path, default_settings)
        elif old_version < Version("0.7"):
            old_settings = """
os: [Windows, Linux, Macos, Android]
arch: [x86, x86_64, armv]
compiler:
    gcc:
        version: ["4.6", "4.7", "4.8", "4.9", "5.1", "5.2", "5.3"]
    Visual Studio:
        runtime: [None, MD, MT, MTd, MDd]
        version: ["8", "9", "10", "11", "12", "14"]
    clang:
        version: ["3.3", "3.4", "3.5", "3.6", "3.7"]
    apple-clang:
        version: ["5.0", "5.1", "6.0", "6.1", "7.0"]

build_type: [None, Debug, Release]
"""
            self._update_settings_yml(old_settings)
        elif old_version < Version("0.8"):
            self.out.info("**** Migrating to conan 0.8 *****")
            settings_backup_path = self.paths.settings_path + ".backup"
            save(settings_backup_path, load(self.paths.settings_path))
            # Save new settings
            save(self.paths.settings_path, default_settings_yml)
            self.out.info("- A new settings.yml has been defined")
            self.out.info("  Your old file has been backup'd to: %s" %
                          settings_backup_path)

            old_conanconf = load(self.paths.conan_conf_path)
            conf = dict(self.paths.conan_config.get_conf("settings_defaults"))
            if conf.get("os", None) in ("Linux", "Macos") and \
               conf.get("compiler", None) in ("gcc", "clang", "apple-clang"):

                # Backup the old config and append the new setting
                config_backup_path = self.paths.conan_conf_path + ".backup"
                save(config_backup_path, old_conanconf)
                new_setting = "libstdc++"
                if conf.get("compiler", None) == "apple-clang":
                    new_setting = "libc++"
                self.paths.conan_config.set("settings_defaults",
                                            "compiler.libcxx", new_setting)
                with open(self.paths.conan_conf_path, 'wb') as configfile:
                    self.paths.conan_config.write(configfile)

                self.out.info("- A new conan.conf has been defined")
                self.out.info("  Your old file has been backup'd to: %s" %
                              config_backup_path)

                self.out.info("- Reseting storage files...")
                if os.path.exists(self.store_path):
                    rmdir(self.store_path)

                # Print information about new setting
                self.out.warn("{0:s} IMPORTANT {0:s}".format("*" * 30))
                self.out.warn(
                    "Conan 0.8 have a new setting for your compiler: 'compiler.libcxx' "
                )
                self.out.warn(
                    "It defines the Standard C++ Library and it's ABI (C99 or C++11)"
                )
                if new_setting == "libstdc++":
                    self.out.warn(
                        "By default, and to keep the higher compatibility in your packages, we setted this setting value to 'libstdc++'"
                    )
                    self.out.warn(
                        "If you are using C++11 features or you want to use the gcc>5.1 ABI, set this setting to 'libstdc++11' "
                    )
                self.out.warn(
                    "If you uploaded some packages it's needed that you regenerate them, conan will set the new setting automatically"
                )
                self.out.warn(
                    "If your packages are written in pure 'C' language, you should deactivate this setting for your package adding this line to your conanfile.py config method:"
                )
                self.out.info(" ")
                self.out.info(" def config(self):")
                self.out.info("     del self.settings.compiler.libcxx")
                self.out.info(" ")
                self.out.warn(
                    "Your local storage has been deleted, perform a 'conan install' in your projects to restore them."
                )
                self.out.warn(
                    "You can read more information about this new setting and how to adapt your packages here: http://blog.conan.io/"
                )
                self.out.warn("*" * 71)
                self.out.info("   ")
        elif old_version < Version("0.8.3"):
            self.out.warn(
                "Migration: Updating settings.yml with new Apple clang 7.3 version"
            )
            default_settings = load(self.paths.settings_path)
            default_settings = default_settings.replace(
                'version: ["5.0", "5.1", "6.0", "6.1", "7.0"]',
                'version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3"]')
            save(self.paths.settings_path, default_settings)
        elif old_version < Version("0.10"):
            old_settings = """
os: [Windows, Linux, Macos, Android, iOS]
arch: [x86, x86_64, armv6, armv7, armv7hf, armv8]
compiler:
    gcc:
        version: ["4.4", "4.5", "4.6", "4.7", "4.8", "4.9", "5.1", "5.2", "5.3", "6.1"]
        libcxx: [libstdc++, libstdc++11]
    Visual Studio:
        runtime: [MD, MT, MTd, MDd]
        version: ["8", "9", "10", "11", "12", "14"]
    clang:
        version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8"]
        libcxx: [libstdc++, libstdc++11, libc++]
    apple-clang:
        version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3"]
        libcxx: [libstdc++, libc++]

build_type: [None, Debug, Release]
"""
            self._update_settings_yml(old_settings)
Beispiel #30
0
class CMakeInstallerConan(ConanFile):
    name = "cmake_installer"
    description = "creates cmake binaries package"
    license = "OSI-approved BSD 3-clause"
    url = "http://github.com/lasote/conan-cmake-installer"
    if conan_version < Version("1.0.0"):
        settings = {
            "os": ["Windows", "Linux", "Macos"],
            "arch": ["x86", "x86_64"]
        }
    else:
        settings = "os_build", "arch_build"
    options = {"version": available_versions}
    default_options = "version=" + [
        v for v in available_versions if "-" not in v
    ][0]
    build_policy = "missing"

    def minor_version(self):
        return ".".join(str(self.cmake_version).split(".")[:2])

    def config_options(self):
        if self.version >= Version("2.8"):  # Means CMake version
            self.options.remove("version")

    def configure(self):
        if self.os == "Macos" and self.arch == "x86":
            raise Exception("Not supported x86 for OSx")

    @property
    def arch(self):
        return self.settings.get_safe("arch_build") or self.settings.get_safe(
            "arch")

    @property
    def os(self):
        return self.settings.get_safe("os_build") or self.settings.get_safe(
            "os")

    @property
    def cmake_version(self):
        if "version" in self.options:
            return str(self.options.version)
        else:
            return self.version

    def get_filename(self):
        os_id = {
            "Macos": "Darwin",
            "Windows": "win32"
        }.get(str(self.os), str(self.os))
        arch_id = {
            "x86": "i386"
        }.get(self.arch, self.arch) if self.os != "Windows" else "x86"
        if self.os == "Linux" and self.cmake_version in ("2.8.12", "3.0.2") and \
           self.arch == "x86_64":
            arch_id = "i386"
        if self.os == "Macos" and self.cmake_version == "2.8.12":
            arch_id = "universal"
        return "cmake-%s-%s-%s" % (self.cmake_version, os_id, arch_id)

    def get_filename_src(self):
        return "cmake-%s" % self.cmake_version

    def build(self):
        minor = self.minor_version()
        ext = "tar.gz" if not self.os == "Windows" else "zip"
        dest_file = "file.tgz" if self.os != "Windows" else "file.zip"
        try:
            url = "https://cmake.org/files/v%s/%s.%s" % (
                minor, self.get_filename(), ext)

            # https://cmake.org/files/v3.6/cmake-3.6.0-Linux-i386.tar.gz
            # https://cmake.org/files/v3.6/cmake-3.6.0-Darwin-x86_64.tar.gz
            # https://cmake.org/files/v3.5/cmake-3.5.2-win32-x86.zip

            self.output.info("Downloading: %s" % url)
            tools.download(url, dest_file, verify=False)
            tools.unzip(dest_file)
        except NotFoundException:
            if self.settings.get_safe("os_build") == "Windows":
                raise ConanException(
                    "Building from sources under Windows is not supported")

            url = "https://cmake.org/files/v%s/%s.%s" % (
                minor, self.get_filename_src(), ext)

            # https://cmake.org/files/v3.6/cmake-3.6.0.tar.gz

            self.output.info("Downloading: %s" % url)
            tools.download(url, dest_file, verify=False)
            tools.unzip(dest_file)

            with tools.chdir(self.get_filename_src()):
                self.run("./bootstrap --prefix=%s" %
                         os.path.join(self.build_folder, self.get_filename()))
                self.run("make")
                self.run("make install")

    def package(self):
        if self.os == "Macos":
            appname = "CMake.app" if self.version != "2.8.12" else "CMake 2.8-12.app"
            self.copy("*",
                      dst="",
                      src=os.path.join(self.get_filename(), appname,
                                       "Contents"))
        else:
            self.copy("*", dst="", src=self.get_filename())

    def package_info(self):
        if self.package_folder is not None:
            minor = self.minor_version()
            self.env_info.path.append(os.path.join(self.package_folder, "bin"))
            self.env_info.CMAKE_ROOT = self.package_folder
            mod_path = os.path.join(self.package_folder, "share",
                                    "cmake-%s" % minor, "Modules")
            self.env_info.CMAKE_MODULE_PATH = mod_path
            if not os.path.exists(mod_path):
                raise Exception("Module path not found: %s" % mod_path)