def save(self, folder, filename=None): filename = filename or GRAPH_INFO_FILE p = os.path.join(folder, filename) serialized_graph_str = self._dumps() save(p, serialized_graph_str) # A bit hacky, but to avoid repetition by now graph_lock_file = GraphLockFile(self.profile_host, self.graph_lock) graph_lock_file.save(os.path.join(folder, LOCKFILE))
def _handle_node_editable(self, node, graph_info): # Get source of information package_layout = self._cache.package_layout(node.ref) base_path = package_layout.base_folder() self._call_package_info(node.conanfile, package_folder=base_path, ref=node.ref) node.conanfile.cpp_info.filter_empty = False # Try with package-provided file editable_cpp_info = package_layout.editable_cpp_info() if editable_cpp_info: editable_cpp_info.apply_to(node.ref, node.conanfile.cpp_info, settings=node.conanfile.settings, options=node.conanfile.options) build_folder = editable_cpp_info.folder( node.ref, EditableLayout.BUILD_FOLDER, settings=node.conanfile.settings, options=node.conanfile.options) if build_folder is not None: build_folder = os.path.join(base_path, build_folder) output = node.conanfile.output self._generator_manager.write_generators( node.conanfile, build_folder, output) write_toolchain(node.conanfile, build_folder, output) save(os.path.join(build_folder, CONANINFO), node.conanfile.info.dumps()) output.info("Generated %s" % CONANINFO) graph_info_node = GraphInfo(graph_info.profile_host, root_ref=node.ref) graph_info_node.options = node.conanfile.options.values graph_info_node.graph_lock = graph_info.graph_lock graph_info_node.save(build_folder) output.info("Generated graphinfo") graph_lock_file = GraphLockFile(graph_info.profile_host, graph_info.profile_build, graph_info.graph_lock) graph_lock_file.save(os.path.join(build_folder, "conan.lock")) save(os.path.join(build_folder, BUILD_INFO), TXTGenerator(node.conanfile).content) output.info("Generated %s" % BUILD_INFO) # Build step might need DLLs, binaries as protoc to generate source files # So execute imports() before build, storing the list of copied_files copied_files = run_imports(node.conanfile, build_folder) report_copied_files(copied_files, output)
def deps_install(app, ref_or_path, install_folder, base_folder, graph_info, remotes=None, build_modes=None, update=False, manifest_folder=None, manifest_verify=False, manifest_interactive=False, generators=None, no_imports=False, create_reference=None, keep_build=False, recorder=None, lockfile_node_id=None, is_build_require=False, add_txt_generator=True, require_overrides=None, conanfile_path=None, test=None, source_folder=None, output_folder=None): """ Fetch and build all dependencies for the given reference @param app: The ConanApp instance with all collaborators @param ref_or_path: ConanFileReference or path to user space conanfile @param install_folder: where the output files will be saved @param build_modes: List of build_modes specified @param update: Check for updated in the upstream remotes (and update) @param manifest_folder: Folder to install the manifests @param manifest_verify: Verify dependencies manifests against stored ones @param manifest_interactive: Install deps manifests in folder for later verify, asking user for confirmation @param generators: List of generators from command line. @param no_imports: Install specified packages but avoid running imports @param add_txt_generator: Add the txt to the list of generators """ out, user_io, graph_manager, cache = app.out, app.user_io, app.graph_manager, app.cache remote_manager, hook_manager = app.remote_manager, app.hook_manager profile_host, profile_build = graph_info.profile_host, graph_info.profile_build if profile_build: out.info("Configuration (profile_host):") out.writeln(profile_host.dumps()) out.info("Configuration (profile_build):") out.writeln(profile_build.dumps()) else: out.info("Configuration:") out.writeln(profile_host.dumps()) deps_graph = graph_manager.load_graph(ref_or_path, create_reference, graph_info, build_modes, False, update, remotes, recorder, lockfile_node_id=lockfile_node_id, is_build_require=is_build_require, require_overrides=require_overrides) graph_lock = graph_info.graph_lock # After the graph is loaded it is defined root_node = deps_graph.root conanfile = root_node.conanfile if root_node.recipe == RECIPE_VIRTUAL: out.highlight("Installing package: %s" % str(ref_or_path)) else: conanfile.output.highlight("Installing package") print_graph(deps_graph, out) try: if cross_building(conanfile): settings = get_cross_building_settings(conanfile) message = "Cross-build from '%s:%s' to '%s:%s'" % settings out.writeln(message, Color.BRIGHT_MAGENTA) except ConanException: # Setting os doesn't exist pass installer = BinaryInstaller(app, recorder=recorder) # TODO: Extract this from the GraphManager, reuse same object, check args earlier build_modes = BuildMode(build_modes, out) installer.install(deps_graph, remotes, build_modes, update, profile_host, profile_build, graph_lock, keep_build=keep_build) graph_lock.complete_matching_prevs() if manifest_folder: manifest_manager = ManifestManager(manifest_folder, user_io=user_io, cache=cache) for node in deps_graph.nodes: if node.recipe in (RECIPE_CONSUMER, RECIPE_VIRTUAL): continue retrieve_exports_sources(remote_manager, cache, node.conanfile, node.ref, remotes) manifest_manager.check_graph(deps_graph, verify=manifest_verify, interactive=manifest_interactive) manifest_manager.print_log() if hasattr(conanfile, "layout") and not test: conanfile.folders.set_base_source(source_folder or conanfile_path) conanfile.folders.set_base_install(output_folder or conanfile_path) conanfile.folders.set_base_imports(output_folder or conanfile_path) conanfile.folders.set_base_generators(output_folder or conanfile_path) else: conanfile.folders.set_base_install(install_folder) conanfile.folders.set_base_imports(install_folder) conanfile.folders.set_base_generators(base_folder) output = conanfile.output if root_node.recipe != RECIPE_VIRTUAL else out if install_folder: # Write generators tmp = list( conanfile.generators) # Add the command line specified generators generators = set(generators) if generators else set() tmp.extend([g for g in generators if g not in tmp]) if add_txt_generator: tmp.append("txt") conanfile.generators = tmp app.generator_manager.write_generators(conanfile, install_folder, conanfile.generators_folder, output) write_toolchain(conanfile, conanfile.generators_folder, output) if not isinstance(ref_or_path, ConanFileReference): # Write conaninfo content = normalize(conanfile.info.dumps()) save(os.path.join(install_folder, CONANINFO), content) output.info("Generated %s" % CONANINFO) graph_info.save(install_folder) output.info("Generated graphinfo") graph_lock_file = GraphLockFile(profile_host, profile_build, graph_lock) graph_lock_file.save(os.path.join(install_folder, "conan.lock")) if not no_imports: run_imports(conanfile) if type(conanfile ).system_requirements != ConanFile.system_requirements: call_system_requirements(conanfile, conanfile.output) if not create_reference and isinstance(ref_or_path, ConanFileReference): # The conanfile loaded is a virtual one. The one w deploy is the first level one neighbours = deps_graph.root.neighbors() deploy_conanfile = neighbours[0].conanfile if hasattr(deploy_conanfile, "deploy") and callable( deploy_conanfile.deploy): run_deploy(deploy_conanfile, install_folder)
def _handle_node_editable(self, node, profile_host, profile_build, graph_lock): # Get source of information conanfile = node.conanfile ref = node.ref package_layout = self._cache.package_layout(ref) base_path = package_layout.base_folder() if hasattr(conanfile, "layout"): conanfile.folders.set_base_folders(base_path, package_layout.output_folder) else: conanfile.folders.set_base_package(base_path) conanfile.folders.set_base_source(None) conanfile.folders.set_base_build(None) conanfile.folders.set_base_install(None) self._call_package_info(conanfile, package_folder=base_path, ref=ref, is_editable=True) # New editables mechanism based on Folders if hasattr(conanfile, "layout"): output = conanfile.output output.info("Rewriting files of editable package " "'{}' at '{}'".format(conanfile.name, conanfile.generators_folder)) self._generator_manager.write_generators( conanfile, conanfile.install_folder, conanfile.generators_folder, output) write_toolchain(conanfile, conanfile.generators_folder, output) output.info("Generated toolchain") graph_info_node = GraphInfo(profile_host, root_ref=node.ref) graph_info_node.options = node.conanfile.options.values graph_info_node.graph_lock = graph_lock graph_info_node.save(base_path) output.info("Generated conan.lock") copied_files = run_imports(conanfile) report_copied_files(copied_files, output) return node.conanfile.cpp_info.filter_empty = False # OLD EDITABLE LAYOUTS: # Try with package-provided file editable_cpp_info = package_layout.editable_cpp_info() if editable_cpp_info: editable_cpp_info.apply_to(ref, conanfile.cpp_info, settings=conanfile.settings, options=conanfile.options) build_folder = editable_cpp_info.folder( ref, EditableLayout.BUILD_FOLDER, settings=conanfile.settings, options=conanfile.options) if build_folder is not None: build_folder = os.path.join(base_path, build_folder) output = conanfile.output self._generator_manager.write_generators( conanfile, build_folder, build_folder, output) write_toolchain(conanfile, build_folder, output) save(os.path.join(build_folder, CONANINFO), conanfile.info.dumps()) output.info("Generated %s" % CONANINFO) graph_info_node = GraphInfo(profile_host, root_ref=node.ref) graph_info_node.options = node.conanfile.options.values graph_info_node.graph_lock = graph_lock graph_info_node.save(build_folder) output.info("Generated graphinfo") graph_lock_file = GraphLockFile(profile_host, profile_build, graph_lock) graph_lock_file.save(os.path.join(build_folder, "conan.lock")) save(os.path.join(build_folder, BUILD_INFO), TXTGenerator(conanfile).content) output.info("Generated %s" % BUILD_INFO) # Build step might need DLLs, binaries as protoc to generate source files # So execute imports() before build, storing the list of copied_files conanfile.folders.set_base_imports(build_folder) copied_files = run_imports(conanfile) report_copied_files(copied_files, output)
def save_lock(self, lockfile): graph_lock_file = GraphLockFile(self.profile_host, self.profile_build, self.graph_lock) graph_lock_file.save(lockfile)