Skip to content

Commit 2f8239d

Browse files
committed
Add RGFW 1.8.1 as an optional modular library
1 parent 91fb27e commit 2f8239d

14 files changed

Lines changed: 373 additions & 9 deletions
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: build-rgfw-modular
2+
on:
3+
workflow_dispatch:
4+
push:
5+
branches: [bleeding, master]
6+
paths-ignore: ['**/*.md']
7+
pull_request:
8+
paths-ignore: ['**/*.md']
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ startsWith(github.ref, 'refs/tags/') && github.run_id || github.event.pull_request.number || github.ref }}
11+
cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/') }}
12+
permissions:
13+
contents: write
14+
actions: read
15+
jobs:
16+
pre-check:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
build_needed: ${{ steps.plan.outputs.build_needed }}
20+
matrix: ${{ steps.plan.outputs.matrix }}
21+
steps:
22+
- uses: actions/checkout@v7.0.1
23+
with:
24+
fetch-depth: 0
25+
- uses: actions/github-script@v9.0.0
26+
id: plan
27+
with:
28+
script: |
29+
await require(`${process.env.GITHUB_WORKSPACE}/scripts/release-build-plan.cjs`).plan({github, context, core, workflow: '.github/workflows/build-rgfw-modular.yml', job: 'build'});
30+
- uses: actions/upload-artifact@v7.0.0
31+
with:
32+
name: build-plan-${{ github.workflow }}
33+
path: .build-plans/*.pkl
34+
include-hidden-files: true
35+
if-no-files-found: error
36+
build:
37+
needs: pre-check
38+
if: needs.pre-check.outputs.build_needed == 'true'
39+
name: RGFW - ${{ matrix.target }} - ${{ matrix.arch }}
40+
runs-on: ${{ matrix.runner }}
41+
strategy:
42+
fail-fast: false
43+
matrix: ${{ fromJSON(needs.pre-check.outputs.matrix) }}
44+
defaults:
45+
run:
46+
shell: bash
47+
env:
48+
TARGET: ${{ matrix.target }}
49+
TYPE: ${{ matrix.target }}
50+
ARCH: ${{ matrix.arch }}
51+
OPTIONAL_ARCHS: ${{ matrix.archs }}
52+
VS_VER: ${{ matrix.vs }}
53+
EMSDK_VERSION: ${{ matrix.emsdk }}
54+
PACKAGE_LIBS: rgfw
55+
FORMULAS_OVERRIDE: rgfw
56+
ALWAYS_BUILD: 1
57+
NO_FORCE: 1
58+
steps:
59+
- uses: msys2/setup-msys2@v2.32.0
60+
if: matrix.target == 'vs' || matrix.target == 'msys2'
61+
with:
62+
release: ${{ matrix.flavor == 'clangarm64' }}
63+
update: true
64+
msystem: ${{ matrix.target == 'msys2' && matrix.flavor || 'MINGW64' }}
65+
install: base-devel git curl unzip
66+
pacboy: cmake:p ninja:p gcc:p
67+
- uses: actions/checkout@v7.0.1
68+
- name: Set up macOS build tools
69+
if: matrix.target == 'osx'
70+
run: bash scripts/apple-install-tools.sh cmake coreutils bash
71+
- name: Set up Emscripten
72+
if: matrix.target == 'emscripten'
73+
run: source scripts/emscripten/setup.sh
74+
- name: Restore compatible binary artifacts
75+
id: baseline
76+
continue-on-error: true
77+
uses: ./.github/actions/platform-artifacts
78+
with:
79+
phase: restore
80+
variant: rgfw-${{ matrix.target }}-${{ matrix.arch }}
81+
archs: ${{ matrix.archs }}
82+
shell: ${{ (matrix.target == 'vs' || matrix.target == 'msys2') && 'msys2 {0}' || 'bash' }}
83+
- name: Build and package RGFW (Windows)
84+
if: matrix.target == 'vs' || matrix.target == 'msys2'
85+
shell: msys2 {0}
86+
run: bash scripts/build-modular-optional.sh
87+
- name: Build and package RGFW (macOS / Emscripten)
88+
if: matrix.target != 'vs' && matrix.target != 'msys2'
89+
run: |
90+
if [ "$TYPE" = emscripten ]; then source "$EMSDK/emsdk_env.sh"; fi
91+
bash scripts/build-modular-optional.sh
92+
- name: Save compatible binary artifacts
93+
if: github.event_name == 'push' && steps.baseline.outcome == 'success'
94+
continue-on-error: true
95+
uses: ./.github/actions/platform-artifacts
96+
with:
97+
phase: save
98+
variant: rgfw-${{ matrix.target }}-${{ matrix.arch }}
99+
archs: ${{ matrix.archs }}
100+
shell: ${{ (matrix.target == 'vs' || matrix.target == 'msys2') && 'msys2 {0}' || 'bash' }}
101+
- name: Upload PR packages for inspection
102+
if: github.event_name == 'pull_request'
103+
uses: actions/upload-artifact@v7.0.0
104+
with:
105+
name: rgfw-${{ matrix.target }}-${{ matrix.arch }}
106+
path: |
107+
out/oF_rgfw_*.zip
108+
out/oF_rgfw_*.tar.bz2
109+
xout/oF_rgfw_*.tar.bz2
110+
if-no-files-found: error
111+
- name: Publish modular archives
112+
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push'
113+
uses: softprops/action-gh-release@v3.0.3
114+
with:
115+
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
116+
tag_name: latest-modular
117+
fail_on_unmatched_files: false
118+
files: |
119+
out/oF_rgfw_*.zip
120+
out/oF_rgfw_*.tar.bz2
121+
xout/oF_rgfw_*.tar.bz2
122+
- name: Download build plans
123+
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push'
124+
uses: actions/download-artifact@v8
125+
with:
126+
name: build-plan-${{ github.workflow }}
127+
path: ${{ runner.temp }}/build-plans
128+
- name: Record verified release metadata
129+
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push'
130+
uses: actions/github-script@v9.0.0
131+
env:
132+
BUILD_PLAN_MATRIX: ${{ toJSON(matrix) }}
133+
with:
134+
github-token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
135+
script: |
136+
await require(`${process.env.GITHUB_WORKSPACE}/scripts/release-build-plan.cjs`).record({github, context, core, workflow: '.github/workflows/build-rgfw-modular.yml', job: 'build', matrix: JSON.parse(process.env.BUILD_PLAN_MATRIX)});

‎.gitignore‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ scripts/linuxarmv6l/firmware-master
3838
scripts/status.txt
3939
*.log
4040
*.xcuserstate
41+
42+
!/.github/workflows/build-rgfw-modular.yml
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
project(rgfw VERSION 1.8.1 LANGUAGES C)
3+
4+
add_library(rgfw STATIC rgfw.c)
5+
target_compile_features(rgfw PUBLIC c_std_99)
6+
target_compile_definitions(rgfw PUBLIC RGFW_OPENGL RGFWDEF=extern)
7+
target_include_directories(rgfw PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>" "$<INSTALL_INTERFACE:include>")
8+
set_target_properties(rgfw PROPERTIES POSITION_INDEPENDENT_CODE ON)
9+
if(EMSCRIPTEN)
10+
# Threading/memory64 are supplied by Apothecary's selected build profile.
11+
elseif(WIN32)
12+
target_link_libraries(rgfw PUBLIC opengl32 gdi32 user32 shell32)
13+
elseif(APPLE)
14+
target_link_libraries(rgfw PUBLIC "-framework Cocoa" "-framework OpenGL" "-framework IOKit" "-framework CoreVideo")
15+
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
16+
find_package(X11 REQUIRED COMPONENTS Xrandr Xcursor Xi Xext)
17+
find_package(OpenGL REQUIRED)
18+
find_package(Threads REQUIRED)
19+
target_link_libraries(rgfw PUBLIC X11::X11 X11::Xrandr X11::Xcursor X11::Xi X11::Xext OpenGL::GL Threads::Threads ${CMAKE_DL_LIBS} m)
20+
else()
21+
message(FATAL_ERROR "RGFW 1.8.1 has no backend for ${CMAKE_SYSTEM_NAME}")
22+
endif()
23+
install(TARGETS rgfw ARCHIVE DESTINATION lib)
24+
install(FILES RGFW.h XDL.h rgfw_apothecary.h DESTINATION include)
25+
install(FILES LICENSE DESTINATION license)

‎apothecary/formulas/rgfw/README.md‎

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# RGFW (optional)
2+
3+
Pinned to upstream RGFW 1.8.1, with its source archive verified by SHA-256.
4+
This formula never joins the core library bundles.
5+
6+
| Target | Backend / packaging |
7+
| --- | --- |
8+
| macOS | Cocoa; x86_64 + arm64 XCFramework |
9+
| Windows MSVC | Win32; x64, ARM64, ARM64EC |
10+
| MSYS2 | Win32; mingw64, ucrt64, clang64, clangarm64 |
11+
| Linux | X11 / GLX; shared GCC10 modular jobs for x86_64 and ARM64 |
12+
| Emscripten | Browser / WebGL; threaded wasm32 and memory64 |
13+
14+
RGFW 1.8.1 does not implement Android, iOS, tvOS, watchOS, visionOS or
15+
Mac Catalyst window backends. Do not substitute a desktop backend or ship an
16+
empty archive for these targets. Wayland is experimental upstream and this
17+
release does not include the protocol headers needed to build it; the Linux
18+
package uses X11 (including XWayland on a Wayland desktop).
19+
20+
Build explicitly, for example:
21+
22+
```sh
23+
TYPE=osx ARCH=arm64 NO_COLOR=1 UI_ANIM=0 ./apo update rgfw
24+
TYPE=linux ARCH=64 GCC_VERSION=10 NO_COLOR=1 UI_ANIM=0 ./apo update rgfw
25+
```
26+
27+
Use `#include <rgfw_apothecary.h>` when linking the precompiled library. The
28+
wrapper enables `RGFW_OPENGL`, uses external API declarations instead of the
29+
upstream inline default, and supplies C linkage for C++ consumers. Do **not**
30+
define `RGFW_IMPLEMENTATION` when linking the archive. The original `RGFW.h`
31+
and `XDL.h` are also shipped unchanged for upstream single-header use.
32+
33+
The library provides windowing and OpenGL context helpers, not an
34+
openFrameworks window backend. Applications still need an explicit integration.
35+
36+
Packages include the license and per-binary Pkl metadata. Raw staged libraries
37+
and non-Apple modular packages also include relocatable `cmake/rgfwConfig.cmake`
38+
(`apothecary::rgfw`) and `pkgconfig/rgfw.pc` files. The CMake target and
39+
`pkg-config --static` carry native link dependencies.
40+
For Emscripten, consumers must use the same pthread/memory-width flags as the
41+
selected archive. macOS consumers should link the XCFramework's matching slice.
42+
43+
Linux is built with the shared Linux modular job. Other supported targets use
44+
`build-rgfw-modular.yml`, which plans builds on Linux before starting native
45+
runners, restores compatible artifacts, publishes archives only on trusted
46+
pushes, and records verified per-configuration Pkl records on `build-state`.
47+
PR builds upload inspectable Actions artifacts without changing releases.

‎apothecary/formulas/rgfw/rgfw.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* Apothecary's static implementation of the unmodified upstream header. */
2+
#define RGFW_IMPLEMENTATION
3+
#include "rgfw_apothecary.h"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
prefix=${pcfiledir}/../../../..
2+
libdir=${pcfiledir}/..
3+
includedir=${prefix}/include
4+
Name: rgfw
5+
Description: Riley's General Framework for Windowing (OpenGL helpers)
6+
Version: @VERSION@
7+
Libs: -L${libdir} -lrgfw
8+
Libs.private: @PRIVATE_LIBS@
9+
Cflags: -I${includedir} -DRGFW_OPENGL -DRGFWDEF=extern

