Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,14 @@ jobs:
cargo +nightly clippy --manifest-path rule-preprocessor/Cargo.toml --all-targets --all-features -- -Dwarnings
cargo clippy --manifest-path libcc2rs/Cargo.toml --all-targets --all-features -- -Dwarnings
cargo clippy --manifest-path libcc2rs-macros/Cargo.toml --all-targets --all-features -- -Dwarnings

- name: Check Python (ruff)
uses: astral-sh/ruff-action@v3
with:
args: 'check'
src: tests/lit/lit/formats/Cpp2RustTest.py
- name: Check Python formatting (ruff)
uses: astral-sh/ruff-action@v3
with:
args: 'format --check'
src: tests/lit/lit/formats/Cpp2RustTest.py
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,23 @@ add_subdirectory(libcc2rs)
add_subdirectory(tests)

find_program(CLANG_FORMAT NAMES clang-format-22 clang-format)
find_program(RUFF NAMES ruff)

file(GLOB_RECURSE ALL_CXX_SOURCES
cpp2rust/*.cpp cpp2rust/*.h tests/*.cpp tests/*.c)

set(PYTHON_SOURCES ${PROJECT_SOURCE_DIR}/tests/lit/lit/formats/Cpp2RustTest.py)

add_custom_target("format"
COMMAND ${CLANG_FORMAT} -i ${ALL_CXX_SOURCES}
COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/rules/Cargo.toml
COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/rule-preprocessor/Cargo.toml
COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs/Cargo.toml
COMMAND rustup run ${RUST_STABLE_VERSION} cargo fmt --manifest-path ${PROJECT_SOURCE_DIR}/libcc2rs-macros/Cargo.toml
COMMAND ${RUFF} --silent check --fix ${PYTHON_SOURCES}
COMMAND ${RUFF} --silent format ${PYTHON_SOURCES}
DEPENDS "${RUST_STAMP_FILE}"
COMMENT "Running clang-format and cargo fmt on all source files"
COMMENT "Running clang-format, cargo fmt, and ruff on all source files"
VERBATIM
)

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ On Ubuntu, install the required dependencies with:
```bash
sudo apt install libclang-22-dev clang++-22 ninja-build cmake python3-tomli
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.95.0
curl -LsSf https://astral.sh/ruff/install.sh | sh
```


Expand Down
Loading
Loading