From e7f4231e935edae79ba2cd4d73a6e49591188bcc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 1 Sep 2016 09:57:48 +0200 Subject: Add support for specifying directory in config.dist.archives --- build2/dist/operation.cxx | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) (limited to 'build2/dist/operation.cxx') diff --git a/build2/dist/operation.cxx b/build2/dist/operation.cxx index 12bcc61..4628350 100644 --- a/build2/dist/operation.cxx +++ b/build2/dist/operation.cxx @@ -45,10 +45,13 @@ namespace build2 static void install (const path& cmd, file&, const dir_path&); - // cd && tar|zip ... . + // cd && tar|zip ... /. // static void - archive (const dir_path& root, const string& pkg, const string& ext); + archive (const dir_path& root, + const string& pkg, + const dir_path& dir, + const string& ext); static void dist_execute (action, const action_targets& ts, bool) @@ -289,8 +292,22 @@ namespace build2 // if (auto l = rs->vars["dist.archives"]) { - for (const string& e: cast (l)) - archive (dist_root, dist_package, e); + for (const path& p: cast (l)) + { + dir_path d (p.relative () ? dist_root : dir_path ()); + d /= p.directory (); + + const string& s (p.string ()); + size_t i (path::traits::find_leaf (s)); + + if (i == string::npos) + fail << "invalid archive '" << s << "' in dist.archives"; + + if (s[i] == '.') // Skip dot if specified. + ++i; + + archive (dist_root, dist_package, d, string (s, i)); + } } } @@ -386,13 +403,16 @@ namespace build2 } static void - archive (const dir_path& root, const string& pkg, const string& e) + archive (const dir_path& root, + const string& pkg, + const dir_path& dir, + const string& e) { string a (pkg + '.' + e); // Delete old archive for good measure. // - path ap (root / path (a)); + path ap (dir / path (a)); if (file_exists (ap, false)) rmfile (ap); @@ -401,9 +421,11 @@ namespace build2 // cstrings args; if (e == "zip") - args = {"zip", "-rq", a.c_str (), pkg.c_str (), nullptr}; + args = {"zip", "-rq", + ap.string ().c_str (), pkg.c_str (), nullptr}; else - args = {"tar", "-a", "-cf", a.c_str (), pkg.c_str (), nullptr}; + args = {"tar", "-a", "-cf", + ap.string ().c_str (), pkg.c_str (), nullptr}; if (verb >= 2) print_process (args); -- cgit v1.1