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/compile-rule.cxx | 10 +++++----- libbuild2/cc/compile-rule.hxx | 3 ++- libbuild2/cc/functions.cxx | 20 +++++++++++++++----- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index 7059f15..1b8a5a8 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -690,12 +690,12 @@ namespace build2 const scope& bs, action a, const file& l, bool la, linfo li, - bool common) const + bool common, + bool original) const { - // @@ Is this a good idea? We don't know which tool will be using - // these... - // - const scope* is (isystem (*this) ? effective_iscope (bs) : nullptr); + const scope* is (!original && isystem (*this) + ? effective_iscope (bs) + : nullptr); append_library_options (ls, args, bs, is, a, l, la, li, common, nullptr); } diff --git a/libbuild2/cc/compile-rule.hxx b/libbuild2/cc/compile-rule.hxx index f3e4a9b..95734e0 100644 --- a/libbuild2/cc/compile-rule.hxx +++ b/libbuild2/cc/compile-rule.hxx @@ -66,7 +66,8 @@ namespace build2 void append_library_options (appended_libraries&, strings&, const scope&, - action, const file&, bool, linfo, bool) const; + action, const file&, bool, linfo, + bool, bool) const; optional find_system_header (const path&) const; 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