Ejemplo n.º 1
0
    def get_recipe_sources(self, conan_reference, export_folder, remote):
        t1 = time.time()

        def filter_function(urls):
            file_url = urls.get(EXPORT_SOURCES_TGZ_NAME)
            if file_url:
                urls = {EXPORT_SOURCES_TGZ_NAME: file_url}
            else:
                return None
            return urls

        zipped_files = self._call_remote(remote, "get_recipe", conan_reference,
                                         export_folder, filter_function)
        duration = time.time() - t1
        log_recipe_sources_download(conan_reference, duration, remote,
                                    zipped_files)

        sources_folder = os.path.join(export_folder, EXPORT_SOURCES_DIR)
        if not zipped_files:
            mkdir(sources_folder)  # create the folder even if no source files
            return

        unzip_and_get_files(zipped_files, export_folder,
                            EXPORT_SOURCES_TGZ_NAME)
        for dirname, _, filenames in os.walk(sources_folder):
            for fname in filenames:
                touch(os.path.join(dirname, fname))
Ejemplo n.º 2
0
    def get_recipe_sources(self, conan_reference, export_folder, remote):
        t1 = time.time()

        def filter_function(urls):
            file_url = urls.get(EXPORT_SOURCES_TGZ_NAME)
            if file_url:
                urls = {EXPORT_SOURCES_TGZ_NAME: file_url}
            else:
                return None
            return urls

        zipped_files = self._call_remote(remote, "get_recipe",
                                         conan_reference, export_folder, filter_function)
        duration = time.time() - t1
        log_recipe_sources_download(conan_reference, duration, remote, zipped_files)

        sources_folder = os.path.join(export_folder, EXPORT_SOURCES_DIR)
        if not zipped_files:
            mkdir(sources_folder)  # create the folder even if no source files
            return

        unzip_and_get_files(zipped_files, export_folder, EXPORT_SOURCES_TGZ_NAME)
        for dirname, _, filenames in os.walk(sources_folder):
            for fname in filenames:
                touch(os.path.join(dirname, fname))
Ejemplo n.º 3
0
    def get_recipe(self, conan_reference, dest_folder, remote):
        """
        Read the conans from remotes
        Will iterate the remotes to find the conans unless remote was specified

        returns (dict relative_filepath:abs_path , remote_name)"""
        rmdir(dest_folder)  # Remove first the destination folder
        t1 = time.time()

        def filter_function(urls):
            if CONANFILE not in list(urls.keys()):
                raise NotFoundException("Conan '%s' doesn't have a %s!" %
                                        (conan_reference, CONANFILE))
            urls.pop(EXPORT_SOURCES_TGZ_NAME, None)
            return urls

        zipped_files = self._call_remote(remote, "get_recipe", conan_reference,
                                         dest_folder, filter_function)
        duration = time.time() - t1
        log_recipe_download(conan_reference, duration, remote, zipped_files)

        unzip_and_get_files(zipped_files, dest_folder, EXPORT_TGZ_NAME)
        # Make sure that the source dir is deleted
        rm_conandir(self._client_cache.source(conan_reference))
        for dirname, _, filenames in os.walk(dest_folder):
            for fname in filenames:
                touch(os.path.join(dirname, fname))
Ejemplo n.º 4
0
    def get_recipe(self, conan_reference, dest_folder, remote):
        """
        Read the conans from remotes
        Will iterate the remotes to find the conans unless remote was specified

        returns (dict relative_filepath:abs_path , remote_name)"""
        rmdir(dest_folder)  # Remove first the destination folder
        t1 = time.time()

        def filter_function(urls):
            if CONANFILE not in list(urls.keys()):
                raise NotFoundException("Conan '%s' doesn't have a %s!"
                                        % (conan_reference, CONANFILE))
            urls.pop(EXPORT_SOURCES_TGZ_NAME, None)
            return urls

        zipped_files = self._call_remote(remote, "get_recipe", conan_reference, dest_folder,
                                         filter_function)
        duration = time.time() - t1
        log_recipe_download(conan_reference, duration, remote, zipped_files)

        unzip_and_get_files(zipped_files, dest_folder, EXPORT_TGZ_NAME)
        # Make sure that the source dir is deleted
        rm_conandir(self._client_cache.source(conan_reference))
        for dirname, _, filenames in os.walk(dest_folder):
            for fname in filenames:
                touch(os.path.join(dirname, fname))
