AtlatestRepositorysigil-graphics

sigil-graphics / treepackage.sgl

1;;; sigil-graphics - 2D graphics for Sigil
2;;;
3;;; Provides 2D rendering capabilities via sokol_gfx and sokol_gp.
4;;; Includes image loading (stb_image) and font rendering (stb_truetype).
5
6(package
7 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: (list
16 (config
17 name: 'dev
18 output-dir: "build/dev"
19 debug?: #t
20 optimize: 0)
21 (config
22 name: 'release
23 output-dir: "build/release"
24 debug?: #f
25 optimize: 2)
27 ;; Windows x86_64 (MinGW via zig) — built so downstream consumers
28 ;; (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 (config
31 name: 'windows-amd64
32 output-dir: "build/windows-amd64"
33 toolchain: 'zig
34 target: "x86_64-windows-gnu"
35 static?: #t
36 debug?: #f
37 optimize: 2
38 features: '(release cross windows))
40 ;; Web (wasm32-wasi): the first-class graphics-on-web build. sokol_gfx's
41 ;; 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 is
43 ;; excluded from this config's deps (config-conditional gating); the sokol
44 ;; backend is self-selected in sokol-graphics.c via __wasm__.
45 (config
46 name: 'web
47 output-dir: "build/web"
48 toolchain: 'zig
49 target: "wasm32-wasi"
50 debug?: #f
51 optimize: 2
52 features: '(web wasm graphics)))
54 dependencies: (list
55 ;; sigil-app provides the native sokol_app window/loop + slog_func. It is a
56 ;; NATIVE-ONLY dep: its C (SOKOL_GLCORE + X11/Cocoa) cannot build for
57 ;; wasm32-wasi, and on web sigil-graphics needs nothing from it (the app
58 ;; shell + slog_func come from the wasm path). Config-conditional gating
59 ;; 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 C
63 ;; (sokol-graphics.c under __wasm__) includes gl_shim.h — propagated here via
64 ;; 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 build
66 ;; --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: (list
71 (library
72 name: 'sigil-graphics
73 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 via
79 ;; LoadLibraryA + GetProcAddress (kernel32 — linked via sigil-app), so no
80 ;; extra link libs are needed beyond what sigil-app provides.
81 ;;
82 ;; Procedural (lambda ctx) form so cross-compile configs evaluate
83 ;; the right branch at link time. (case (host-os) ...) was evaluated
84 ;; once at package-load on the host, leaking `-lGL` into Windows
85 ;; 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: (list
94 (task
95 name: 'build
96 description: "Build sigil-graphics"
97 steps: (list
98 (compile-c-sources
99 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-selects
103 ;; the backend from __wasm__, so this one build task serves both the
104 ;; 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"))))))