comparison gui_ze/gui_ze.bzl @ 156:cd35e600ae34

[MarkDown Converter] Fixed few things and made a test
author June Park <parkjune1995@gmail.com>
date Mon, 12 Jan 2026 15:20:39 -0800
parents bdcc610eeed8
children f3084bca7317
comparison
equal deleted inserted replaced
155:3bb45eb67906 156:cd35e600ae34
200 ), 200 ),
201 "data": attr.label_list(allow_files=True), 201 "data": attr.label_list(allow_files=True),
202 "src_folder": attr.string(), 202 "src_folder": attr.string(),
203 }, 203 },
204 ) 204 )
205
206 def _bun_run_impl(ctx):
207 actual_exe = ctx.actions.declare_file(ctx.label.name)
208
209 # 1. Get the workspace name (crucial for runfiles paths)
210 workspace_name = ctx.workspace_name
211
212 # 2. Define the paths relative to the runfiles root
213 bun_path = ctx.executable._bun.short_path
214 src_path = ctx.file.src.short_path
215
216 # 3. Create the launcher script
217 # We use a template to handle the environment and pathing
218 script_content = """#!/bin/bash
219 # Find the runfiles directory
220 if [[ -z "$RUNFILES_DIR" ]]; then
221 if [[ -d "$0.runfiles" ]]; then
222 RUNFILES_DIR="$0.runfiles"
223 fi
224 fi
225
226 # Navigate to the workspace root inside runfiles
227 cd "$RUNFILES_DIR/{workspace}"
228 pwd
229 # Execute bun with the src file and any extra arguments
230 exec "./{bun_bin}" run "./{src_file}" "$@"
231 """.format(
232 workspace = workspace_name,
233 bun_bin = bun_path,
234 src_file = src_path
235 )
236
237 ctx.actions.write(
238 output = actual_exe,
239 content = script_content,
240 is_executable = True,
241 )
242
243 return [
244 DefaultInfo(
245 executable = actual_exe,
246 runfiles = ctx.runfiles(
247 files = [ctx.file.src] + ctx.files.data + ctx.files._bun_files
248 ).merge(ctx.attr._bun[DefaultInfo].default_runfiles),
249 ),
250 ]
251
252 # TODO: Fix the rules so that it can do relative import.
253 bun_run = rule(
254 implementation = _bun_run_impl,
255 executable = True,
256 attrs = {
257 "src": attr.label(allow_single_file = True, mandatory = True),
258 "data": attr.label_list(allow_files = True),
259 "_bun": attr.label(
260 default = Label("//third_party/bun:bun"),
261 executable = True,
262 cfg = "exec"
263 ),
264 "_bun_files": attr.label(default = Label("//third_party/bun:bun_files")),
265 },
266 )
267
205 268
206 def _move_files_into_dir_impl(ctx): 269 def _move_files_into_dir_impl(ctx):
207 srcs = ctx.files.srcs 270 srcs = ctx.files.srcs
208 outs = [] 271 outs = []
209 for src in srcs: 272 for src in srcs: