From 8f8ab1e8f6d85748547c0d0e9987eed4f3c3e17b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 17 Apr 2015 15:08:05 +0200 Subject: Add support for target groups, use to handle obj/obja/objso object targets --- build/search.cxx | 60 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'build/search.cxx') diff --git a/build/search.cxx b/build/search.cxx index 6434bf7..7fa9720 100644 --- a/build/search.cxx +++ b/build/search.cxx @@ -19,29 +19,29 @@ using namespace std; namespace build { target* - search_existing_target (prerequisite& p) + search_existing_target (const prerequisite_key& pk) { tracer trace ("search_existing_target"); - assert (p.target == nullptr); + const target_key& tk (pk.tk); - // Look for an existing target in this prerequisite's directory scope. + // Look for an existing target in this directory scope. // dir_path d; - if (p.dir.absolute ()) - d = p.dir; // Already normalized. + if (tk.dir->absolute ()) + d = *tk.dir; // Already normalized. else { - d = p.scope.path (); + d = pk.scope->path (); - if (!p.dir.empty ()) + if (!tk.dir->empty ()) { - d /= p.dir; + d /= *tk.dir; d.normalize (); } } - auto i (targets.find (p.type, d, p.name, p.ext, trace)); + auto i (targets.find (*tk.type, d, *tk.name, *tk.ext, trace)); if (i == targets.end ()) return 0; @@ -49,29 +49,29 @@ namespace build target& t (**i); level4 ([&]{trace << "existing target " << t << " for prerequsite " - << p;}); + << pk;}); - p.target = &t; return &t; } target* - search_existing_file (prerequisite& p, const dir_paths& sp) + search_existing_file (const prerequisite_key& pk, const dir_paths& sp) { tracer trace ("search_existing_file"); - assert (p.dir.relative ()); + const target_key& tk (pk.tk); + assert (tk.dir->relative ()); // Go over paths and extension looking for a file. // for (const dir_path& d: sp) { - path f (d / p.dir / path (p.name)); + path f (d / *tk.dir / path (*tk.name)); f.normalize (); // @@ TMP: use target name as an extension. // - const string& e (p.ext != nullptr ? *p.ext : p.type.name); + const string& e (*tk.ext != nullptr ? **tk.ext : tk.type->name); if (!e.empty ()) { @@ -85,22 +85,23 @@ namespace build continue; level4 ([&]{trace << "found existing file " << f << " for prerequsite " - << p;}); + << pk;}); // Find or insert. // - auto r (targets.insert (p.type, f.directory (), p.name, p.ext, trace)); + auto r ( + targets.insert ( + *tk.type, f.directory (), *tk.name, *tk.ext, trace)); // Has to be a path_target. // path_target& t (dynamic_cast (r.first)); level4 ([&]{trace << (r.second ? "new" : "existing") << " target " - << t << " for prerequsite " << p;}); + << t << " for prerequsite " << pk;}); t.path (move (f)); t.mtime (mt); - p.target = &t; return &t; } @@ -108,38 +109,37 @@ namespace build } target& - create_new_target (prerequisite& p) + create_new_target (const prerequisite_key& pk) { tracer trace ("create_new_target"); - assert (p.target == nullptr); + const target_key& tk (pk.tk); - // We default to the target in this prerequisite's directory scope. + // We default to the target in this directory scope. // dir_path d; - if (p.dir.absolute ()) - d = p.dir; // Already normalized. + if (tk.dir->absolute ()) + d = *tk.dir; // Already normalized. else { - d = p.scope.path (); + d = pk.scope->path (); - if (!p.dir.empty ()) + if (!tk.dir->empty ()) { - d /= p.dir; + d /= *tk.dir; d.normalize (); } } // Find or insert. // - auto r (targets.insert (p.type, move (d), p.name, p.ext, trace)); + auto r (targets.insert (*tk.type, move (d), *tk.name, *tk.ext, trace)); assert (r.second); target& t (r.first); - level4 ([&]{trace << "new target " << t << " for prerequsite " << p;}); + level4 ([&]{trace << "new target " << t << " for prerequsite " << pk;}); - p.target = &t; return t; } } -- cgit v1.1