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
5 changes: 5 additions & 0 deletions .clang-format-ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Repository-relative exclusions for shared FormatValidation.
# Only src/, include/, and tests/ are selected; dependencies and artifacts are excluded.
**/thirdparty/**
**/build/**
**/install/**
31 changes: 31 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: clang-format

on:
push:
pull_request:
workflow_dispatch:

permissions:
contents: read

concurrency:
group: clang-format-${{ github.ref }}
cancel-in-progress: true

jobs:
clang-format:
runs-on: ubuntu-24.04
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install pinned formatter
run: python -m pip install clang-format==23.1.3
- name: Configure formatting targets
run: cmake -S . -B build/format -DFORMAT_VALIDATION_ONLY=ON
- name: Check all owned C/C++ sources
run: cmake --build build/format --target format-check
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
/thirdparty/cache/
*.user
__pycache__/

# Generated from the shared FormatValidation source during CMake configuration.
/.clang-format
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
cmake_minimum_required(VERSION 3.21)
option(FORMAT_VALIDATION_ONLY "Configure only clang-format targets without native dependencies" OFF)
if(FORMAT_VALIDATION_ONLY)
project(FormatValidation LANGUAGES NONE)
include(cmake/FormatValidation.cmake)
return()
endif()
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
project(SCCameraFix LANGUAGES CXX)
Expand Down Expand Up @@ -89,3 +95,6 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
metahooksv_add_launch_game()
endif()
endif()

# Shared formatting targets are explicit; ordinary native builds do not run them.
include(cmake/FormatValidation.cmake)
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,36 @@ scripts\build-SCCameraFix-x86-Release.bat -DMETAHOOK_SOURCE_PATH=D:\MetaHook
The path is the repository root that provides `include/metahook.h`, `include/HLSDK` and `include/Interface`.

SCCameraFix uses no Capstone and no SourceSDK headers; the MetaHook SDK tree is its only dependency besides VC-LTL. Pass `-DSCCAMERAFIX_SYNC_GAMEDATA=OFF` to build without downloading gamedata.

## C/C++ formatting

Formatting uses [MetaHookSv/FormatValidation](https://github.com/MetaHookSv/FormatValidation)
and clang-format **23.1.3**, with the DiligentCore style (4 spaces, preserved include
order). Install the formatter for the Python interpreter used by CMake:

```sh
python -m pip install clang-format==23.1.3
cmake -S . -B build/format "-DFORMAT_VALIDATION_ONLY=ON"
cmake --build build/format --target format-check
cmake --build build/format --target format
```

The format-only configuration needs CMake 3.21+, Git, Python 3.9+ (CI uses 3.12),
and a build generator; `-G Ninja` works without Visual Studio. It prepares no native
SDK or game dependencies. Formatting targets are explicit and are not part of a
normal DLL build. With a Visual Studio generator, add `--config Debug` or
`--config Release` when building a formatting target.

The aggregate provides `FORMAT_VALIDATION_SOURCE_PATH=thirdparty/FormatValidation`.
Standalone components accept that CMake variable or its environment counterpart;
if empty, FetchContent downloads the fixed tooling commit. Quote relative paths,
for example `"-DFORMAT_VALIDATION_SOURCE_PATH=../../thirdparty/FormatValidation"`.
Configuration generates the ignored root `.clang-format` for editors; change the
shared style rather than that generated copy. An optional
`FORMAT_VALIDATION_CLANG_FORMAT_EXECUTABLE` selects an explicit formatter, whose
version must still match the pin.

Checks cover owned C/C++ files in `src/`, `include/`, and `tests/`, including
non-ignored new files. Repository-relative exclusions live in `.clang-format-ignore`.
Third-party sources and build artifacts are excluded. The `clang-format` workflow
checks the full scope on pushes, pull requests, and manual runs.
26 changes: 26 additions & 0 deletions cmake/FormatValidation.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Shared tool implementation; only this dependency bootstrap belongs to the consumer.
if(NOT DEFINED FORMAT_VALIDATION_SOURCE_PATH)
set(FORMAT_VALIDATION_SOURCE_PATH "$ENV{FORMAT_VALIDATION_SOURCE_PATH}" CACHE PATH
"FormatValidation source tree; empty fetches the pinned tooling")
endif()
if(FORMAT_VALIDATION_SOURCE_PATH)
get_filename_component(_format_validation_source "${FORMAT_VALIDATION_SOURCE_PATH}"
ABSOLUTE BASE_DIR "${CMAKE_CURRENT_LIST_DIR}/..")
else()
include(FetchContent)
FetchContent_Declare(sccamerafix_format_validation
GIT_REPOSITORY https://github.com/MetaHookSv/FormatValidation.git
GIT_TAG 13c9fabe058e1f887ad1b03bb6884de911192c6a # v1.0.0; retained immutable tooling commit
GIT_SUBMODULES ""
# Populate the tooling without configuring its own test project.
SOURCE_SUBDIR cmake)
FetchContent_MakeAvailable(sccamerafix_format_validation)
set(_format_validation_source "${sccamerafix_format_validation_SOURCE_DIR}")
endif()
foreach(_format_validation_file .clang-format clang-format-validate.py cmake/FormatValidation.cmake)
if(NOT EXISTS "${_format_validation_source}/${_format_validation_file}")
message(FATAL_ERROR "FORMAT_VALIDATION_SOURCE_PATH is missing ${_format_validation_file}: ${_format_validation_source}")
endif()
endforeach()
include("${_format_validation_source}/cmake/FormatValidation.cmake")
format_validation_add_component(SCCameraFix "${CMAKE_CURRENT_SOURCE_DIR}")
Loading
Loading