bear: fix

The previous build system patch was incomplete and left the `wrapper.d`
directory empty, leaving Bear unable to pick up any build commands
at all and breaking the functional test suite, which we also weren't
running. Switch to overriding CMake flags instead and add the patches
and dependencies necessary to get the functional tests running to
prevent a future regression.

I've checked that the instructions in Nix's
`doc/manual/src/contributing/hacking.md` work after this change,
which is what started this yak shave in the first place.

authored by Emily and committed by Justin Restivo ec4de101 f50e2019

+63 -30
+31 -3
pkgs/development/tools/build-managers/bear/default.nix
··· 13 13 , zlib 14 14 , sqlite 15 15 , re2 16 + , lit 17 + , python3 18 + , coreutils 16 19 }: 17 20 18 21 stdenv.mkDerivation rec { ··· 26 29 hash = "sha256-1nZPzgLWcmaRkOUXdm16IW2Nw/p1w8GBGEfZX/v+En0="; 27 30 }; 28 31 29 - nativeBuildInputs = [ cmake pkg-config ]; 32 + nativeBuildInputs = [ 33 + cmake 34 + pkg-config 35 + 36 + # Used for functional tests, which run during buildPhase. 37 + lit 38 + python3 39 + ]; 30 40 31 41 buildInputs = [ 32 42 grpc ··· 41 51 re2 42 52 ]; 43 53 54 + cmakeFlags = [ 55 + # Build system and generated files concatenate install prefix and 56 + # CMAKE_INSTALL_{BIN,LIB}DIR, which breaks if these are absolute paths. 57 + "-DCMAKE_INSTALL_BINDIR=bin" 58 + "-DCMAKE_INSTALL_LIBDIR=lib" 59 + ]; 60 + 44 61 patches = [ 45 - # Default libexec would be set to /nix/store/*-bear//nix/store/*-bear/libexec/... 46 - ./no-double-relative.patch 62 + # Fix toolchain environment variable handling and the Darwin SIP check. 63 + ./fix-functional-tests.patch 47 64 ]; 65 + 66 + postPatch = '' 67 + patchShebangs test/bin 68 + 69 + # /usr/bin/env is used in test commands and embedded scripts. 70 + find test -name '*.sh' \ 71 + -exec sed -ie 's|/usr/bin/env|${coreutils}/bin/env|g' {} + 72 + ''; 73 + 74 + # Functional tests use loopback networking. 75 + __darwinAllowLocalNetworking = true; 48 76 49 77 meta = with lib; { 50 78 broken = stdenv.isDarwin;
+32
pkgs/development/tools/build-managers/bear/fix-functional-tests.patch
··· 1 + diff --git a/test/lit.cfg b/test/lit.cfg 2 + index 118c979..b69fecc 100644 3 + --- a/test/lit.cfg 4 + +++ b/test/lit.cfg 5 + @@ -207,13 +207,8 @@ def is_preload_disabled(): 6 + if is_windows: 7 + return True 8 + elif sys.platform == 'darwin': 9 + - command = ['csrutil', 'status'] 10 + - pattern = re.compile(r'System Integrity Protection status:\s+enabled') 11 + - try: 12 + - output = subprocess.check_output(command, stderr=subprocess.STDOUT) 13 + - return any(pattern.match(line) for line in output.decode('utf-8').splitlines()) 14 + - except (OSError, subprocess.CalledProcessError): 15 + - return False 16 + + # csrutil(8) isn't available in the Nix build sandbox. 17 + + return True 18 + else: 19 + return False 20 + 21 + @@ -221,6 +216,11 @@ def is_preload_disabled(): 22 + if not is_preload_disabled(): 23 + config.available_features.add('preload') 24 + 25 + +# Preserve the variables required for the Nix toolchain wrappers. 26 + +for var, value in os.environ.items(): 27 + + if var.startswith('NIX_'): 28 + + config.environment[var] = value 29 + + 30 + print(config.substitutions) 31 + print(config.environment) 32 + print(config.available_features)
-27
pkgs/development/tools/build-managers/bear/no-double-relative.patch
··· 1 - diff --git a/source/config.h.in b/source/config.h.in 2 - index 6b659c2..f7bdf22 100644 3 - --- a/source/config.h.in 4 - +++ b/source/config.h.in 5 - @@ -108,8 +108,8 @@ namespace cmd { 6 - } 7 - 8 - namespace wrapper { 9 - - constexpr char DEFAULT_PATH[] = "@ROOT_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/bear/wrapper"; 10 - - constexpr char DEFAULT_DIR_PATH[] = "@ROOT_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/bear/wrapper.d"; 11 - + constexpr char DEFAULT_PATH[] = "@CMAKE_INSTALL_LIBDIR@/bear/wrapper"; 12 - + constexpr char DEFAULT_DIR_PATH[] = "@CMAKE_INSTALL_LIBDIR@/bear/wrapper.d"; 13 - 14 - constexpr char FLAG_VERBOSE[] = "--verbose"; 15 - constexpr char FLAG_DESTINATION[] = "--destination"; 16 - @@ -134,9 +134,9 @@ namespace cmd { 17 - // And use the `libexec.so` path default value with a single path, 18 - // that matches both. (The match can be achieved by the $LIB token 19 - // expansion from the dynamic loader. See `man ld.so` for more.) 20 - - constexpr char DEFAULT_PATH[] = "@ROOT_INSTALL_PREFIX@/$LIB/bear/@CMAKE_SHARED_LIBRARY_PREFIX@exec@CMAKE_SHARED_LIBRARY_SUFFIX@"; 21 - + constexpr char DEFAULT_PATH[] = "$LIB/bear/@CMAKE_SHARED_LIBRARY_PREFIX@exec@CMAKE_SHARED_LIBRARY_SUFFIX@"; 22 - #else 23 - - constexpr char DEFAULT_PATH[] = "@ROOT_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/bear/@CMAKE_SHARED_LIBRARY_PREFIX@exec@CMAKE_SHARED_LIBRARY_SUFFIX@"; 24 - + constexpr char DEFAULT_PATH[] = "@CMAKE_INSTALL_LIBDIR@/bear/@CMAKE_SHARED_LIBRARY_PREFIX@exec@CMAKE_SHARED_LIBRARY_SUFFIX@"; 25 - #endif 26 - constexpr char KEY_REPORTER[] = "INTERCEPT_REPORT_COMMAND"; 27 - constexpr char KEY_DESTINATION[] = "INTERCEPT_REPORT_DESTINATION";