def _run_local_scm(conanfile, conanfile_folder, src_folder, output): """ Only called when 'conan source' in user space :param conanfile: recipe :param src_folder: specified src_folder :param conanfile_folder: Folder containing the local conanfile :param output: Output :return: """ scm_data = get_scm_data(conanfile) if not scm_data: return dest_dir = os.path.normpath( os.path.join(src_folder, scm_data.subfolder or "")) # In user space, if revision="auto", then copy if scm_data.capture_origin or scm_data.capture_revision: # FIXME: or clause? scm = SCM(scm_data, conanfile_folder, output) scm_url = scm_data.url if scm_data.url != "auto" else \ scm.get_qualified_remote_url(remove_credentials=True) src_path = scm.get_local_path_to_url(url=scm_url) if src_path and src_path != dest_dir: excluded = SCM(scm_data, src_path, output).excluded_files output.info("SCM: Getting sources from folder: %s" % src_path) merge_directories(src_path, dest_dir, excluded=excluded) return output.info("SCM: Getting sources from url: '%s'" % scm_data.url) scm = SCM(scm_data, dest_dir, output) scm.checkout()
def _run_cache_scm(conanfile, scm_sources_folder, src_folder, output): """ :param conanfile: recipe :param src_folder: sources folder in the cache, (Destination dir) :param scm_sources_folder: scm sources folder in the cache, where the scm sources were exported :param output: output :return: """ scm_data = get_scm_data(conanfile) if not scm_data: return if scm_data.subfolder: dest_dir = os.path.normpath( os.path.join(src_folder, scm_data.subfolder)) else: dest_dir = src_folder if os.path.exists(scm_sources_folder): output.info("Copying previously cached scm sources") merge_directories(scm_sources_folder, dest_dir) else: output.info("SCM: Getting sources from url: '%s'" % scm_data.url) try: scm = SCM(scm_data, dest_dir, output) scm.checkout() except Exception as e: raise ConanException("Couldn't checkout SCM: %s" % str(e)) # This is a bit weird. Why after a SCM should we remove files. # Maybe check conan 2.0 # TODO: Why removing in the cache? There is no danger. _clean_source_folder(dest_dir)
def _run_scm(conanfile, src_folder, local_sources_path, output, cache): scm_data = get_scm_data(conanfile) if not scm_data: return dest_dir = os.path.normpath(os.path.join(src_folder, scm_data.subfolder)) if cache: # When in cache, capturing the sources from user space is done only if exists captured = local_sources_path and os.path.exists(local_sources_path) else: # In user space, if revision="auto", then copy captured = scm_data.capture_origin or scm_data.capture_revision local_sources_path = local_sources_path if captured else None if local_sources_path: excluded = SCM(scm_data, local_sources_path, output).excluded_files output.info("Getting sources from folder: %s" % local_sources_path) merge_directories(local_sources_path, dest_dir, excluded=excluded) else: output.info("Getting sources from url: '%s'" % scm_data.url) scm = SCM(scm_data, dest_dir, output) scm.checkout() if cache: # This is a bit weird. Why after a SCM should we remove files. Maybe check conan 2.0 _clean_source_folder(dest_dir)
def _run_scm(conanfile, src_folder, local_sources_path, output, cache): scm_data = get_scm_data(conanfile) if not scm_data: return dest_dir = os.path.normpath(os.path.join(src_folder, scm_data.subfolder)) if cache: # When in cache, capturing the sources from user space is done only if exists if not local_sources_path or not os.path.exists(local_sources_path): local_sources_path = None else: # In user space, if revision="auto", then copy if scm_data.capture_origin or scm_data.capture_revision: # FIXME: or clause? scm = SCM(scm_data, local_sources_path, output) scm_url = scm_data.url if scm_data.url != "auto" else \ scm.get_qualified_remote_url(remove_credentials=True) src_path = scm.get_local_path_to_url(url=scm_url) if src_path: local_sources_path = src_path else: local_sources_path = None if local_sources_path and conanfile.develop: excluded = SCM(scm_data, local_sources_path, output).excluded_files output.info("Getting sources from folder: %s" % local_sources_path) merge_directories(local_sources_path, dest_dir, excluded=excluded) else: output.info("Getting sources from url: '%s'" % scm_data.url) scm = SCM(scm_data, dest_dir, output) scm.checkout() if cache: # This is a bit weird. Why after a SCM should we remove files. Maybe check conan 2.0 _clean_source_folder(dest_dir)
def _fetch_scm(scm_data, dest_dir, local_sources_path, output): if local_sources_path: excluded = SCM(scm_data, local_sources_path).excluded_files output.info("Getting sources from folder: %s" % local_sources_path) merge_directories(local_sources_path, dest_dir, excluded=excluded) else: output.info("Getting sources from url: '%s'" % scm_data.url) scm = SCM(scm_data, dest_dir) scm.checkout() _clean_source_folder(dest_dir)