Skip to content

Commit 57de13c

Browse files
committed
0.31.4
1 parent b2c7886 commit 57de13c

File tree

82 files changed

+4300
-3278
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+4300
-3278
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
!/src
1111
!.clang-format
1212
!.cmake-format.json
13+
!.gersemirc
1314
!.gitattributes
1415
!.gitignore
1516
!buildspec.json

CMakeLists.txt

Lines changed: 136 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ project(${_name} VERSION ${_version})
88
# Set default build type to RelWithDebInfo for local development
99
# RelWithDebInfo provides optimized code with debug symbols (PDB files on Windows)
1010
if(NOT CMAKE_BUILD_TYPE)
11-
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build (Debug, Release, or RelWithDebInfo)" FORCE)
11+
set(CMAKE_BUILD_TYPE
12+
"RelWithDebInfo"
13+
CACHE STRING
14+
"Choose the type of build (Debug, Release, or RelWithDebInfo)"
15+
FORCE
16+
)
1217
endif()
1318
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
1419

@@ -20,29 +25,85 @@ include(helpers)
2025

2126
# Read buildspec.json early for Qt configuration
2227
file(READ "${CMAKE_SOURCE_DIR}/buildspec.json" buildspec)
23-
string(JSON QT6_VERSION GET ${buildspec} dependencies qt6 version)
28+
string(
29+
JSON QT6_VERSION
30+
GET ${buildspec}
31+
dependencies
32+
qt6
33+
version
34+
)
2435

25-
# Persistent dependency directory (survives cache clears)
26-
if(WIN32)
27-
set(DEPS_DIR "${CMAKE_SOURCE_DIR}/_deps/${CMAKE_VS_PLATFORM_NAME}")
28-
else()
29-
set(DEPS_DIR "${CMAKE_SOURCE_DIR}/_deps")
30-
endif()
36+
# Define architecture-specific dependency directory in the build directory
37+
# Use CMAKE_BINARY_DIR so it works with any configured build directory
38+
set(DEPS_DIR "${CMAKE_BINARY_DIR}/obs-deps")
3139

