anki/qt/aqt/forms/compile.bzl

29 lines
754 B
Python
Raw Normal View History

2021-10-05 05:18:43 +02:00
def compile(name, ui_file, py_file, builder):
native.genrule(
name = name,
srcs = [ui_file],
outs = [py_file],
2021-10-05 05:18:43 +02:00
cmd = "$(location {builder}) $(location {ui_file}) $(location {py_file})".format(
builder = builder,
ui_file = ui_file,
py_file = py_file,
),
tools = [
2021-10-05 05:18:43 +02:00
builder,
],
message = "Building UI",
)
2021-10-05 05:18:43 +02:00
def compile_all(name, builder, srcs, suffix):
py_files = []
for ui_file in srcs:
2021-10-05 05:18:43 +02:00
fname = ui_file.replace(".ui", "") + suffix
py_file = fname + ".py"
py_files.append(py_file)
2021-10-05 05:18:43 +02:00
compile(fname, ui_file, py_file, builder)
native.filegroup(
2021-10-05 05:18:43 +02:00
name = name,
srcs = py_files,
)