From 5c8fc857b790de371ba6f38b3eec214398f8eae0 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 20 Mar 2018 14:36:31 +0200 Subject: Add support for config.dist.uncommitted --- build2/version/init.cxx | 26 ++++++++++++++++++++++---- build2/version/module.hxx | 2 ++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/build2/version/init.cxx b/build2/version/init.cxx index f793c98..c6729f1 100644 --- a/build2/version/init.cxx +++ b/build2/version/init.cxx @@ -12,6 +12,8 @@ #include #include +#include + #include #include @@ -253,11 +255,26 @@ namespace build2 module& m (static_cast (*mod)); const standard_version& v (m.version); - // If the dist module has been loaded, set its dist.package and register - // the post-processing callback. + // If the dist module is used, set its dist.package and register the + // post-processing callback. // if (auto* dm = rs.modules.lookup (dist::module::name)) { + // Make sure dist is init'ed, not just boot'ed. + // + if (!cast_false (rs["dist.loaded"])) + load_module (rs, rs, "dist", l); + + // Add the config.dist.uncommitted configuration variable (a bit cozy + // adding other module's config variable but I am not sure calling it + // config.version.dist.uncommitted would be better). + // + auto& vp (var_pool.rw (rs)); + { + const auto& var (vp.insert ("config.dist.uncommitted", true)); + m.dist_uncommitted = cast_false (config::optional (rs, var)); + } + // Don't touch if dist.package was set by the user. // value& val (rs.assign (dm->var_dist_package)); @@ -335,8 +352,9 @@ namespace build2 // Complain if this is an uncommitted snapshot. // - if (v.snapshot () && !m.committed) - fail << "distribution of uncommitted project " << rs.src_path (); + if (v.snapshot () && !m.committed && !m.dist_uncommitted) + fail << "distribution of uncommitted project " << rs.src_path () << + info << "specify config.dist.uncommitted=true to force"; // The plan is simple, re-serialize the manifest into a temporary file // fixing up the version. Then move the temporary file to the original. diff --git a/build2/version/module.hxx b/build2/version/module.hxx index a5a667a..e057e7d 100644 --- a/build2/version/module.hxx +++ b/build2/version/module.hxx @@ -32,6 +32,8 @@ namespace build2 const variable* in_symbol = nullptr; // in.symbol const variable* in_substitution = nullptr; // in.substitution + bool dist_uncommitted = false; + module (butl::standard_version v, bool c, dependency_constraints d) -- cgit v1.1