aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/version/init.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-09-25 13:42:17 +0200
committerKaren Arutyunov <karen@codesynthesis.com>2020-09-29 15:19:19 +0300
commit55a9ff6c72da30ad8761938d00c94355a0cb1b04 (patch)
treeb9edefcb50cfaa975303b3d52f1cd8fc25998cad /libbuild2/version/init.cxx
parent9dba2e1e7a8aa8de4d5236ab6b5a81d6cf34df1a (diff)
Add bootstrap distribution mode (!config.dist.bootstrap=true)
In this mode the dist meta-operation does not load the project (but does bootstrap it) and adds all the source files into the distribution only ignoring files and directories that start with a dot. This mode is primarily meant for situation where the project cannot (yet) be loaded due to missing dependencies.
Diffstat (limited to 'libbuild2/version/init.cxx')
-rw-r--r--libbuild2/version/init.cxx83
1 files changed, 41 insertions, 42 deletions
diff --git a/libbuild2/version/init.cxx b/libbuild2/version/init.cxx
index d11b2f3..ced9c68 100644
--- a/libbuild2/version/init.cxx
+++ b/libbuild2/version/init.cxx
@@ -30,6 +30,44 @@ namespace build2
static const in_rule in_rule_;
static const manifest_install_rule manifest_install_rule_;
+ static void
+ dist_callback (const path&, const scope&, void*);
+
+ void
+ boot_post (scope& rs, const location&, module_boot_post_extra& extra)
+ {
+ // If the dist module is used, set its dist.package and register the
+ // post-processing callback.
+ //
+ if (auto* dm = rs.find_module<dist::module> (dist::module::name))
+ {
+ // Don't touch if dist.package was set by the user.
+ //
+ value& val (rs.assign (dm->var_dist_package));
+
+ if (!val)
+ {
+ auto& m (extra.module_as<module> ());
+ const standard_version& v (m.version);
+
+ // We've already verified in boot() it is named.
+ //
+ string p (project (rs).string ());
+ p += '-';
+ p += v.string ();
+ val = move (p);
+
+ // Only register the post-processing callback if this is a rewritten
+ // snapshot.
+ //
+ if (m.rewritten)
+ dm->register_callback (dir_path (".") / manifest_file,
+ &dist_callback,
+ &m);
+ }
+ }
+ }
+
void
boot (scope& rs, const location& l, module_boot_extra& extra)
{
@@ -281,19 +319,17 @@ namespace build2
// Initialize second (dist.package, etc).
//
+ extra.post = &boot_post;
extra.init = module_boot_init::before_second;
}
- static void
- dist_callback (const path&, const scope&, void*);
-
bool
init (scope& rs,
scope&,
const location& l,
bool first,
bool,
- module_init_extra& extra)
+ module_init_extra&)
{
tracer trace ("version::init");
@@ -304,43 +340,6 @@ namespace build2
//
load_module (rs, rs, "in.base", l);
- auto& m (extra.module_as<module> ());
- const standard_version& v (m.version);
-
- // If the dist module is used, set its dist.package and register the
- // post-processing callback.
- //
- if (auto* dm = rs.find_module<dist::module> (dist::module::name))
- {
- // Make sure dist is init'ed, not just boot'ed.
- //
- load_module (rs, rs, "dist", l);
-
- m.dist_uncommitted = cast_false<bool> (rs["config.dist.uncommitted"]);
-
- // Don't touch if dist.package was set by the user.
- //
- value& val (rs.assign (dm->var_dist_package));
-
- if (!val)
- {
- // We've already verified in boot() it is named.
- //
- string p (project (rs).string ());
- p += '-';
- p += v.string ();
- val = move (p);
-
- // Only register the post-processing callback if this is a rewritten
- // snapshot.
- //
- if (m.rewritten)
- dm->register_callback (dir_path (".") / manifest_file,
- &dist_callback,
- &m);
- }
- }
-
// Register rules.
//
rs.insert_rule<file> (perform_update_id, "version.in", in_rule_);
@@ -363,7 +362,7 @@ namespace build2
// Complain if this is an uncommitted snapshot.
//
- if (!m.committed && !m.dist_uncommitted)
+ if (!m.committed && !cast_false<bool> (rs["config.dist.uncommitted"]))
fail << "distribution of uncommitted project " << rs.src_path () <<
info << "specify config.dist.uncommitted=true to force";