From 658e0b3dbf496f6489ee6a5054f5609a7fa9ce5a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 24 Jun 2022 06:11:04 +0200 Subject: Add ability to control -I translation in $x.lib_poptions() --- libbuild2/cc/functions.cxx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'libbuild2/cc/functions.cxx') diff --git a/libbuild2/cc/functions.cxx b/libbuild2/cc/functions.cxx index a0a0b4f..e7deb80 100644 --- a/libbuild2/cc/functions.cxx +++ b/libbuild2/cc/functions.cxx @@ -99,6 +99,9 @@ namespace build2 // For the second signature, targets can only be utility libraries // (including the libul{} group). // + // If in the first signature is NULL, then it is treated as + // the second signature. + // struct lib_thunk_data { const char* x; @@ -137,7 +140,7 @@ namespace build2 names& ts_ns (vs[0].as ()); // optional li; - if (vs.size () > 1) + if (vs.size () > 1 && !vs[1].null) { names& ot_ns (vs[1].as ()); // @@ -228,7 +231,7 @@ namespace build2 void compile_rule:: functions (function_family& f, const char* x) { - // $.lib_poptions([, ]) + // $.lib_poptions([, [, ]]) // // Return the preprocessor options that should be passed when compiling // sources that depend on the specified libraries. The second argument @@ -240,6 +243,12 @@ namespace build2 // obtaining poptions to be passed to tools other than C/C++ compilers // (for example, Qt moc). // + // If is true, then return the original -I options without + // performing any translation (for example, to -isystem or /external:I). + // This is the default if is omitted. To get the translation for + // the common interface options, pass [null] for and true for + // . + // // Note that passing multiple targets at once is not a mere convenience: // this also allows for more effective duplicate suppression. // @@ -251,12 +260,12 @@ namespace build2 // Note that this function is not pure. // f.insert (".lib_poptions", false). - insert> ( + insert, optional> ( &lib_thunk, lib_thunk_data { x, [] (void* ls, strings& r, - const vector_view&, const module& m, const scope& bs, + const vector_view& vs, const module& m, const scope& bs, action a, const target& l, bool la, optional li) { // If this is libul{}, get the matched member (see bin::libul_rule @@ -269,13 +278,14 @@ namespace build2 l.prerequisite_targets[a].back ().target->as ())); bool common (!li); + bool original (vs.size () > 2 ? convert (vs[2]) : !li); if (!li) li = link_info (bs, link_type (f).type); m.append_library_options ( *static_cast (ls), r, - bs, a, f, la, *li, common); + bs, a, f, la, *li, common, original); }}); // $.find_system_header() -- cgit v1.1