aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-07-16 06:14:39 +0200
committerKaren Arutyunov <karen@codesynthesis.com>2020-07-16 15:48:26 +0300
commitf3cac67d4467a5e01cef503f59026e08b84266d8 (patch)
tree602e36284f31753947c9380c3ea9fbe2048605a1
parente8f7ad1e7d4aa47daad62105d2c41bcfd61d67e8 (diff)
Create glue buildfile in bdep-new --package mode
-rw-r--r--NEWS3
-rw-r--r--bdep/new.cxx26
2 files changed, 28 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index c7da512..7d9cdd3 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,9 @@ Version 0.13.0
See the SOURCE LAYOUT section in bdep-new(1) for details and a large
number of layout examples.
+ * The bdep-new command in the --package mode now creates the glue buildfile
+ for the project.
+
* The bdep-new command now generates the .gitattributes file.
* The bdep-new --subdirectory mode option has been renamed to --source.
diff --git a/bdep/new.cxx b/bdep/new.cxx
index 8a180ec..8f025ff 100644
--- a/bdep/new.cxx
+++ b/bdep/new.cxx
@@ -2833,7 +2833,7 @@ cmd_new (cmd_new_options&& o, cli::group_scanner& args)
for (auto& rm: rms)
rm.cancel ();
- // packages.manifest
+ // packages.manifest and glue buildfile
//
if (pkg)
{
@@ -2852,6 +2852,30 @@ cmd_new (cmd_new_options&& o, cli::group_scanner& args)
{
fail << "unable to write to " << f << ": " << e;
}
+
+ // Only create the glue buildfile if we've also created packages.manifest.
+ //
+ if (!e)
+ {
+ path f (prj / buildfile_file);
+ if (!exists (f))
+ try
+ {
+ ofdstream os (f, (fdopen_mode::out |
+ fdopen_mode::create |
+ fdopen_mode::exclusive));
+ os << "# Glue buildfile that \"pulls\" all the packages in the project." << '\n'
+ << "#" << '\n'
+ << "import pkgs = */" << '\n'
+ << '\n'
+ << "./: $pkgs" << '\n';
+ os.close ();
+ }
+ catch (const io_error& e)
+ {
+ fail << "unable to write to " << f << ": " << e;
+ }
+ }
}
// Run post hooks.