aboutsummaryrefslogtreecommitdiff
path: root/build2/b.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-03-14 11:37:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-03-14 11:37:14 +0200
commit233255f0e14f364841751755958375fe27380ba6 (patch)
tree1571f125ad89f729cbf0c3d7c0b09aba8fe0fc20 /build2/b.cxx
parentf262632b20628136369889ebc67a65b252b233af (diff)
Implement implied buildfile support
In essence, if the buildfile is: ./: */ Then it can be omitted entirely (provided there is at least one subdirectory).
Diffstat (limited to 'build2/b.cxx')
-rw-r--r--build2/b.cxx36
1 files changed, 27 insertions, 9 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index 15ace65..b13300e 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -911,16 +911,31 @@ main (int argc, char* argv[])
trace << " amalgamat: " << cast<dir_path> (l);
}
+ path bf;
const path& bfn (ops.buildfile ());
- path bf (bfn.string () != "-" ? src_base / bfn : bfn);
- // If we were guessing src_base, check that the buildfile
- // exists and if not, issue more detailed diagnostics.
- //
- if (guessing && bf.string () != "-" && !exists (bf))
- fail << bf << " does not exist"
- << info << "consider explicitly specifying src_base "
- << "for " << tn;
+ if (bfn.string () != "-")
+ {
+ bf = src_base / bfn;
+
+ if (!exists (bf))
+ {
+ // If we were guessing src_base then don't try any implied
+ // buildfile tricks.
+ //
+ if (guessing)
+ fail << bf << " does not exist" <<
+ info << "consider explicitly specifying src_base for " << tn;
+
+ // If the target is a directory and src_base exists, then assume
+ // implied buildfile; see dir::search_implied().
+ //
+ if ((tn.directory () || tn.type == "dir") && exists (src_base))
+ bf.clear ();
+ }
+ }
+ else
+ bf = bfn;
// Enter project-wide (as opposed to global) variable overrides.
//
@@ -1040,7 +1055,10 @@ main (int argc, char* argv[])
? out_src (d, rs)
: dir_path ());
- mif->search (rs, target_key {ti, &d, &out, &tn.value, e}, l, tgs);
+ mif->search (rs, bs,
+ target_key {ti, &d, &out, &tn.value, e},
+ l,
+ tgs);
}
} // target