From 8a1c7da357873a645405c0f5b8cc75d751dedb83 Mon Sep 17 00:00:00 2001 From: Kane York Date: Sat, 1 Aug 2020 17:20:18 -0700 Subject: feat(3p/nix/build-shell): add run_clang_tidy script This makes it easy to quickly run clang-tidy on tvix without seeing errors from the generated files. Change-Id: I0e25089c5626aebdb5c016629a68da9ccd26c124 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1556 Tested-by: BuildkiteCI Reviewed-by: glittershark --- third_party/nix/default.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'third_party') diff --git a/third_party/nix/default.nix b/third_party/nix/default.nix index 704ba3f5fa..adb1bd33d1 100644 --- a/third_party/nix/default.nix +++ b/third_party/nix/default.nix @@ -150,7 +150,14 @@ in lib.fix (self: pkgs.llvmPackages.libcxxStdenv.mkDerivation { # TODO(tazjin): docs generation? passthru = { - build-shell = self.overrideAttrs (_: { + build-shell = self.overrideAttrs (up: rec { + run_clang_tidy = pkgs.writeShellScriptBin "run-clang-tidy" '' + test -f compile_commands.json || (echo "run from build output directory"; exit 1) || exit 1 + ${pkgs.jq}/bin/jq < compile_commands.json -r 'map(.file)|.[]' | grep -v '/generated/' | ${pkgs.parallel}/bin/parallel ${pkgs.clang-tools}/bin/clang-tidy -p compile_commands.json $@ + ''; + + installCheckInputs = up.installCheckInputs ++ [run_clang_tidy]; + shellHook = '' export NIX_DATA_DIR="${toString depotPath}/third_party" export NIX_TEST_VAR=foo -- cgit 1.4.1