about summary refs log tree commit diff
path: root/third_party
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-07-23T18·55-0700
committerkanepyork <rikingcoding@gmail.com>2020-07-23T21·46+0000
commitb8e94002d6a0a416a3128e1bc275d73f59700321 (patch)
tree1a08833539e179abedde4590e37041c6aaeab2ee /third_party
parentbe98295dc24492f6607cce04ba586e3897a83543 (diff)
feat(3p/nix): run clang-tidy during builds r/1435
We need to -isystem the libcxx header files in order for clang-tidy to ignore them, as the Nix clang toolchain isn't doing that automatically.

Change-Id: I05b9e9bd522de4c0e2ad543214f6bf6ab66a306b
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1359
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party')
-rw-r--r--third_party/nix/.clang-tidy3
-rw-r--r--third_party/nix/CMakeLists.txt13
-rw-r--r--third_party/nix/default.nix4
3 files changed, 19 insertions, 1 deletions
diff --git a/third_party/nix/.clang-tidy b/third_party/nix/.clang-tidy
new file mode 100644
index 0000000000..4e0e8b6e0e
--- /dev/null
+++ b/third_party/nix/.clang-tidy
@@ -0,0 +1,3 @@
+---
+WarningsAsErrors: 'abseil-*'
+...
diff --git a/third_party/nix/CMakeLists.txt b/third_party/nix/CMakeLists.txt
index 71651a9b11..7591debb13 100644
--- a/third_party/nix/CMakeLists.txt
+++ b/third_party/nix/CMakeLists.txt
@@ -7,6 +7,9 @@ set(CMAKE_CXX_STANDARD 17)
 # clangd and clang-tidy.
 set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 
+# Enable warnings
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
+
 # Provide an output path for pkgconfig.
 include(GNUInstallDirs)
 set(PKGCONFIG_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
@@ -25,6 +28,16 @@ find_package(absl REQUIRED)
 find_package(gRPC REQUIRED)
 find_package(glog REQUIRED)
 
+find_program(CLANG_TIDY_PATH clang-tidy)
+if (CLANG_TIDY_PATH)
+  set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_PATH}")
+
+  # nix's toolchain has a problem with system header includes, so clang-tidy requires a manual -isystem
+  if (DEFINED ENV{LIBCXX_INCLUDE})
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem $ENV{LIBCXX_INCLUDE}")
+  endif()
+endif()
+
 # generate a configuration file (autoheader-style) to configure
 # certain symbols that Nix depends on.
 configure_file(config.h.in nix_config.h @ONLY)
diff --git a/third_party/nix/default.nix b/third_party/nix/default.nix
index bbd0e0120a..bc25689461 100644
--- a/third_party/nix/default.nix
+++ b/third_party/nix/default.nix
@@ -81,7 +81,6 @@ in pkgs.llvmPackages.libcxxStdenv.mkDerivation {
     mkdir build
     cd build
     cmake .. \
-      -DCMAKE_CXX_FLAGS='-Wall -Werror' \
       -DCMAKE_INSTALL_PREFIX=$out \
       -DCMAKE_BUILD_TYPE=Release \
       -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF \
@@ -110,6 +109,9 @@ in pkgs.llvmPackages.libcxxStdenv.mkDerivation {
   # that they can be included by CMake.
   NIX_PROTO_SRCS = protoSrcs;
 
+  # Work around broken system header include flags in the cxx toolchain.
+  LIBCXX_INCLUDE = "${pkgs.llvmPackages.libcxx}/include/c++/v1";
+
   # Install the various symlinks to the Nix binary which users expect
   # to exist.
   postInstall = ''