1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# -*- Python -*-
"""Yocto rule for yocto compiler autoconfiguration."""
def _tpl(repository_ctx, tpl, substitutions={}, out=None):
if not out:
out = tpl
repository_ctx.template(
out,
Label("//third_party/toolchains/yocto:%s.tpl" % tpl),
substitutions)
def _yocto_compiler_configure_impl(repository_ctx):
if "CT_NAME" in repository_ctx.os.environ:
cross_tool_name = repository_ctx.os.environ["CT_NAME"]
else:
cross_tool_name = "x86_64-wrs-linux"
_tpl(repository_ctx, "cc_config.bzl", {
"%{YOCTO_COMPILER_PATH}%": str(repository_ctx.path(
repository_ctx.attr.remote_config_repo,
)),
"%{CT_NAME}%": cross_tool_name,
})
repository_ctx.symlink(repository_ctx.attr.build_file, "BUILD")
yocto_compiler_configure = repository_rule(
implementation = _yocto_compiler_configure_impl,
attrs = {
"remote_config_repo": attr.string(mandatory = False, default =""),
"build_file": attr.label(),
},
)
|