From f3cac67d4467a5e01cef503f59026e08b84266d8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 16 Jul 2020 06:14:39 +0200 Subject: Create glue buildfile in bdep-new --package mode --- NEWS | 3 +++ bdep/new.cxx | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) 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. -- cgit v1.1