Files
eagle0/tools/rules_unity3d/unity3d.bzl
T

32 lines
1.4 KiB
Python

def _unity3d_binary_impl(ctx):
out_file = ctx.actions.declare_file(ctx.label.name)
src_file = ctx.attr.src.files.to_list()[0]
print("src_file.path is %s" % src_file, ctx.label)
# ctx.actions.write(output=out_file, content="Hello")
#command = "xvfb-run --auto-servernum --server-args='-screen 0 640x480x24'
# command = "LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 HOME=`pwd` u3d run -- -batchmode -nographics -quit -logFile `pwd`/editor.log -projectPath '{}' -buildWindows>
# print("command is %s " % command, ctx.label)
ctx.actions.run_shell(
inputs = [src_file],
outputs = [out_file],
progress_message = "Generating unity3d binary {}".format(out_file.path),
env = {
"LANG": "en_US.UTF-8",
"LC_ALL": "en_US.UTF-8",
"HOME": "",
},
arguments = [src_file.path, out_file.path],
command = "xvfb-run --auto-servernum --server-args='-screen 0 640x480x24' u3d run -- -batchmode -nographics -quit -logFile `pwd`/editor.log -projectPath \"$1\" -buildWindows64Player \"$2\"",
)
return [DefaultInfo(files = depset([out_file]))]
unity3d_binary = rule(
implementation = _unity3d_binary_impl,
attrs = {
"build_command": attr.string(mandatory = True),
"src": attr.label(mandatory = True, allow_single_file = True),
"deps": attr.label_list(),
},
)