Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .github/actions/setup-dependencies-native/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ runs:
gsettings-desktop-schemas
libnotify4
libnotify-dev
clang-format
clang-tidy
libwebkit2gtk-4.1-dev
libgtk-3-dev
libglib2.0-dev
Expand Down
119 changes: 119 additions & 0 deletions .github/scripts/native_quality.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#!/usr/bin/env bash
set -euo pipefail

repo_root="$(git rev-parse --show-toplevel)"
native_root="${repo_root}/src/InfiniFrame.Native"
quality_root="${native_root}/build/native-quality"

collect_format_sources() {
git -C "${repo_root}" ls-files --cached --others --exclude-standard -- \
'src/InfiniFrame.Native/*.cpp' \
'src/InfiniFrame.Native/*.h' \
'src/InfiniFrame.Native/*.mm' \
'src/InfiniFrame.Native/**/*.cpp' \
'src/InfiniFrame.Native/**/*.h' \
'src/InfiniFrame.Native/**/*.mm' |
grep -v '^src/InfiniFrame.Native/Dependencies/' |
sed "s#^#${repo_root}/#"
}

run_format_check() {
mapfile -t sources < <(collect_format_sources)

if [[ ${#sources[@]} -eq 0 ]]; then
echo "No native sources found for clang-format."
return 0
fi

clang-format --dry-run --Werror "${sources[@]}"
}

configure_tidy_build() {
cmake -S "${native_root}" \
-B "${quality_root}/tidy" \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DINFINIFRAME_BUILD_TEST_EXPORTS=ON
}

collect_tidy_sources() {
local compile_commands="${quality_root}/tidy/compile_commands.json"

python3 - "${compile_commands}" "${repo_root}" <<'PY'
import json
import pathlib
import sys

compile_commands = pathlib.Path(sys.argv[1])
repo_root = pathlib.Path(sys.argv[2]).resolve()
native_root = repo_root / "src" / "InfiniFrame.Native"
dependencies_root = native_root / "Dependencies"

entries = json.loads(compile_commands.read_text(encoding="utf-8"))
seen = set()

for entry in entries:
source = pathlib.Path(entry["file"]).resolve()

if dependencies_root in source.parents:
continue

if native_root not in (source, *source.parents):
continue

if source.suffix not in {".cpp", ".mm"}:
continue

if source in seen:
continue

seen.add(source)
print(source)
PY
}

run_clang_tidy() {
configure_tidy_build
mapfile -t sources < <(collect_tidy_sources)

if [[ ${#sources[@]} -eq 0 ]]; then
echo "No native compile database sources found for clang-tidy."
return 0
fi

clang-tidy \
-p "${quality_root}/tidy" \
--checks='-*,clang-analyzer-*' \
--warnings-as-errors='clang-analyzer-*' \
"${sources[@]}"
}

run_sanitizer_build() {
cmake -S "${native_root}" \
-B "${quality_root}/sanitizer" \
-DCMAKE_BUILD_TYPE=Debug \
-DINFINIFRAME_BUILD_TEST_EXPORTS=ON

cmake --build "${quality_root}/sanitizer" --parallel
}

case "${1:-all}" in
format)
run_format_check
;;
clang-tidy)
run_clang_tidy
;;
sanitizer-build)
run_sanitizer_build
;;
all)
run_format_check
run_clang_tidy
run_sanitizer_build
;;
*)
echo "Usage: $0 [format|clang-tidy|sanitizer-build|all]" >&2
exit 2
;;
esac
18 changes: 16 additions & 2 deletions .github/workflows/shared-testing-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ jobs:
brew-cache-key: ${{ matrix.os }}-${{ matrix.arch }}-brew-native-${{ hashFiles('.github/actions/setup-dependencies-native/action.yml', '.github/workflows/shared-testing-linux.yml') }}
brew-restore-key: ${{ matrix.os }}-${{ matrix.arch }}-brew-native-

- name: Native Format Check
if: matrix.arch == 'x64'
run: bash .github/scripts/native_quality.sh format

- name: Native Clang-Tidy
if: matrix.arch == 'x64'
run: bash .github/scripts/native_quality.sh clang-tidy

- name: Native Sanitizer Build
if: matrix.arch == 'x64'
run: bash .github/scripts/native_quality.sh sanitizer-build

- name: Compile GSettings schemas
run: sudo glib-compile-schemas /usr/share/glib-2.0/schemas/

Expand All @@ -96,11 +108,13 @@ jobs:
--configuration Release \
--no-restore \
/p:SolutionDir="${{ github.workspace }}/" \
/p:Platform=${{ matrix.arch }}
/p:Platform=${{ matrix.arch }} \
/p:InfiniFrameNativeTestExports=true

dotnet build InfiniFrame.GitHubActions.Testing.slnf \
--configuration Release \
--no-restore
--no-restore \
/p:InfiniFrameNativeTestExports=true

- name: Verify Native Binaries
uses: ./.github/actions/validate-native-test-binaries
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/shared-testing-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ jobs:
--configuration Release \
--no-restore \
/p:SolutionDir="${{ github.workspace }}/" \
/p:Platform=${{ matrix.arch }}
/p:Platform=${{ matrix.arch }} \
/p:InfiniFrameNativeTestExports=true

- name: Build Release
run: dotnet build InfiniFrame.GitHubActions.Testing.slnf --configuration Release --no-restore
run: dotnet build InfiniFrame.GitHubActions.Testing.slnf --configuration Release --no-restore /p:InfiniFrameNativeTestExports=true

- name: Verify Native Binaries
uses: ./.github/actions/validate-native-test-binaries
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/shared-testing-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ jobs:
--configuration Release `
--no-restore `
-p:SolutionDir="${{ github.workspace }}/" `
-p:Platform=${{ matrix.arch }}
-p:Platform=${{ matrix.arch }} `
-p:InfiniFrameNativeTestExports=true

dotnet build InfiniFrame.GitHubActions.Testing.slnf `
--configuration Release `
--no-restore
--no-restore `
-p:InfiniFrameNativeTestExports=true

- name: Verify Native Binaries
uses: ./.github/actions/validate-native-test-binaries
Expand Down
55 changes: 54 additions & 1 deletion src/InfiniFrame.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")

option(INFINIFRAME_BUILD_TEST_EXPORTS "Build test-only native exports into InfiniFrame.Native" OFF)

if (APPLE)
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "" FORCE)
endif ()
Expand All @@ -31,21 +33,50 @@ infiniframe_setup_dependencies()
# Source Files
# ----------------------------------------------------------------------------------------------------------------------
set(COMMON_SOURCES
Exports.cpp
Interop/Exports.cpp
Interop/Exports.Browser.cpp
Interop/Exports.Dialog.cpp
Interop/Exports.Events.cpp
Interop/Exports.Lifecycle.cpp
Interop/Exports.Memory.cpp
Interop/Exports.Platform.cpp
Interop/Exports.WindowCommands.cpp
)

set(TEST_SOURCES
Exports.Tests.cpp
)

if (NOT INFINIFRAME_BUILD_TEST_EXPORTS)
set(TEST_SOURCES)
endif ()

set(WINDOWS_SOURCES
Platform/Windows/Window.cpp
Platform/Windows/Monitors.Win32.cpp
Platform/Windows/Notifications.WinToast.cpp
Platform/Windows/UiDispatcher.Win32.cpp
Platform/Windows/WindowProc.Win32.cpp
Platform/Windows/WebView2Bridge.Win32.cpp
Platform/Windows/WebView2CustomSchemes.Win32.cpp
Platform/Windows/WebView2Host.Win32.cpp
Platform/Windows/WebView2Messaging.Win32.cpp
Platform/Windows/WebView2ResourceRequests.Win32.cpp
Platform/Windows/WebView2Settings.Win32.cpp
Platform/Windows/DarkMode.cpp
Platform/Windows/Dialog.cpp
)

set(LINUX_SOURCES
Platform/Linux/Window.cpp
Platform/Linux/Monitors.Gtk.cpp
Platform/Linux/Notifications.LibNotify.cpp
Platform/Linux/UiDispatcher.Gtk.cpp
Platform/Linux/WindowState.Gtk.cpp
Platform/Linux/WebKitBridge.Gtk.cpp
Platform/Linux/WebKitCustomSchemes.Gtk.cpp
Platform/Linux/WebKitMessaging.Gtk.cpp
Platform/Linux/WebKitSettings.Gtk.cpp
Platform/Linux/Dialog.cpp
)

Expand All @@ -56,12 +87,26 @@ set(MAC_SOURCES
Platform/Mac/NavigationDelegate.mm
Platform/Mac/UrlSchemeHandler.mm
Platform/Mac/NSWindowBorderless.mm
Platform/Mac/Monitors.Cocoa.mm
Platform/Mac/Notifications.UserNotifications.Cocoa.mm
Platform/Mac/UiDispatcher.Cocoa.mm
Platform/Mac/WKCustomSchemes.Cocoa.mm
Platform/Mac/WKJsInterop.Cocoa.mm
Platform/Mac/WKWebViewBridge.Cocoa.mm
Platform/Mac/WKWebViewSettings.Cocoa.mm
Platform/Mac/WindowState.Cocoa.mm
Platform/Mac/Dialog.mm
Platform/Mac/Window.mm
)

set(HEADER_FILES
Core/InfiniFrame.h
Interop/InitParamsReader.h
Interop/ExportApi.h
Interop/NativeBuffer.h
Interop/NativeResult.h
Interop/NativeString.h
Shared/CustomSchemeResponse.h
Core/InfiniFrameWindow.h
Core/InfiniFrameDialog.h
Embedded/Embedded.h
Expand All @@ -73,12 +118,18 @@ set(HEADER_FILES
Utils/Common.h
Utils/Event.h
Platform/Windows/ToastHandler.h
Platform/Windows/WindowImpl.Win32.h
Platform/Windows/WindowProc.Win32.h
Platform/Windows/WebView2CustomSchemes.Win32.h
Platform/Linux/WindowImpl.Gtk.h
Platform/Linux/WebKitMessaging.Gtk.h
Platform/Windows/DarkMode.h
Platform/Mac/AppDelegate.h
Platform/Mac/NavigationDelegate.h
Platform/Mac/NSWindowBorderless.h
Platform/Mac/UiDelegate.h
Platform/Mac/WindowDelegate.h
Platform/Mac/WindowImpl.Cocoa.h
Platform/Mac/UrlSchemeHandler.h
)

Expand All @@ -96,6 +147,8 @@ if (WIN32)
elseif (APPLE)
infiniframe_configure_macos_target(
${PROJECT_NAME}
"${COMMON_SOURCES}"
"${TEST_SOURCES}"
"${MAC_SOURCES}"
"${HEADER_FILES}"
)
Expand Down
Loading