view mrjunejune/BUILD @ 242:543df0fe7168

[tools] Add full HLS player support
author MrJuneJune <me@mrjunejune.com>
date Mon, 03 Aug 2026 13:14:41 -0700
parents 9c2eec61a152
children b8aa08503378
line wrap: on
line source

load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_cc//cc:cc_library.bzl", "cc_library")
load("@aspect_rules_js//js:defs.bzl", "js_library")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("//gui_ze:gui_ze.bzl", "move_files_into_dir", "bundle", "webp_image")

_PNG_ASSETS = [
  "23k",
  "blue-noise-random",
  "blue-noises-optimal",
  "dog-treat",
  "epi_all_colors",
  "icon-192",
  "icon-512",
  "icon-maskable-512",
  "logo_black",
  "logo_white",
  "logo_white_og",
  "sprite_shiba0",
  "sprite_shiba1",
  "sprite_shiba2",
  "sprite_shiba3",
  "start-large",
  "start-small-1",
  "start-small-2",
  "start-small-3",
  "vscode",
  "wabbit_alpha",
  "white-noise-grass",
]

_LOSSLESS_WEBP_ASSETS = [
  "dog-treat",
  "epi_all_colors",
  "icon-192",
  "icon-512",
  "icon-maskable-512",
  "logo_black",
  "logo_white",
  "logo_white_og",
  "sprite_shiba0",
  "sprite_shiba1",
  "sprite_shiba2",
  "sprite_shiba3",
  "start-large",
  "start-small-1",
  "start-small-2",
  "start-small-3",
  "wabbit_alpha",
]

[
  webp_image(
    name = "webp_{}".format(asset.replace("-", "_")),
    src = "assets/png/{}.png".format(asset),
    out = "generated_webp/{}.webp".format(asset),
    lossless = asset in _LOSSLESS_WEBP_ASSETS,
  )
  for asset in _PNG_ASSETS
]

filegroup(
  name = "generated_webp_assets",
  srcs = [
    ":webp_{}".format(asset.replace("-", "_"))
    for asset in _PNG_ASSETS
  ],
)

filegroup(
  name = "sample_hls_mp4",
  srcs = ["assets/video/sample_hls.mp4"],
  visibility = [
    "//mrjunejune:__pkg__",
    "//third_party/ffmpeg:__pkg__",
  ],
)

cc_binary(
  name = "generate_hls_sample",
  srcs = ["generate_hls_sample.c"],
  args = [
    "$(location :sample_hls_mp4)",
    "mrjunejune/src/public/hls-sample",
  ],
  data = [":sample_hls_mp4"],
  deps = ["//third_party/ffmpeg:ffmpeg_cli"],
)

move_files_into_dir(
  name = "generated_public_webp",
  srcs = [":generated_webp_assets"],
  dest = "src/public",
)

# Files
move_files_into_dir(
    name = "hlsjs_runtime",
    srcs = ["@hlsjs//:dist/hls.min.js"],
    dest = "src/public",
)

move_files_into_dir(
  name = "react_pages",
  srcs = [
    "//react_games:games"
  ],
  dest = "src/games",
)

move_files_into_dir(
  name = "shared_js_non_public",
  srcs = [
    "//markdown_converter:markdown_to_html",
    "//markdown_converter:markdown_to_html_wasm",
  ],
  dest = "src",
)

move_files_into_dir(
  name = "shared_js_file",
  srcs = [
    "//third_party/highlight:js",
  ],
  dest = "src/public/highlight",
)

move_files_into_dir(
  name = "rich_editor_js",
  srcs = [
    "//rich_editor:rich_editor",
  ],
  dest = "src/public/js",
)

move_files_into_dir(
  name = "icons",
  srcs = [
    "//assets:icons",
  ],
  dest = "src/public/icons",
)

filegroup(
  name = "public_files",
  srcs = glob(
    ["src/public/*"],
    exclude = ["src/public/*.png"],
  ) + [":generated_public_webp", ":hlsjs_runtime"],
  visibility = ["//visibility:public"],
)

filegroup(
  name = "public_fonts_files",
  srcs = glob(["src/public/fonts/*"]),
  visibility = ["//visibility:public"],
)
    
filegroup(
  name = "src_files",
  srcs = glob(
    ["src/**"],
    exclude = ["src/**/*.png"],
  ) + [":react_pages", ":shared_js_non_public", ":shared_js_file", ":rich_editor_js", ":icons", ":generated_public_webp", ":hlsjs_runtime"],
  visibility = ["//mrjunejune/test:__pkg__"],
)

js_library(
  name = "hls_player_js",
  srcs = ["src/tools/hls_player/hls-player.js"],
  visibility = ["//mrjunejune/test:__pkg__"],
)

# Server binary
cc_binary(
  name = "mrjunejune_server",
  srcs = ["main.c"],
  deps = [
    "//seobeo:seobeo",
    "//markdown_converter:markdown_to_html_c",
    "//s3:s3",
    "//deita:deita",
  ],
  copts = ["-D_GNU_SOURCE"],
  linkopts = ["-lpthread"],
  data = [
    ":src_files",
    ":config_file",
    "//:env_file",
  ],
  visibility = ["//mrjunejune/test:__pkg__"],
)

# Debug build with verbose logging
cc_binary(
  name = "mrjunejune_server_debug",
  srcs = ["main.c"],
  deps = [
    "//seobeo:seobeo_debug",
    "//markdown_converter:markdown_to_html_c",
    "//s3:s3",
    "//deita:deita",
  ],
  copts = ["-D_GNU_SOURCE"],
  linkopts = ["-lpthread"],
  data = [
    ":src_files",
    ":config_file",
    "//:env_file",
  ],
)

filegroup(
  name = "config_file",
  srcs = [".config"],
  visibility = ["//visibility:public"],
)

filegroup(
  name = "data_dir",
  srcs = glob(["data/*"]),
  visibility = ["//visibility:public"],
)

# Run this to create html files
cc_binary(
  name = "create_html_from_md",
  srcs = ["create_html_from_md.c"],
  deps = [
    "//markdown_converter:markdown_to_html_c",
    "//dowa:dowa"
  ],
  data = [":src_files"],
)

# Release bundle
bundle(
  name = "mrjunejune_server_bundle",
  binary = ":mrjunejune_server",
)

bundle(
  name = "mrjunejune_server_debug_bundle",
  binary = ":mrjunejune_server_debug",
)

sh_binary(
  name = "generate_resume_pdf",
  srcs = ["generate_resume_pdf.sh"],
  data = [
    ":mrjunejune_server",
    "@bazel_tools//tools/bash/runfiles",
    "@playwright_chromium_linux//:chrome",
    "@playwright_chromium_linux//:chromium",
  ],
)