Mercurial
diff gui_ze/gui_ze.bzl @ 25:342726584be2
[Bun] Fixed how bun would be ran within bazel.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Thu, 09 Oct 2025 06:41:02 -0700 |
| parents | 7d3fa1a7a854 |
| children | ccb42d5bf8fd |
line wrap: on
line diff
--- a/gui_ze/gui_ze.bzl Tue Oct 07 09:13:29 2025 -0700 +++ b/gui_ze/gui_ze.bzl Thu Oct 09 06:41:02 2025 -0700 @@ -75,7 +75,6 @@ mkdir -p {outdir} unzip -j {src} {inner} -d {outdir} chmod +x {outdir}/bun - mv {outdir}/bun {out} """.format( outdir = out.dirname, src = ctx.files.srcs[0].path, @@ -91,8 +90,8 @@ bun_binary = rule( implementation = _bun_binary_impl, attrs = { - "srcs": attr.label_list(allow_files=True), - "src_folder": attr.string(), + "srcs": attr.label_list(allow_files=True), + "src_folder": attr.string(), }, executable = True, ) @@ -104,8 +103,8 @@ This sucks because you need to either copy node module into the root folder where main.ts file exists or copy everything outwards. I chose to do it in this way. - TODO: If possible, maybe create a node_module inside of the main target path and create a symlink, - but I couldn't get it to work lol. + TODO: If possible, maybe create a node_module inside of the main target path and create a symlink + TODO: Add a specific path for node_modules """ out = ctx.actions.declare_file(ctx.label.name + ".js") inputs = [ctx.file.src] + ctx.files.data @@ -116,12 +115,13 @@ tools = [ctx.executable._bun] + inputs, command = """ cp -r third_party/bun/** . \ - && cp -r playground/** . \ - && {} build {} --outfile {} + && cp -r {src_folder}/** . \ + && export NODE_PATH=./node_modules && {bun_path} build {input_path} --outfile {output_path} """.format( - ctx.executable._bun.path, - ctx.file.src.path.split("/")[-1], - out.path, + bun_path = ctx.executable._bun.path, + src_folder = ctx.attr.src_folder, + input_path = ctx.file.src.path.split("/")[-1], + output_path = out.path, ), progress_message = "Bundling {} with Bun!\n\n".format(ctx.file.src.path), ) @@ -138,6 +138,7 @@ cfg = "exec", ), "data": attr.label_list(allow_files=True), + "src_folder": attr.string(), }, )