aboutsummaryrefslogtreecommitdiff
path: root/build2/search.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-02-19 15:15:43 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-02-19 15:15:43 +0200
commit29f6e38b4f8d55f3da61fcd061c8b8ff3c5eaa00 (patch)
tree6f57661d78d089e439162adfdb71f1448898745b /build2/search.cxx
parent114fb345a5223ea513851f57c8c002abc1496c4a (diff)
Make search_existing_file() more consistent
Diffstat (limited to 'build2/search.cxx')
-rw-r--r--build2/search.cxx37
1 files changed, 17 insertions, 20 deletions
diff --git a/build2/search.cxx b/build2/search.cxx
index f0b163a..c7a7783 100644
--- a/build2/search.cxx
+++ b/build2/search.cxx
@@ -88,14 +88,26 @@ namespace build2
const target_key& ctk (cpk.tk);
const scope* s (cpk.scope);
+ path f;
+
if (ctk.dir->absolute ())
+ f = *ctk.dir; // Already normalized.
+ else
{
- // Bail out if not inside project's src_root.
- //
- if (s == nullptr || !ctk.dir->sub (s->root_scope ()->src_path ()))
- return nullptr;
+ f = s->src_path ();
+
+ if (!ctk.dir->empty ())
+ {
+ f /= *ctk.dir;
+ f.normalize ();
+ }
}
+ // Bail out if not inside project's src_root.
+ //
+ if (s == nullptr || !f.sub (s->root_scope ()->src_path ()))
+ return nullptr;
+
// Figure out the extension. Pretty similar logic to file::derive_path().
//
optional<string> ext (ctk.ext);
@@ -128,21 +140,6 @@ namespace build2
// Check if there is a file.
//
- path f;
-
- if (tk.dir->absolute ())
- f = *tk.dir; // Already normalized.
- else
- {
- f = s->src_path ();
-
- if (!tk.dir->empty ())
- {
- f /= *tk.dir;
- f.normalize ();
- }
- }
-
f /= *tk.name;
if (!ext->empty ())
@@ -171,7 +168,7 @@ namespace build2
//
// In the other two cases we use the prerequisite's out (in case it is
// relative, we need to complete it, which is @@ OUT TODO). Note that we
- // blindly trust the user's value which can be use for some interesting
+ // blindly trust the user's value which can be used for some interesting
// tricks, for example:
//
// ../cxx{foo}@./