Ejemplo n.º 5
0
def build_windows_subsystem(profile, make_program):
    """ The AutotoolsDeps can be used also in pure Makefiles, if the makefiles follow
    the Autotools conventions
    """
    # FIXME: cygwin in CI (my local machine works) seems broken for path with spaces
    client = TestClient(path_with_spaces=False)
    client.run("new hello/0.1 --template=cmake_lib")
    # TODO: Test Windows subsystems in CMake, at least msys is broken
    os.rename(os.path.join(client.current_folder, "test_package"),
              os.path.join(client.current_folder, "test_package2"))
    client.save({"profile": profile})
    client.run("create . --profile=profile")

    main = gen_function_cpp(name="main", includes=["hello"], calls=["hello"])
    makefile = gen_makefile(apps=["app"])

    conanfile = textwrap.dedent("""
        from conans import ConanFile
        from conan.tools.gnu import AutotoolsToolchain, Autotools, AutotoolsDeps

        class TestConan(ConanFile):
            requires = "hello/0.1"
            settings = "os", "compiler", "arch", "build_type"
            exports_sources = "Makefile"
            generators = "AutotoolsDeps", "AutotoolsToolchain"

            def build(self):
                autotools = Autotools(self)
                autotools.make()
        """)
    client.save({"app.cpp": main,
                 "Makefile": makefile,
                 "conanfile.py": conanfile,
                 "profile": profile}, clean_first=True)

    client.run("install . --profile=profile")
    cmd = environment_wrap_command(["conanbuildenv",
                                    "conanautotoolstoolchain",
                                    "conanautotoolsdeps"], client.current_folder, make_program)
    client.run_command(cmd)
    client.run_command("app")
    # TODO: fill compiler version when ready
    check_exe_run(client.out, "main", "gcc", None, "Release", "x86_64", None)
    assert "hello/0.1: Hello World Release!" in client.out

    client.save({"app.cpp": gen_function_cpp(name="main", msg="main2",
                                             includes=["hello"], calls=["hello"])})
    # Make sure it is newer
    t = time.time() + 1
    touch(os.path.join(client.current_folder, "app.cpp"), (t, t))

    client.run("build .")
    client.run_command("app")
    # TODO: fill compiler version when ready
    check_exe_run(client.out, "main2", "gcc", None, "Release", "x86_64", None, cxx11_abi=0)
    assert "hello/0.1: Hello World Release!" in client.out
    return client.out
Ejemplo n.º 6
0
    def get_package(self, package_reference, dest_folder, remote):
        """
        Read the conans package from remotes
        Will iterate the remotes to find the conans unless remote was specified

        returns (dict relative_filepath:abs_path , remote_name)"""
        zipped_files = self._call_remote(remote, "get_package", package_reference, dest_folder)
        files = unzip_and_get_files(zipped_files, dest_folder, PACKAGE_TGZ_NAME)
        # Issue #214 https://github.com/conan-io/conan/issues/214
        for dirname, _, files in os.walk(dest_folder):
            for fname in files:
                touch(os.path.join(dirname, fname))

        return files
Ejemplo n.º 7
0
    def get_package(self, package_reference, remote):
        """
        Read the conans package from remotes
        Will iterate the remotes to find the conans unless remote was specified

        returns (dict relative_filepath:content , remote_name)"""
        package_files = self._call_remote(remote, "get_package", package_reference)
        destination_dir = self._paths.package(package_reference)
        uncompress_files(package_files, destination_dir, PACKAGE_TGZ_NAME)

        # Issue #214 https://github.com/conan-io/conan/issues/214
        for dirname, _, files in os.walk(destination_dir):
            for fname in files:
                touch(os.path.join(dirname, fname))
Ejemplo n.º 8
0
    def get_package(self, package_reference, remote):
        """
        Read the conans package from remotes
        Will iterate the remotes to find the conans unless remote was specified

        returns (dict relative_filepath:content , remote_name)"""
        package_files = self._call_remote(remote, "get_package", package_reference)
        destination_dir = self._paths.package(package_reference)
        uncompress_files(package_files, destination_dir, PACKAGE_TGZ_NAME)

        # Issue #214 https://github.com/conan-io/conan/issues/214
        for dirname, _, files in os.walk(destination_dir):
            for fname in files:
                touch(os.path.join(dirname, fname))
Ejemplo n.º 9
0
    def get_package(self, package_reference, dest_folder, remote):
        """
        Read the conans package from remotes
        Will iterate the remotes to find the conans unless remote was specified

        returns (dict relative_filepath:abs_path , remote_name)"""
        rm_conandir(dest_folder)  # Remove first the destination folder
        t1 = time.time()
        zipped_files = self._call_remote(remote, "get_package", package_reference, dest_folder)
        duration = time.time() - t1
        log_package_download(package_reference, duration, remote, zipped_files)
        unzip_and_get_files(zipped_files, dest_folder, PACKAGE_TGZ_NAME)
        # Issue #214 https://github.com/conan-io/conan/issues/214
        for dirname, _, filenames in os.walk(dest_folder):
            for fname in filenames:
                touch(os.path.join(dirname, fname))
