From 1845141809aa91b03718066a6f46863885a6a887 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 7 Mar 2019 09:06:37 +0200 Subject: Add support for alternative build file/directory naming scheme Now the build/*.build, buildfile, and .buildignore filesystem entries in a project can alternatively (but consistently) be called build2/*.build2, build2file, and .build2ignore. See a note at the beginning of the Project Structure section in the manual for details (motivation, restrictions, etc). --- build2/parser.cxx | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'build2/parser.cxx') diff --git a/build2/parser.cxx b/build2/parser.cxx index f703e90..ef6691d 100644 --- a/build2/parser.cxx +++ b/build2/parser.cxx @@ -1236,15 +1236,24 @@ namespace build2 // 'buildfile'. // path p (move (n.dir)); + + bool a; if (n.value.empty ()) - p /= buildfile_file; + a = true; else { - bool d (path::traits::is_separator (n.value.back ())); - + a = path::traits::is_separator (n.value.back ()); p /= path (move (n.value)); - if (d) - p /= buildfile_file; + } + + if (a) + { + // This shouldn't happen but let's make sure. + // + if (root_->root_extra == nullptr) + fail (l) << "build file naming scheme is not yet known"; + + p /= root_->root_extra->buildfile_file; } l6 ([&]{trace (l) << "relative path " << p;}); @@ -3228,15 +3237,21 @@ namespace build2 include_match (move (v), move (e), a); }; - auto process = [&e, &appf, sp] (path&& m, const string& p, bool interm) + auto process = [this, &e, &appf, sp] (path&& m, + const string& p, + bool interm) { // Ignore entries that start with a dot unless the pattern that // matched them also starts with a dot. Also ignore directories - // containing the .buildignore file. + // containing the .buildignore file (ignoring the test if we don't + // have a sufficiently setup project root). // const string& s (m.string ()); if ((p[0] != '.' && s[path::traits::find_leaf (s)] == '.') || - (m.to_directory () && exists (*sp / m / buildignore_file))) + (root_ != nullptr && + root_->root_extra != nullptr && + m.to_directory () && + exists (*sp / m / root_->root_extra->buildignore_file))) return !interm; // Note that we have to make copies of the extension since there will -- cgit v1.1