Skip to content

Commit 92a301c

Browse files
committed
feat: support inline modules, refactor ci
1 parent 5969055 commit 92a301c

6 files changed

Lines changed: 103 additions & 74 deletions

File tree

.github/workflows/build.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
type: string
77
default: master
88
description: The ref of saucer to use
9+
cmake:
10+
type: string
11+
default: -Dsaucer_bindings_static=ON -Dsaucer_bindings_modules="desktop;loop" -Dsaucer_bindings_inline_modules="desktop;loop"
12+
description: Additional CMake Arguments to pass
913

1014
name: 🏗️ Build Bindings
1115

@@ -15,7 +19,7 @@ jobs:
1519
fail-fast: false
1620

1721
matrix:
18-
backend: [WebKit, WebKitGtk, WebView2, WebView2-Rfl, WebView2-Hack, WebView2-Hack-Rfl, Qt]
22+
backend: [WebKit, WebKit-Universal, WebKitGtk, WebView2, WebView2-Hack, Qt]
1923
config: [Debug, Release, RelWithDebInfo, MinSizeRel]
2024

2125
include:
@@ -30,18 +34,6 @@ jobs:
3034
os: windows-latest
3135
cmake-args: -Dsaucer_msvc_hack=ON -Dglaze_DISABLE_SIMD_WHEN_SUPPORTED=ON
3236

33-
- backend: WebView2-Rfl
34-
backend-override: WebView2
35-
platform: Windows
36-
os: windows-latest
37-
cmake-args: -Dsaucer_serializer=Rflpp
38-
39-
- backend: WebView2-Hack-Rfl
40-
backend-override: WebView2
41-
platform: Windows
42-
os: windows-latest
43-
cmake-args: -Dsaucer_msvc_hack=ON -Dsaucer_serializer=Rflpp
44-
4537
- backend: Qt
4638
platform: Linux
4739
os: ubuntu-latest
@@ -58,9 +50,15 @@ jobs:
5850
platform: MacOS
5951
os: macos-latest
6052

53+
- backend: WebKit-Universal
54+
backend-override: WebKit
55+
platform: MacOS
56+
os: macos-latest
57+
cmake-args: -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"
58+
6159
runs-on: ${{ matrix.os }}
6260
container: ${{ matrix.container }}
63-
name: bindings-${{ matrix.backend }}-${{ matrix.config }}
61+
name: ${{ matrix.config}}-${{ matrix.backend }}
6462

6563
steps:
6664
- name: 📥 Checkout
@@ -80,10 +78,10 @@ jobs:
8078
backend: ${{ matrix.backend-override || matrix.backend }}
8179
platform: ${{ matrix.platform }}
8280
build-type: ${{ matrix.config }}
83-
cmake-args: ${{ matrix.cmake-args }}
81+
cmake-args: -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=saucer-bin -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=saucer-bin ${{ matrix.cmake-args }} ${{ github.event.inputs.cmake }}
8482

8583
- name: 📦 Upload Artifact
8684
uses: actions/upload-artifact@v4
8785
with:
88-
name: Binding (${{ matrix.backend }}-${{ matrix.config }})
89-
path: build
86+
name: "${{ matrix.config }}: ${{ matrix.backend }}"
87+
path: build/saucer-bin

CMakeLists.txt

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,56 @@
11
cmake_minimum_required(VERSION 3.21)
2-
project(saucer-bindings LANGUAGES CXX VERSION 8.0.2)
2+
project(saucer-bindings LANGUAGES CXX VERSION 8.0.3)
33

44
# +-------------------------------------------------------------------------------------------------------+
55
# | Library switches |
66
# +-------------------------------------------------------------------------------------------------------+
77

8-
option(saucer_desktop "Enable support for the desktop module" ON)
9-
option(saucer_pdf "Enable support for the pdf module" ON)
10-
option(saucer_loop "Enable support for the loop module" ON)
8+
option(saucer_bindings_static "Build saucer as a static library" OFF)
9+
10+
# +-------------------------------------------------------------------------------------------------------+
11+
# | Library options |
12+
# +-------------------------------------------------------------------------------------------------------+
13+
14+
set(saucer_bindings_modules "desktop;pdf;loop" CACHE STRING "A list of modules to build")
15+
set(saucer_bindings_inline_modules "" CACHE STRING "A list of modules to inline into the built library")
16+
17+
# +-------------------------------------------------------------------------------------------------------+
18+
# | Convenience wrapper over `message` |
19+
# +-------------------------------------------------------------------------------------------------------+
20+
21+
function(bindings_message LEVEL MESSAGE)
22+
message(${LEVEL} "saucer-bindings: ${MESSAGE}")
23+
endfunction()
24+
25+
# +-------------------------------------------------------------------------------------------------------+
26+
# | Ensure valid library options |
27+
# +-------------------------------------------------------------------------------------------------------+
28+
29+
set(saucer_bindings_valid_modules desktop pdf loop)
30+
31+
set_property(CACHE saucer_bindings_modules PROPERTY STRINGS ${saucer_bindings_valid_modules})
32+
set_property(CACHE saucer_bindings_inline_modules PROPERTY STRINGS ${saucer_bindings_valid_modules})
33+
34+
foreach (value IN LISTS saucer_bindings_modules)
35+
if (value IN_LIST saucer_bindings_valid_modules)
36+
continue()
37+
endif()
38+
39+
bindings_message(FATAL_ERROR "Bad module (${value}) expected one or multiple of ${saucer_bindings_valid_modules}")
40+
endforeach()
41+
42+
foreach (value IN LISTS saucer_bindings_inline_modules)
43+
if (value IN_LIST saucer_bindings_valid_modules)
44+
continue()
45+
endif()
46+
47+
bindings_message(FATAL_ERROR "Bad inline module (${value}) expected one or multiple of ${saucer_bindings_valid_modules}")
48+
endforeach()
49+
50+
if (saucer_bindings_static)
51+
bindings_message(WARNING "Building saucer as static library...")
52+
bindings_message(WARNING "This is not recommended as it can lead to duplicated symbols!")
53+
endif()
1154

