From b267a60e8f45b8a3b69975fd196d821299618fd7 Mon Sep 17 00:00:00 2001 From: Jeremy Nimmer Date: Thu, 11 Jan 2018 12:14:45 -0500 Subject: [PATCH] Rewrite pkg_config_repository from scratch This adds two new features: - injecting deps directly, without having to fork the template; - allowing wrapping without having to repeat the template label. This also removes our dependency on @kythe, so we can remove that from our workspace as well. This implementation should also be substantially easier to change over time as we grow new requirements, such as better aligning the install rules with the pkg-config results, managing shared vs static linking, etc. --- WORKSPACE | 51 ++--- third_party/com_github_google_kythe/LICENSE | 202 ----------------- third_party/com_github_google_kythe/WORKSPACE | 6 - .../tools/build_rules/config/BUILD.bazel | 7 - .../tools/build_rules/config/BUILD.tpl | 12 - .../tools/build_rules/config/common.bzl | 66 ------ .../tools/build_rules/config/local.bzl | 58 ----- .../tools/build_rules/config/pkg_config.bzl | 190 ---------------- .../tools/build_rules/config/system.bzl | 73 ------- .../tools/build_rules/config/wrapped_ctx.bzl | 39 ---- .../tools/cdexec/BUILD.bazel | 10 - .../tools/cdexec/cdexec.bzl | 12 - .../tools/cdexec/cdexec.sh | 57 ----- .../com_github_google_kythe/vendor.txt | 6 - tools/lint/buildifier-tables.json | 9 + tools/workspace/expat/expat.bzl | 11 +- tools/workspace/gflags/gflags.bzl | 11 +- tools/workspace/pkg_config.BUILD.tpl | 14 ++ tools/workspace/pkg_config.bzl | 205 ++++++++++++++++++ tools/workspace/yaml_cpp/yaml_cpp.BUILD.tpl | 18 -- tools/workspace/zlib/zlib.bzl | 11 +- 21 files changed, 255 insertions(+), 813 deletions(-) delete mode 100644 third_party/com_github_google_kythe/LICENSE delete mode 100644 third_party/com_github_google_kythe/WORKSPACE delete mode 100644 third_party/com_github_google_kythe/tools/build_rules/config/BUILD.bazel delete mode 100644 third_party/com_github_google_kythe/tools/build_rules/config/BUILD.tpl delete mode 100644 third_party/com_github_google_kythe/tools/build_rules/config/common.bzl delete mode 100644 third_party/com_github_google_kythe/tools/build_rules/config/local.bzl delete mode 100644 third_party/com_github_google_kythe/tools/build_rules/config/pkg_config.bzl delete mode 100644 third_party/com_github_google_kythe/tools/build_rules/config/system.bzl delete mode 100644 third_party/com_github_google_kythe/tools/build_rules/config/wrapped_ctx.bzl delete mode 100644 third_party/com_github_google_kythe/tools/cdexec/BUILD.bazel delete mode 100644 third_party/com_github_google_kythe/tools/cdexec/cdexec.bzl delete mode 100755 third_party/com_github_google_kythe/tools/cdexec/cdexec.sh delete mode 100644 third_party/com_github_google_kythe/vendor.txt create mode 100644 tools/workspace/pkg_config.BUILD.tpl create mode 100644 tools/workspace/pkg_config.bzl delete mode 100644 tools/workspace/yaml_cpp/yaml_cpp.BUILD.tpl diff --git a/WORKSPACE b/WORKSPACE index c4ab2ecbe4a8..c9b595cc3214 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -18,23 +18,10 @@ workspace(name = "drake") load("//tools/workspace:bitbucket.bzl", "bitbucket_archive") load("//tools/workspace:github.bzl", "github_archive") +load("//tools/workspace:pkg_config.bzl", "pkg_config_repository") load("//tools/workspace:which.bzl", "which") load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") -local_repository( - name = "kythe", - # TODO(jwnimmer-tri) According to Bazel documentation, the `path` argument - # to `local_repository()` is supposed be an absolute path. We should be - # using using the __workspace_dir__ prefix here, like the other third_party - # workspace items below. However, doing so causes loading-phase errors. - # We suspect that those errors are due to a Bazel bug, possibly related to - # either bazelbuild/bazel#2811 and/or bazelbuild/bazel#269. Since the only - # use of kythe tooling is for pkg_config_package, and we plan to implement - # our own version of that soon anyway, we'll leave this alone for now, - # rather than diagnosing the errors. - path = "third_party/com_github_google_kythe", -) - github_archive( name = "tinydir", repository = "cxong/tinydir", @@ -75,31 +62,29 @@ new_local_repository( path = __workspace_dir__ + "/third_party/com_kitware_gitlab_cmake_cmake", ) -load("@kythe//tools/build_rules/config:pkg_config.bzl", "pkg_config_package") - -pkg_config_package( +pkg_config_repository( name = "ibex", modname = "ibex", ) -pkg_config_package( +pkg_config_repository( name = "dreal", modname = "dreal", ) -pkg_config_package( +pkg_config_repository( name = "glib", modname = "glib-2.0", ) -pkg_config_package( +pkg_config_repository( name = "gthread", modname = "gthread-2.0", ) # Load in the paths and flags to the system version of the protobuf runtime; # the Bazel build rules are loaded into "protobuf" via local_repository above. -pkg_config_package( +pkg_config_repository( name = "libprotobuf", modname = "protobuf", ) @@ -252,12 +237,12 @@ github_archive( build_file = "tools/workspace/fcl/fcl.BUILD.bazel", ) -pkg_config_package( +pkg_config_repository( name = "ipopt", modname = "ipopt", ) -pkg_config_package( +pkg_config_repository( name = "nlopt", modname = "nlopt", ) @@ -293,12 +278,12 @@ github_archive( build_file = "tools/workspace/lcmtypes_robotlocomotion/lcmtypes_robotlocomotion.BUILD.bazel", # noqa ) -pkg_config_package( +pkg_config_repository( name = "blas", modname = "blas", ) -pkg_config_package( +pkg_config_repository( name = "lapack", modname = "lapack", ) @@ -319,11 +304,11 @@ github_archive( build_file = "tools/workspace/tinyobjloader/tinyobjloader.BUILD.bazel", ) -pkg_config_package( +pkg_config_repository( name = "yaml_cpp", - atleast_version = "0.5.2", - build_file_template = "@drake//tools/workspace/yaml_cpp:yaml_cpp.BUILD.tpl", # noqa modname = "yaml-cpp", + atleast_version = "0.5.2", + extra_deps = ["@boost//:boost_headers"], ) load("//tools/workspace/buildifier:buildifier.bzl", "buildifier_repository") @@ -441,27 +426,27 @@ expat_repository( name = "expat", ) -pkg_config_package( +pkg_config_repository( name = "glew", modname = "glew", ) -pkg_config_package( +pkg_config_repository( name = "liblz4", modname = "liblz4", ) -pkg_config_package( +pkg_config_repository( name = "libpng", modname = "libpng", ) -pkg_config_package( +pkg_config_repository( name = "tinyxml", modname = "tinyxml", ) -pkg_config_package( +pkg_config_repository( name = "tinyxml2", modname = "tinyxml2", ) diff --git a/third_party/com_github_google_kythe/LICENSE b/third_party/com_github_google_kythe/LICENSE deleted file mode 100644 index d64569567334..000000000000 --- a/third_party/com_github_google_kythe/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/third_party/com_github_google_kythe/WORKSPACE b/third_party/com_github_google_kythe/WORKSPACE deleted file mode 100644 index 87ca36e82007..000000000000 --- a/third_party/com_github_google_kythe/WORKSPACE +++ /dev/null @@ -1,6 +0,0 @@ -# -*- python -*- - -# This file marks a workspace root for the Bazel build system. see -# http://bazel.io/ . - -workspace(name = "kythe") diff --git a/third_party/com_github_google_kythe/tools/build_rules/config/BUILD.bazel b/third_party/com_github_google_kythe/tools/build_rules/config/BUILD.bazel deleted file mode 100644 index ecb9098631f1..000000000000 --- a/third_party/com_github_google_kythe/tools/build_rules/config/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -package( - default_visibility = ["//visibility:public"], -) - -exports_files([ - "BUILD.tpl", -] + glob(["*.bzl"])) diff --git a/third_party/com_github_google_kythe/tools/build_rules/config/BUILD.tpl b/third_party/com_github_google_kythe/tools/build_rules/config/BUILD.tpl deleted file mode 100644 index cf4e135bd1d6..000000000000 --- a/third_party/com_github_google_kythe/tools/build_rules/config/BUILD.tpl +++ /dev/null @@ -1,12 +0,0 @@ -package( - default_visibility = ["//visibility:public"], -) - -cc_library( - name = "%{name}", - srcs = ["%{srcs}"], - hdrs = glob(["include/**"]), - defines = ["%{defines}"], - includes = ["%{includes}"], - linkopts = ["%{linkopts}"], -) diff --git a/third_party/com_github_google_kythe/tools/build_rules/config/common.bzl b/third_party/com_github_google_kythe/tools/build_rules/config/common.bzl deleted file mode 100644 index c9f01ade5937..000000000000 --- a/third_party/com_github_google_kythe/tools/build_rules/config/common.bzl +++ /dev/null @@ -1,66 +0,0 @@ -load(":wrapped_ctx.bzl", "repo_file", "repo_template") - -def error(message): - return struct(value=None, error=message) - -def success(value): - return struct(value=value, error=None) - -def globvalue(values, exclude=None, exclude_directories=True): - keyword_arguments = {} - if exclude: - keyword_arguments["exclude"] = exclude - if not exclude_directories: - keyword_arguments["exclude_directories"] = exclude_directories - return struct(context="list", - function_name="glob", - arguments=(values,), - keyword_arguments=keyword_arguments) - -def _fmt_key(key, context): - if context == "list": - return repr(["%{" + key + "}"]) - else: - return repr("%{" + key + "}") - -def _fmt_args(values): - return ", ".join([repr(v) for v in values]) - -def _fmt_kwargs(values): - return ", ".join(["%s=%s" % (k, repr(v)) for k, v in values.items()]) - -def _fmt_value(value): - if type(value) == "struct" and hasattr(value, "function_name"): - args = [] - if value.arguments: - args += [_fmt_args(value.arguments)] - if value.keyword_arguments: - args += [_fmt_kwargs(value.keyword_arguments)] - return "{}({})".format(value.function_name, ", ".join(args)) - else: - return repr(value) - -def _tmpl_entry(key, value): - context = getattr(value, "context", type(value)) - return _fmt_key(key, context), _fmt_value(value) - -def _tmpl_dict(values): - tmpl = {} - for item in values.items(): - key, value = _tmpl_entry(*item) - tmpl[key] = value - return tmpl - -def write_build(repo_ctx, includes, defines, linkopts, srcs=None): - if srcs == None: - srcs = ["empty.cc"] - # TODO(shahms): See if we can finally do away with this on OS X. - repo_file(repo_ctx, "empty.cc", "", False) - subs = _tmpl_dict({ - "name": repo_ctx.name, - "srcs": srcs, - "includes": includes, - "defines": defines, - "linkopts": linkopts, - }) - repo_template(repo_ctx, "BUILD", repo_ctx.attr.build_file_template, subs) diff --git a/third_party/com_github_google_kythe/tools/build_rules/config/local.bzl b/third_party/com_github_google_kythe/tools/build_rules/config/local.bzl deleted file mode 100644 index 0e555ea42213..000000000000 --- a/third_party/com_github_google_kythe/tools/build_rules/config/local.bzl +++ /dev/null @@ -1,58 +0,0 @@ -load(":common.bzl", "globvalue", "error", "success", "write_build") -load(":wrapped_ctx.bzl", "repo_path", "repo_symlink") - -def _find_home(repo_ctx): - varname = repo_ctx.attr.envvar - if varname in repo_ctx.os.environ: - return success(repo_path(repo_ctx, repo_ctx.os.environ[varname])) - if repo_ctx.attr.default: - return success(repo_path(repo_ctx, repo_ctx.attr.default)) - tmpl = "Environment variable '{}' not set and no default specified" - return error(tmpl.format(varname)) - -def setup_local_cc_library(repo_ctx): - home = _find_home(repo_ctx) - if home.error != None: - return home - paths = [home.value.get_child(p) for p in ["lib", "include"]] - for child in paths: - if not child.exists: - return error("{} not found".format(child)) - for child in paths: - repo_symlink(repo_ctx, child, child.basename) - # The values below should result in the following behavior: - # 1) "fully static" builds will be that, for any combination of .a and .so - # 2) "mostly static" builds will link statically against the lib if a .a is - # present, dynamically otherwise. - # 3) "dynamic" builds will link dynamically if a .so is present. - # - # All dynamic linking should prefer the specified path, but will - # use the system search path as well. - write_build(repo_ctx, - # In theory, Bazel supports versioned .so files, - # but in practice including them breaks static linking. - srcs=globvalue(["lib/*.a", "lib/*.so", "lib/*.dylib"]), - defines=repo_ctx.attr.defines, - includes=["include"], - linkopts=["-Wl,-rpath " + str(paths[0])]) - return success(True) - -def _impl(repo_ctx): - error = setup_local_cc_library(repo_ctx).error - if error != None: - fail(error) - -local_cc_library_configure = repository_rule( - _impl, - attrs = { - "envvar": attr.string(mandatory = True), - "default": attr.string(), - "defines": attr.string_list(), - "build_file_template": attr.label( - default = Label("@kythe//tools/build_rules/config:BUILD.tpl"), - single_file = True, - allow_files = True, - ), - }, - local = True, -) diff --git a/third_party/com_github_google_kythe/tools/build_rules/config/pkg_config.bzl b/third_party/com_github_google_kythe/tools/build_rules/config/pkg_config.bzl deleted file mode 100644 index 8a40a1795df9..000000000000 --- a/third_party/com_github_google_kythe/tools/build_rules/config/pkg_config.bzl +++ /dev/null @@ -1,190 +0,0 @@ -"""Skylark module for system libraries known to pkg-config. - -pkg_config_module(name, modname, - atleast_version, exact_version, max_version) - Create a local repository based on the results of pkg-config. - - Args: - name: string. The name of the repository. - modname: string. The name of the pkg-config module. - atleast_version: Optional, string. Require at least this version. - exact_version: Optional, string. Require exactly this version. - max_version: Optional, string. Require less than this version. - - The configured repository will have a `cc_library` target with the - provided `name`. -""" - -load(":common.bzl", "error", "success", "write_build") -load(":wrapped_ctx.bzl", "unwrap") - -def _write_build(repo_ctx, cflags, linkopts): - # Silence a warning about unknown cflags. - unsupported_cflags = ["frounding-math", "ffloat-store", "ffloat-store", "msse", "mfpmath"] - cflags = [cflag for cflag in cflags - if all([not cflag.startswith("-" + unsupported_cflag) - for unsupported_cflag in unsupported_cflags])] - if "-pthread" in cflags and "-pthread" in linkopts: - cflags.remove("-pthread") - includes, defines = _parse_cflags(repo_ctx, cflags) - write_build(repo_ctx, includes, defines, linkopts) - -def _fail(repo_ctx, message, tail=""): - """Fail with message if repo_ctx.attr.mandatory, otherwise warn.""" - modname = repo_ctx.attr.modname - if tail: - message = "\nError processing {}: {}\n\n{}".format(modname, message, tail) - else: - message = "\nError processing {}: {}".format(modname, message) - return error(message) - -def _find(repo_ctx): - pkg_config = unwrap(repo_ctx).which("pkg-config") - if pkg_config == None: - return _fail(repo_ctx, "Unable to find pkg-config executable") - return success(pkg_config) - -def _exists(repo_ctx, pc_args): - result = unwrap(repo_ctx).execute(pc_args + ["--print-errors", "--exists"]) - if result.return_code != 0: - return _fail(repo_ctx, "Unable to find module", result.stderr) - return success(True) - -def _installed_version(repo_ctx, pc_args): - result = unwrap(repo_ctx).execute(pc_args + ["--modversion"]) - if result.return_code != 0: - return _fail(repo_ctx, "Unable to determine installed version", result.stderr) - return success(result.stdout.strip()) - -def _check_version(repo_ctx, pc_args): - version_args = [] - for name in ["atleast_version", "max_version", "exact_version"]: - value = getattr(repo_ctx.attr, name, "") - if value: - version_args += ["--{}={}".format(name.replace("_", "-"), value)] - if not version_args: - return success(True) - - result = unwrap(repo_ctx).execute(pc_args + version_args) - if result.return_code != 0: - version = _installed_version(repo_ctx, pc_args) - if version.error != None: - return version - return _fail(repo_ctx, - "Installed version {} doesn't match constraints: {}".format( - version.value, " ".join(version_args)), - result.stderr) - else: - return success(True) - -def _cflags(repo_ctx, pc_args): - result = unwrap(repo_ctx).execute(pc_args + ["--cflags"]) - if result.return_code != 0: - return _fail(repo_ctx, "Unable to determine cflags", result.stderr) - stdout = result.stdout - return success([arg for arg in stdout.strip().split(" ") if arg]) - -def _linkopts(repo_ctx, pc_args): - result = unwrap(repo_ctx).execute(pc_args + ["--static", "--libs"]) - if result.return_code != 0: - return _fail(repo_ctx, "Unable to determine linkopts", result.stderr) - stdout = result.stdout - args = [arg for arg in stdout.strip().split(" ") if arg] - # Bazel "linkopts=" must be either switches ("-foo"), variables ("$(FOO)"), - # or labels ("foo"). We should only get switches from `pkg-config --libs`. - # However, sometimes it produces "-framework CoreFoundation" or similar, - # which is *supposed* to be a single switch, but our split heuristic chopped - # it up. We recombine non-switch args with their preceeding arg as a repair. - # We process args in reserve order to keep our loop index unchanged by a pop. - for i in reversed(range(len(args))): - # Switches stay put. - if args[i].startswith("-"): - continue - # A non-switch arg should be recombined with the preceding arg. - non_switch_arg = args.pop(i) - if i == 0: - _fail() - args[i - 1] += " " + non_switch_arg - return success(args) - -def _extract_prefix(flags, prefix): - stripped, remain = [], [] - for arg in flags: - if arg.startswith(prefix): - stripped += [arg[len(prefix):]] - else: - remain += [arg] - return stripped, remain - -def _extract_includes(cflags): - return _extract_prefix(cflags, "-I") - -def _extract_defines(cflags): - return _extract_prefix(cflags, "-D") - -def _symlink_directories(repo_ctx, basename, pathnames): - result = [] - root = unwrap(repo_ctx).path("") - base = root.get_child(basename) - rootlen = len(str(base)) - len(basename) # Include separator length. - for srcpath in [unwrap(repo_ctx).path(p) for p in pathnames]: - destpath = base.get_child(str(srcpath).replace('/', '_')) - unwrap(repo_ctx).symlink(srcpath, destpath) - result += [str(destpath)[rootlen:]] - return result - -def _parse_cflags(repo_ctx, cflags): - includes, cflags = _extract_includes(cflags) - defines, cflags = _extract_defines(cflags) - if cflags: - print("In pkg-config module {}, unhandled cflags: {}".format( - repo_ctx.attr.modname, cflags)) - - # We can only reliably point to include directories. - # `linkopts` leak into runtime for dynamic libraries and - # should point to the system paths. - includes = _symlink_directories(repo_ctx, "include", includes) - return includes, defines - -def setup_pkg_config_package(repo_ctx): - pkg_config = _find(repo_ctx) - if pkg_config.error != None: - return pkg_config - pc_args = [pkg_config.value, repo_ctx.attr.modname] - exists = _exists(repo_ctx, pc_args) - if exists.error != None: - return exists - version = _check_version(repo_ctx, pc_args) - if version.error != None: - return version - cflags = _cflags(repo_ctx, pc_args) - if cflags.error != None: - return cflags - - linkopts = _linkopts(repo_ctx, pc_args) - if linkopts.error != None: - return linkopts - - _write_build(repo_ctx, cflags.value, linkopts.value) - return success(True) - -def _impl(repo_ctx): - error = setup_pkg_config_package(repo_ctx).error - if error != None: - fail(error) - -pkg_config_package = repository_rule( - _impl, - attrs = { - "modname": attr.string(mandatory = True), - "atleast_version": attr.string(), - "max_version": attr.string(), - "exact_version": attr.string(), - "build_file_template": attr.label( - default = Label("@kythe//tools/build_rules/config:BUILD.tpl"), - single_file = True, - allow_files = True, - ), - }, - local = True, -) diff --git a/third_party/com_github_google_kythe/tools/build_rules/config/system.bzl b/third_party/com_github_google_kythe/tools/build_rules/config/system.bzl deleted file mode 100644 index 05ba98ae8ef1..000000000000 --- a/third_party/com_github_google_kythe/tools/build_rules/config/system.bzl +++ /dev/null @@ -1,73 +0,0 @@ -"""C System Library dependencies. - -This package exports a repository rule and macro. - -cc_system_package_configure: - This repository_rule combines behavior of both - local_cc_library_configure and pkg_config_package rules. - It first attempts to find the specified environment variable. - If present, it tries to use a local library directory at that path. - If absent or the rule fails, it attempts to use `pkg-config` to configure - the dependency. - Finally, if a default path is specified it will attempt to use that - as a local directory before failing. - -cc_system_package: - This is a macro which munges the name passed into a 'local_{name}' - repository, whose `:local_{name}` target is then bound to '{name}'. -""" - -load("@kythe//tools/build_rules/config:wrapped_ctx.bzl", "wrapctx") -load("@kythe//tools/build_rules/config:local.bzl", "setup_local_cc_library") -load("@kythe//tools/build_rules/config:pkg_config.bzl", "setup_pkg_config_package") - -def try_local_library(repo_ctx): - if repo_ctx.attr.envvar and repo_ctx.attr.envvar in repo_ctx.os.environ: - error = setup_local_cc_library(repo_ctx).error - if not error: - return None - print(repo_ctx.attr.envvar, "defined but unusable:", error) - return "" # Printed error as warning. - -def try_pkg_config(repo_ctx): - return setup_pkg_config_package(repo_ctx).error - -def try_default(repo_ctx): - if not repo_ctx.attr.default: - return "" - return setup_local_cc_library(repo_ctx).error - -def _impl(repo_ctx): - errors = [] - for setup in [try_local_library, try_pkg_config, try_default]: - error = setup(repo_ctx) - if error == None: - return - elif error: # Ignore "empty" errors. - errors += [error] - fail("\n".join(errors)) - -cc_system_package_configure = repository_rule( - _impl, - attrs = { - "modname": attr.string(mandatory = True), - "atleast_version": attr.string(), - "max_version": attr.string(), - "exact_version": attr.string(), - "envvar": attr.string(), - "default": attr.string(), - "defines": attr.string_list(), - "build_file_template": attr.label( - default = Label("@kythe//tools/build_rules/config:BUILD.tpl"), - single_file = True, - allow_files = True, - ), - }, - local = True, -) - -def cc_system_package(*, name, **kwargs): - if 'modname' not in kwargs: - kwargs['modname'] = name - cc_system_package_configure(name="local_" + name, **kwargs) - native.bind(name=name, actual="@local_{name}//:{name}".format(name=name)) diff --git a/third_party/com_github_google_kythe/tools/build_rules/config/wrapped_ctx.bzl b/third_party/com_github_google_kythe/tools/build_rules/config/wrapped_ctx.bzl deleted file mode 100644 index 3c1843eaf3f7..000000000000 --- a/third_party/com_github_google_kythe/tools/build_rules/config/wrapped_ctx.bzl +++ /dev/null @@ -1,39 +0,0 @@ -def unwrap(repository_ctx): - return getattr(repository_ctx, "repository_ctx", repository_ctx) - -def wrapctx(repository_ctx, attr=None, os=None, name=None, root=None): - if attr == None: - attr = repository_ctx.attr - if os == None: - os = repository_ctx.os - if name == None: - name = repository_ctx.name - if root == None: - root = repo_root(repository_ctx) - return struct( - repository_ctx=unwrap(repository_ctx), attr=attr, os=os, name=name, root=root) - -def repo_execute(ctx, args): - return unwrap(ctx).execute(args) - -def repo_root(ctx): - if hasattr(ctx, "root"): - return ctx.root - return ctx.path("") - -def repo_file(ctx, dest, contents, executable=True): - return unwrap(ctx).file(repo_path(ctx, dest), contents, executable) - -def repo_path(ctx, name): - if type(name) == "string" and not name.startswith("/"): - return repo_root(ctx).get_child(name) - elif type(name) == "path": - return name - return unwrap(ctx).path(name) - -def repo_symlink(ctx, src, dest): - return unwrap(ctx).symlink(repo_path(ctx, src), repo_path(ctx, dest)) - -def repo_template(ctx, dest, template, repl, executable=True): - return unwrap(ctx).template( - repo_path(ctx, dest), repo_path(ctx, template), repl, executable) diff --git a/third_party/com_github_google_kythe/tools/cdexec/BUILD.bazel b/third_party/com_github_google_kythe/tools/cdexec/BUILD.bazel deleted file mode 100644 index e8f20455c7a2..000000000000 --- a/third_party/com_github_google_kythe/tools/cdexec/BUILD.bazel +++ /dev/null @@ -1,10 +0,0 @@ -package( - default_visibility = ["//visibility:public"], -) - -exports_files(["cdexec.bzl"]) - -sh_binary( - name = "cdexec", - srcs = ["cdexec.sh"], -) diff --git a/third_party/com_github_google_kythe/tools/cdexec/cdexec.bzl b/third_party/com_github_google_kythe/tools/cdexec/cdexec.bzl deleted file mode 100644 index 1ab0ca2837dd..000000000000 --- a/third_party/com_github_google_kythe/tools/cdexec/cdexec.bzl +++ /dev/null @@ -1,12 +0,0 @@ -"""Skylark module with utilities and macros for running actions with cdexec.""" - -def rootpath(path): - """Returns a string which cdexec will interpret as absolute. - - Specifically, if the path starts with '/', it is returned unmodified. - Otherwise, the returns the path prefixed by the literal string '${PWD}/' - which will be expanded by the `cdexec` script into the Bazel exec root. - """ - if path.startswith("/"): - return path - return "${PWD}/" + path diff --git a/third_party/com_github_google_kythe/tools/cdexec/cdexec.sh b/third_party/com_github_google_kythe/tools/cdexec/cdexec.sh deleted file mode 100755 index 6798cec5cf82..000000000000 --- a/third_party/com_github_google_kythe/tools/cdexec/cdexec.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -# cdexec is a command wrapper for adapting utilities like cmake or ./configure -# which expect to read or output files relative to their current working -# directory for running under Bazel. - -usage() { - cat < - cdexec [-q|--quiet] -t|--temp TEMPLATE - -cdexec is a utility which changes current working directory, replaces all -occurrences of '\$\{PWD\}' from the command line with the previous PWD -and then execs that command line. -EOF -} - -_cdexec() { - local -r _ROOT="$PWD" # Save PWD. - local _QUIET="" # Allow silencing stdout. - local _DEST="" # The directory to cd into. - - while true; do - case "$1" in - -q | --quiet) - _QUIET="yes" - shift - ;; - -t | --temp) - shift - _DEST="$(mktemp -d "$1")" - shift - ;; - -*) - echo "Unrecognized option: $1" - usage - exit 1 - ;; - *) - if [[ "$_DEST" == "" ]]; then - _DEST="$1" - shift - fi - break # Exit at the first non-option argument. - ;; - esac - done - cd "$_DEST" - # Exec the remaining arguments, replacing ${PWD} with the original root. - # TODO(shahms): allow escaping the ${PWD}. - if [ "$_QUIET" = "yes" ]; then - exec "${@//\$\{PWD\}/${_ROOT}}" > /dev/null - else - exec "${@//\$\{PWD\}/${_ROOT}}" - fi -} - -_cdexec "$@" diff --git a/third_party/com_github_google_kythe/vendor.txt b/third_party/com_github_google_kythe/vendor.txt deleted file mode 100644 index dfd6ab20fb2d..000000000000 --- a/third_party/com_github_google_kythe/vendor.txt +++ /dev/null @@ -1,6 +0,0 @@ -The files in this directory tree (other than this file) are derived from Kythe: - - remote = "https://github.com/google/kythe.git" - sha = "5a42e0137ae93a3d890303ac03183156664e875d" - -Please update this metadata when copying new versions from upstream. diff --git a/tools/lint/buildifier-tables.json b/tools/lint/buildifier-tables.json index f3ea3508498e..ee0e78c68db3 100644 --- a/tools/lint/buildifier-tables.json +++ b/tools/lint/buildifier-tables.json @@ -37,6 +37,15 @@ "new_local_repository.path": 300, "new_local_repository.build_file_content": 360, + "pkg_config_repository.atleast_version": 200, + "pkg_config_repository.extra_srcs": 300, + "pkg_config_repository.extra_hdrs": 301, + "pkg_config_repository.extra_copts": 302, + "pkg_config_repository.extra_defines": 303, + "pkg_config_repository.extra_includes": 304, + "pkg_config_repository.extra_linkopts": 305, + "pkg_config_repository.extra_deps": 306, + "install.targets": 400, "install.archive_dest": 401, "install.archive_strip_prefix": 401, diff --git a/tools/workspace/expat/expat.bzl b/tools/workspace/expat/expat.bzl index 87859ec39ee4..ebb0d92c4ffd 100644 --- a/tools/workspace/expat/expat.bzl +++ b/tools/workspace/expat/expat.bzl @@ -25,8 +25,8 @@ Argument: """ load( - "@kythe//tools/build_rules/config:pkg_config.bzl", - "setup_pkg_config_package", + "@drake//tools/workspace:pkg_config.bzl", + "setup_pkg_config_repository", ) load("@drake//tools/workspace:os.bzl", "determine_os") @@ -59,7 +59,7 @@ cc_library( repository_ctx.file("BUILD", content = file_content, executable = False) else: - error = setup_pkg_config_package(repository_ctx).error + error = setup_pkg_config_repository(repository_ctx).error if error != None: fail(error) @@ -67,11 +67,6 @@ cc_library( expat_repository = repository_rule( attrs = { "modname": attr.string(default = "expat"), - "build_file_template": attr.label( - default = Label("@kythe//tools/build_rules/config:BUILD.tpl"), - single_file = True, - allow_files = True, - ), }, local = True, implementation = _impl, diff --git a/tools/workspace/gflags/gflags.bzl b/tools/workspace/gflags/gflags.bzl index b12deb58e470..fce58ad7064c 100644 --- a/tools/workspace/gflags/gflags.bzl +++ b/tools/workspace/gflags/gflags.bzl @@ -25,8 +25,8 @@ Argument: """ load( - "@kythe//tools/build_rules/config:pkg_config.bzl", - "setup_pkg_config_package", + "@drake//tools/workspace:pkg_config.bzl", + "setup_pkg_config_repository", ) load("@drake//tools/workspace:os.bzl", "determine_os") @@ -56,7 +56,7 @@ cc_library( repository_ctx.file("BUILD", content = file_content, executable = False) else: - error = setup_pkg_config_package(repository_ctx).error + error = setup_pkg_config_repository(repository_ctx).error if error != None: fail(error) @@ -64,11 +64,6 @@ cc_library( gflags_repository = repository_rule( attrs = { "modname": attr.string(default = "gflags"), - "build_file_template": attr.label( - default = Label("@kythe//tools/build_rules/config:BUILD.tpl"), - single_file = True, - allow_files = True, - ), }, local = True, implementation = _impl, diff --git a/tools/workspace/pkg_config.BUILD.tpl b/tools/workspace/pkg_config.BUILD.tpl new file mode 100644 index 000000000000..2800c88d33e2 --- /dev/null +++ b/tools/workspace/pkg_config.BUILD.tpl @@ -0,0 +1,14 @@ +# -*- python -*- + +package(default_visibility = ["//visibility:public"]) + +cc_library( + name = %{name}, + srcs = %{srcs}, + hdrs = %{hdrs}, + copts = %{copts}, + defines = %{defines}, + includes = %{includes}, + linkopts = %{linkopts}, + deps = %{deps}, +) diff --git a/tools/workspace/pkg_config.bzl b/tools/workspace/pkg_config.bzl new file mode 100644 index 000000000000..20ebe28383c0 --- /dev/null +++ b/tools/workspace/pkg_config.bzl @@ -0,0 +1,205 @@ +# -*- python -*- + +_DEFAULT_TEMPLATE = Label("@drake//tools/workspace:pkg_config.BUILD.tpl") + +def _run_pkg_config(repository_ctx, command_line): + """Run command_line and return its tokenized output.""" + result = repository_ctx.execute(command_line) + if result.return_code != 0: + return struct(error = "error {} from {}: {}{}".format( + result.return_code, command_line, result.stdout, result.stderr)) + tokens = [x for x in result.stdout.strip().split(" ") if x] + return struct(tokens = tokens, error = None) + +def setup_pkg_config_repository(repository_ctx): + """This is the macro form of the pkg_config_repository() rule below. + Refer to that rule's API documentation for details. + + This flavor of this rule is intended to be called by other repository_rule + implementation functions. The pkg_config_repository flavor of this rule is + intended to be called directly from the WORKSPACE file, or from a macro + that was called by the WORKSPACE file. + """ + # First locate pkg-config on the $PATH. + tool_path = repository_ctx.which("pkg-config") + if not tool_path: + return struct(error = "Could not find pkg-config on PATH={}".format( + repository_ctx.os.environ["PATH"])) + args = [tool_path, repository_ctx.attr.modname] + + # Check if we can find the required *.pc file of any version. + result = _run_pkg_config(repository_ctx, args) + if result.error != None: + return result + + # If we have a minimum version, enforce that. + atleast_version = getattr(repository_ctx.attr, "atleast_version", "") + if atleast_version: + result = _run_pkg_config(repository_ctx, args + [ + "--atleast-version", atleast_version]) + if result.error != None: + return struct(error = result.error + "during version check") + + # Determine linkopts. + result = _run_pkg_config(repository_ctx, args + ["--static", "--libs"]) + if result.error != None: + return result + linkopts = result.tokens + # Bazel "linkopts=" must be either switches ("-foo"), variables ("$(FOO)"), + # or labels ("foo"). We should only get switches from `pkg-config --libs`. + # However, sometimes it produces "-framework CoreFoundation" or similar, + # which is *supposed* to be a single switch, but our split heuristic + # chopped it up. We recombine non-switch args with their preceeding arg as + # a repair. We process args in reserve order to keep our loop index + # unchanged by a pop. + for i in reversed(range(len(linkopts))): + # Switches stay put. + if linkopts[i].startswith("-"): + continue + # A non-switch arg should be recombined with the preceding arg. + non_switch_arg = linkopts.pop(i) + if i == 0: + return struct(error = "malformed linkopts: " + repr(linkopts)) + linkopts[i - 1] += " " + non_switch_arg + + # Determine cflags; we'll split into includes and defines in a moment. + result = _run_pkg_config(repository_ctx, args + ["--cflags"]) + if result.error != None: + return result + cflags = result.tokens + # Placate whiny compilers. + if "-pthread" in cflags and "-pthread" in linkopts: + cflags.remove("-pthread") + + # Split cflags into includes and defines. The -I paths from pkg-config + # will be absolute paths; we'll make them relative in a moment. + absolute_includes = [] + defines = [] + unknown_cflags = [] + # We process in reserve order to keep our loop index unchanged by a pop. + for cflag in cflags: + if cflag.startswith("-I"): + absolute_includes += [cflag[2:]] + elif cflag.startswith("-D"): + defines += [cflag[2:]] + elif cflag in [ + "-frounding-math", + "-ffloat-store", + "-msse", + "-msse2", + "-msse3", + "-msse4", + "-mfpmath"]: + # We know these are okay to ignore. + pass + else: + unknown_cflags += [cflag] + if unknown_cflags: + print("pkg-config of {} returned flags that we will ignore: {}".format( + repository_ctx.attr.modname, unknown_cflags)) + + # Symlink the absolute include paths into our repository, to obtain + # relative paths for them as required by cc_library's attributes. + includes = [] + hdrs_path = repository_ctx.path("include") + for item in absolute_includes: + symlink_dest = item.replace('/', '_') + repository_ctx.symlink( + repository_ctx.path(item), + hdrs_path.get_child(symlink_dest)) + includes += ["include/" + symlink_dest] + hdrs_prologue = "glob([\"include/**\"]) + " + + # Write out the BUILD file. + substitutions = { + "%{name}": repr( + repository_ctx.name), + "%{srcs}": repr( + getattr(repository_ctx.attr, "extra_srcs", [])), + "%{hdrs}": ( + hdrs_prologue + repr( + getattr(repository_ctx.attr, "extra_hdrs", []))), + "%{copts}": repr( + getattr(repository_ctx.attr, "extra_copts", [])), + "%{defines}": repr( + defines + getattr(repository_ctx.attr, "extra_defines", [])), + "%{includes}": repr( + includes + getattr(repository_ctx.attr, "extra_includes", [])), + "%{linkopts}": repr( + linkopts + getattr(repository_ctx.attr, "extra_linkopts", [])), + "%{deps}": repr( + getattr(repository_ctx.attr, "extra_deps", [])), + } + template = getattr( + repository_ctx.attr, "build_file_template", _DEFAULT_TEMPLATE) + repository_ctx.template("BUILD", template, substitutions) + + return struct(value = True, error = None) + +def _impl(repository_ctx): + result = setup_pkg_config_repository(repository_ctx) + if result.error != None: + fail("Unable to complete pkg-config setup for @{} repository: {}". + format(repository_ctx.name, result.error)) + +pkg_config_repository = repository_rule( + attrs = { + "modname": attr.string(mandatory = True), + "atleast_version": attr.string(), + "build_file_template": attr.label( + default = _DEFAULT_TEMPLATE, + single_file = True, + allow_files = True, + ), + "extra_srcs": attr.string_list(), + "extra_hdrs": attr.string_list(), + "extra_copts": attr.string_list(), + "extra_defines": attr.string_list(), + "extra_includes": attr.string_list(), + "extra_linkopts": attr.string_list(), + "extra_deps": attr.string_list(), + }, + environ = [ + "PATH", + "PKG_CONFIG_PATH", + ], + local = True, + implementation = _impl, +) + +"""Creates a repository that contains a single library target, based on the +results of invoking pkg-config. + +The pkg_config_repository flavor of this rule is intended to be called directly +from the WORKSPACE file, or from a macro that was called by the WORKSPACE file. +The setup_pkg_config_repository flavor of this rule is intended to be called by +other repository_rule implementation functions. + +Example: + WORKSPACE: + load("@drake//tools/workspace:pkg_config.bzl", "pkg_config_repository") + pkg_config_repository( + name = "foo", + modname = "foo-2.0", + ) + + BUILD: + cc_library( + name = "foobar", + deps = ["@foo"], + srcs = ["bar.cc"], + ) + +Args: + name: A unique name for this rule. + modname: The library name as known to pkg-config. + atleast_version: (Optional) The --atleast-version to pkg-config. + build_file_template: (Optional) (Advanced) Override the BUILD template. + extra_srcs: (Optional) Extra items to add to the library target. + extra_hdrs: (Optional) Extra items to add to the library target. + extra_copts: (Optional) Extra items to add to the library target. + extra_defines: (Optional) Extra items to add to the library target. + extra_includes: (Optional) Extra items to add to the library target. + extra_linkopts: (Optional) Extra items to add to the library target. + extra_deps: (Optional) Extra items to add to the library target. +""" diff --git a/tools/workspace/yaml_cpp/yaml_cpp.BUILD.tpl b/tools/workspace/yaml_cpp/yaml_cpp.BUILD.tpl deleted file mode 100644 index ebff1b5ee0f0..000000000000 --- a/tools/workspace/yaml_cpp/yaml_cpp.BUILD.tpl +++ /dev/null @@ -1,18 +0,0 @@ -# Altered copy of the pkg_config_package build template. -# Adds a hard-coded dependency on "@boost" to work around a yaml-cpp -# misconfiguration. -# https://github.com/RobotLocomotion/drake/pull/7602#issuecomment-353093726 - -package( - default_visibility = ["//visibility:public"], -) - -cc_library( - name = "%{name}", - srcs = ["%{srcs}"], - hdrs = glob(["include/**"]), - defines = ["%{defines}"], - includes = ["%{includes}"], - linkopts = ["%{linkopts}"], - deps = ["@boost//:boost_headers"] -) diff --git a/tools/workspace/zlib/zlib.bzl b/tools/workspace/zlib/zlib.bzl index 8dd41fb63edc..58d55081cb9c 100644 --- a/tools/workspace/zlib/zlib.bzl +++ b/tools/workspace/zlib/zlib.bzl @@ -25,8 +25,8 @@ Argument: """ load( - "@kythe//tools/build_rules/config:pkg_config.bzl", - "setup_pkg_config_package", + "@drake//tools/workspace:pkg_config.bzl", + "setup_pkg_config_repository", ) load("@drake//tools/workspace:os.bzl", "determine_os") @@ -58,7 +58,7 @@ cc_library( repository_ctx.file("BUILD", content = file_content, executable = False) else: - error = setup_pkg_config_package(repository_ctx).error + error = setup_pkg_config_repository(repository_ctx).error if error != None: fail(error) @@ -66,11 +66,6 @@ cc_library( zlib_repository = repository_rule( attrs = { "modname": attr.string(default = "zlib"), - "build_file_template": attr.label( - default = Label("@kythe//tools/build_rules/config:BUILD.tpl"), - single_file = True, - allow_files = True, - ), }, local = True, implementation = _impl,