forked from VowpalWabbit/vowpal_wabbit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Use nix to manage dev tooling starting with clang-tidy (Vowpal…
…Wabbit#4292) * use nix for clang tidy and clang format * test using nix for clang tidy * check for only errors * allow output from action * dont lint tests with clang-tidy * grouping and prevent false positives * dont warn on magic numbers * rename * add missing change * remove a few more lints * back to 14 * Create .clang-format * Update .clang-format * use src dir to allow -fix * add to format * improve usability of script
- Loading branch information
1 parent
f8dacd4
commit a295b6e
Showing
6 changed files
with
170 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
{ | ||
# Currently, this flake only contains tools helpful for development. | ||
# Over time, we may add a package definition and other things. | ||
description = "Development utils for Vowpal Wabbit."; | ||
|
||
inputs.flake-utils.url = "github:numtide/flake-utils"; | ||
|
||
outputs = { self, nixpkgs, flake-utils }: | ||
flake-utils.lib.eachDefaultSystem (system: | ||
let pkgs = nixpkgs.legacyPackages.${system}; in | ||
let | ||
generate-compile-commands = '' | ||
echo -n "Generating compile_commands.json... " | ||
rm -rf $TMPDIR/compile_commands_build | ||
mkdir -p $TMPDIR/compile_commands_build | ||
cmake -S . -B "$TMPDIR/compile_commands_build" \ | ||
-DCMAKE_EXPORT_COMPILE_COMMANDS=On \ | ||
-DRAPIDJSON_SYS_DEP=On \ | ||
-DFMT_SYS_DEP=On \ | ||
-DSPDLOG_SYS_DEP=On \ | ||
-DVW_BOOST_MATH_SYS_DEP=On \ | ||
-DVW_ZLIB_SYS_DEP=On \ | ||
-DVW_GTEST_SYS_DEP=On \ | ||
-DVW_EIGEN_SYS_DEP=On \ | ||
-DBUILD_TESTING=Off \ | ||
-DVW_BUILD_VW_C_WRAPPER=Off > cmake_compile_commands_output.txt 2>&1 | ||
if [ $? -ne 0 ]; then | ||
echo "Failed" | ||
echo | ||
cat cmake_compile_commands_output.txt >&2 | ||
exit 1 | ||
else | ||
echo "Done" | ||
rm cmake_compile_commands_output.txt | ||
fi | ||
''; | ||
in | ||
let | ||
core-dependencies = [ | ||
pkgs.spdlog | ||
pkgs.fmt | ||
pkgs.zlib | ||
pkgs.rapidjson | ||
pkgs.eigen | ||
pkgs.gtest | ||
pkgs.boost | ||
pkgs.cmake | ||
]; | ||
in | ||
let | ||
python-clang-tidy-package = pkgs.stdenv.mkDerivation { | ||
name = "python-clang-tidy"; | ||
src = pkgs.fetchurl { | ||
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/clang-tools-extra-14.0.6.src.tar.xz"; | ||
sha256 = "sha256-fPO4/1bGXE0erjxWiD/EpsvD/586FTCnTWbkXScnGGY="; | ||
}; | ||
sourceRoot = "clang-tools-extra-14.0.6.src"; | ||
phases = [ "unpackPhase" "installPhase" "fixupPhase" ]; | ||
propagatedBuildInputs = [ pkgs.python3 pkgs.clang-tools_14 ]; | ||
installPhase = '' | ||
mkdir -p $out/bin | ||
cp clang-tidy/tool/run-clang-tidy.py $out/bin | ||
cp clang-tidy/tool/run-clang-tidy.py $out/bin/run-clang-tidy | ||
cp clang-tidy/tool/clang-tidy-diff.py $out/bin | ||
cp clang-tidy/tool/clang-tidy-diff.py $out/bin/clang-tidy-diff | ||
''; | ||
}; | ||
in | ||
let | ||
python-clang-format-package = pkgs.stdenv.mkDerivation { | ||
name = "python-clang-format"; | ||
src = pkgs.fetchurl { | ||
url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.6/clang-14.0.6.src.tar.xz"; | ||
sha256 = "sha256-K1hHtqYxGLnv5chVSDY8gf/glrZsOzZ16VPiY0KuQDE="; | ||
}; | ||
sourceRoot = "clang-14.0.6.src"; | ||
phases = [ "unpackPhase" "installPhase" "fixupPhase" ]; | ||
propagatedBuildInputs = [ pkgs.python3 pkgs.clang-tools_14 ]; | ||
installPhase = '' | ||
mkdir -p $out/bin | ||
cp tools/clang-format/clang-format-diff.py $out/bin | ||
cp tools/clang-format/clang-format-diff.py $out/bin/clang-format-diff | ||
''; | ||
}; | ||
in | ||
let | ||
clang-tidy-all-script = pkgs.writeShellScriptBin "vw-clang-tidy" '' | ||
${generate-compile-commands} | ||
${python-clang-tidy-package}/bin/run-clang-tidy -p $TMPDIR/compile_commands_build -quiet -header-filter=vw/* "$@" | ||
''; | ||
in | ||
let | ||
clang-tidy-diff-script = pkgs.writeShellScriptBin "vw-clang-tidy-diff" '' | ||
${generate-compile-commands} | ||
${python-clang-tidy-package}/bin/clang-tidy-diff -p1 -path $TMPDIR/compile_commands_build -r '^.*\.(cc|h)\$' -quiet -use-color "$@" <&0 | ||
''; | ||
in | ||
{ | ||
formatter = pkgs.nixpkgs-fmt; | ||
devShell = pkgs.mkShell { | ||
packages = [ | ||
python-clang-tidy-package | ||
python-clang-format-package | ||
clang-tidy-all-script | ||
clang-tidy-diff-script | ||
] ++ core-dependencies; | ||
}; | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters