1"""Repository rule for arm compiler autoconfiguration.""" 2 3def _tpl(repository_ctx, tpl, substitutions = {}, out = None): 4 if not out: 5 out = tpl 6 repository_ctx.template( 7 out, 8 Label("//third_party/toolchains/cpus/arm:%s.tpl" % tpl), 9 substitutions, 10 ) 11 12def _arm_compiler_configure_impl(repository_ctx): 13 # We need to find a cross-compilation include directory for Python, so look 14 # for an environment variable. Be warned, this crosstool template is only 15 # regenerated on the first run of Bazel, so if you change the variable after 16 # it may not be reflected in later builds. Doing a shutdown and clean of Bazel 17 # doesn't fix this, you'll need to delete the generated file at something like: 18 # external/local_config_arm_compiler/CROSSTOOL in your Bazel install. 19 if "CROSSTOOL_PYTHON_INCLUDE_PATH" in repository_ctx.os.environ: 20 python_include_path = repository_ctx.os.environ["CROSSTOOL_PYTHON_INCLUDE_PATH"] 21 else: 22 python_include_path = "/usr/include/python2.7" 23 _tpl(repository_ctx, "cc_config.bzl", { 24 "%{ARM_COMPILER_PATH}%": str(repository_ctx.path( 25 repository_ctx.attr.remote_config_repo_arm, 26 )), 27 "%{AARCH64_COMPILER_PATH}%": str(repository_ctx.path( 28 repository_ctx.attr.remote_config_repo_aarch64, 29 )), 30 "%{PYTHON_INCLUDE_PATH}%": python_include_path, 31 }) 32 repository_ctx.symlink(repository_ctx.attr.build_file, "BUILD") 33 34arm_compiler_configure = repository_rule( 35 implementation = _arm_compiler_configure_impl, 36 attrs = { 37 "remote_config_repo_arm": attr.string(mandatory = False, default = ""), 38 "remote_config_repo_aarch64": attr.string(mandatory = False, default = ""), 39 "build_file": attr.label(), 40 }, 41) 42