1255
# +-------------------------------------------------------------------------------------------------------+
1356
# | CMake options |
@@ -82,9 +125,9 @@ include("cmake/cpm.cmake")
82125

83126
CPMFindPackage(
84127
NAME saucer
85-
VERSION 8.0.2
128+
VERSION 8.0.3
86129
GIT_REPOSITORY "https://github.com/saucer/saucer"
87-
OPTIONS "saucer_static OFF" "CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON"
130+
OPTIONS "saucer_static ${saucer_bindings_static}" "CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON"
88131
)
89132

90133
target_link_libraries(${PROJECT_NAME} PUBLIC saucer::saucer saucer::private)
@@ -107,14 +150,7 @@ endif()
107150

108151
include("cmake/module.cmake")
109152

110-
if (saucer_desktop)
111-
add_subdirectory("modules/desktop")
112-
endif()
153+
foreach(module IN LISTS saucer_bindings_modules)
154+
add_subdirectory("modules/${module}")
155+
endforeach()
113156

114-
if (saucer_pdf)
115-
add_subdirectory("modules/pdf")
116-
endif()
117-
118-
if (saucer_loop)
119-
add_subdirectory("modules/loop")
120-
endif()

cmake/module.cmake

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1+
cmake_policy(SET CMP0140 NEW)
2+
13
function(saucer_bindings_add_module NAME MACRO)
2-
message(STATUS "[saucer-bindings] Adding module: ${NAME}")
4+
set(MODULE_NAME "saucer-bindings-${NAME}")
5+
set(MODULE_ALIAS "saucer::bindings::${NAME}")
6+
7+
if ("${NAME}" IN_LIST saucer_bindings_inline_modules)
8+
add_library(${MODULE_NAME} OBJECT)
9+
target_sources(${PROJECT_NAME} PRIVATE $<TARGET_OBJECTS:${MODULE_NAME}>)
10+
else()
11+
add_library(${MODULE_NAME} MODULE)
12+
target_link_libraries(${MODULE_NAME} PUBLIC ${PROJECT_NAME})
13+
endif()
14+
15+
add_library(${MODULE_ALIAS} ALIAS ${MODULE_NAME})
16+
17+
target_compile_features(${MODULE_NAME} PRIVATE cxx_std_23)
18+
set_target_properties(${MODULE_NAME} PROPERTIES CXX_STANDARD 23 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON)
319

4-
saucer_bindings_hide_symbols(${NAME})
5-
saucer_bindings_export(${NAME} ${MACRO})
20+
saucer_bindings_hide_symbols(${MODULE_NAME})
21+
saucer_bindings_export(${MODULE_NAME} ${MACRO})
622

723
get_target_property(priv_includes saucer::bindings INCLUDE_DIRECTORIES)
24+
target_include_directories(${MODULE_NAME} PRIVATE ${priv_includes})
825

9-
target_link_libraries(${NAME} PUBLIC saucer::bindings)
10-
target_include_directories(${NAME} PRIVATE ${priv_includes})
26+
return(PROPAGATE MODULE_NAME)
1127
endfunction()

modules/desktop/CMakeLists.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
project(saucer-bindings-desktop LANGUAGES CXX VERSION 8.0.0)
2-
31
# --------------------------------------------------------------------------------------------------------
42
# Setup library
53
# --------------------------------------------------------------------------------------------------------
64

7-
add_library(${PROJECT_NAME} SHARED)
8-
add_library(saucer::bindings::desktop ALIAS ${PROJECT_NAME})
9-
10-
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_23)
11-
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 23 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON)
5+
saucer_bindings_add_module(desktop "SAUCER_DESKTOP_EXPORT")
126

137
# --------------------------------------------------------------------------------------------------------
148
# Include directories
159
# --------------------------------------------------------------------------------------------------------
1610

