view mrjunejune/BUILD @ 264:04fee26ecce0

add authenticated JRPG conversation platform Add reusable auth/session storage, owned conversation recovery, guest quotas, admin workflows, URL-routed conversation UI, mobile frame support, and parallel browser acceptance. Co-authored-by: Copilot <[email protected]>
author MrJuneJune <me@mrjunejune.com>
date Fri, 07 Aug 2026 07:34:12 -0700
parents b401627fc49e
children 056790c4fb0d
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 = "design_system_components",
  srcs = ["//design_system:components"],
  dest = "src/public/design-system/components",
)

move_files_into_dir(
  name = "design_system_styles",
  srcs = ["//design_system:styles"],
  dest = "src/public/design-system/styles",
)

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

filegroup(
  name = "public_files",
  srcs = glob(
    [
      "src/public/*",
      "src/public/jrpg/*",
    ],
    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 = "html_src_files",
  srcs = glob(["src/**/*.html"]),
  visibility = ["//mrjunejune/test:__pkg__"],
)

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

filegroup(
  name = "src_files_development",
  srcs = [":src_files"],
  visibility = ["//mrjunejune/test:__pkg__"],
)

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

cc_library(
  name = "template_renderer",
  srcs = ["template_renderer.c"],
  hdrs = ["template_renderer.h"],
  deps = [
    "//dowa:dowa",
    "//seobeo:seobeo",
  ],
  visibility = [
    "//mrjunejune:__pkg__",
    "//mrjunejune/test:__pkg__",
  ],
)

cc_library(
  name = "latex_renderer",
  srcs = ["latex_renderer.c"],
  hdrs = ["latex_renderer.h"],
  copts = ["-D_GNU_SOURCE"],
  data = select({
    "//config:linux_x86_64": ["//third_party/tectonic:runtime"],
    "//conditions:default": [],
  }),
  deps = ["//dowa:dowa"],
  visibility = ["//mrjunejune/test:__pkg__"],
)

cc_library(
  name = "conversation_store",
  srcs = ["conversation_store.c"],
  hdrs = ["conversation_store.h"],
  deps = [
    "//deita:deita",
    "//dowa:dowa",
  ],
  linkopts = ["-lpthread"],
  visibility = ["//mrjunejune/test:__pkg__"],
)

cc_library(
  name = "conversation_api",
  srcs = ["conversation_api.c"],
  hdrs = ["conversation_api.h"],
  deps = [
    ":auth_api",
    ":conversation_store",
    ":inference_bridge",
    "//auth:auth_store",
    "//dowa:dowa",
    "//seobeo:seobeo",
  ],
  linkopts = ["-lpthread"],
)

cc_library(
  name = "admin_api",
  srcs = ["admin_api.c"],
  hdrs = ["admin_api.h"],
  deps = [
    ":auth_api",
    ":template_renderer",
    "//auth:auth_crypto",
    "//auth:auth_store",
    "//dowa:dowa",
    "//seobeo:seobeo",
    "@openssl//:crypto",
  ],
  visibility = ["//mrjunejune/test:__pkg__"],
)

# Same sources compiled with test-hook symbols exposed.
cc_library(
  name = "admin_api_with_test_hooks",
  srcs = ["admin_api.c"],
  hdrs = ["admin_api.h"],
  copts = ["-DADMIN_API_TEST_HOOKS"],
  deps = [
    ":auth_api_with_test_hooks",
    ":template_renderer",
    "//auth:auth_crypto",
    "//auth:auth_store",
    "//dowa:dowa",
    "//seobeo:seobeo",
    "@openssl//:crypto",
  ],
  linkopts = ["-lpthread"],
  testonly = True,
  visibility = ["//mrjunejune/test:__pkg__"],
)

cc_library(
  name = "auth_api",
  srcs = ["auth_api.c"],
  hdrs = ["auth_api.h"],
  deps = [
    ":template_renderer",
    "//auth:auth_crypto",
    "//auth:auth_store",
    "//dowa:dowa",
    "//seobeo:seobeo",
    "@openssl//:crypto",
  ],
  linkopts = ["-lpthread"],
  visibility = ["//mrjunejune/test:__pkg__"],
)

# Same sources, compiled with test-hook symbols exposed.
cc_library(
  name = "auth_api_with_test_hooks",
  srcs = ["auth_api.c"],
  hdrs = ["auth_api.h"],
  copts = ["-DAUTH_API_TEST_HOOKS"],
  deps = [
    ":template_renderer",
    "//auth:auth_crypto",
    "//auth:auth_store",
    "//dowa:dowa",
    "//seobeo:seobeo",
    "@openssl//:crypto",
  ],
  linkopts = ["-lpthread"],
  testonly = True,
  visibility = ["//mrjunejune/test:__pkg__"],
)

cc_library(
  name = "inference_bridge",
  srcs = ["inference_bridge.c"],
  hdrs = ["inference_bridge.h"],
  deps = ["//dowa:dowa"],
  linkopts = ["-lpthread"],
  visibility = ["//mrjunejune/test:__pkg__"],
)

filegroup(
  name = "tectonic_runtime_data",
  srcs = select({
    "//config:linux_x86_64": ["//third_party/tectonic:runtime"],
    "//conditions:default": [],
  }),
)

filegroup(
  name = "inference_runtime_data",
  srcs = [
    "inference_sidecar_launcher.sh",
    "inference_stack.sh",
    "production_entrypoint.sh",
    "//mrjunejune/inference:production_runtime_binaries",
    "//mrjunejune/inference:litellm_config.yaml",
    "@copilot_cli_linux_x86_64//:copilot",
    "@python_3_11//:files",
    "@python_3_11//:python3",
  ],
)

# Server binary
cc_binary(
  name = "mrjunejune_server",
  srcs = ["main.c"],
  deps = [
    ":admin_api",
    ":auth_api",
    ":conversation_api",
    ":template_renderer",
    "//seobeo:seobeo",
    "//markdown_converter:markdown_to_html_c",
    "//s3:s3",
    "//deita:deita",
    ":latex_renderer",
    "//auth:auth_crypto",
  ],
  copts = ["-D_GNU_SOURCE"],
  linkopts = ["-lpthread"],
  data = [
    ":src_files",
    ":inference_runtime_data",
    ":tectonic_runtime_data",
  ],
  visibility = ["//mrjunejune/test:__pkg__"],
)

# Debug build with verbose logging
cc_binary(
  name = "mrjunejune_server_debug",
  srcs = ["main.c"],
  deps = [
    ":admin_api",
    ":auth_api",
    ":conversation_api",
    ":template_renderer",
    "//seobeo:seobeo_debug",
    "//markdown_converter:markdown_to_html_c",
    "//s3:s3",
    "//deita:deita",
    ":latex_renderer",
    "//auth:auth_crypto",
  ],
  copts = [
    "-D_GNU_SOURCE",
    "-DMRJUNEJUNE_DEVELOPMENT_CONFIG",
  ],
  linkopts = ["-lpthread"],
  data = [
    ":src_files_development",
    ":config_file",
    ":inference_runtime_data",
    ":tectonic_runtime_data",
    "//:env_file",
  ],
  visibility = ["//mrjunejune/test:__pkg__"],
)

alias(
  name = "mrjunejune_server_dev",
  actual = ":mrjunejune_server_debug",
)

sh_binary(
  name = "run_inference_stack",
  srcs = ["inference_stack.sh"],
  args = [
    "$(location :mrjunejune_server)",
    "$(location :inference_sidecar_launcher.sh)",
    "$(location //mrjunejune/inference:copilot_sidecar_zip)",
    "$(location @copilot_cli_linux_x86_64//:copilot)",
    "$(location //mrjunejune/inference:litellm_proxy_zip)",
    "$(location //mrjunejune/inference:litellm_config.yaml)",
    "$(location @python_3_11//:python3)",
    "$(location //mrjunejune/inference:mock_sidecar)",
  ],
  data = [
    ":mrjunejune_server",
    ":inference_sidecar_launcher.sh",
    "//mrjunejune/inference:copilot_sidecar_zip",
    "//mrjunejune/inference:litellm_config.yaml",
    "//mrjunejune/inference:litellm_proxy_zip",
    "//mrjunejune/inference:mock_sidecar",
    "@copilot_cli_linux_x86_64//:copilot",
    "@python_3_11//:files",
    "@python_3_11//:python3",
  ],
)

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",
  visibility = ["//mrjunejune/test:__pkg__"],
)

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

alias(
  name = "mrjunejune_server_dev_bundle",
  actual = ":mrjunejune_server_debug_bundle",
)

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",
  ],
)