aboutsummaryrefslogtreecommitdiff
path: root/bpkg/pkg-configure.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'bpkg/pkg-configure.cxx')
-rw-r--r--bpkg/pkg-configure.cxx135
1 files changed, 56 insertions, 79 deletions
diff --git a/bpkg/pkg-configure.cxx b/bpkg/pkg-configure.cxx
index 20a2567..c440877 100644
--- a/bpkg/pkg-configure.cxx
+++ b/bpkg/pkg-configure.cxx
@@ -19,32 +19,7 @@ using namespace butl;
namespace bpkg
{
- // 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).
- //
- 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_variable> config_sources; // Note: name and source.
- };
-
- // Note: loads selected packages.
- //
- static configure_prerequisites_result
+ configure_prerequisites_result
pkg_configure_prerequisites (const common_options& o,
database& db,
transaction&,
@@ -55,6 +30,10 @@ namespace bpkg
bool simulate,
const function<find_database_function>& fdb)
{
+ tracer trace ("pkg_configure_prerequisites");
+
+ tracer_guard tg (db, trace);
+
package_prerequisites prereqs;
strings vars;
@@ -263,6 +242,10 @@ namespace bpkg
// Also note that such modules are marked with `requires:
// bootstrap` in their manifest.
//
+ // Note that we currently don't support global overrides
+ // in the shared build2 context (but could probably do,
+ // if necessary).
+ //
dir_path od (sp->effective_out_root (pdb.config));
vars.push_back ("config.import." + sp->name.variable () +
"='" + od.representation () + '\'');
@@ -339,13 +322,9 @@ namespace bpkg
database& db,
transaction& t,
const shared_ptr<selected_package>& p,
- const dependencies& deps,
- const vector<size_t>* alts,
- package_skeleton&& ps,
- const vector<package_name>* pps,
+ configure_prerequisites_result&& cpr,
bool disfigured,
- bool simulate,
- const function<find_database_function>& fdb)
+ bool simulate)
{
tracer trace ("pkg_configure");
@@ -367,41 +346,13 @@ namespace bpkg
l4 ([&]{trace << "src_root: " << src_root << ", "
<< "out_root: " << out_root;});
- // Verify all our prerequisites are configured and populate the
- // prerequisites list.
- //
assert (p->prerequisites.empty ());
-
- configure_prerequisites_result cpr (
- pkg_configure_prerequisites (o,
- db,
- t,
- deps,
- alts,
- move (ps),
- pps,
- simulate,
- fdb));
-
p->prerequisites = move (cpr.prerequisites);
+ // Configure.
+ //
if (!simulate)
{
- // Form the buildspec.
- //
- string bspec;
-
- // Use path representation to get canonical trailing slash.
- //
- if (src_root == out_root)
- bspec = "configure('" + out_root.representation () + "')";
- else
- bspec = "configure('" +
- src_root.representation () + "'@'" +
- out_root.representation () + "')";
-
- l4 ([&]{trace << "buildspec: " << bspec;});
-
// Unless this package has been completely disfigured, disfigure all the
// package configuration variables to reset all the old values to
// defaults (all the new user/dependent/reflec values, including old
@@ -424,8 +375,21 @@ namespace bpkg
dvar += "**'";
}
- // Configure.
+ // Form the buildspec.
+ //
+ string bspec;
+
+ // Use path representation to get canonical trailing slash.
//
+ if (src_root == out_root)
+ bspec = "configure('" + out_root.representation () + "')";
+ else
+ bspec = "configure('" +
+ src_root.representation () + "'@'" +
+ out_root.representation () + "')";
+
+ l4 ([&]{trace << "buildspec: " << bspec;});
+
try
{
run_b (o,
@@ -436,25 +400,11 @@ namespace bpkg
}
catch (const failed&)
{
- // If we failed to configure the package, make sure we revert
- // it back to the unpacked state by running disfigure (it is
- // valid to run disfigure on an un-configured build). And if
- // disfigure fails as well, then the package will be set into
- // the broken state.
- //
-
- // Indicate to pkg_disfigure() we are partially configured.
+ // See below for comments.
//
p->out_root = out_root.leaf ();
p->state = package_state::broken;
-
- // Commits the transaction.
- //
- pkg_disfigure (o, db, t,
- p,
- true /* clean */,
- true /* disfigure */,
- false /* simulate */);
+ pkg_disfigure (o, db, t, p, true, true, false);
throw;
}
@@ -468,6 +418,33 @@ namespace bpkg
t.commit ();
}
+ void
+ pkg_configure (const common_options& o,
+ database& db,
+ transaction& t,
+ const shared_ptr<selected_package>& p,
+ const dependencies& deps,
+ const vector<size_t>* alts,
+ package_skeleton&& ps,
+ const vector<package_name>* pps,
+ bool disfigured,
+ bool simulate,
+ const function<find_database_function>& fdb)
+ {
+ configure_prerequisites_result cpr (
+ pkg_configure_prerequisites (o,
+ db,
+ t,
+ deps,
+ alts,
+ move (ps),
+ pps,
+ simulate,
+ fdb));
+
+ pkg_configure (o, db, t, p, move (cpr), disfigured, simulate);
+ }
+
shared_ptr<selected_package>
pkg_configure_system (const package_name& n,
const version& v,