From 23827edd998db30dd1f0d6a14f09399aa7d07b69 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 13 May 2021 15:38:53 +0200 Subject: Add ${c,cxx}.find_system_{header,library}() functions --- libbuild2/cc/compile-rule.cxx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libbuild2/cc/compile-rule.cxx') diff --git a/libbuild2/cc/compile-rule.cxx b/libbuild2/cc/compile-rule.cxx index f8529fb..90a6024 100644 --- a/libbuild2/cc/compile-rule.cxx +++ b/libbuild2/cc/compile-rule.cxx @@ -175,6 +175,21 @@ namespace build2 throw invalid_argument ("invalid preprocessed value '" + s + "'"); } + optional compile_rule:: + find_system_header (const path& f) const + { + path p; // Reuse the buffer. + for (const dir_path& d: sys_inc_dirs) + { + if (file_exists ((p = d, p /= f), + true /* follow_symlinks */, + true /* ignore_errors */)) + return p; + } + + return nullopt; + } + struct compile_rule::match_data { explicit -- cgit v1.1