1"""Repository rule for ARM cross 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("//tensorflow/tools/toolchains/embedded/arm-linux:%s.tpl" % tpl), 9 substitutions, 10 ) 11 12def _arm_linux_toolchain_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/python3.5" 23 _tpl(repository_ctx, "cc_config.bzl", { 24 "%{AARCH64_COMPILER_PATH}%": str(repository_ctx.path( 25 repository_ctx.attr.aarch64_repo, 26 )), 27 "%{ARMHF_COMPILER_PATH}%": str(repository_ctx.path( 28 repository_ctx.attr.armhf_repo, 29 )), 30 "%{PYTHON_INCLUDE_PATH}%": python_include_path, 31 }) 32 repository_ctx.symlink(Label(repository_ctx.attr.build_file), "BUILD") 33 34arm_linux_toolchain_configure = repository_rule( 35 implementation = _arm_linux_toolchain_configure_impl, 36 attrs = { 37 "aarch64_repo": attr.string(mandatory = True, default = ""), 38 "armhf_repo": attr.string(mandatory = True, default = ""), 39 "build_file": attr.string(), 40 }, 41) 42