comparison hg-web/BUILD @ 190:a2725419f988 hg-web

Updated so that bun builds will with already existing js files.
author MrJuneJune <me@mrjunejune.com>
date Sat, 24 Jan 2026 21:06:42 -0800
parents 32ce881452fa
children a06710325c30
comparison
equal deleted inserted replaced
188:32ce881452fa 190:a2725419f988
1 load("@rules_cc//cc:cc_binary.bzl", "cc_binary") 1 load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2 load("//gui_ze:gui_ze.bzl", "move_files_into_dir", "bundle", "bun_build") 2 load("//gui_ze:gui_ze.bzl", "move_files_into_dir", "bundle", "bun_bundle")
3 3
4 # External 4 # Source files
5 move_files_into_dir( 5 filegroup(
6 name = "external_js_ts_moved", 6 name = "src_ts_files",
7 srcs = [ 7 srcs = glob([
8 "//markdown_converter:markdown_to_html_wasm", 8 "src/**/*.ts",
9 ], 9 "src/**/*.tsx",
10 dest = "src", 10 "src/**/*.js",
11 "src/**/*.jsx",
12 ], allow_empty = True),
11 ) 13 )
12 14
13 filegroup( 15 # Bundle TypeScript with Bun
14 name = "external_js_ts", 16 bun_bundle(
15 srcs = [":external_js_ts_moved"],
16 )
17
18 # Internal
19 filegroup(
20 name = "raw_file",
21 srcs = glob(["src/**"]),
22 )
23
24 filegroup(
25 name = "all_ts_files",
26 srcs = [":external_js_ts"] + glob([
27 "**/*.ts",
28 "**/*.tsx",
29 "**/*.js",
30 "**/*.jsx",
31 ], allow_empty=True)
32 )
33
34 # Generate js file...
35 bun_build(
36 name = "page", 17 name = "page",
37 src = "src/main.tsx", 18 src = "src/main.tsx",
38 src_folder = "hg-web", 19 deps = [
39 data = [ 20 ":src_ts_files",
40 "//third_party/bun:bun_files", 21 "//markdown_converter:markdown_to_html_wasm",
41 ":all_ts_files",
42 ], 22 ],
43 visibility = ["//visibility:public"], 23 visibility = ["//visibility:public"],
44 ) 24 )
45 25
26 # Prepare compiled assets
46 move_files_into_dir( 27 move_files_into_dir(
47 name = "compiled_ts", 28 name = "compiled_js",
48 srcs = [ 29 srcs = [
49 ":page", 30 ":page",
31 "//markdown_converter:markdown_to_html_wasm",
32 "//third_party/highlight:js",
50 ], 33 ],
51 dest = "src", 34 dest = "src",
52 ) 35 )
53 36
54 move_files_into_dir( 37 move_files_into_dir(
55 name = "public_files", 38 name = "public_files",
56 srcs = [ 39 srcs = ["//mrjunejune:public_files"],
57 "//mrjunejune:public_files"
58 ],
59 dest = "src/public", 40 dest = "src/public",
60 ) 41 )
61 42
62 filegroup( 43 filegroup(
63 name = "src_files", 44 name = "all_assets",
64 srcs = [":raw_file", ":compiled_ts", "public_files"], 45 srcs = glob(["src/**"]) + [":compiled_js", ":public_files"],
65 ) 46 )
66 47
67 # Binary 48 # Server binaries
68 cc_binary( 49 cc_binary(
69 name = "hg_web_server", 50 name = "hg_web_server",
70 srcs = ["main.c"], 51 srcs = ["main.c"],
71 deps = [ 52 deps = ["//seobeo:seobeo"],
72 "//seobeo:seobeo", 53 data = [":all_assets"],
73 ], 54 )
74 data = [":src_files"], 55
56 cc_binary(
57 name = "hg_web_server_debug",
58 srcs = ["main.c"],
59 deps = ["//seobeo:seobeo"],
60 data = [":all_assets"],
75 ) 61 )
76 62
77 bundle( 63 bundle(
78 name = "hg_web_server_bundle", 64 name = "hg_web_server_bundle",
79 binary = ":hg_web_server", 65 binary = ":hg_web_server",
80 ) 66 )
81
82 cc_binary(
83 name = "hg_web_server_debug",
84 srcs = ["main.c"],
85 deps = ["//seobeo:seobeo"],
86 data = [":src_files"],
87 )
88