From 7b9eb752cad04aaadc4552d0f26d307b04af1869 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 7 Feb 2017 08:09:53 +0200 Subject: Pass const target& to recipes --- build2/cc/common.cxx | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'build2/cc/common.cxx') diff --git a/build2/cc/common.cxx b/build2/cc/common.cxx index e7b26a1..62a4ab2 100644 --- a/build2/cc/common.cxx +++ b/build2/cc/common.cxx @@ -49,14 +49,14 @@ namespace build2 const scope& top_bs, lorder top_lo, const dir_paths& top_sysd, - file& l, + const file& l, bool la, - const function& proc_impl, // Implementation? - const function& proc_lib, // True if system library. - const function& proc_opt, // *.export. @@ -213,10 +213,10 @@ namespace build2 // if (impl && !c_e_libs.defined () && !x_e_libs.defined ()) { - for (target* p: l.prerequisite_targets) + for (const target* p: l.prerequisite_targets) { bool a; - file* f; + const file* f; if ((a = (f = p->is_a ()) != nullptr) || (f = p->is_a ()) != nullptr) @@ -287,7 +287,7 @@ namespace build2 if (sysd == nullptr) find_sysd (); if (!lo) find_lo (); - file& t (resolve_library (bs, n, *lo, *sysd, usrd)); + const file& t (resolve_library (bs, n, *lo, *sysd, usrd)); if (proc_lib) { @@ -385,7 +385,7 @@ namespace build2 // will select exactly the same target as the library's matched rule and // that's the only way to guarantee it will be up-to-date. // - file& common:: + const file& common:: resolve_library (const scope& s, name n, lorder lo, @@ -395,7 +395,7 @@ namespace build2 if (n.type != "lib" && n.type != "liba" && n.type != "libs") fail << "target name " << n << " is not a library"; - target* xt (nullptr); + const target* xt (nullptr); if (n.dir.absolute () && !n.qualified ()) { @@ -422,12 +422,12 @@ namespace build2 // dir_path out; prerequisite_key pk {n.proj, {tt, &n.dir, &out, &n.value, ext}, &s}; - xt = search_library (sysd, usrd, pk); + xt = search_library (sysd, usrd, pk); //@@ TM const if (xt == nullptr) { if (n.qualified ()) - xt = &import (pk); + xt = &import (pk); //@@ TM const else fail << "unable to find library " << pk; } @@ -435,10 +435,10 @@ namespace build2 // If this is lib{}, pick appropriate member. // - if (lib* l = xt->is_a ()) + if (const lib* l = xt->is_a ()) xt = &link_member (*l, lo); // Pick liba{} or libs{}. - return static_cast (*xt); + return static_cast (*xt); } // Note that pk's scope should not be NULL (even if dir is absolute). If -- cgit v1.1