github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/third_party/toolchains/cpus/arm/arm_compiler_configure.bzl (about)

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