view hg-web/BUILD @ 271:13d61401c57d

redirect Copilot cache to service state Set XDG_CACHE_HOME from the configured inference state so the systemd service can extract Copilot outside its protected home directory. Co-authored-by: Copilot <[email protected]>
author MrJuneJune <me@mrjunejune.com>
date Fri, 07 Aug 2026 13:24:05 -0700
parents c5129452493e
children
line wrap: on
line source

load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
load("@rules_shell//shell:sh_test.bzl", "sh_test")
load("//gui_ze:gui_ze.bzl", "move_files_into_dir", "bundle", "bun_bundle")

# Source files
filegroup(
  name = "src_ts_files",
  srcs = glob([
    "src/**/*.ts",
    "src/**/*.tsx",
    "src/**/*.js",
    "src/**/*.jsx",
  ], allow_empty = True),
)

# Bundle TypeScript with Bun
bun_bundle(
  name = "page",
  src = "src/main.tsx",
  deps = [
    ":src_ts_files",
    "//markdown_converter:markdown_to_html_wasm",
    "//third_party/highlight:js",
  ],
  visibility = ["//visibility:public"],
)

# Prepare compiled assets
move_files_into_dir(
  name = "compiled_js",
  srcs = [
    ":page",
    "//markdown_converter:markdown_to_html_wasm",
    "//third_party/highlight:js",
  ],
  dest = "src",
)

move_files_into_dir(
  name = "public_files",
  srcs = ["//mrjunejune:public_files"],
  dest = "src/public",
)

move_files_into_dir(
  name = "public_fonts_files",
  srcs = ["//mrjunejune:public_fonts_files"],
  dest = "src/public/fonts",
)

filegroup(
  name = "all_assets",
  srcs = glob(["src/**"]) + [":compiled_js", ":public_files", ":public_fonts_files"],
)

genrule(
  name = "run_hg_web_launcher",
  srcs = ["run.sh"],
  outs = ["run_hg_web"],
  cmd = "cp $(location run.sh) $@ && chmod 0555 $@",
)

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

filegroup(
  name = "runtime_files",
  srcs = [
    ":run_hg_web_launcher",
    ":mercurial_runtime_data",
  ],
)

# Server binaries
cc_binary(
  name = "hg_web_server",
  srcs = ["main.c"],
  deps = ["//seobeo:seobeo"],
  data = [
    ":all_assets",
    ":runtime_files",
  ],
  visibility = ["//hg-web:__subpackages__"],
)

cc_binary(
  name = "hg_web_server_debug",
  srcs = ["main.c"],
  deps = ["//seobeo:seobeo"],
  data = [
    ":all_assets",
    ":runtime_files",
  ],
)

sh_binary(
  name = "dev",
  srcs = ["dev.sh"],
  data = [
    ":hg_web_server",
    ":mercurial_runtime_data",
    "@bazel_tools//tools/bash/runfiles",
  ],
)

test_suite(
  name = "tests",
  tests = [
    ":repository_sync_test",
    "//hg-web/e2e:app_e2e_test",
  ],
)

sh_test(
  name = "repository_sync_test",
  srcs = ["repository_sync_test.sh"],
  data = [
    "//third_party/mercurial:runtime",
    "@bazel_tools//tools/bash/runfiles",
  ],
  target_compatible_with = [
    "@platforms//cpu:x86_64",
    "@platforms//os:linux",
  ],
)

bundle(
  name = "hg_web_server_bundle",
  binary = ":hg_web_server",
)

sh_binary(
  name = "deploy",
  srcs = ["deploy.sh"],
  data = [
    ":hg_web_server_bundle",
    "nginx/hg-web.conf.template",
    "systemd/hg-web.service.template",
    "@bazel_tools//tools/bash/runfiles",
  ],
)