def source(self, current_path, reference, force): if not isinstance(reference, ConanFileReference): output = ScopedOutput("PROJECT", self._user_io.out) conanfile_path = os.path.join(reference, CONANFILE) conanfile = load_consumer_conanfile( conanfile_path, current_path, self._client_cache.settings, self._runner, output, default_profile=self._client_cache.default_profile, deps_cpp_info_required=None) config_source_local(current_path, conanfile, output) else: output = ScopedOutput(str(reference), self._user_io.out) conanfile_path = self._client_cache.conanfile(reference) conanfile = load_consumer_conanfile( conanfile_path, current_path, self._client_cache.settings, self._runner, output, default_profile=self._client_cache.default_profile, reference=reference, deps_cpp_info_required=None) src_folder = self._client_cache.source(reference, conanfile.short_paths) export_folder = self._client_cache.export(reference) export_src_folder = self._client_cache.export_sources( reference, conanfile.short_paths) config_source(export_folder, export_src_folder, src_folder, conanfile, output, force)
def _prepare_sources(self, conanfile, pref, package_layout, conanfile_path, source_folder, build_folder, remotes): export_folder = package_layout.export() export_source_folder = package_layout.export_sources() scm_sources_folder = package_layout.scm_sources() complete_recipe_sources(self._remote_manager, self._cache, conanfile, pref.ref, remotes) _remove_folder_raising(build_folder) config_source(export_folder, export_source_folder, scm_sources_folder, source_folder, conanfile, self._output, conanfile_path, pref.ref, self._hook_manager, self._cache) if not getattr(conanfile, 'no_copy_source', False): self._output.info('Copying sources to build folder') try: shutil.copytree(source_folder, build_folder, symlinks=True) except Exception as e: msg = str(e) if "206" in msg: # System error shutil.Error 206: Filename or extension too long msg += "\nUse short_paths=True if paths too long" raise ConanException( "%s\nError copying sources to build folder" % msg) logger.debug("BUILD: Copied to %s", build_folder) logger.debug("BUILD: Files copied %s", ",".join(os.listdir(build_folder)))
def source(self, reference, force): assert(isinstance(reference, ConanFileReference)) output = ScopedOutput(str(reference), self._user_io.out) conan_file_path = self._client_cache.conanfile(reference) conanfile = self._loader().load_conan(conan_file_path, output) src_folder = self._client_cache.source(reference, conanfile.short_paths) export_folder = self._client_cache.export(reference) config_source(export_folder, src_folder, conanfile, output, force)
def source(self, reference, force): assert (isinstance(reference, ConanFileReference)) output = ScopedOutput(str(reference), self._user_io.out) conan_file_path = self._client_cache.conanfile(reference) conanfile = self._loader().load_conan(conan_file_path, output) src_folder = self._client_cache.source(reference, conanfile.short_paths) export_folder = self._client_cache.export(reference) config_source(export_folder, src_folder, conanfile, output, force)
def _prepare_sources(self, conanfile, pref, package_layout, remotes): export_folder = package_layout.export() export_source_folder = package_layout.export_sources() scm_sources_folder = package_layout.scm_sources() conanfile_path = package_layout.conanfile() source_folder = package_layout.source() retrieve_exports_sources(self._remote_manager, self._cache, conanfile, pref.ref, remotes) config_source(export_folder, export_source_folder, scm_sources_folder, source_folder, conanfile, self._output, conanfile_path, pref.ref, self._hook_manager, self._cache)
def prepare_build(self): if self.build_reference != self._package_reference and \ os.path.exists(self.build_folder) and hasattr(self._conan_file, "build_id"): self._skip_build = True return # build_id is not caching the build folder, so actually rebuild the package _handle_system_requirements(self._conan_file, self._package_reference, self._client_cache, self._out) export_folder = self._client_cache.export(self._conan_ref) export_source_folder = self._client_cache.export_sources( self._conan_ref, self._conan_file.short_paths) try: rmdir(self.build_folder) rmdir(self.package_folder) except OSError as e: raise ConanException( "%s\n\nCouldn't remove folder, might be busy or open\n" "Close any app using it, and retry" % str(e)) self._out.info('Building your package in %s' % self.build_folder) sources_pointer = self._client_cache.scm_folder(self._conan_ref) local_sources_path = load(sources_pointer) if os.path.exists( sources_pointer) else None config_source(export_folder, export_source_folder, local_sources_path, self.source_folder, self._conan_file, self._out) self._out.info('Copying sources to build folder') if getattr(self._conan_file, 'no_copy_source', False): mkdir(self.build_folder) self._conan_file.source_folder = self.source_folder else: if platform.system( ) == "Windows" and os.getenv("CONAN_USER_HOME_SHORT") != "None": from conans.util.windows import ignore_long_path_files ignore = ignore_long_path_files(self.source_folder, self.build_folder, self._out) else: ignore = None shutil.copytree(self.source_folder, self.build_folder, symlinks=True, ignore=ignore) logger.debug("Copied to %s", self.build_folder) logger.debug("Files copied %s", os.listdir(self.build_folder)) self._conan_file.source_folder = self.build_folder
def prepare_build(self): if os.path.exists(self.build_folder) and hasattr( self._conan_file, "build_id"): self._skip_build = True return # build_id is not caching the build folder, so actually rebuild the package _handle_system_requirements(self._conan_file, self._package_reference, self._client_cache, self._out) package_folder = self._client_cache.package( self._package_reference, self._conan_file.short_paths) src_folder = self._client_cache.source(self._conan_ref, self._conan_file.short_paths) export_folder = self._client_cache.export(self._conan_ref) export_source_folder = self._client_cache.export_sources( self._conan_ref, self._conan_file.short_paths) try: rmdir(self.build_folder) rmdir(package_folder) except OSError as e: raise ConanException( "%s\n\nCouldn't remove folder, might be busy or open\n" "Close any app using it, and retry" % str(e)) self._out.info('Building your package in %s' % self.build_folder) config_source(export_folder, export_source_folder, src_folder, self._conan_file, self._out) self._out.info('Copying sources to build folder') if getattr(self._conan_file, 'no_copy_source', False): mkdir(self.build_folder) self._conan_file.source_folder = src_folder else: if not long_paths_support: from conans.util.windows import ignore_long_path_files ignore = ignore_long_path_files(src_folder, self.build_folder, self._out) else: ignore = None shutil.copytree(src_folder, self.build_folder, symlinks=True, ignore=ignore) logger.debug("Copied to %s", self.build_folder) logger.debug("Files copied %s", os.listdir(self.build_folder)) self._conan_file.source_folder = self.build_folder
def source(self, current_path, reference, force): if not isinstance(reference, ConanFileReference): output = ScopedOutput("PROJECT", self._user_io.out) conan_file_path = os.path.join(reference, CONANFILE) conanfile = self._loader(current_path).load_conan(conan_file_path, output, consumer=True) _load_info_file(current_path, conanfile, output) export_folder = reference config_source_local(export_folder, current_path, conanfile, output) else: output = ScopedOutput(str(reference), self._user_io.out) conan_file_path = self._client_cache.conanfile(reference) conanfile = self._loader(current_path).load_conan(conan_file_path, output, reference=reference) _load_info_file(current_path, conanfile, output) src_folder = self._client_cache.source(reference, conanfile.short_paths) export_folder = self._client_cache.export(reference) config_source(export_folder, src_folder, conanfile, output, force)
def source(self, current_path, reference, force): if not isinstance(reference, ConanFileReference): output = ScopedOutput("PROJECT", self._user_io.out) conan_file_path = os.path.join(reference, CONANFILE) conanfile = self._loader().load_conan(conan_file_path, output, consumer=True) self._load_deps_info(current_path, conanfile, output) export_folder = reference config_source_local(export_folder, current_path, conanfile, output) else: output = ScopedOutput(str(reference), self._user_io.out) conan_file_path = self._client_cache.conanfile(reference) conanfile = self._loader().load_conan(conan_file_path, output, reference=reference) self._load_deps_info(current_path, conanfile, output) src_folder = self._client_cache.source(reference, conanfile.short_paths) export_folder = self._client_cache.export(reference) config_source(export_folder, src_folder, conanfile, output, force)
def source(self, current_path, reference, force): if not isinstance(reference, ConanFileReference): output = ScopedOutput("PROJECT", self._user_io.out) conanfile_path = os.path.join(reference, CONANFILE) conanfile = load_consumer_conanfile(conanfile_path, current_path, self._client_cache.settings, self._runner, output, error=None) export_folder = reference config_source_local(current_path, conanfile, output) else: output = ScopedOutput(str(reference), self._user_io.out) conanfile_path = self._client_cache.conanfile(reference) conanfile = load_consumer_conanfile(conanfile_path, current_path, self._client_cache.settings, self._runner, output, reference, error=None) src_folder = self._client_cache.source(reference, conanfile.short_paths) export_folder = self._client_cache.export(reference) config_source(export_folder, src_folder, conanfile, output, force)
def prepare_build(self): if self.build_reference != self._package_reference and \ os.path.exists(self.build_folder) and hasattr(self._conan_file, "build_id"): self._skip_build = True return # build_id is not caching the build folder, so actually rebuild the package _handle_system_requirements(self._conan_file, self._package_reference, self._client_cache, self._out) export_folder = self._client_cache.export(self._conan_ref) export_source_folder = self._client_cache.export_sources(self._conan_ref, self._conan_file.short_paths) try: rmdir(self.build_folder) rmdir(self.package_folder) except OSError as e: raise ConanException("%s\n\nCouldn't remove folder, might be busy or open\n" "Close any app using it, and retry" % str(e)) self._out.info('Building your package in %s' % self.build_folder) config_source(export_folder, export_source_folder, self.source_folder, self._conan_file, self._out) self._out.info('Copying sources to build folder') if getattr(self._conan_file, 'no_copy_source', False): mkdir(self.build_folder) self._conan_file.source_folder = self.source_folder else: if platform.system() == "Windows" and os.getenv("CONAN_USER_HOME_SHORT") != "None": from conans.util.windows import ignore_long_path_files ignore = ignore_long_path_files(self.source_folder, self.build_folder, self._out) else: ignore = None shutil.copytree(self.source_folder, self.build_folder, symlinks=True, ignore=ignore) logger.debug("Copied to %s", self.build_folder) logger.debug("Files copied %s", os.listdir(self.build_folder)) self._conan_file.source_folder = self.build_folder
def _build_package(self, export_folder, src_folder, build_folder, conan_file, output): """ builds the package, creating the corresponding build folder if necessary and copying there the contents from the src folder. The code is duplicated in every build, as some configure processes actually change the source code """ output.info('Building your package in %s' % build_folder) config_source(export_folder, src_folder, conan_file, output) output.info('Copying sources to build folder') def check_max_path_len(src, files): if platform.system() != "Windows": return [] filtered_files = [] for the_file in files: source_path = os.path.join(src, the_file) # Without storage path, just relative rel_path = os.path.relpath(source_path, src_folder) dest_path = os.path.normpath(os.path.join(build_folder, rel_path)) # it is NOT that "/" is counted as "\\" so it counts double # seems a bug in python, overflows paths near the limit of 260, if len(dest_path) >= 249: filtered_files.append(the_file) output.warn("Filename too long, file excluded: %s" % dest_path) return filtered_files shutil.copytree(src_folder, build_folder, symlinks=True, ignore=check_max_path_len) logger.debug("Copied to %s" % build_folder) logger.debug("Files copied %s" % os.listdir(build_folder)) os.chdir(build_folder) conan_file._conanfile_directory = build_folder # Read generators from conanfile and generate the needed files logger.debug("Writing generators") write_generators(conan_file, build_folder, output) logger.debug("Files copied after generators %s" % os.listdir(build_folder)) # Build step might need DLLs, binaries as protoc to generate source files # So execute imports() before build, storing the list of copied_files from conans.client.importer import run_imports copied_files = run_imports(conan_file, build_folder, output) try: # This is necessary because it is different for user projects # than for packages conan_file._conanfile_directory = build_folder logger.debug("Call conanfile.build() with files in build folder: %s" % os.listdir(build_folder)) conan_file.build() self._out.writeln("") output.success("Package '%s' built" % conan_file.info.package_id()) output.info("Build folder %s" % build_folder) except Exception as e: os.chdir(src_folder) self._out.writeln("") output.error("Package '%s' build failed" % conan_file.info.package_id()) output.warn("Build folder %s" % build_folder) raise ConanException("%s: %s" % (conan_file.name, str(e))) finally: conan_file._conanfile_directory = export_folder # Now remove all files that were imported with imports() for f in copied_files: try: if(f.startswith(build_folder)): os.remove(f) except Exception: self._out.warn("Unable to remove imported file from build: %s" % f)
def _build_package(self, export_folder, src_folder, build_folder, package_folder, conan_file, output): """ builds the package, creating the corresponding build folder if necessary and copying there the contents from the src folder. The code is duplicated in every build, as some configure processes actually change the source code """ try: rmdir(build_folder) rmdir(package_folder) except Exception as e: raise ConanException( "%s\n\nCouldn't remove folder, might be busy or open\n" "Close any app using it, and retry" % str(e)) output.info('Building your package in %s' % build_folder) config_source(export_folder, src_folder, conan_file, output) output.info('Copying sources to build folder') def check_max_path_len(src, files): if platform.system() != "Windows": return [] filtered_files = [] for the_file in files: source_path = os.path.join(src, the_file) # Without storage path, just relative rel_path = os.path.relpath(source_path, src_folder) dest_path = os.path.normpath( os.path.join(build_folder, rel_path)) # it is NOT that "/" is counted as "\\" so it counts double # seems a bug in python, overflows paths near the limit of 260, if len(dest_path) >= 249: filtered_files.append(the_file) output.warn("Filename too long, file excluded: %s" % dest_path) return filtered_files if getattr(conan_file, 'no_copy_source', False): mkdir(build_folder) conan_file.source_folder = src_folder else: shutil.copytree(src_folder, build_folder, symlinks=True, ignore=check_max_path_len) logger.debug("Copied to %s" % build_folder) logger.debug("Files copied %s" % os.listdir(build_folder)) conan_file.source_folder = build_folder os.chdir(build_folder) conan_file.build_folder = build_folder conan_file._conanfile_directory = build_folder # Read generators from conanfile and generate the needed files logger.debug("Writing generators") write_generators(conan_file, build_folder, output) logger.debug("Files copied after generators %s" % os.listdir(build_folder)) # Build step might need DLLs, binaries as protoc to generate source files # So execute imports() before build, storing the list of copied_files from conans.client.importer import run_imports copied_files = run_imports(conan_file, build_folder, output) try: # This is necessary because it is different for user projects # than for packages logger.debug( "Call conanfile.build() with files in build folder: %s" % os.listdir(build_folder)) with conanfile_exception_formatter(str(conan_file), "build"): conan_file.build() self._out.writeln("") output.success("Package '%s' built" % conan_file.info.package_id()) output.info("Build folder %s" % build_folder) except Exception as exc: os.chdir(src_folder) self._out.writeln("") output.error("Package '%s' build failed" % conan_file.info.package_id()) output.warn("Build folder %s" % build_folder) if isinstance(exc, ConanExceptionInUserConanfileMethod): raise exc raise ConanException(exc) finally: conan_file._conanfile_directory = export_folder # Now remove all files that were imported with imports() for f in copied_files: try: if (f.startswith(build_folder)): os.remove(f) except Exception: self._out.warn( "Unable to remove imported file from build: %s" % f)
def _build_package(self): """ builds the package, creating the corresponding build folder if necessary and copying there the contents from the src folder. The code is duplicated in every build, as some configure processes actually change the source code. Receives the build_folder because it can change if the method build_id() exists """ package_folder = self._client_cache.package( self._package_reference, self._conan_file.short_paths) src_folder = self._client_cache.source(self._conan_ref, self._conan_file.short_paths) export_folder = self._client_cache.export(self._conan_ref) export_source_folder = self._client_cache.export_sources( self._conan_ref, self._conan_file.short_paths) try: rmdir(self.build_folder) rmdir(package_folder) except Exception as e: raise ConanException( "%s\n\nCouldn't remove folder, might be busy or open\n" "Close any app using it, and retry" % str(e)) self._out.info('Building your package in %s' % self.build_folder) config_source(export_folder, export_source_folder, src_folder, self._conan_file, self._out) self._out.info('Copying sources to build folder') if getattr(self._conan_file, 'no_copy_source', False): mkdir(self.build_folder) self._conan_file.source_folder = src_folder else: if platform.system( ) == "Windows" and os.getenv("CONAN_USER_HOME_SHORT") != "None": from conans.util.windows import ignore_long_path_files ignore = ignore_long_path_files(src_folder, self.build_folder, self._out) else: ignore = None shutil.copytree(src_folder, self.build_folder, symlinks=True, ignore=ignore) logger.debug("Copied to %s" % self.build_folder) logger.debug("Files copied %s" % os.listdir(self.build_folder)) self._conan_file.source_folder = self.build_folder os.chdir(self.build_folder) self._conan_file.build_folder = self.build_folder self._conan_file._conanfile_directory = self.build_folder # Read generators from conanfile and generate the needed files logger.debug("Writing generators") write_generators(self._conan_file, self.build_folder, self._out) logger.debug("Files copied after generators %s" % os.listdir(self.build_folder)) # Build step might need DLLs, binaries as protoc to generate source files # So execute imports() before build, storing the list of copied_files from conans.client.importer import run_imports copied_files = run_imports(self._conan_file, self.build_folder, self._out) try: # This is necessary because it is different for user projects # than for packages logger.debug( "Call conanfile.build() with files in build folder: %s" % os.listdir(self.build_folder)) self._out.highlight("Calling build()") with conanfile_exception_formatter(str(self._conan_file), "build"): self._conan_file.build() self._out.success("Package '%s' built" % self._conan_file.info.package_id()) self._out.info("Build folder %s" % self.build_folder) except Exception as exc: os.chdir(src_folder) self._out.writeln("") self._out.error("Package '%s' build failed" % self._conan_file.info.package_id()) self._out.warn("Build folder %s" % self.build_folder) if isinstance(exc, ConanExceptionInUserConanfileMethod): raise exc raise ConanException(exc) finally: self._conan_file._conanfile_directory = export_folder # Now remove all files that were imported with imports() for f in copied_files: try: if f.startswith(self.build_folder): os.remove(f) except Exception: self._out.warn( "Unable to remove imported file from build: %s" % f)
def _build_package(self, export_folder, src_folder, build_folder, package_folder, conan_file, output): """ builds the package, creating the corresponding build folder if necessary and copying there the contents from the src folder. The code is duplicated in every build, as some configure processes actually change the source code """ output.info('Building your package in %s' % build_folder) if not build_exists(build_folder): config_source(export_folder, src_folder, conan_file, output) output.info('Copying sources to build folder') def check_max_path_len(src, files): if platform.system() != "Windows": return [] filtered_files = [] for the_file in files: source_path = os.path.join(src, the_file) # Without storage path, just relative rel_path = os.path.relpath(source_path, src_folder) dest_path = os.path.normpath( os.path.join(build_folder, rel_path)) # it is NOT that "/" is counted as "\\" so it counts double # seems a bug in python, overflows paths near the limit of 260, if len(dest_path) >= 249: filtered_files.append(the_file) output.warn("Filename too long, file excluded: %s" % dest_path) return filtered_files shutil.copytree(src_folder, build_folder, symlinks=True, ignore=check_max_path_len) os.chdir(build_folder) conan_file._conanfile_directory = build_folder # Read generators from conanfile and generate the needed files write_generators(conan_file, build_folder, output) # Build step might need DLLs, binaries as protoc to generate source files # So execute imports() before build, storing the list of copied_files from conans.client.importer import FileImporter local_installer = FileImporter(self._deps_graph, self._paths, build_folder) conan_file.copy = local_installer conan_file.imports() copied_files = local_installer.execute() import_output = ScopedOutput("%s imports()" % output.scope, output) report_copied_files(copied_files, import_output) try: # This is necessary because it is different for user projects # than for packages conan_file._conanfile_directory = build_folder conan_file.build() self._out.writeln("") output.success("Package '%s' built" % conan_file.info.package_id()) output.info("Build folder %s" % build_folder) except Exception as e: os.chdir(src_folder) self._out.writeln("") output.error("Package '%s' build failed" % conan_file.info.package_id()) output.warn("Build folder %s" % build_folder) raise ConanException("%s: %s" % (conan_file.name, str(e))) finally: conan_file._conanfile_directory = export_folder # Now remove all files that were imported with imports() for f in copied_files: try: if (f.startswith(build_folder)): os.remove(f) except Exception: self._out.warn( "Unable to remove imported file from build: %s" % f)