From 67af141e3affa21dc9118c7f0060ab746cfb6fba Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 10 Jul 2018 14:26:37 +0200 Subject: Add support for archive checksum generation during distribution Now we can do: $ b dist: ... \ config.dist.archives='tar.gz zip' \ config.dist.checksums='sha1 sha256' And end up with .tar.gz.sha1, .tar.gz.sha256, .zip.sha1, and .zip.sha256 checksum files in addition to archives. --- build2/dist/init.cxx | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'build2/dist/init.cxx') diff --git a/build2/dist/init.cxx b/build2/dist/init.cxx index df162a2..5a7fddf 100644 --- a/build2/dist/init.cxx +++ b/build2/dist/init.cxx @@ -41,14 +41,21 @@ namespace build2 // Note: some overridable, some not. // - // config.dist.archives is a list of archive extensions that can be - // optionally prefixed with a directory. If it is relative, then it is - // prefixed with config.dist.root. Otherwise, the archive is written - // to the absolute location. - // - vp.insert ("config.dist.root", true); - vp.insert ("config.dist.archives", true); - vp.insert ("config.dist.cmd", true); + // config.dist.archives is a list of archive extensions (e.g., zip, + // tar.gz) that can be optionally prefixed with a directory. If it is + // relative, then it is prefixed with config.dist.root. Otherwise, the + // archive is written to the absolute location. + // + // config.dist.checksums is a list of archive checksum extensions (e.g., + // sha1, sha256) that can also be optionally prefixed with a directory + // with the same semantics as config.dist.archives. If the directory is + // absent, then the checksum file is written into the same directory as + // the corresponding archive. + // + vp.insert ("config.dist.root", true); + vp.insert ("config.dist.archives", true); + vp.insert ("config.dist.checksums", true); + vp.insert ("config.dist.cmd", true); // Allow distribution of uncommitted projects. This is enforced by the // version module. @@ -58,6 +65,7 @@ namespace build2 vp.insert ("dist.root"); vp.insert ("dist.cmd"); vp.insert ("dist.archives"); + vp.insert ("dist.checksums"); vp.insert ("dist.uncommitted"); vp.insert ("dist", variable_visibility::target); // Flag. @@ -143,14 +151,26 @@ namespace build2 } // dist.archives + // dist.checksums // { - value& v (rs.assign ("dist.archives")); + value& a (rs.assign ("dist.archives")); + value& c (rs.assign ("dist.checksums")); if (s) { if (lookup l = config::optional (rs, "config.dist.archives")) - v = *l; + a = *l; + + if (lookup l = config::optional (rs, "config.dist.checksums")) + { + c = *l; + + if (!c.empty () && (!a || a.empty ())) + fail << "config.dist.checksums specified without " + << "config.dist.archives"; + + } } } -- cgit v1.1