‎apothecary/formulas/rgfw/rgfw.sh‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
# Optional RGFW windowing library. Upstream has no mobile Apple/Android backend.
3+
FORMULA_TYPES=("osx" "vs" "msys2" "linux" "emscripten")
4+
FORMULA_DEPENDS=()
5+
VER=1.8.1
6+
BUILD_ID=1
7+
SHA256="39f9dc8f89e86926fe2be4ffd6cdc877c1e7d179e24e3c803389ece50d6aef60"
8+
GIT_URL=https://github.com/ColleagueRiley/RGFW
9+
GIT_TAG=$VER
10+
DEFINES="-DRGFW_OPENGL -DRGFWDEF=extern -DBUILD_SHARED_LIBS=OFF"
11+
12+
function download() {
13+
. "$DOWNLOADER_SCRIPT"
14+
downloader "${GIT_URL}/archive/refs/tags/${VER}.tar.gz"
15+
verify_sha256 "${VER}.tar.gz" "$SHA256" || return 1
16+
mkdir -p rgfw
17+
tar -xf "${VER}.tar.gz" -C rgfw --strip-components=1 || return 1
18+
rm "${VER}.tar.gz"
19+
}
20+
21+
function prepare() {
22+
cp "$FORMULA_DIR/CMakeLists.txt" "$FORMULA_DIR/rgfw.c" "$FORMULA_DIR/rgfw_apothecary.h" .
23+
}
24+
25+
function build() {
26+
local bdir="build_${TYPE}_${PLATFORM}" args=()
27+
args+=(-DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX="$(pwd)/$bdir/Release" -DCMAKE_C_STANDARD="${C_STANDARD:-17}")
28+
case "$TYPE" in
29+
osx)
30+
args+=(-DCMAKE_TOOLCHAIN_FILE="$APOTHECARY_DIR/toolchains/ios.toolchain.cmake"
31+
-DPLATFORM="$PLATFORM" -DDEPLOYMENT_TARGET="$MIN_SDK_VER"
32+
-DENABLE_BITCODE=OFF -DENABLE_ARC=OFF -DCMAKE_C_FLAGS="${FLAG_RELEASE:-}")
33+
;;
34+
vs)
35+
args+=(-G "Visual Studio ${VS_VER_GEN}" -A "$PLATFORM"
36+
-DCMAKE_C_FLAGS_RELEASE="${VS_C_FLAGS:-} ${FLAGS_RELEASE:-} ${EXCEPTION_FLAGS:-}")
37+
;;
38+
msys2) args+=(-G Ninja -DCMAKE_C_FLAGS="${FLAG_RELEASE:-}") ;;
39+
linux)
40+
if [ "${CROSSCOMPILING:-0}" = 1 ]; then
41+
. "$APOTHECARY_DIR/configure/${TYPE}${PLATFORM}_configure.sh" "$ABI"
42+
fi
43+
args+=(-DCMAKE_TOOLCHAIN_FILE="$APOTHECARY_DIR/toolchains/linux${PLATFORM}.toolchain.cmake"
44+
-DGCC_VERSION="${GCC_VERSION:-10}" -DCMAKE_C_FLAGS="${FLAG_RELEASE:-} ${CFLAGS:-}")
45+
;;
46+
emscripten)
47+
local memory64=0
48+
[ "$ARCH" != 64 ] || memory64=1
49+
args+=(-DCMAKE_TOOLCHAIN_FILE="$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
50+
-DCMAKE_C_FLAGS="${FLAG_RELEASE:-} -sMEMORY64=$memory64")
51+
;;
52+
*) echo "RGFW has no backend for TYPE=$TYPE" >&2; return 1 ;;
53+
esac
54+
cmake -S . -B "$bdir" "${args[@]}" || return 1
55+
cmake --build "$bdir" --config Release --target install --parallel "${PARALLEL_MAKE:-2}"
56+
}
57+
58+
function copy() {
59+
local prefix="build_${TYPE}_${PLATFORM}/Release" rgfw_binary=librgfw.a
60+
[ "$TYPE" != vs ] || rgfw_binary=rgfw.lib
61+
local libdir="$1/lib/$TYPE/$PLATFORM"
62+
mkdir -p "$1/include" "$1/license" "$libdir/cmake" "$libdir/pkgconfig"
63+
cp "$prefix/include/"*.h "$1/include/" || return 1
64+
cp "$prefix/license/LICENSE" "$1/license/" || return 1
65+
cp "$prefix/lib/$rgfw_binary" "$libdir/$rgfw_binary" || return 1
66+
cp "$FORMULA_DIR/rgfwConfig.cmake" "$libdir/cmake/rgfwConfig.cmake"
67+
local private_libs=""
68+
case "$TYPE" in
69+
osx) private_libs="-framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo" ;;
70+
vs|msys2) private_libs="-lopengl32 -lgdi32 -luser32 -lshell32" ;;
71+
linux) private_libs="-lX11 -lXrandr -lXcursor -lXi -lXext -lGL -ldl -lpthread -lm" ;;
72+
esac
73+
sed -e "s/@VERSION@/$VER/g" -e "s/@PRIVATE_LIBS@/$private_libs/g" \
74+
"$FORMULA_DIR/rgfw.pc.in" > "$libdir/pkgconfig/rgfw.pc"
75+
local CXX
76+
CXX=$(sed -n 's/^set(CMAKE_C_COMPILER "\([^"]*\)")/\1/p' \
77+
build_${TYPE}_${PLATFORM}/CMakeFiles/*/CMakeCCompiler.cmake | head -n 1)
78+
. "$SECURE_SCRIPT"
79+
secure "$libdir/$rgfw_binary" rgfw.pkl "$VER" "$DEFINES" "$BUILD_ID" "$FORMULA_DEPENDS" "$SHA256"
80+
}
81+
82+
function clean() { cmake --build "build_${TYPE}_${PLATFORM}" --target clean; }
83+
function load() {
84+
. "$LOAD_SCRIPT"
85+
loadsave "$TYPE" rgfw "$ARCH" "$VER" "$LIBS_DIR_REAL/rgfw/lib/$TYPE/$PLATFORM" "$BUILD_ID" | tail -n 1
86+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Relocatable configuration for the Apothecary staging layout.
2+
if(TARGET apothecary::rgfw)
3+
return()
4+
endif()
5+
get_filename_component(_rgfw_prefix "${CMAKE_CURRENT_LIST_DIR}/../../../.." ABSOLUTE)
6+
find_library(_rgfw_library NAMES rgfw PATHS "${CMAKE_CURRENT_LIST_DIR}/.." NO_DEFAULT_PATH REQUIRED)
7+
add_library(apothecary::rgfw STATIC IMPORTED)
8+
set_target_properties(apothecary::rgfw PROPERTIES IMPORTED_LOCATION "${_rgfw_library}"
9+
INTERFACE_INCLUDE_DIRECTORIES "${_rgfw_prefix}/include" INTERFACE_COMPILE_DEFINITIONS "RGFW_OPENGL;RGFWDEF=extern")
10+
if(EMSCRIPTEN)
11+
elseif(WIN32)
12+
set_property(TARGET apothecary::rgfw PROPERTY INTERFACE_LINK_LIBRARIES opengl32 gdi32 user32 shell32)
13+
elseif(APPLE)
14+
set_property(TARGET apothecary::rgfw PROPERTY INTERFACE_LINK_LIBRARIES "-framework Cocoa;-framework OpenGL;-framework IOKit;-framework CoreVideo")
15+
else()
16+
include(CMakeFindDependencyMacro)
17+
find_dependency(X11 COMPONENTS Xrandr Xcursor Xi Xext)
18+
find_dependency(OpenGL)
19+
find_dependency(Threads)
20+
set_property(TARGET apothecary::rgfw PROPERTY INTERFACE_LINK_LIBRARIES "X11::X11;X11::Xrandr;X11::Xcursor;X11::Xi;X11::Xext;OpenGL::GL;Threads::Threads;${CMAKE_DL_LIBS};m")
21+
endif()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Include this wrapper when linking Apothecary's precompiled RGFW library.
2+
* Do not define RGFW_IMPLEMENTATION in an application linking librgfw. */
3+
#ifndef APOTHECARY_RGFW_H
4+
#define APOTHECARY_RGFW_H
5+
#ifndef RGFW_OPENGL
6+
#define RGFW_OPENGL
7+
#endif
8+
#ifndef RGFWDEF
9+
#define RGFWDEF extern
10+
#endif
11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
#include "RGFW.h"
15+
#ifdef __cplusplus
16+
}
17+
#endif
18+
#endif

‎scripts/build-matrices.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,8 @@
199199
"libssh2",
200200
"curl",
201201
"poco",
202-
"dawn"
202+
"dawn",
203+
"rgfw"
203204
],
204205
"arch": [
205206
"64",

0 commit comments

Comments
 (0)