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.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: (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 window package (the app shell comes from the wasm bridge). sigil-desktop 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-desktop (the package named sigil-app through 0.9.x; the repo is
56 ;; being renamed in place on Codeberg, the old URL redirects) provides
57 ;; the window and GL context (GLFW) and the C surface this package
58 ;; builds its swapchain and GL loader on (include/sigil-desktop.h). It
59 ;; is a NATIVE-ONLY dep: its C cannot build for wasm32-wasi, and on web
60 ;; sigil-graphics needs nothing from it (the app shell comes from the
61 ;; wasm path). Config-conditional gating excludes it from `web`.
62 ;; name: is needed while the URL still says sigil-app: sigil-build derives
63 ;; 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 C
67 ;; (sokol-graphics.c under __wasm__) includes gl_shim.h — propagated here via
68 ;; 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 build
70 ;; --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: (list
75 (library
76 name: 'sigil-graphics
77 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 through
84 ;; sigil-desktop's proc loader (GLFW's glfwGetProcAddress) into
85 ;; gl_native_loader.h's pointers, and GLFW dlopens libGL / libEGL /
86 ;; opengl32.dll itself, so nothing GL-related is linked (was -lGL on
87 ;; Linux). Darwin: OpenGL.framework stays so GLFW's NSGL finds the
88 ;; bundle loaded (CFBundleGetBundleWithIdentifier); Metal and MetalKit
89 ;; are gone, nothing here is Metal (no macOS build has run yet).
90 ;;
91 ;; Procedural (lambda ctx) form so cross-compile configs evaluate
92 ;; the right branch at link time. (case (host-os) ...) was evaluated
93 ;; once at package-load on the host, leaking `-lGL` into Windows
94 ;; 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: (list
103 (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: (list
107 (task
108 name: 'build
109 description: "Build sigil-graphics"
110 steps: (list
111 (compile-c-sources
112 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-selects
116 ;; the backend from __wasm__, so this one build task serves both the
117 ;; 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"))))))