Mercurial
comparison gui_ze/gui_ze.bzl @ 241:9c2eec61a152
[assets] Generate site images as WebP with Bazel
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 03 Aug 2026 11:26:30 -0700 |
| parents | 9f4429c49733 |
| children | 70f2a3dafc1c |
comparison
equal
deleted
inserted
replaced
| 240:c345083cd8a7 | 241:9c2eec61a152 |
|---|---|
| 304 attrs = { | 304 attrs = { |
| 305 "srcs": attr.label_list(allow_files=True), | 305 "srcs": attr.label_list(allow_files=True), |
| 306 "dest": attr.string(), | 306 "dest": attr.string(), |
| 307 }, | 307 }, |
| 308 ) | 308 ) |
| 309 | |
| 310 def webp_image(name, src, out, quality = 90, lossless = False): | |
| 311 """Convert one image to WebP as a Bazel build action.""" | |
| 312 native.genrule( | |
| 313 name = name, | |
| 314 srcs = [src], | |
| 315 outs = [out], | |
| 316 tools = ["@libwebp_linux_x86_64//:bin/cwebp"], | |
| 317 cmd = "$(location @libwebp_linux_x86_64//:bin/cwebp) -quiet -m 6 {} -q {} $(location {}) -o $@".format( | |
| 318 "-lossless" if lossless else "", | |
| 319 quality, | |
| 320 src, | |
| 321 ), | |
| 322 ) | |
| 309 | 323 |
| 310 def _move_to_directory_impl(ctx): | 324 def _move_to_directory_impl(ctx): |
| 311 srcs = ctx.files.data | 325 srcs = ctx.files.data |
| 312 res = [] | 326 res = [] |
| 313 for src in srcs: | 327 for src in srcs: |