about summary refs log tree commit diff
path: root/pkgs/development/tools/build-managers
diff options
context:
space:
mode:
authorOlli Helenius <liff@iki.fi>2019-01-09 23:00:16 +0200
committerOlli Helenius <liff@iki.fi>2019-01-09 23:00:16 +0200
commit4cb889f1660e243de3fdadcd6697e5e9676722a7 (patch)
tree6ffef6750961c879a20c55670b0e86ff8386d943 /pkgs/development/tools/build-managers
parenta6a8712146986bceec359589712e12057d25f1ea (diff)
downloadnixlib-4cb889f1660e243de3fdadcd6697e5e9676722a7.tar
nixlib-4cb889f1660e243de3fdadcd6697e5e9676722a7.tar.gz
nixlib-4cb889f1660e243de3fdadcd6697e5e9676722a7.tar.bz2
nixlib-4cb889f1660e243de3fdadcd6697e5e9676722a7.tar.lz
nixlib-4cb889f1660e243de3fdadcd6697e5e9676722a7.tar.xz
nixlib-4cb889f1660e243de3fdadcd6697e5e9676722a7.tar.zst
nixlib-4cb889f1660e243de3fdadcd6697e5e9676722a7.zip
bear: fix wrapper detection patch by checking result of find_executable
With the wrapper detection patch, if a build invokes an executable that cannot
be found in PATH by `find_executable`, bear will fail with an `AttributeError`
in `os.path.realpath`.

This can happen if the build invokes some project-local tool or command, like
`./build-something`.

Instead of calling using the result of `find_executable` directly, first check
whether the executable was found and fall back to original Bear behavior if
it was not.
Diffstat (limited to 'pkgs/development/tools/build-managers')
-rw-r--r--pkgs/development/tools/build-managers/bear/ignore_wrapper.patch24
1 files changed, 14 insertions, 10 deletions
diff --git a/pkgs/development/tools/build-managers/bear/ignore_wrapper.patch b/pkgs/development/tools/build-managers/bear/ignore_wrapper.patch
index f70e3811f654..8effc723bbab 100644
--- a/pkgs/development/tools/build-managers/bear/ignore_wrapper.patch
+++ b/pkgs/development/tools/build-managers/bear/ignore_wrapper.patch
@@ -1,6 +1,6 @@
---- Bear-2.3.11-src/bear/main.py.in	1970-01-01 01:00:01.000000000 +0100
-+++ Bear-2.3.11-src-patch/bear/main.py.in	1970-01-01 01:00:01.000000000 +0100
-@@ -49,6 +49,7 @@
+--- a/bear/main.py.in
++++ b/bear/main.py.in
+@@ -49,6 +49,7 @@ import tempfile
  import shutil
  import contextlib
  import logging
@@ -8,16 +8,20 @@
  
  # Map of ignored compiler option for the creation of a compilation database.
  # This map is used in _split_command method, which classifies the parameters
-@@ -540,7 +541,11 @@
-                 any(pattern.match(cmd) for pattern in COMPILER_PATTERNS_CXX)
+@@ -569,7 +570,15 @@ class Compilation:
+                 (compiler, language, rest of the command) otherwise """
  
          if command:  # not empty list will allow to index '0' and '1:'
 -            executable = os.path.basename(command[0])  # type: str
-+            absolute_executable = os.path.realpath(find_executable(command[0]))
-+            if 'wrapper' in absolute_executable:
-+                return None
-+
-+            executable = os.path.basename(absolute_executable) # type: str
++            executable_file = find_executable(command[0])
++            if executable_file:
++                absolute_executable = os.path.realpath(executable_file)
++                # Ignore Nix wrappers.
++                if 'wrapper' in absolute_executable:
++                    return None
++                executable = os.path.basename(absolute_executable)
++            else:
++                executable = os.path.basename(command[0])
              parameters = command[1:]  # type: List[str]
              # 'wrapper' 'parameters' and
              # 'wrapper' 'compiler' 'parameters' are valid.
\ No newline at end of file