32-
# Qt paths for Windows builds
40+
# Configure Qt paths for cross-compilation on Windows
3341
if(WIN32)
3442
if(CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64")
35-
# ARM64 cross-compilation: use x64 Qt tools with ARM64 libraries
43+
# ARM64 Cross-compilation setup
44+
# x64 Qt host tools are in source-dir/_deps/x64 (persistent across builds)
3645
set(QT_HOST_PATH "${CMAKE_SOURCE_DIR}/_deps/x64/obs-deps-qt6-${QT6_VERSION}-x64")
37-
set(Qt6_DIR "${DEPS_DIR}/obs-deps-qt6-${QT6_VERSION}-ARM64/lib/cmake/Qt6" CACHE PATH "" FORCE)
38-
set(Qt6CoreTools_DIR "${QT_HOST_PATH}/lib/cmake/Qt6CoreTools" CACHE PATH "" FORCE)
39-
set(Qt6GuiTools_DIR "${QT_HOST_PATH}/lib/cmake/Qt6GuiTools" CACHE PATH "" FORCE)
40-
set(Qt6WidgetsTools_DIR "${QT_HOST_PATH}/lib/cmake/Qt6WidgetsTools" CACHE PATH "" FORCE)
41-
set(CMAKE_AUTOMOC_MOC_EXECUTABLE "${QT_HOST_PATH}/bin/moc.exe" CACHE FILEPATH "" FORCE)
42-
set(CMAKE_AUTOUIC_UIC_EXECUTABLE "${QT_HOST_PATH}/bin/uic.exe" CACHE FILEPATH "" FORCE)
43-
set(CMAKE_AUTORCC_RCC_EXECUTABLE "${QT_HOST_PATH}/bin/rcc.exe" CACHE FILEPATH "" FORCE)
46+
set(Qt6_DIR
47+
"${DEPS_DIR}/obs-deps-qt6-${QT6_VERSION}-ARM64/lib/cmake/Qt6"
48+
CACHE STRING
49+
"Qt6 ARM64 CMake directory"
50+
FORCE
51+
)
52+
53+
message(STATUS "ARM64 Cross-compilation detected")
54+
message(STATUS "QT_HOST_PATH: ${QT_HOST_PATH}")
55+
message(STATUS "Qt6_DIR: ${Qt6_DIR}")
56+
57+
# Check if x64 Qt host tools exist
58+
if(EXISTS "${QT_HOST_PATH}/bin/moc.exe")
59+
message(STATUS "Found x64 Qt host tools at: ${QT_HOST_PATH}")
60+
else()
61+
message(
62+
FATAL_ERROR
63+
"x64 Qt host tools not found at: ${QT_HOST_PATH}. ARM64 cross-compilation requires both x64 and ARM64 Qt dependencies."
64+
)
65+
endif()
66+
67+
# Set Qt host tools for cross-compilation (use x64 tools for ARM64 builds)
68+
set(Qt6CoreTools_DIR "${QT_HOST_PATH}/lib/cmake/Qt6CoreTools" CACHE STRING "Qt6 x64 Core Tools" FORCE)
69+
set(Qt6GuiTools_DIR "${QT_HOST_PATH}/lib/cmake/Qt6GuiTools" CACHE STRING "Qt6 x64 GUI Tools" FORCE)
70+
set(Qt6WidgetsTools_DIR "${QT_HOST_PATH}/lib/cmake/Qt6WidgetsTools" CACHE STRING "Qt6 x64 Widget Tools" FORCE)
71+
72+
# Explicitly set tool executables that AUTOMOC/AUTOUIC/AUTORCC will use
73+
set(CMAKE_AUTOMOC_MOC_EXECUTABLE
74+
"${QT_HOST_PATH}/bin/moc.exe"
75+
CACHE FILEPATH
76+
"MOC executable for ARM64 cross-compilation"
77+
FORCE
78+
)
79+
set(CMAKE_AUTOUIC_UIC_EXECUTABLE
80+
"${QT_HOST_PATH}/bin/uic.exe"
81+
CACHE FILEPATH
82+
"UIC executable for ARM64 cross-compilation"
83+
FORCE
84+
)
85+
set(CMAKE_AUTORCC_RCC_EXECUTABLE
86+
"${QT_HOST_PATH}/bin/rcc.exe"
87+
CACHE FILEPATH
88+
"RCC executable for ARM64 cross-compilation"
89+
FORCE
90+
)
91+
92+
# Also set the legacy variables for compatibility
93+
set(QT_MOC_EXECUTABLE "${QT_HOST_PATH}/bin/moc.exe")
94+
set(QT_RCC_EXECUTABLE "${QT_HOST_PATH}/bin/rcc.exe")
95+
set(QT_UIC_EXECUTABLE "${QT_HOST_PATH}/bin/uic.exe")
96+
97+
message(STATUS "Set CMAKE_AUTOMOC_MOC_EXECUTABLE to: ${CMAKE_AUTOMOC_MOC_EXECUTABLE}")
4498
else()
45-
set(Qt6_DIR "${DEPS_DIR}/obs-deps-qt6-${QT6_VERSION}-x64/lib/cmake/Qt6" CACHE PATH "" FORCE)
99+
# x64 build - set paths to x64 Qt
100+
set(Qt6_DIR
101+
"${DEPS_DIR}/obs-deps-qt6-${QT6_VERSION}-x64/lib/cmake/Qt6"
102+
CACHE STRING
103+
"Qt6 x64 CMake directory"
104+
FORCE
105+
)
106+
message(STATUS "x64 build detected - using x64 Qt at: ${Qt6_DIR}")
46107
endif()
47108
endif()
48109

@@ -58,8 +119,19 @@ if(ENABLE_FRONTEND_API)
58119
endif()
59120

60121
# Qt is always required for proper window parenting
61-
find_package(Qt6 COMPONENTS Widgets Core REQUIRED)
62-
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Qt6::Core Qt6::Widgets)
122+
find_package(
123+
Qt6
124+
COMPONENTS
125+
Widgets
126+
Core
127+
REQUIRED
128+
)
129+
target_link_libraries(
130+
${CMAKE_PROJECT_NAME}
131+
PRIVATE
132+
Qt6::Core
133+
Qt6::Widgets
134+
)
63135
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE ENABLE_QT)
64136
target_compile_options(
65137
${CMAKE_PROJECT_NAME}
@@ -69,57 +141,86 @@ target_compile_options(
69141
)
70142
set_target_properties(
71143
${CMAKE_PROJECT_NAME}
72-
PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON
144+
PROPERTIES
145+
AUTOMOC
146+
ON
147+
AUTOUIC
148+
ON
149+
AUTORCC
150+
ON
73151
)
74152

75153
file(GLOB_RECURSE _sources CONFIGURE_DEPENDS src/*.cpp)
76154
target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${_sources})
77155

78156
set_target_properties_plugin(${CMAKE_PROJECT_NAME} PROPERTIES OUTPUT_NAME ${_name})
79157

80-
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES CXX_STANDARD 23)
158+
set_target_properties(
159+
${CMAKE_PROJECT_NAME}
160+
PROPERTIES
161+
CXX_STANDARD
162+
23
163+
)
81164

82165
add_subdirectory(lib/atkaudio)
83166

84167
string(JSON PLUGIN_DISPLAY_NAME GET ${buildspec} displayName)
85168
string(JSON PLUGIN_AUTHOR GET ${buildspec} author)
86-
string(JSON PLUGIN_OBS_VERSION_REQUIRED GET ${buildspec} dependencies obs-studio version)
169+
string(
170+
JSON PLUGIN_OBS_VERSION_REQUIRED
171+
GET ${buildspec}
172+
dependencies
173+
obs-studio
174+
version
175+
)
87176
string(TIMESTAMP PLUGIN_YEAR "%Y")
88177
set(PLUGIN_AUTHOR "${PLUGIN_AUTHOR}")
89178

90179
configure_file(src/config.h.in config.h @ONLY)
91180

92181
include(./lib/atkaudio/cmake/cpack.cmake)
93182

94-
95183
# Build tests
96184
include(CTest)
97185
add_subdirectory(tests)
98186

99187
# Automatically run install after build (skip in CI or when installing to system directories without permissions)
100188
if(NOT DEFINED ENV{CI} AND NOT DEFINED ENV{GITHUB_ACTIONS} AND NOT CMAKE_INSTALL_PREFIX MATCHES "^/usr")
101-
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
102-
COMMAND ${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --config $<CONFIG> --component plugin
189+
add_custom_command(
190+
TARGET ${CMAKE_PROJECT_NAME}
191+
POST_BUILD
192+
COMMAND
193+
${CMAKE_COMMAND} --install ${CMAKE_BINARY_DIR} --config $<CONFIG> --component plugin
103194
COMMENT "Installing plugin after build..."
104195
)
105196
endif()
106197

107-
# On non-CI Linux builds, copy plugin to user home directory after build
198+
# On non-CI Linux builds, copy plugin and scanner to user home directory after build
108199
if(NOT DEFINED ENV{CI} AND NOT DEFINED ENV{GITHUB_ACTIONS} AND UNIX AND NOT APPLE)
109200
message(STATUS "Configuring post-build copy to ~/.config/obs-studio/plugins/")
110201
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
111202
set(_user_arch "64bit")
112203
else()
113204
set(_user_arch "32bit")
114205
endif()
115-
116-
add_custom_command(TARGET ${CMAKE_PROJECT_NAME} POST_BUILD
117-
COMMAND ${CMAKE_COMMAND} -E make_directory "$ENV{HOME}/.config/obs-studio/plugins/${_name}/bin/${_user_arch}"
118-
COMMAND ${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:${CMAKE_PROJECT_NAME}>" "$ENV{HOME}/.config/obs-studio/plugins/${_name}/bin/${_user_arch}/"
119-
COMMAND ${CMAKE_COMMAND} -E make_directory "$ENV{HOME}/.config/obs-studio/plugins/${_name}/data"
120-
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/data" "$ENV{HOME}/.config/obs-studio/plugins/${_name}/data"
121-
COMMENT "Copying ${_name} to user home OBS plugins directory..."
206+
207+
add_custom_command(
208+
TARGET ${CMAKE_PROJECT_NAME}
209+
POST_BUILD
210+
COMMAND
211+
${CMAKE_COMMAND} -E make_directory "$ENV{HOME}/.config/obs-studio/plugins/${_name}/bin/${_user_arch}"
212+
COMMAND
213+
${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:${CMAKE_PROJECT_NAME}>"
214+
"$ENV{HOME}/.config/obs-studio/plugins/${_name}/bin/${_user_arch}/"
215+
COMMAND
216+
${CMAKE_COMMAND} -E copy_if_different "$<TARGET_FILE:${CMAKE_PROJECT_NAME}_scanner>"
217+
"$ENV{HOME}/.config/obs-studio/plugins/${_name}/bin/${_user_arch}/"
218+
COMMAND
219+
${CMAKE_COMMAND} -E make_directory "$ENV{HOME}/.config/obs-studio/plugins/${_name}/data"
220+
COMMAND
221+
${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/data"
222+
"$ENV{HOME}/.config/obs-studio/plugins/${_name}/data"
223+
COMMENT "Copying ${_name} and scanner to user home OBS plugins directory..."
122224
VERBATIM
123225
)
124226
endif()
125-

CMakePresets.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@
204204
"description": "Windows build for x64",
205205
"configuration": "RelWithDebInfo"
206206
},
207+
{
208+
"name": "windows-x64-release",
209+
"configurePreset": "windows-x64",
210+
"displayName": "Windows x64 Release",
211+
"description": "Windows build for x64 (full Release configuration)",
212+
"configuration": "Release"
213+
},
207214
{
208215
"name": "windows-ci-x64",
209216
"configurePreset": "windows-ci-x64",

build-aux/pre-commit

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/sh
2+
# Pre-commit hook for clang-format and gersemi
3+
# Runs formatters on staged files before commit
4+
# This file should be copied or symlinked to .git/hooks/pre-commit
5+
6+
set -e
7+
8+
ROOT_DIR=$(git rev-parse --show-toplevel)
9+
10+
RED='\033[0;31m'
11+
GREEN='\033[0;32m'
12+
YELLOW='\033[0;33m'
13+
NC='\033[0m'
14+
15+
echo "Running pre-commit formatting checks..."
16+
17+
# --- clang-format check ---
18+
CPP_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '\.(c|cpp|h|hpp|cc|cxx|hxx)$' || true)
19+
20+
if [ -n "$CPP_FILES" ]; then
21+
echo "Checking C/C++ files with clang-format..."
22+
23+
if command -v clang-format >/dev/null 2>&1; then
24+
CLANG_FORMAT="clang-format"
25+
elif command -v clang-format-19 >/dev/null 2>&1; then
26+
CLANG_FORMAT="clang-format-19"
27+
elif command -v clang-format-18 >/dev/null 2>&1; then
28+
CLANG_FORMAT="clang-format-18"
29+
else
30+
echo "${YELLOW}Warning: clang-format not found, skipping C/C++ formatting check${NC}"
31+
CLANG_FORMAT=""
32+
fi
33+
34+
if [ -n "$CLANG_FORMAT" ]; then
35+
for file in $CPP_FILES; do
36+
if [ -f "$ROOT_DIR/$file" ]; then
37+
if ! $CLANG_FORMAT --style=file --dry-run --Werror "$ROOT_DIR/$file" 2>/dev/null; then
38+
echo "${RED}Formatting required: $file${NC}"
39+
$CLANG_FORMAT --style=file -i "$ROOT_DIR/$file"
40+
git add "$ROOT_DIR/$file"
41+
echo "${GREEN}Formatted and re-staged: $file${NC}"
42+
fi
43+
fi
44+
done
45+
fi
46+
fi
47+
48+
# --- gersemi check ---
49+
CMAKE_FILES=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '(CMakeLists\.txt|\.cmake)$' || true)
50+
51+
if [ -n "$CMAKE_FILES" ]; then
52+
echo "Checking CMake files with gersemi..."
53+
54+
if command -v gersemi >/dev/null 2>&1; then
55+
GERSEMI="gersemi"
56+
else
57+
echo "${YELLOW}Warning: gersemi not found, skipping CMake formatting check${NC}"
58+
echo "${YELLOW}Install with: pip install gersemi${NC}"
59+
GERSEMI=""
60+
fi
61+
62+
if [ -n "$GERSEMI" ]; then
63+
for file in $CMAKE_FILES; do
64+
if [ -f "$ROOT_DIR/$file" ]; then
65+
if ! $GERSEMI --check "$ROOT_DIR/$file" 2>/dev/null; then
66+
echo "${RED}Formatting required: $file${NC}"
67+
$GERSEMI -i "$ROOT_DIR/$file"
68+
git add "$ROOT_DIR/$file"
69+
echo "${GREEN}Formatted and re-staged: $file${NC}"
70+
fi
71+
fi
72+
done
73+
fi
74+
fi
75+
76+
echo "${GREEN}Pre-commit checks completed.${NC}"
77+
exit 0

build-aux/run-clang-format

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/sh
2+
# Run clang-format on all C/C++ files in the project
3+
# Usage: ./run-clang-format [--check]
4+
5+
set -e
6+
7+
ROOT_DIR=$(git rev-parse --show-toplevel 2>/dev/null || dirname "$(dirname "$0")")
8+
9+
# Find clang-format
10+
if command -v clang-format >/dev/null 2>&1; then
11+
CLANG_FORMAT="clang-format"
12+
elif command -v clang-format-19 >/dev/null 2>&1; then
13+
CLANG_FORMAT="clang-format-19"
14+
elif command -v clang-format-18 >/dev/null 2>&1; then
15+
CLANG_FORMAT="clang-format-18"
16+
else
17+
echo "Error: clang-format not found"
18+
exit 1
19+
fi
20+
21+
echo "Using: $($CLANG_FORMAT --version)"
22+
23+
# Find all C/C++ files
24+
CPP_FILES=$(find "$ROOT_DIR/src" "$ROOT_DIR/lib" "$ROOT_DIR/tests" -type f \( -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" \) 2>/dev/null || true)
25+
26+
if [ -z "$CPP_FILES" ]; then
27+
echo "No C/C++ files found"
28+
exit 0
29+
fi
30+
31+
if [ "$1" = "--check" ]; then
32+
echo "Checking formatting..."
33+
FAILED=0
34+
for file in $CPP_FILES; do
35+
if ! $CLANG_FORMAT --style=file --dry-run --Werror "$file" 2>/dev/null; then
36+
echo "Needs formatting: $file"
37+
FAILED=1
38+
fi
39+
done
40+
if [ $FAILED -eq 1 ]; then
41+
echo "Some files need formatting. Run without --check to format."
42+
exit 1
43+
fi
44+
echo "All files are properly formatted."
45+
else
46+
echo "Formatting files..."
47+
echo "$CPP_FILES" | xargs $CLANG_FORMAT --style=file -i
48+
echo "Done."
49+
fi

0 commit comments

Comments
 (0)