Skip to content

Commit

Permalink
build: fix building with clang
Browse files Browse the repository at this point in the history
  • Loading branch information
diamante0018 committed Dec 1, 2024
1 parent 4d594e9 commit c5f4a1d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: check-formatting

on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
types: [opened, synchronize, reopened]

jobs:
check-formatting:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@main

- name: Install LLVM and Clang
uses: KyleMayes/[email protected]
with:
version: "17.0"

- name: Test formatting for all files
working-directory: ${{ github.workspace }}
run: |
export CLANG_FORMAT_BIN="${LLVM_PATH}/bin/clang-format"
./scripts/check-format.sh
8 changes: 8 additions & 0 deletions scripts/check-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Go to repository root
cd "$(dirname "$0")/.." || exit 2

CLANG_FORMAT_BIN="${CLANG_FORMAT_BIN:-clang-format}"

find ./src -iname '*.hpp' -o -iname '*.cpp' | xargs $CLANG_FORMAT_BIN -Werror -ferror-limit=1 --dry-run
4 changes: 2 additions & 2 deletions src/client/loader/component_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ class component_loader final {

template <typename T> static T* get() {
for (const auto& component_ : get_components()) {
if (typeid(*component_.get()) == typeid(T)) {
return reinterpret_cast<T*>(component_.get());
if (auto c = dynamic_cast<T*>(component_.get())) {
return c;
}
}

Expand Down

0 comments on commit c5f4a1d

Please sign in to comment.