[Bazel] Change external_zlib attribute to string
authorMichael McLoughlin <mbm@aurora.tech>
Thu, 22 Jul 2021 23:01:49 +0000 (16:01 -0700)
committerGeoffrey Martin-Noble <gcmn@google.com>
Thu, 22 Jul 2021 23:02:37 +0000 (16:02 -0700)
commitb4f8a000f6c907a9e9f06f85c8d40ef9c235002e
tree78f38faaa345c28a59037304a74f42f28309f576
parentcf8a1f62083c3edbf2cd08bb16d57a70dc45722c
[Bazel] Change external_zlib attribute to string

When using `llvm_zlib_external` rule with `external_zlib` attribute set to a
label referring to the main repository, like `@//third_party/zlib`, it will be
replaced with `//third_party/zlib` after template substitution. This will then
attempt to find `//third_party/zlib` within the local repository
`@llvm_zlib//third_party/zlib`, which does not exist, rather than the intended
reference back to the main repository. The issue appears to be that the
conversion of `Label` type to string with
`str(repository_ctx.attr.external_zlib)`, which is causing the main repository
qualifier to be lost.

This diff fixes the issue by changing the `external_zlib` attribute to
`attr.string` type rather than `attr.label`.

In future a more elegant solution may be possible that preserves use of the
`Label` type, depending on resolution of the issue
https://github.com/bazelbuild/bazel/issues/13731.

Ported from Github PR https://github.com/google/llvm-bazel/pull/236.

Reviewed By: GMNGeoffrey

Differential Revision: https://reviews.llvm.org/D106606
utils/bazel/zlib.bzl