17-
target_include_directories(${PROJECT_NAME} PUBLIC "include")
18-
target_include_directories(${PROJECT_NAME} PRIVATE "include/saucer")
11+
target_include_directories(${MODULE_NAME} PUBLIC "include")
12+
target_include_directories(${MODULE_NAME} PRIVATE "include/saucer")
1913

2014
# --------------------------------------------------------------------------------------------------------
2115
# Add Sources
2216
# --------------------------------------------------------------------------------------------------------
2317

24-
target_sources(${PROJECT_NAME} PRIVATE
18+
target_sources(${MODULE_NAME} PRIVATE
2519
"src/desktop.cpp"
2620
)
2721

@@ -35,5 +29,4 @@ CPMFindPackage(
3529
GIT_REPOSITORY "https://github.com/saucer/desktop"
3630
)
3731

38-
target_link_libraries(${PROJECT_NAME} PRIVATE saucer::desktop)
39-
saucer_bindings_add_module(${PROJECT_NAME} "SAUCER_DESKTOP_EXPORT")
32+
target_link_libraries(${MODULE_NAME} PRIVATE saucer::desktop)

modules/loop/CMakeLists.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
project(saucer-bindings-loop LANGUAGES CXX VERSION 8.0.0)
2-
31
# --------------------------------------------------------------------------------------------------------
42
# Setup library
53
# --------------------------------------------------------------------------------------------------------
64

7-
add_library(${PROJECT_NAME} SHARED)
8-
add_library(saucer::bindings::loop ALIAS ${PROJECT_NAME})
9-
10-
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_23)
11-
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 23 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON)
5+
saucer_bindings_add_module(loop "SAUCER_LOOP_EXPORT")
126

137
# --------------------------------------------------------------------------------------------------------
148
# Include directories
159
# --------------------------------------------------------------------------------------------------------
1610

17-
target_include_directories(${PROJECT_NAME} PUBLIC "include")
18-
target_include_directories(${PROJECT_NAME} PRIVATE "include/saucer")
11+
target_include_directories(${MODULE_NAME} PUBLIC "include")
12+
target_include_directories(${MODULE_NAME} PRIVATE "include/saucer")
1913

2014
# --------------------------------------------------------------------------------------------------------
2115
# Add Sources
2216
# --------------------------------------------------------------------------------------------------------
2317

24-
target_sources(${PROJECT_NAME} PRIVATE
18+
target_sources(${MODULE_NAME} PRIVATE
2519
"src/loop.cpp"
2620
)
2721

@@ -35,5 +29,4 @@ CPMFindPackage(
3529
GIT_REPOSITORY "https://github.com/saucer/loop"
3630
)
3731

38-
target_link_libraries(${PROJECT_NAME} PRIVATE saucer::loop)
39-
saucer_bindings_add_module(${PROJECT_NAME} "SAUCER_LOOP_EXPORT")
32+
target_link_libraries(${MODULE_NAME} PRIVATE saucer::loop)

modules/pdf/CMakeLists.txt

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,21 @@
1-
project(saucer-bindings-pdf LANGUAGES CXX VERSION 8.0.0)
2-
31
# --------------------------------------------------------------------------------------------------------
42
# Setup library
53
# --------------------------------------------------------------------------------------------------------
64

7-
add_library(${PROJECT_NAME} SHARED)
8-
add_library(saucer::bindings::pdf ALIAS ${PROJECT_NAME})
9-
10-
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_23)
11-
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 23 CXX_EXTENSIONS OFF CXX_STANDARD_REQUIRED ON)
5+
saucer_bindings_add_module(pdf "SAUCER_PDF_EXPORT")
126

137
# --------------------------------------------------------------------------------------------------------
148
# Include directories
159
# --------------------------------------------------------------------------------------------------------
1610

17-
target_include_directories(${PROJECT_NAME} PUBLIC "include")
18-
target_include_directories(${PROJECT_NAME} PRIVATE "include/saucer")
11+
target_include_directories(${MODULE_NAME} PUBLIC "include")
12+
target_include_directories(${MODULE_NAME} PRIVATE "include/saucer")
1913

2014
# --------------------------------------------------------------------------------------------------------
2115
# Add Sources
2216
# --------------------------------------------------------------------------------------------------------
2317

24-
target_sources(${PROJECT_NAME} PRIVATE
18+
target_sources(${MODULE_NAME} PRIVATE
2519
"src/pdf.cpp"
2620
)
2721

@@ -35,5 +29,4 @@ CPMFindPackage(
3529
GIT_REPOSITORY "https://github.com/saucer/pdf"
3630
)
3731

38-
target_link_libraries(${PROJECT_NAME} PRIVATE saucer::pdf)
39-
saucer_bindings_add_module(${PROJECT_NAME} "SAUCER_PDF_EXPORT")
32+
target_link_libraries(${MODULE_NAME} PRIVATE saucer::pdf)

0 commit comments

Comments
 (0)