aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-08-26 10:01:32 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-08-26 10:01:32 +0200
commit97e00dccb4a9d3abc3c896b33560ed6aed0a1763 (patch)
treebd17e1fc480ea56232a0b4c6f22bb691bc61ee1d /libbuild2/parser.cxx
parent8e0e8edb727a5367d991880b033eb13060f4c8eb (diff)
Factor target name processing code from parser to scope
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx54
1 files changed, 4 insertions, 50 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 2af5762..5e5b029 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -128,8 +128,8 @@ namespace build2
const location& loc,
tracer& tr)
{
- auto r (process_target (p, n, o, loc));
- return p.ctx.targets.insert (*r.first, // target type
+ auto r (p.scope_->find_target_type (n, o, loc));
+ return p.ctx.targets.insert (r.first, // target type
move (n.dir),
move (o.dir),
move (n.value),
@@ -147,8 +147,8 @@ namespace build2
const location& loc,
tracer& tr)
{
- auto r (process_target (p, n, o, loc));
- return p.ctx.targets.find (*r.first, // target type
+ auto r (p.scope_->find_target_type (n, o, loc));
+ return p.ctx.targets.find (r.first, // target type
n.dir,
o.dir,
n.value,
@@ -156,52 +156,6 @@ namespace build2
tr);
}
- static pair<const target_type*, optional<string>>
- process_target (parser& p,
- name& n, // If n.pair, then o is out dir.
- name& o,
- const location& loc)
- {
- auto r (p.scope_->find_target_type (n, loc));
-
- if (r.first == nullptr)
- p.fail (loc) << "unknown target type " << n.type;
-
- bool src (n.pair); // If out-qualified, then it is from src.
- if (src)
- {
- assert (n.pair == '@');
-
- if (!o.directory ())
- p.fail (loc) << "expected directory after '@'";
- }
-
- dir_path& d (n.dir);
-
- const dir_path& sd (p.scope_->src_path ());
- const dir_path& od (p.scope_->out_path ());
-
- if (d.empty ())
- d = src ? sd : od; // Already dormalized.
- else
- {
- if (d.relative ())
- d = (src ? sd : od) / d;
-
- d.normalize ();
- }
-
- dir_path out;
- if (src && sd != od) // If in-source build, then out must be empty.
- {
- out = o.dir.relative () ? od / o.dir : move (o.dir);
- out.normalize ();
- }
- o.dir = move (out); // Result.
-
- return r;
- }
-
~enter_target ()
{
if (p_ != nullptr)