comparison infinite_canvas/BUILD @ 276:b55c22cff335

Add interactive infinite canvas prototype
author MrJuneJune <me@mrjunejune.com>
date Mon, 17 Aug 2026 16:57:56 -0700
parents
children 8d560f50ed4c
comparison
equal deleted inserted replaced
274:c9be578316a6 276:b55c22cff335
1 load("@emsdk//emscripten_toolchain:wasm_rules.bzl", "wasm_cc_binary")
2 load("@rules_cc//cc:cc_library.bzl", "cc_library")
3 load("@rules_cc//cc:cc_test.bzl", "cc_test")
4 load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
5 load("//gui_ze:gui_ze.bzl", "move_files_into_dir")
6 load("//third_party/raylib:raylib.bzl", "raylib_binary")
7
8 cc_library(
9 name = "theme",
10 srcs = ["theme.c"],
11 hdrs = ["theme.h"],
12 deps = [
13 "//dowa:dowa",
14 "//third_party/raylib:raylib",
15 ],
16 linkopts = select({
17 "//config:windows": ["-ladvapi32"],
18 "//conditions:default": [],
19 }),
20 )
21
22 cc_library(
23 name = "canvas",
24 srcs = ["canvas.c"],
25 hdrs = ["canvas.h"],
26 deps = [
27 "//dowa:dowa",
28 ":theme",
29 "//third_party/raylib:raylib",
30 ],
31 visibility = ["//visibility:public"],
32 )
33
34 cc_library(
35 name = "dev_ui",
36 srcs = ["dev_ui.c"],
37 hdrs = ["dev_ui.h"],
38 deps = [
39 ":canvas",
40 ":theme",
41 "//third_party/raylib:raygui",
42 ],
43 )
44
45 cc_library(
46 name = "web_surface",
47 srcs = select({
48 "//config:linux": ["web_surface_native.cc"],
49 "//config:macos": ["web_surface_native.cc"],
50 "//config:windows": ["web_surface_native.cc"],
51 "//conditions:default": ["web_surface_web.c"],
52 }),
53 hdrs = ["web_surface.h"],
54 copts = select({
55 "//config:linux": ["-std=c++20"],
56 "//config:macos": ["-std=c++20"],
57 "//conditions:default": [],
58 }),
59 deps = [
60 ":canvas",
61 ":theme",
62 "//dowa:dowa",
63 "//third_party/raylib:raylib",
64 ] + select({
65 "//config:linux": [
66 "@cef//:cef",
67 "@cef//:cef_wrapper",
68 ],
69 "//config:macos": ["@cef//:cef_wrapper"],
70 "//config:windows": ["@cef//:cef_wrapper"],
71 "//conditions:default": [],
72 }),
73 )
74
75 filegroup(
76 name = "inter_font",
77 srcs = ["assets/Inter-Variable.ttf"],
78 )
79
80 filegroup(
81 name = "fonts",
82 srcs = [
83 ":inter_font",
84 "assets/OFL.txt",
85 ],
86 )
87
88 filegroup(
89 name = "image_placeholder",
90 srcs = ["assets/image-placeholder.svg"],
91 )
92
93 filegroup(
94 name = "image_view",
95 srcs = ["assets/image-view.html"],
96 )
97
98 raylib_binary(
99 name = "app_bin",
100 srcs = ["main.c"],
101 data = [
102 ":fonts",
103 ":image_placeholder",
104 ":image_view",
105 ] + select({
106 "//config:linux": [
107 "@cef//:resources",
108 "@cef//:sos",
109 ],
110 "//config:macos": ["@cef//:cef_framework"],
111 "//config:windows": [
112 "@cef//:dlls",
113 "@cef//:resources",
114 ],
115 "//conditions:default": [],
116 }),
117 deps = [
118 ":canvas",
119 ":web_surface",
120 "//dowa:dowa",
121 "//third_party/raylib:raylib",
122 ],
123 )
124
125 raylib_binary(
126 name = "dev_bin",
127 srcs = ["main.c"],
128 data = [
129 ":fonts",
130 ":image_placeholder",
131 ":image_view",
132 ] + select({
133 "//config:linux": [
134 "@cef//:resources",
135 "@cef//:sos",
136 ],
137 "//config:macos": ["@cef//:cef_framework"],
138 "//config:windows": [
139 "@cef//:dlls",
140 "@cef//:resources",
141 ],
142 "//conditions:default": [],
143 }),
144 defines = ["INFINITE_CANVAS_DEV_UI"],
145 deps = [
146 ":canvas",
147 ":dev_ui",
148 ":theme",
149 ":web_surface",
150 "//dowa:dowa",
151 "//third_party/raylib:raylib",
152 ],
153 )
154
155 sh_binary(
156 name = "app_linux",
157 srcs = ["run_native.sh"],
158 data = [":app_bin"],
159 )
160
161 sh_binary(
162 name = "dev_linux",
163 srcs = ["run_native.sh"],
164 data = [":dev_bin"],
165 )
166
167 alias(
168 name = "app",
169 actual = select({
170 "//config:linux": ":app_linux",
171 "//conditions:default": ":app_bin",
172 }),
173 )
174
175 alias(
176 name = "dev",
177 actual = select({
178 "//config:linux": ":dev_linux",
179 "//conditions:default": ":dev_bin",
180 }),
181 )
182
183 filegroup(
184 name = "shell",
185 srcs = ["index.html"],
186 )
187
188 raylib_binary(
189 name = "web_bin",
190 srcs = ["main.c"],
191 additional_linker_inputs = [
192 ":image_placeholder",
193 ":inter_font",
194 ],
195 data = [
196 ":fonts",
197 ":image_placeholder",
198 ],
199 defines = ["INFINITE_CANVAS_DEV_UI"],
200 deps = [
201 ":canvas",
202 ":dev_ui",
203 ":web_surface",
204 "//dowa:dowa",
205 "//third_party/raylib:raylib",
206 ],
207 linkopts_wasm = [
208 "-sUSE_GLFW=3",
209 "-sMIN_WEBGL_VERSION=2",
210 "-sMAX_WEBGL_VERSION=2",
211 "-sALLOW_MEMORY_GROWTH",
212 "--preload-file=$(location :inter_font)@/infinite_canvas/assets/Inter-Variable.ttf",
213 "--preload-file=$(location :image_placeholder)@/infinite_canvas/assets/image-placeholder.svg",
214 ],
215 )
216
217 wasm_cc_binary(
218 name = "infinite_canvas_wasm",
219 cc_target = ":web_bin",
220 )
221
222 move_files_into_dir(
223 name = "web_bundle",
224 srcs = [
225 ":infinite_canvas_wasm",
226 ":shell",
227 ],
228 dest = "web",
229 )
230
231 cc_test(
232 name = "canvas_test",
233 srcs = ["canvas_test.c"],
234 deps = [":canvas"],
235 )
236
237 sh_binary(
238 name = "serve",
239 srcs = ["serve.sh"],
240 data = [":web_bundle"],
241 )