From 27547e341f32782ad2d7fd998dde1cb04f4bf1db Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 28 May 2020 14:03:12 +0200 Subject: Allow calling certain search_existing() versions during load phase This is necessary for $target.path() implementation. --- libbuild2/algorithm.cxx | 5 ----- libbuild2/algorithm.hxx | 10 +++++++--- libbuild2/file.hxx | 3 ++- libbuild2/file.ixx | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/libbuild2/algorithm.cxx b/libbuild2/algorithm.cxx index 11f2a56..0924540 100644 --- a/libbuild2/algorithm.cxx +++ b/libbuild2/algorithm.cxx @@ -71,8 +71,6 @@ namespace build2 const target* search_existing (context& ctx, const prerequisite_key& pk) { - assert (ctx.phase == run_phase::match || ctx.phase == run_phase::execute); - return pk.proj ? import_existing (ctx, pk) : search_existing_target (ctx, pk); @@ -109,9 +107,6 @@ namespace build2 const target* search_existing (const name& cn, const scope& s, const dir_path& out) { - assert (s.ctx.phase == run_phase::match || - s.ctx.phase == run_phase::execute); - // See also scope::find_prerequisite_key(). // name n (cn); diff --git a/libbuild2/algorithm.hxx b/libbuild2/algorithm.hxx index 390516a..de09469 100644 --- a/libbuild2/algorithm.hxx +++ b/libbuild2/algorithm.hxx @@ -23,7 +23,8 @@ namespace build2 LIBBUILD2_SYMEXPORT const target& search (const target&, const prerequisite&); - // As above but only search for an already existing target. + // As above but only search for an already existing target. Note that unlike + // the above, this version can be called during the execute phase. // LIBBUILD2_SYMEXPORT const target* search_existing (const prerequisite&); @@ -38,6 +39,9 @@ namespace build2 LIBBUILD2_SYMEXPORT const target& search (const target&, const prerequisite_key&); + // Note that unlike the above version, this one can be called during the + // load and execute phases. + // LIBBUILD2_SYMEXPORT const target* search_existing (context&, const prerequisite_key&); @@ -94,8 +98,8 @@ namespace build2 LIBBUILD2_SYMEXPORT const target& search (const target&, name, const scope&); - // Unlike the above version, this one can be called during the execute - // phase. Return NULL for unknown target types. + // Return NULL for unknown target types. Note that unlike the above version, + // these ones can be called during the load and execute phases. // LIBBUILD2_SYMEXPORT const target* search_existing (const name&, diff --git a/libbuild2/file.hxx b/libbuild2/file.hxx index 78be600..3bceb80 100644 --- a/libbuild2/file.hxx +++ b/libbuild2/file.hxx @@ -389,7 +389,8 @@ namespace build2 operator<< (ostream&, const pair&); // As import phase 2 but only imports as an already existing target. But - // unlike it, this function can be called during the execute phase. + // unlike it, this function can be called during the load and execute + // phases. // // Note: similar to search_existing(). // diff --git a/libbuild2/file.ixx b/libbuild2/file.ixx index 7c09d3d..4a9f411 100644 --- a/libbuild2/file.ixx +++ b/libbuild2/file.ixx @@ -80,7 +80,6 @@ namespace build2 inline const target* import_existing (context& ctx, const prerequisite_key& pk) { - assert (ctx.phase == run_phase::match || ctx.phase == run_phase::execute); return import (ctx, pk, false, nullopt, true, location ()); } } -- cgit v1.1