diff --git a/pkgs/by-name/be/bear/0001-exclude-tests-from-all.patch b/pkgs/by-name/be/bear/0001-exclude-tests-from-all.patch deleted file mode 100644 index 4a72bb41bbed..000000000000 --- a/pkgs/by-name/be/bear/0001-exclude-tests-from-all.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -85,8 +85,9 @@ - ${CMAKE_CACHE_ARGS_EXTRA} - BUILD_ALWAYS - 1 -- TEST_BEFORE_INSTALL -+ TEST_EXCLUDE_FROM_MAIN - 1 -+ STEP_TARGETS test - TEST_COMMAND - ctest # or `ctest -T memcheck` - ) -@@ -102,7 +103,8 @@ - -DCMAKE_INSTALL_LIBDIR:PATH=${CMAKE_INSTALL_LIBDIR} - -DCMAKE_INSTALL_BINDIR:PATH=${CMAKE_INSTALL_BINDIR} - -DSTAGED_INSTALL_PREFIX:PATH=${STAGED_INSTALL_PREFIX} -- TEST_BEFORE_INSTALL -+ TEST_EXCLUDE_FROM_MAIN -+ STEP_TARGETS test - 1 - INSTALL_COMMAND - "" diff --git a/pkgs/by-name/be/bear/package.nix b/pkgs/by-name/be/bear/package.nix index 5ace2224e728..ea69998aa5c3 100644 --- a/pkgs/by-name/be/bear/package.nix +++ b/pkgs/by-name/be/bear/package.nix @@ -1,110 +1,43 @@ { lib, - stdenv, fetchFromGitHub, - cmake, - ninja, - pkg-config, - grpc, - protobuf, - openssl, - nlohmann_json, - gtest, - spdlog, - c-ares, - zlib, - sqlite, - re2, - lit, - python3, - coreutils, + rustPlatform, + installShellFiles, + lld, }: -stdenv.mkDerivation (finalAttrs: { +rustPlatform.buildRustPackage (finalAttrs: { pname = "bear"; - version = "3.1.6"; + version = "4.0.3"; src = fetchFromGitHub { owner = "rizsotto"; repo = "bear"; rev = finalAttrs.version; - hash = "sha256-fWNMjqF5PCjGfFGReKIUiJ5lv8z6j7HeBn5hvbnV2V4="; + hash = "sha256-VZNrWfeeOJ5+qLg6hby4vR5rKKO7+mVOKp2p+lvwGOc="; }; - strictDeps = true; + cargoHash = "sha256-61hKYDPPQ79QF3BNCLn2LxiCsoll+MGAMZ8obOVuNZI="; nativeBuildInputs = [ - cmake - ninja - pkg-config - grpc - protobuf + installShellFiles + lld ]; - buildInputs = [ - grpc - protobuf - openssl - nlohmann_json - spdlog - c-ares - zlib - sqlite - re2 - ]; - - patches = [ - # This patch is necessary to run tests in a separate phase. By default - # test targets are run with ALL, which is not what we want. This patch creates - # separate 'test' step targets for each cmake ExternalProject: - # - BearTest-test (functional lit tests) - # - BearSource-test (unit tests via gtest) - ./0001-exclude-tests-from-all.patch - ]; - - nativeCheckInputs = [ - lit - python3 - ]; - - checkInputs = [ - gtest - ]; - - cmakeFlags = [ - # Build system and generated files concatenate install prefix and - # CMAKE_INSTALL_{BIN,LIB}DIR, which breaks if these are absolute paths. - (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") - (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") - (lib.cmakeBool "ENABLE_UNIT_TESTS" finalAttrs.finalPackage.doCheck) - (lib.cmakeBool "ENABLE_FUNC_TESTS" finalAttrs.finalPackage.doCheck) - ]; - - checkTarget = lib.concatStringsSep " " [ - "BearTest-test" - "BearSource-test" - ]; - - doCheck = true; - - env = { - # Disable failing tests. The cause is not immediately clear. - LIT_FILTER_OUT = lib.concatStringsSep "|" [ - "cases/compilation/output/config/filter_compilers.sh" - "cases/intercept/preload/posix/execvpe/success_to_resolve.c" - "cases/intercept/preload/posix/popen/success.c" - "cases/intercept/preload/posix/posix_spawnp/success_to_resolve.c" - "cases/intercept/preload/posix/system/success.c" - "cases/intercept/preload/shell_commands_intercepted_without_shebang.sh" - ]; - }; - postPatch = '' - patchShebangs test/bin + substituteInPlace bear/build.rs \ + --replace-fail 'const DEFAULT_WRAPPER_PATH: &str = "/usr/local/libexec/bear";' \ + "const DEFAULT_WRAPPER_PATH: &str = \"$out/libexec/bear\";" \ + --replace-fail 'const DEFAULT_PRELOAD_PATH: &str = "/usr/local/libexec/bear/$LIB";' \ + "const DEFAULT_PRELOAD_PATH: &str = \"$out/lib\";" + ''; - # /usr/bin/env is used in test commands and embedded scripts. - find test -name '*.sh' \ - -exec sed -i -e 's|/usr/bin/env|${coreutils}/bin/env|g' {} + + postInstall = '' + # wrapper should not end up on path + install -d $out/libexec/bear + mv $out/bin/wrapper $out/libexec/bear/wrapper + + installManPage man/bear.1 ''; # Functional tests use loopback networking.