Ejemplo n.º 10
0
    def get_package(self, package_reference, dest_folder, remote):
        """
        Read the conans package from remotes
        Will iterate the remotes to find the conans unless remote was specified

        returns (dict relative_filepath:abs_path , remote_name)"""
        zipped_files = self._call_remote(remote, "get_package",
                                         package_reference, dest_folder)
        files = unzip_and_get_files(zipped_files, dest_folder,
                                    PACKAGE_TGZ_NAME)
        # Issue #214 https://github.com/conan-io/conan/issues/214
        for dirname, _, files in os.walk(dest_folder):
            for fname in files:
                touch(os.path.join(dirname, fname))

        return files
Ejemplo n.º 11
0
    def get_package(self, package_reference, dest_folder, remote):
        """
        Read the conans package from remotes
        Will iterate the remotes to find the conans unless remote was specified

        returns (dict relative_filepath:abs_path , remote_name)"""
        rm_conandir(dest_folder)  # Remove first the destination folder
        t1 = time.time()
        zipped_files = self._call_remote(remote, "get_package", package_reference, dest_folder)
        duration = time.time() - t1
        log_package_download(package_reference, duration, remote, zipped_files)
        unzip_and_get_files(zipped_files, dest_folder, PACKAGE_TGZ_NAME)
        # Issue #214 https://github.com/conan-io/conan/issues/214
        for dirname, _, filenames in os.walk(dest_folder):
            for fname in filenames:
                touch(os.path.join(dirname, fname))
Ejemplo n.º 12
0
    def get_recipe(self, conan_reference, dest_folder, remote):
        """
        Read the conans from remotes
        Will iterate the remotes to find the conans unless remote was specified

        returns (dict relative_filepath:abs_path , remote_name)"""
        rmdir(dest_folder)  # Remove first the destination folder
        zipped_files = self._call_remote(remote, "get_recipe", conan_reference, dest_folder)
        files = unzip_and_get_files(zipped_files, dest_folder, EXPORT_TGZ_NAME)
        # Make sure that the source dir is deleted
        rm_conandir(self._client_cache.source(conan_reference))
        for dirname, _, filenames in os.walk(dest_folder):
            for fname in filenames:
                touch(os.path.join(dirname, fname))
#       TODO: Download only the CONANFILE file and only download the rest of files
#       in install if needed (not found remote package)
        return files
Ejemplo n.º 13
0
def configuration_install(app,
                          uri,
                          verify_ssl,
                          config_type=None,
                          args=None,
                          source_folder=None,
                          target_folder=None):
    cache, output, requester = app.cache, app.out, app.requester
    configs = []
    configs_file = cache.config_install_file
    if os.path.isfile(configs_file):
        try:
            configs = json.loads(load(configs_file))
        except Exception as e:
            raise ConanException("Error loading configs-install file: %s\n%s" %
                                 (configs_file, str(e)))
        configs = [_ConfigOrigin(config) for config in configs]
    if uri is None:
        if config_type or args or not verify_ssl:  # Not the defaults
            if not configs:
                raise ConanException("Called config install without arguments")
            # Modify the last one
            config = configs[-1]
            config.config_type = config_type or config.type
            config.args = args or config.args
            config.verify_ssl = verify_ssl or config.verify_ssl
            _process_config(config, cache, output, requester)
            _save_configs(configs_file, configs)
        else:
            if not configs:
                raise ConanException("Called config install without arguments")
            # Execute the previously stored ones
            for config in configs:
                output.info("Config install:  %s" % _hide_password(config.uri))
                _process_config(config, cache, output, requester)
            touch(cache.config_install_file)
    else:
        # Execute and store the new one
        config = _ConfigOrigin.from_item(uri, config_type, verify_ssl, args,
                                         source_folder, target_folder)
        _process_config(config, cache, output, requester)
        if config not in configs:
            configs.append(config)
        else:
            configs = [(c if c != config else config) for c in configs]
        _save_configs(configs_file, configs)
Ejemplo n.º 14
0
    def get_recipe(self, conan_reference, dest_folder, remote):
        """
        Read the conans from remotes
        Will iterate the remotes to find the conans unless remote was specified

        returns (dict relative_filepath:abs_path , remote_name)"""
        zipped_files = self._call_remote(remote, "get_recipe", conan_reference,
                                         dest_folder)
        files = unzip_and_get_files(zipped_files, dest_folder, EXPORT_TGZ_NAME)
        # Make sure that the source dir is deleted
        rm_conandir(self._client_cache.source(conan_reference))
        for dirname, _, filenames in os.walk(dest_folder):
            for fname in filenames:
                touch(os.path.join(dirname, fname))


#       TODO: Download only the CONANFILE file and only download the rest of files
#       in install if needed (not found remote package)
        return files