From 646378b19800de8b55736379d12ee404b5a26ab2 Mon Sep 17 00:00:00 2001 From: Yinzuo Jiang Date: Sat, 18 May 2024 20:21:01 +0800 Subject: [PATCH] fix: remove `-10` suffix for clang-tidy and clang-format in install_deps.sh Default llvm toolchain version in Ubuntu 20.04 is 10, while Ubuntu 22.04 does not have `clang-tidy-10` or `clang-format-10` by default. issue: #33142 Signed-off-by: Yinzuo Jiang --- docs/design_docs/segcore/scripts_and_tools.md | 2 +- internal/core/run_clang_format.sh | 9 ++++++++- scripts/install_deps.sh | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/design_docs/segcore/scripts_and_tools.md b/docs/design_docs/segcore/scripts_and_tools.md index a364563935823..105ac5a954348 100644 --- a/docs/design_docs/segcore/scripts_and_tools.md +++ b/docs/design_docs/segcore/scripts_and_tools.md @@ -5,7 +5,7 @@ The following scripts and commands may be used during segcore development. ## code format - under milvus/internal/core directory - - run `./run_clang_format .` to format cpp code + - run `./run_clang_format.sh .` to format cpp code - to call clang-format-10, need to install `apt install clang-format-10` in advance - call `build-support/add_${lang}_license.sh` to add license info for cmake and cpp files - under milvus/ directory diff --git a/internal/core/run_clang_format.sh b/internal/core/run_clang_format.sh index 2aa22c514473a..3aee407f0d1e4 100755 --- a/internal/core/run_clang_format.sh +++ b/internal/core/run_clang_format.sh @@ -6,8 +6,15 @@ else fi CorePath=$1 +# Check if clang-format-10 exists +if command -v clang-format-10 >/dev/null 2>&1; then + ClangFormatCmd=clang-format-10 +else + ClangFormatCmd=clang-format +fi + formatThis() { - find "$1" | grep -E "(*\.cpp|*\.h|*\.cc)$" | grep -v "gen_tools/templates" | grep -v "\.pb\." | grep -v "tantivy-binding.h" | xargs clang-format-10 -i + find "$1" | grep -E "(*\.cpp|*\.h|*\.cc)$" | grep -v "gen_tools/templates" | grep -v "\.pb\." | grep -v "tantivy-binding.h" | xargs $ClangFormatCmd -i } formatThis "${CorePath}/src" diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index 8ae371aa2a075..800121c6b7b50 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -21,7 +21,7 @@ function install_linux_deps() { # for Ubuntu 20.04 sudo apt install -y wget curl ca-certificates gnupg2 \ g++ gcc gfortran git make ccache libssl-dev zlib1g-dev zip unzip \ - clang-format-10 clang-tidy-10 lcov libtool m4 autoconf automake python3 python3-pip \ + clang-format clang-tidy lcov libtool m4 autoconf automake python3 python3-pip \ pkg-config uuid-dev libaio-dev libopenblas-dev libgoogle-perftools-dev sudo pip3 install conan==1.61.0