aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/compile-rule.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-10-04 10:27:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-10-04 10:27:55 +0200
commite1a1d978d364c723935acfc7b56fae8b8253d054 (patch)
tree02b9bdac94800c7d29b40584f7a135f220cd22df /libbuild2/cc/compile-rule.cxx
parentdb8336a686a85f0e458acb2d5f1ad442585bfc9a (diff)
Add support for treating specific libraries as always internal
Diffstat (limited to 'libbuild2/cc/compile-rule.cxx')
-rw-r--r--libbuild2/cc/compile-rule.cxx33
1 files changed, 27 insertions, 6 deletions
diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx
index 7636722..9149f0c 100644
--- a/libbuild2/cc/compile-rule.cxx
+++ b/libbuild2/cc/compile-rule.cxx
@@ -6,6 +6,8 @@
#include <cstdlib> // exit()
#include <cstring> // strlen(), strchr(), strncmp()
+#include <libbutl/path-pattern.hxx>
+
#include <libbuild2/file.hxx>
#include <libbuild2/depdb.hxx>
#include <libbuild2/scope.hxx>
@@ -503,14 +505,33 @@ namespace build2
if (const strings* ops = cast_null<strings> (l[var]))
{
+ // If enabled, remap -I to -isystem or /external:I for paths that
+ // are outside of the internal scope provided the library is not
+ // whitelisted.
+ //
+ auto whitelist = [&l] (const strings* pats)
+ {
+ return (pats != nullptr &&
+ find_if (pats->begin (), pats->end (),
+ [&l] (const string& pat)
+ {
+ return path_match (l.name, pat);
+ }) != pats->end ());
+ };
+
+ const scope* is (d.is);
+
+ if (is != nullptr && whitelist (c_internal_libs))
+ is = nullptr;
+
+ if (is != nullptr && whitelist (x_internal_libs))
+ is = nullptr;
+
for (auto i (ops->begin ()), e (ops->end ()); i != e; ++i)
{
const string& o (*i);
- // If enabled, remap -I to -isystem or /external:I for paths that
- // are outside of the internal scope.
- //
- if (d.is != nullptr)
+ if (is != nullptr)
{
// See if this is -I<dir> or -I <dir> (or /I... for MSVC).
//
@@ -587,8 +608,8 @@ namespace build2
// Translate if it's neither in src nor in out of the
// internal scope.
//
- if (!sub (d.is->src_path ()) &&
- (d.is->out_eq_src () || !sub (d.is->out_path ())))
+ if (!sub (is->src_path ()) &&
+ (is->out_eq_src () || !sub (is->out_path ())))
{
// Note: must use original value (path is temporary).
//