aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-24 15:16:42 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-24 15:16:42 +0200
commitf96f707ae4598e2ecc616a6e2aa47ace943c7eb5 (patch)
treee8ebc2fbece9a67b2533a8fc166a9384a73d9e19
parent04be612dead00c36c8c6ff748c252e8e5d3b1e5c (diff)
Add --forward option to bdep-submit
This option instructs the submit command to use each package's forwarded configuration in order to prepare the distributions. This help with setups where there is no single configuration that had all the packages (such as a build system module project).
-rw-r--r--bdep/project.cxx11
-rw-r--r--bdep/project.hxx9
-rw-r--r--bdep/publish.cli8
-rw-r--r--bdep/publish.cxx95
-rw-r--r--bdep/sync.cxx23
-rw-r--r--bdep/sync.hxx10
6 files changed, 127 insertions, 29 deletions
diff --git a/bdep/project.cxx b/bdep/project.cxx
index 7f80c9f..d8cfc8a 100644
--- a/bdep/project.cxx
+++ b/bdep/project.cxx
@@ -5,7 +5,6 @@
#include <bdep/project.hxx>
#include <bdep/project-odb.hxx>
-#include <libbutl/b.mxx>
#include <libbutl/manifest-parser.mxx>
#include <libbpkg/manifest.hxx>
@@ -406,10 +405,8 @@ namespace bdep
}
}
- // Obtain build2 project info for package source or output directories.
- //
- static b_project_info
- package_info (const common_options& o, const dir_path& d)
+ package_info
+ package_b_info (const common_options& o, const dir_path& d)
{
try
{
@@ -437,7 +434,7 @@ namespace bdep
standard_version
package_version (const common_options& o, const dir_path& d)
{
- b_project_info pi (package_info (o, d));
+ package_info pi (package_b_info (o, d));
if (pi.version.empty ())
fail << "empty version for package directory " << d;
@@ -456,7 +453,7 @@ namespace bdep
// Note: the package directory inside the configuration is a bit of an
// assumption.
//
- b_project_info pi (package_info (o, (dir_path (cfg) /= p.string ())));
+ package_info pi (package_b_info (o, (dir_path (cfg) /= p.string ())));
if (pi.version.empty ())
fail << "empty version for package " << p;
diff --git a/bdep/project.hxx b/bdep/project.hxx
index 9f628f5..83cefc9 100644
--- a/bdep/project.hxx
+++ b/bdep/project.hxx
@@ -7,6 +7,8 @@
#include <odb/core.hxx>
+#include <libbutl/b.mxx>
+
#include <libbpkg/package-name.hxx>
#include <bdep/types.hxx>
@@ -266,6 +268,13 @@ namespace bdep
package_version (const common_options&,
const dir_path& cfg,
const package_name&);
+
+ // Obtain build2 project info for package source or output directory.
+ //
+ using package_info = butl::b_project_info;
+
+ package_info
+ package_b_info (const common_options&, const dir_path&);
}
#endif // BDEP_PROJECT_HXX
diff --git a/bdep/publish.cli b/bdep/publish.cli
index cba7436..1d3771c 100644
--- a/bdep/publish.cli
+++ b/bdep/publish.cli
@@ -24,7 +24,7 @@ namespace bdep
\c{<pkg-spec> = (\b{--directory}|\b{-d} <pkg-dir>)... | <prj-spec>\n
<prj-spec> = \b{--directory}|\b{-d} <prj-dir>\n
- <cfg-spec> = \b{@}<cfg-name> | \b{--config}|\b{-c} <cfg-dir>}
+ <cfg-spec> = \b{@}<cfg-name> | \b{--config}|\b{-c} <cfg-dir> | \b{--forward}}
\h|DESCRIPTION|
@@ -143,6 +143,12 @@ namespace bdep
other recognized outcomes refer to the submission service
documentation."
}
+
+ bool --forward
+ {
+ "Use the forwarded configuration for each package instead of the
+ default configuration."
+ }
};
"\h|ENVIRONMENT|
diff --git a/bdep/publish.cxx b/bdep/publish.cxx
index ab58025..0e13b86 100644
--- a/bdep/publish.cxx
+++ b/bdep/publish.cxx
@@ -49,6 +49,8 @@ namespace bdep
info << "use --control to specify explicitly" << endf;
}
+ // If cfg is empty, then use each package's (forwarded) source directory.
+ //
static int
cmd_publish (const cmd_publish_options& o,
const dir_path& prj,
@@ -109,11 +111,12 @@ namespace bdep
struct package
{
package_name name;
+ dir_path path;
standard_version version;
package_name project;
string section; // alpha|beta|stable (or --section)
- path archive;
+ bdep::path archive;
string checksum;
package_manifest manifest;
@@ -146,7 +149,9 @@ namespace bdep
package_name n (move (pl.name));
package_name p (pl.project ? move (*pl.project) : n);
- standard_version v (package_version (o, cfg, n));
+ standard_version v (cfg.empty ()
+ ? package_version (o, prj / pl.path)
+ : package_version (o, cfg, n));
// Should we allow publishing snapshots and, if so, to which section?
// For example, is it correct to consider a "between betas" snapshot a
@@ -185,6 +190,7 @@ namespace bdep
v.beta () ? "beta" : "stable");
pkgs.push_back (package {move (n),
+ move (pl.path),
move (v),
move (p),
move (s),
@@ -249,10 +255,13 @@ namespace bdep
// build2's version module by default does not allow distribution of
// uncommitted projects.
//
+ dir_path d (cfg.empty ()
+ ? prj / p.path
+ : dir_path (cfg) /= p.name.string ());
run_b (
o,
"dist:",
- "'" + (dir_path (cfg) /= p.name.string ()).representation () + "'",
+ "'" + d.representation () + "'",
"config.dist.root='" + dr.representation () + "'",
"config.dist.archives=tar.gz",
"config.dist.checksums=sha256",
@@ -793,6 +802,15 @@ namespace bdep
{
tracer trace ("publish");
+ if (o.forward ())
+ {
+ if (const char* n = (o.config_name_specified () ? "@<cfg-name>" :
+ o.config_id_specified () ? "--config-id" :
+ o.config_specified () ? "--config|-c" :
+ o.all () ? "--all|-a" : nullptr))
+ fail << n << " specified together with --forward";
+ }
+
// If we are publishing the entire project, then we have two choices: we
// can publish all the packages in the project or we can only do so for
// packages that were initialized in the configuration that we are going
@@ -808,33 +826,68 @@ namespace bdep
const dir_path& prj (pp.project);
- // We need a single configuration to prepare package distribution.
+ // Unless we are using the forwarded configurations, we need a single
+ // configuration to prepare package distributions.
//
- shared_ptr<configuration> cfg;
+ dir_path cfg_dir;
+
+ if (o.forward ())
{
- // Don't keep the database open longer than necessary.
+ // Note: in this case we don't even open the database.
//
- database db (open (prj, trace));
+ dir_paths cfgs;
+
+ for (const package_location& pl: pp.packages)
+ {
+ dir_path d (prj / pl.path);
- transaction t (db.begin ());
- configurations cfgs (find_configurations (o, prj, t));
- t.commit ();
+ package_info pi (package_b_info (o, d));
- if (cfgs.size () > 1)
- fail << "multiple configurations specified for publish";
+ if (pi.src_root == pi.out_root)
+ fail << "package " << pl.name << " source directory is not forwarded" <<
+ info << "package source directory is " << d;
- // Verify packages are present in the configuration.
- //
- verify_project_packages (pp, cfgs);
+ // Get the configuration root.
+ //
+ (pi.out_root /= pi.amalgamation).normalize ();
- cfg = move (cfgs[0]);
+ if (find (cfgs.begin (), cfgs.end (), pi.out_root) == cfgs.end ())
+ cfgs.push_back (move (pi.out_root));
+ }
+
+ // Pre-sync the configurations to avoid triggering the build system hook
+ // (see sync for details).
+ //
+ for (const dir_path& cfg: cfgs)
+ cmd_sync_implicit (o, cfg);
}
+ else
+ {
+ shared_ptr<configuration> cfg;
+ {
+ // Don't keep the database open longer than necessary.
+ //
+ database db (open (prj, trace));
- // Pre-sync the configuration to avoid triggering the build system hook
- // (see sync for details).
- //
- cmd_sync (o, prj, cfg, strings () /* pkg_args */, true /* implicit */);
+ transaction t (db.begin ());
+ configurations cfgs (find_configurations (o, prj, t));
+ t.commit ();
+
+ if (cfgs.size () > 1)
+ fail << "multiple configurations specified for publish";
+
+ // Verify packages are present in the configuration.
+ //
+ verify_project_packages (pp, cfgs);
+
+ cfg = move (cfgs[0]);
+ }
+
+ cmd_sync (o, prj, cfg, strings () /* pkg_args */, true /* implicit */);
+
+ cfg_dir = cfg->path;
+ }
- return cmd_publish (o, prj, cfg->path, move (pp.packages));
+ return cmd_publish (o, prj, cfg_dir, move (pp.packages));
}
}
diff --git a/bdep/sync.cxx b/bdep/sync.cxx
index 3c51882..1ed3c12 100644
--- a/bdep/sync.cxx
+++ b/bdep/sync.cxx
@@ -604,6 +604,29 @@ namespace bdep
strings () /* dep_pkgs */);
}
+ void
+ cmd_sync_implicit (const common_options& co,
+ const dir_path& cfg,
+ bool fetch,
+ bool yes,
+ bool name_cfg)
+ {
+ if (!synced (cfg, true /* implicit */))
+ cmd_sync (co,
+ cfg,
+ dir_path (),
+ nullptr,
+ strings (),
+ true /* implicit */,
+ fetch,
+ yes,
+ name_cfg,
+ nullopt /* upgrade */,
+ nullopt /* recursive */,
+ package_locations () /* prj_pkgs */,
+ strings () /* dep_pkgs */);
+ }
+
int
cmd_sync (cmd_sync_options&& o, cli::group_scanner& args)
{
diff --git a/bdep/sync.hxx b/bdep/sync.hxx
index 5711a3f..a74b228 100644
--- a/bdep/sync.hxx
+++ b/bdep/sync.hxx
@@ -31,6 +31,16 @@ namespace bdep
bool yes = true,
bool name_cfg = false);
+ // As above but perform an implicit sync without a configuration object
+ // (i.e., as if from the hook).
+ //
+ void
+ cmd_sync_implicit (const common_options&,
+ const dir_path& cfg,
+ bool fetch = true,
+ bool yes = true,
+ bool name_cfg = true);
+
int
cmd_sync (cmd_sync_options&&, cli::group_scanner& args);