From 306ad185e8d8f50923316bdd1b68ef9a3b1e50e6 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 11 Apr 2023 14:47:42 +0200 Subject: Split package configuration into two passes in pkg-build --- bpkg/pkg-configure.hxx | 75 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 10 deletions(-) (limited to 'bpkg/pkg-configure.hxx') diff --git a/bpkg/pkg-configure.hxx b/bpkg/pkg-configure.hxx index 16ed96f..a7409b9 100644 --- a/bpkg/pkg-configure.hxx +++ b/bpkg/pkg-configure.hxx @@ -21,6 +21,14 @@ namespace bpkg int pkg_configure (const pkg_configure_options&, cli::scanner& args); + // Configure a system package and commit the transaction. + // + shared_ptr + pkg_configure_system (const package_name&, + const version&, + database&, + transaction&); + // The custom search function. If specified, it is called by pkg_configure() // to obtain the database to search for the prerequisite in, instead of // searching for it in the linked databases, recursively. If the function @@ -31,7 +39,14 @@ namespace bpkg const package_name&, bool buildtime); - // Configure the package, update its state, and commit the transaction. + // Given dependencies of a package, return its prerequisite packages, + // configuration variables that resulted from selection of these + // prerequisites (import, reflection, etc), and sources of the configuration + // variables resulted from evaluating the reflect clauses. See + // pkg_configure() for the semantics of the dependency list. Fail if for + // some of the dependency alternative lists there is no satisfactory + // alternative (all its dependencies are configured, satisfy the respective + // constraints, etc). // // The package dependency constraints are expected to be complete. // @@ -50,6 +65,54 @@ namespace bpkg // dependency decisions" mode). Failed that, select an alternative as if no // prerequisites are specified (the "make dependency decisions" mode). // + struct configure_prerequisites_result + { + package_prerequisites prerequisites; + strings config_variables; // Note: name and value. + + // Only contains sources of configuration variables collected using the + // package skeleton, excluding those user-specified variables which are + // not the project variables for the specified package (module + // configuration variables, etc). Thus, it is not parallel to the + // config_variables member. + // + vector config_sources; // Note: name and source. + }; + + // Return the "would be" state for packages that would be configured + // by this stage. + // + using find_package_state_function = + optional> ( + const shared_ptr&); + + // Note: loads selected packages. + // + configure_prerequisites_result + pkg_configure_prerequisites (const common_options&, + database&, + transaction&, + const dependencies&, + const vector* alternatives, + package_skeleton&&, + const vector* prev_prerequisites, + bool simulate, + const function&, + const function&); + + // Configure the package, update its state, and commit the transaction. + // + void + pkg_configure (const common_options&, + database&, + transaction&, + const shared_ptr&, + configure_prerequisites_result&&, + bool disfigured, + bool simulate); + + // Note: loads selected packages. + // void pkg_configure (const common_options&, database&, @@ -58,18 +121,10 @@ namespace bpkg const dependencies&, const vector* alternatives, package_skeleton&&, - const vector* prerequisites, + const vector* prev_prerequisites, bool disfigured, bool simulate, const function& = {}); - - // Configure a system package and commit the transaction. - // - shared_ptr - pkg_configure_system (const package_name&, - const version&, - database&, - transaction&); } #endif // BPKG_PKG_CONFIGURE_HXX -- cgit v1.1