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.1"9
sigil: "^0.17"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 sokol_app (the app shell comes from the wasm bridge). sigil-app 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-app provides the native sokol_app window/loop + slog_func. It is a56
;; NATIVE-ONLY dep: its C (SOKOL_GLCORE + X11/Cocoa) cannot build for57
;; wasm32-wasi, and on web sigil-graphics needs nothing from it (the app58
;; shell + slog_func come from the wasm path). Config-conditional gating59
;; excludes it from the `web` build.60
(from-git url: "codeberg:sigil/sigil-app" version: "^0.9.0"61
configs: '(dev release windows-amd64))62
;; Web-only: the raw-GLES3 WebGL2 binding. sigil-graphics' web C63
;; (sokol-graphics.c under __wasm__) includes gl_shim.h — propagated here via64
;; sigil-wasm-gles3's c-include-dirs — and its gl* calls resolve to the "gl"65
;; import module the binding provides. This is what makes `sigil build66
;; --config web` first-class (no compile-C-directly / dev-redirect hacks).67
(from-git url: "codeberg:sigil/sigil" package: "sigil-wasm-gles3" version: "^0.17"68
configs: '(web)))70
libraries: (list71
(library72
name: 'sigil-graphics73
c-sources: '("src/c/sokol-graphics.c" "src/c/stb_impl.c"74
"src/c/graphics.c" "src/c/image.c" "src/c/font.c")75
c-include-dirs: '("vendor/sokol" "vendor/stb")76
native-init: "sigil__init_sigil_graphics_module"77
;; Platform-specific linker flags for OpenGL.78
;; Windows: sokol_gfx's GL backend loads opengl32.dll dynamically via79
;; LoadLibraryA + GetProcAddress (kernel32 — linked via sigil-app), so no80
;; extra link libs are needed beyond what sigil-app provides.81
;;82
;; Procedural (lambda ctx) form so cross-compile configs evaluate83
;; the right branch at link time. (case (host-os) ...) was evaluated84
;; once at package-load on the host, leaking `-lGL` into Windows85
;; cross builds.86
link-flags: (lambda (ctx)87
(case (target-os ctx)88
((linux) '("-lGL"))89
((darwin) '("-framework" "OpenGL" "-framework" "Metal" "-framework" "MetalKit"))90
((windows) '())91
(else '())))))93
tasks: (list94
(task95
name: 'build96
description: "Build sigil-graphics"97
steps: (list98
(compile-c-sources99
sources: '("src/c/sokol-graphics.c" "src/c/stb_impl.c"100
"src/c/graphics.c" "src/c/image.c" "src/c/font.c")101
include-dirs: '("vendor/sokol" "vendor/stb")102
;; No -DSOKOL_GLCORE/-DSOKOL_GLES3 here: sokol-graphics.c self-selects103
;; the backend from __wasm__, so this one build task serves both the104
;; native configs and the wasm `web` config.105
flags: (with-sigil-c-flags '("-std=c99" "-D_GNU_SOURCE"106
"-DSOKOL_NO_ENTRY"107
"-Wno-unused-parameter" "-Wno-unused-function" "-Wno-sign-compare")))108
(create-static-library name: "sigil-graphics")109
(compile-sigil-modules sources: "src/**/*.sgl"110
output-dir: (config-output-subdir "lib"))))))