From d81ad6a0b20613ac77e115ca273cd48eaeeae1c8 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 16 Oct 2016 13:21:35 +0200 Subject: Add target::out_dir() accessor --- build2/install/rule.cxx | 3 +-- build2/target | 5 ++++- build2/target.cxx | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx index 82dde04..68000af 100644 --- a/build2/install/rule.cxx +++ b/build2/install/rule.cxx @@ -273,8 +273,7 @@ namespace build2 { // The target can be in out or src. // - const dir_path& d ( - (t.out.empty () ? t.dir : t.out).leaf (p->out_path ())); + const dir_path& d (t.out_dir ().leaf (p->out_path ())); // Add it as another leading directory rather than modifying // the last one directly; somehow, it feels right. diff --git a/build2/target b/build2/target index 3123905..8c2b2da 100644 --- a/build2/target +++ b/build2/target @@ -149,6 +149,9 @@ namespace build2 const string name; const string* ext; // Extension. NULL - unspecified, empty - no extension. + const dir_path& + out_dir () const {return out.empty () ? dir : out;} + // Target group to which this target belongs, if any. Note that we assume // that the group and all its members are in the same scope (for example, // in variable lookup). We also don't support nested groups (with a small @@ -308,7 +311,7 @@ namespace build2 bool in (const scope& s) const { - return (out.empty () ? dir : out).sub (s.out_path ()); + return out_dir ().sub (s.out_path ()); } // Prerequisites. diff --git a/build2/target.cxx b/build2/target.cxx index 540f4b4..3b6e06f 100644 --- a/build2/target.cxx +++ b/build2/target.cxx @@ -110,7 +110,7 @@ namespace build2 // If this target is from the src tree, use its out directory to find // the scope. // - return scopes.find (out.empty () ? dir : out); + return scopes.find (out_dir ()); } scope& target:: -- cgit v1.1