1
+ #! /bin/bash
2
+
3
+ # Copyright (C) 2024 Intel Corporation
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions
15
+ # and limitations under the License.
16
+ #
17
+ # SPDX-License-Identifier: Apache-2.0
18
+
19
+
20
+
21
+ # this is for developer local check only.
22
+ # not used by github action
23
+
24
+ if [ -z " ${MLIR_DIR} " ]; then
25
+ echo " The environment variable MLIR_DIR is not set."
26
+ exit 1
27
+ fi
28
+
29
+ # set PR_REF if your pr target is not main
30
+ PR_REF=${PR_REF:- main}
31
+
32
+ MERGE_BASE=$( git merge-base $PR_REF HEAD)
33
+ CHANGED_FILES=$( git diff --name-only $MERGE_BASE HEAD | paste -sd' ' )
34
+
35
+ mkdir -p build
36
+ cd build
37
+
38
+ # if you do not have clang/clang++/clang-tidy
39
+ # please install it
40
+ # conda install -c conda-forge clangxx cxx-compiler clang-tools
41
+
42
+ cmake ../../ \
43
+ -DCMAKE_BUILD_TYPE=Release \
44
+ -DMLIR_DIR=${MLIR_DIR} \
45
+ -DCMAKE_EXPORT_COMPILE_COMMANDS=True \
46
+ -DCMAKE_C_COMPILER=$( which clang) \
47
+ -DCMAKE_CXX_COMPILER=$( which clang++) \
48
+ -DLLVM_EXTERNAL_LIT=$( which lit)
49
+
50
+ for f in $( find ./include -name Makefile) ; do
51
+ target=$( make -f $f help | grep IncGen) ;
52
+ if [[ $? -eq 0 ]]; then
53
+ cd ${f% Makefile} && make ${target# ...} && cd -;
54
+ fi ;
55
+ done
56
+
57
+ wget https://raw.githubusercontent.com/llvm/llvm-project/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py -O run-clang-tidy.py
58
+ wget https://raw.githubusercontent.com/llvm/llvm-project/main/mlir/.clang-tidy -O .clang-tidy
59
+
60
+ python3 run-clang-tidy.py -warnings-as-errors=* -p ./ -config-file .clang-tidy -clang-tidy-binary $( which clang-tidy) $CHANGED_FILES
0 commit comments