Exemple #1
0
    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
                write_generators(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")
                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)
Exemple #2
0
    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)