diff --git a/projects/rocm-smi-lib/.clang-format b/projects/rocm-smi-lib/.clang-format new file mode 100644 index 0000000000..0bca7eb76f --- /dev/null +++ b/projects/rocm-smi-lib/.clang-format @@ -0,0 +1,4 @@ +--- +Language: Cpp +BasedOnStyle: Google +ColumnLimit: 100 diff --git a/projects/rocm-smi-lib/.clang-tidy b/projects/rocm-smi-lib/.clang-tidy new file mode 100644 index 0000000000..11402fd8da --- /dev/null +++ b/projects/rocm-smi-lib/.clang-tidy @@ -0,0 +1,25 @@ +# THIS FILE IS GENERATED FROM .clangd! +# Run .update-clang-tidy.sh to regenerate. +Checks: + bugprone*, + clang-analyzer*, + google*, + misc*, + modernize*, + -abseil*, + -bugprone-easily-swappable-parameters, + -bugprone-reserved-identifier, + -clang-analyzer-security.insecureAPI.strcpy, + -cppcoreguidelines*, + -cppcoreguidelines-pro*, + -misc-non-copyable-objects, + -misc-use-anonymous-namespace, + -modernize-avoid-c-arrays, + -modernize-redundant-void-arg, + -modernize-use-auto, + -modernize-use-nodiscard, + -modernize-use-noexcept, + -modernize-use-trailing-return-type, + -modernize-use-using, + -performance*, + -readability*, diff --git a/projects/rocm-smi-lib/.clangd b/projects/rocm-smi-lib/.clangd new file mode 100644 index 0000000000..74ae437a6f --- /dev/null +++ b/projects/rocm-smi-lib/.clangd @@ -0,0 +1,37 @@ +CompileFlags: + Remove: -W* + Add: [-Wall, -pedantic, -I/opt/rocm/include, -I/opt/rocm/include/hsa, -I/opt/rocm/include/rocprofiler] + Compiler: clang++ + +# list here: https://clang.llvm.org/extra/clang-tidy/checks/list.html +Diagnostics: + UnusedIncludes: Strict + # rules below are copied into .clang-tidy using ./.update-clang-tidy.sh + # please keep the rules sorted alphabetically + ClangTidy: + Add: [ + bugprone*, + clang-analyzer*, + google*, + misc*, + modernize*, + ] + Remove: [ + abseil*, + bugprone-easily-swappable-parameters, + bugprone-reserved-identifier, + clang-analyzer-security.insecureAPI.strcpy, + cppcoreguidelines*, + cppcoreguidelines-pro*, + misc-non-copyable-objects, + misc-use-anonymous-namespace, + modernize-avoid-c-arrays, + modernize-redundant-void-arg, + modernize-use-auto, + modernize-use-nodiscard, + modernize-use-noexcept, + modernize-use-trailing-return-type, + modernize-use-using, + performance*, + readability*, + ] diff --git a/projects/rocm-smi-lib/.editorconfig b/projects/rocm-smi-lib/.editorconfig index 86ca34a181..a97ea56020 100644 --- a/projects/rocm-smi-lib/.editorconfig +++ b/projects/rocm-smi-lib/.editorconfig @@ -10,3 +10,4 @@ root = true charset = utf-8 indent_style = space indent_size = 2 +max_line_length = 100 diff --git a/projects/rocm-smi-lib/.gitignore b/projects/rocm-smi-lib/.gitignore index 71facfe540..3e67867c25 100644 --- a/projects/rocm-smi-lib/.gitignore +++ b/projects/rocm-smi-lib/.gitignore @@ -23,3 +23,8 @@ device/ __pycache__ README README.html + +# do NOT ignore these files +!.clang-format +!.clang-tidy +!.clangd diff --git a/projects/rocm-smi-lib/.pre-commit-config.yaml b/projects/rocm-smi-lib/.pre-commit-config.yaml new file mode 100644 index 0000000000..d84939508a --- /dev/null +++ b/projects/rocm-smi-lib/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +# - How to use: +# python3 -m pip install pre-commit +# pre-commit install --install hooks +# Upon a new commit - the hooks should automagically run +# +# - How to skip: +# git commit --no-verify +# or +# SKIP=clang-format-docker git commit +# SKIP=cpplint-docker git commit + +fail_fast: false +repos: + # For portability I decided to use Docker containers + - repo: https://github.com/dmitrii-galantsev/pre-commit-docker-cpplint + rev: 0.0.3 + hooks: + - id: clang-format-docker + - id: cpplint-docker + # Below is a local way of running formatters and linters + # NOTE: clang-tidy is not used in the above tests + # - repo: https://github.com/pocc/pre-commit-hooks + # rev: v1.3.5 + # hooks: + # - id: clang-format + # args: [--no-diff, -i] + # - id: clang-tidy + # args: [-p=build, --quiet] + # - id: cpplint + # args: [--verbose=5] diff --git a/projects/rocm-smi-lib/.update-clang-tidy.sh b/projects/rocm-smi-lib/.update-clang-tidy.sh new file mode 100755 index 0000000000..9607b35714 --- /dev/null +++ b/projects/rocm-smi-lib/.update-clang-tidy.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +set -x # trace +set -e # exit immediately if command fails +set -u # exit if an undefined variable is found + +awk ' +BEGIN { + print "# THIS FILE IS GENERATED FROM .clangd!" + print "# Run ./.update-clang-tidy.sh to regenerate." + print "Checks:" +} +/Add: \[$/{ +a=1 + next +} +/]/{ + a=0 +} +a{ +gsub(/^\s+/," ") + print +} + +/Remove: \[$/{ +r=1 + next +} +/]/{ + r=0 +} +r{ + gsub(/^\s+/," -") + print +} +' .clangd | tee .clang-tidy diff --git a/projects/rocm-smi-lib/CPPLINT.cfg b/projects/rocm-smi-lib/CPPLINT.cfg new file mode 100644 index 0000000000..b63692c6df --- /dev/null +++ b/projects/rocm-smi-lib/CPPLINT.cfg @@ -0,0 +1,3 @@ +set noparent +linelength=100 +filter=-build/include_subdir,-legal/copyright,-runtime/printf,-build/c++11,-runtime/int,-build/header_guard