AtlatestRepositorysigil-graphics
sigil-graphics / treepackage.sgl
1
;;; sigil-graphics - 2D graphics for Sigil2
;;;3
;;; Provides 2D rendering capabilities via sokol_gfx and sokol_gp.4
;;; Includes image loading (stb_image) and font rendering (stb_truetype).6
(package7
name: "sigil-graphics"8
version: "0.11.4"9
sigil: "0.20"10
description: "2D graphics, image loading, and font rendering for Sigil"11
url: "https://codeberg.org/sigil/sigil-graphics"12
license: "BSD-3-Clause"13
authors: (list "David Wilson <[email protected]>")15
configs: (list16
(config17
name: 'dev18
output-dir: "build/dev"19
debug?: #t20
optimize: 0)21
(config22
name: 'release23
output-dir: "build/release"24
debug?: #f25
optimize: 2)27
;; Windows x86_64 (MinGW via zig) — built so downstream consumers28
;; (e.g., cinder-cantata) can produce Windows binaries from Linux.29
;; Mirrors the windows-amd64 config in sigil-audio and the main sigil package.30
(config31
name: 'windows-amd6432
output-dir: "build/windows-amd64"33
toolchain: 'zig34
target: "x86_64-windows-gnu"35
static?: #t36
debug?: #f37
optimize: 238
features: '(release cross windows))40
;; Web (wasm32-wasi): the first-class graphics-on-web build. sokol_gfx's41
;; GLES3 backend over the sigil-wasm-gles3 raw-WebGL2 binding, no Emscripten,42
;; no window package (the app shell comes from the wasm bridge). sigil-desktop is43
;; excluded from this config's deps (config-conditional gating); the sokol44
;; backend is self-selected in sokol-graphics.c via __wasm__.45
(config46
name: 'web47
output-dir: "build/web"48
toolchain: 'zig49
target: "wasm32-wasi"50
debug?: #f51
optimize: 252
features: '(web wasm graphics)))54
dependencies: (list55
;; sigil-desktop (the package named sigil-app through 0.9.x; the repo is56
;; being renamed in place on Codeberg, the old URL redirects) provides57
;; the window and GL context (GLFW) and the C surface this package58
;; builds its swapchain and GL loader on (include/sigil-desktop.h). It59
;; is a NATIVE-ONLY dep: its C cannot build for wasm32-wasi, and on web60
;; sigil-graphics needs nothing from it (the app shell comes from the61
;; wasm path). Config-conditional gating excludes it from `web`.62
;; name: is needed while the URL still says sigil-app: sigil-build derives63
;; the dependency name from the URL and looks the package up by it.64
(from-git url: "codeberg:sigil/sigil-app" name: "sigil-desktop" version: "^0.10.0"65
configs: '(dev release windows-amd64))66
;; Web-only: the raw-GLES3 WebGL2 binding. sigil-graphics' web C67
;; (sokol-graphics.c under __wasm__) includes gl_shim.h — propagated here via68
;; sigil-wasm-gles3's c-include-dirs — and its gl* calls resolve to the "gl"69
;; import module the binding provides. This is what makes `sigil build70
;; --config web` first-class (no compile-C-directly / dev-redirect hacks).71
(from-git url: "codeberg:sigil/sigil" package: "sigil-wasm-gles3" version: ">=0.21"72
configs: '(web)))74
libraries: (list75
(library76
name: 'sigil-graphics77
c-sources: '("src/c/sokol-graphics.c" "src/c/stb_impl.c"78
"src/c/graphics.c" "src/c/image.c" "src/c/font.c")79
c-include-dirs: '("vendor/sokol" "vendor/stb")80
native-init: "sigil__init_sigil_graphics_module"81
;; Platform linker flags.82
;;83
;; Linux and Windows: none. GL entry points are loaded through84
;; sigil-desktop's proc loader (GLFW's glfwGetProcAddress) into85
;; gl_native_loader.h's pointers, and GLFW dlopens libGL / libEGL /86
;; opengl32.dll itself, so nothing GL-related is linked (was -lGL on87
;; Linux). Darwin: OpenGL.framework stays so GLFW's NSGL finds the88
;; bundle loaded (CFBundleGetBundleWithIdentifier); Metal and MetalKit89
;; are gone, nothing here is Metal (no macOS build has run yet).90
;;91
;; Procedural (lambda ctx) form so cross-compile configs evaluate92
;; the right branch at link time. (case (host-os) ...) was evaluated93
;; once at package-load on the host, leaking `-lGL` into Windows94
;; cross builds.95
link-flags: (lambda (ctx)96
(case (target-os ctx)97
((linux) '())98
((darwin) '("-framework" "OpenGL"))99
((windows) '())100
(else '())))))102
dev-dependencies: (list103
(from-git url: "codeberg:sigil/sigil" package: "sigil-test" version: ">=0.21")104
(from-git url: "codeberg:sigil/sigil" package: "sigil-test-runner" version: ">=0.21"))106
tasks: (list107
(task108
name: 'build109
description: "Build sigil-graphics"110
steps: (list111
(compile-c-sources112
sources: '("src/c/sokol-graphics.c" "src/c/stb_impl.c"113
"src/c/graphics.c" "src/c/image.c" "src/c/font.c")114
include-dirs: '("vendor/sokol" "vendor/stb")115
;; No -DSOKOL_GLCORE/-DSOKOL_GLES3 here: sokol-graphics.c self-selects116
;; the backend from __wasm__, so this one build task serves both the117
;; native configs and the wasm `web` config.118
flags: (with-sigil-c-flags '("-std=c99" "-D_GNU_SOURCE"119
"-DSOKOL_NO_ENTRY"120
"-Wno-unused-parameter" "-Wno-unused-function" "-Wno-sign-compare")))121
(create-static-library name: "sigil-graphics")122
(compile-sigil-modules sources: "src/**/*.sgl"123
output-dir: (config-output-subdir "lib"))))))