aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/bin
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-10-09 12:08:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-10-09 12:08:45 +0200
commit66de0d06e5b6c002cbc7d18e18685e3ea44d3848 (patch)
tree34688ee9d0c4d00de0f58e2f6f017f026a23abe6 /libbuild2/bin
parent09e0cf71552d7f6e4f864b997db9913b9e9ae187 (diff)
Prepend pattern search paths to PATH when running binutils
This way any dependent tools (such as mt.exe that is invoked by link.exe) are first search for in there.
Diffstat (limited to 'libbuild2/bin')
-rw-r--r--libbuild2/bin/init.cxx25
-rw-r--r--libbuild2/bin/utility.hxx47
2 files changed, 48 insertions, 24 deletions
diff --git a/libbuild2/bin/init.cxx b/libbuild2/bin/init.cxx
index 07888f6..db9db0e 100644
--- a/libbuild2/bin/init.cxx
+++ b/libbuild2/bin/init.cxx
@@ -20,6 +20,7 @@
#include <libbuild2/bin/rule.hxx>
#include <libbuild2/bin/guess.hxx>
#include <libbuild2/bin/target.hxx>
+#include <libbuild2/bin/utility.hxx>
using namespace std;
using namespace butl;
@@ -37,30 +38,6 @@ namespace build2
static const strings liba_lib {"static", "shared"};
static const strings libs_lib {"shared", "static"};
- struct pattern_paths
- {
- const char* pattern = nullptr;
- const char* paths = nullptr;
- };
-
- static inline pattern_paths
- lookup_pattern (scope& rs)
- {
- pattern_paths r;
-
- // Theoretically, we could have both the pattern and the search paths,
- // for example, the pattern can come first followed by the paths.
- //
- if (const string* v = cast_null<string> (rs["bin.pattern"]))
- {
- (path::traits_type::is_separator (v->back ())
- ? r.paths
- : r.pattern) = v->c_str ();
- }
-
- return r;
- }
-
bool
vars_init (scope& rs,
scope&,
diff --git a/libbuild2/bin/utility.hxx b/libbuild2/bin/utility.hxx
new file mode 100644
index 0000000..cc2b727
--- /dev/null
+++ b/libbuild2/bin/utility.hxx
@@ -0,0 +1,47 @@
+// file : libbuild2/bin/utility.hxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#ifndef LIBBUILD2_BIN_UTILITY_HXX
+#define LIBBUILD2_BIN_UTILITY_HXX
+
+#include <libbuild2/types.hxx>
+#include <libbuild2/utility.hxx>
+
+#include <libbuild2/scope.hxx>
+#include <libbuild2/variable.hxx>
+
+namespace build2
+{
+ namespace bin
+ {
+ // Lookup the bin.pattern value and split it into the pattern and the
+ // search paths.
+ //
+ struct pattern_paths
+ {
+ const char* pattern = nullptr;
+ const char* paths = nullptr;
+ };
+
+ inline pattern_paths
+ lookup_pattern (const scope& rs)
+ {
+ pattern_paths r;
+
+ // Theoretically, we could have both the pattern and the search paths,
+ // for example, the pattern can come first followed by the paths.
+ //
+ if (const string* v = cast_null<string> (rs["bin.pattern"]))
+ {
+ (path::traits_type::is_separator (v->back ())
+ ? r.paths
+ : r.pattern) = v->c_str ();
+ }
+
+ return r;
+ }
+ }
+}
+
+#endif // LIBBUILD2_BIN_UTILITY_HXX