From 03278a644ebdca54b79649298f3d230e70d916f8 Mon Sep 17 00:00:00 2001 From: zhangstevenunity <128771452+zhangstevenunity@users.noreply.github.com> Date: Sat, 4 Apr 2026 09:53:55 +0800 Subject: [PATCH 1/3] chore: add clang-tidy configuration --- .clang-tidy | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..a8c991c4 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,37 @@ +# Copyright (c) 2026 Huawei Technologies Co., Ltd. +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of +# CANN Open Software License Agreement Version 2.0 (the "License"). +# Please refer to the License for details. You may not use this file except in compliance with the License. +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +# See LICENSE in the root of the software repository for the full text of the License. +# ----------------------------------------------------------------------------------------------------------- + +# Based on the .clang-tidy configuration in hw-native-sys/pypto, +# adapted to the directory layout of this repository. +# -clang-analyzer-unix.Malloc is disabled due to false positives. +Checks: > + bugprone-*, + clang-analyzer-*, + clang-diagnostic-*, + google-*, + modernize-*, + performance-*, + portability-*, + misc-include-cleaner, + -bugprone-easily-swappable-parameters, + -clang-analyzer-unix.Malloc, + -google-build-using-namespace, + -modernize-avoid-c-arrays, + -modernize-concat-nested-namespaces, + -modernize-return-braced-init-list, + -modernize-use-auto, + -modernize-use-trailing-return-type, + -performance-enum-size, + -performance-inefficient-string-concatenation, + -portability-template-virtual-member-function + +WarningsAsErrors: "*" +HeaderFilterRegex: '.*(include[/\\]|lib[/\\]).*\.(h|hpp)$' +HeaderFileExtensions: ["h", "hpp"] +ImplementationFileExtensions: ["cpp", "cc", "c"] From 443f986b752efef24a1cf17ebf80b482bc85e9f6 Mon Sep 17 00:00:00 2001 From: zhangstevenunity <128771452+zhangstevenunity@users.noreply.github.com> Date: Sat, 4 Apr 2026 09:59:25 +0800 Subject: [PATCH 2/3] chore: add clang-format configuration --- .clang-format | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .clang-format diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..6c69e209 --- /dev/null +++ b/.clang-format @@ -0,0 +1,13 @@ +# Copyright (c) 2026 Huawei Technologies Co., Ltd. +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of +# CANN Open Software License Agreement Version 2.0 (the "License"). +# Please refer to the License for details. You may not use this file except in compliance with the License. +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +# See LICENSE in the root of the software repository for the full text of the License. +# ----------------------------------------------------------------------------------------------------------- + +BasedOnStyle: Google +DerivePointerAlignment: false +ColumnLimit: 110 +PointerAlignment: Left From 2b366287ea6c1d90b5d6dce176e07fcecc22310c Mon Sep 17 00:00:00 2001 From: zhangstevenunity <128771452+zhangstevenunity@users.noreply.github.com> Date: Sat, 4 Apr 2026 10:05:34 +0800 Subject: [PATCH 3/3] chore: add pre-commit configuration --- .pre-commit-config.yaml | 54 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..29070795 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,54 @@ +# Copyright (c) 2026 Huawei Technologies Co., Ltd. +# This program is free software, you can redistribute it and/or modify it under the terms and conditions of +# CANN Open Software License Agreement Version 2.0 (the "License"). +# Please refer to the License for details. You may not use this file except in compliance with the License. +# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, +# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. +# See LICENSE in the root of the software repository for the full text of the License. +# ----------------------------------------------------------------------------------------------------------- + +# Adapted from hw-native-sys/pypto for this repository. +# Project-specific hooks from pypto are intentionally omitted here when the +# supporting scripts or config files do not exist in PTOAS yet. + +default_language_version: + python: python3 + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-added-large-files + exclude: ^docs/images/ + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v21.1.0 + hooks: + - id: clang-format + types_or: [c++, c] + files: ^(include/|lib/|tools/).*\.(h|hpp|c|cc|cpp)$ + exclude: ^tools/ptobc/generated/ + + - repo: https://github.com/cpplint/cpplint + rev: 2.0.0 + hooks: + - id: cpplint + files: ^(include/|lib/|tools/).*\.(h|hpp|c|cc|cpp)$ + exclude: ^tools/ptobc/generated/ + args: + - --root=. + - --linelength=110 + - --filter=-whitespace/parens,-whitespace/indent_namespace,-runtime/references + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.14.8 + hooks: + - id: ruff-check + files: ^(\.github/scripts/|python/).*\.(py|pyi)$ + args: [--fix] + - id: ruff-format + files: ^(\.github/scripts/|python/).*\.(py|pyi)$ + args: [--line-length=110]