diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2024-06-07 08:08:36 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2024-06-07 08:08:36 +0200 |
commit | 63bd5b82459036c647a521efb2c8668ceb520ec5 (patch) | |
tree | eea34c190ace749955dcbe033b03e06fd0a9b5b3 | |
parent | adc86e88e4628778731d8c76e53454d3ad47eeb7 (diff) |
Use combined -L option form for extra system search paths
The split one was just too much of an eye-sore in the logs.
-rw-r--r-- | libbuild2/cc/link-rule.cxx | 14 | ||||
-rw-r--r-- | libbuild2/utility.hxx | 28 | ||||
-rw-r--r-- | libbuild2/utility.txx | 21 |
3 files changed, 47 insertions, 16 deletions
diff --git a/libbuild2/cc/link-rule.cxx b/libbuild2/cc/link-rule.cxx index 6b0c337..417cba5 100644 --- a/libbuild2/cc/link-rule.cxx +++ b/libbuild2/cc/link-rule.cxx @@ -3479,13 +3479,19 @@ namespace build2 append_args (sargs1); } - else + else if (b != x) { - append_option_values ( - args, + // Use the more canonical combined form (-L/usr/local/lib) even + // though it's less efficient (the split one is just too much of an + // eye-sore in the logs). + // + append_combined_option_values ( + sargs1, "-L", b, x, - [] (const dir_path& d) {return d.string ().c_str ();}); + [] (const dir_path& d) -> const string& {return d.string ();}); + + append_args (sargs1); } } diff --git a/libbuild2/utility.hxx b/libbuild2/utility.hxx index b534f41..151b409 100644 --- a/libbuild2/utility.hxx +++ b/libbuild2/utility.hxx @@ -877,17 +877,29 @@ namespace build2 // template <typename I, typename F> void - append_option_values (cstrings&, - const char* opt, - I begin, I end, - F&& get = [] (const string& s) {return s.c_str ();}); + append_option_values ( + cstrings&, + const char* opt, + I begin, I end, + F&& get = [] (const string& s) {return s.c_str ();}); template <typename I, typename F> void - append_option_values (sha256&, - const char* opt, - I begin, I end, - F&& get = [] (const string& s) {return s;}); + append_option_values ( + sha256&, + const char* opt, + I begin, I end, + F&& get = [] (const string& s) -> const string& {return s;}); + + // As above but in a combined form (e.g., -L/usr/local/lib). + // + template <typename I, typename F> + void + append_combined_option_values ( + strings&, + const char* opt, + I begin, I end, + F&& get = [] (const string& s) -> const string& {return s;}); // As above but append a single option (used for append/hash uniformity). // diff --git a/libbuild2/utility.txx b/libbuild2/utility.txx index d2fc29c..cdf510f 100644 --- a/libbuild2/utility.txx +++ b/libbuild2/utility.txx @@ -5,16 +5,16 @@ namespace build2 { template <typename I, typename F> void - append_option_values (cstrings& args, const char* o, I b, I e, F&& get) + append_option_values (cstrings& ss, const char* o, I b, I e, F&& get) { if (b != e) { - args.reserve (args.size () + (e - b)); + ss.reserve (ss.size () + (e - b)); for (; b != e; ++b) { - args.push_back (o); - args.push_back (get (*b)); + ss.push_back (o); + ss.push_back (get (*b)); } } } @@ -30,6 +30,19 @@ namespace build2 } } + template <typename I, typename F> + void + append_combined_option_values (strings& ss, const char* o, I b, I e, F&& get) + { + if (b != e) + { + ss.reserve (ss.size () + (e - b)); + + for (; b != e; ++b) + ss.push_back (string (o) += get (*b)); + } + } + template <typename K> basic_path<char, K> relative (const basic_path<char, K>& p) |