From f7af97ebc3f0ec11ef31869de7084b2405ed576b Mon Sep 17 00:00:00 2001 From: Leonmmcoset Date: Sat, 18 Apr 2026 20:04:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .clang-format | 14 +++++++++ .github/workflows/style-check.yml | 50 +++++++++++++++++++++++++++++++ clks/kernel/panic.c | 4 +-- 3 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 .clang-format create mode 100644 .github/workflows/style-check.yml diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..07d78e6 --- /dev/null +++ b/.clang-format @@ -0,0 +1,14 @@ +--- +Language: Cpp +BasedOnStyle: LLVM +IndentWidth: 4 +TabWidth: 4 +UseTab: Never +ColumnLimit: 120 +BreakBeforeBraces: Attach +PointerAlignment: Right +SortIncludes: Never +AllowShortIfStatementsOnASingleLine: Never +AllowShortFunctionsOnASingleLine: Empty +SpaceBeforeParens: ControlStatements +... diff --git a/.github/workflows/style-check.yml b/.github/workflows/style-check.yml new file mode 100644 index 0000000..e3769a0 --- /dev/null +++ b/.github/workflows/style-check.yml @@ -0,0 +1,50 @@ +name: Code Style Check + +on: + push: + pull_request: + +permissions: + contents: read + +jobs: + clang-format: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install clang-format + run: | + sudo apt-get update + sudo apt-get install -y clang-format + + - name: Check C/C++ style + shell: bash + run: | + set -euo pipefail + + mapfile -t files < <( + git ls-files \ + '*.c' '*.h' '*.cc' '*.cpp' '*.cxx' '*.hpp' '*.hxx' \ + | grep -Ev '^(limine/|third_party/|build/|build-cmake/)' || true + ) + + if [[ ${#files[@]} -eq 0 ]]; then + echo "No C/C++ files to check." + exit 0 + fi + + for f in "${files[@]}"; do + clang-format -i "$f" + done + + if ! git diff --quiet -- "${files[@]}"; then + echo "Code style check failed. Please run clang-format on changed files." + echo "" + git diff -- "${files[@]}" + exit 1 + fi + + echo "Code style check passed." diff --git a/clks/kernel/panic.c b/clks/kernel/panic.c index 95f53b0..3acaef6 100644 --- a/clks/kernel/panic.c +++ b/clks/kernel/panic.c @@ -624,7 +624,7 @@ CLKS_NORETURN void clks_panic(const char *reason) { } clks_panic_emit_backtrace(&console, rip, rbp, rsp); - clks_panic_console_write(&console, "\nSystem halted. Please reboot the VM.\n"); + clks_panic_console_write(&console, "\nSystem halted. Please reboot the computer.\n"); } else { clks_panic_emit_backtrace(CLKS_NULL, rip, rbp, rsp); } @@ -691,7 +691,7 @@ CLKS_NORETURN void clks_panic_exception(const char *name, clks_panic_console_write(&console, "\n"); clks_panic_emit_backtrace(&console, rip, rbp, rsp); - clks_panic_console_write(&console, "\nSystem halted. Please reboot the VM.\n"); + clks_panic_console_write(&console, "\nSystem halted. Please reboot the computer.\n"); } else { clks_panic_emit_backtrace(CLKS_NULL, rip, rbp, rsp); }