This gist demonstrates usage of github.com/kythe/kythe as a dependency in a bazel-based project
Last active
October 13, 2020 19:23
-
-
Save justbuchanan/92c9e19fb33515cab8354da5638d1789 to your computer and use it in GitHub Desktop.
Use github.com/kythe/kythe as a bazel dependency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ensure clang is used, by default, over any other C++ installation (e.g. gcc). | |
build --client_env=CC=clang | |
# We require C++17, but bazel defaults to C++0x (pre-C++11). | |
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17 --client_env=BAZEL_CXXOPTS=-std=c++17 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3.4.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bazel-* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# simple target that depends on a kythe indexer (but doesn't use it) | |
genrule( | |
name = "test", | |
outs = ["out.txt"], | |
cmd = "touch $(location out.txt)", | |
tools = [ | |
"@io_kythe//kythe/cxx/indexer/textproto:textproto_indexer", | |
], | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
workspace( | |
name = "com_test", | |
managed_directories = {"@npm": ["node_modules"]}, | |
) | |
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | |
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | |
# http_archive( | |
# name = "io_kythe", | |
# strip_prefix = "kythe-0.0.48", | |
# urls = ["https://github.com/kythe/kythe/archive/v0.0.48.tar.gz"], | |
# ) | |
git_repository( | |
name = "io_kythe", | |
branch = "master", | |
remote = "https://github.com/kythe/kythe", | |
) | |
http_archive( | |
name = "bazel_toolchains", | |
sha256 = "882fecfc88d3dc528f5c5681d95d730e213e39099abff2e637688a91a9619395", | |
strip_prefix = "bazel-toolchains-3.4.0", | |
urls = [ | |
"https://github.com/bazelbuild/bazel-toolchains/releases/download/3.4.0/bazel-toolchains-3.4.0.tar.gz", | |
"https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/3.4.0/bazel-toolchains-3.4.0.tar.gz", | |
], | |
) | |
load("@io_kythe//:setup.bzl", "kythe_rule_repositories", "maybe") | |
kythe_rule_repositories() | |
# TODO(schroederc): remove this. This needs to be loaded before loading the | |
# go_* rules. Normally, this is done by go_rules_dependencies in external.bzl, | |
# but because we want to overload some of those dependencies, we need the go_* | |
# rules before go_rules_dependencies. Likewise, we can't precisely control | |
# when loads occur within a Starlark file so we now need to load this | |
# manually... | |
load("@io_bazel_rules_go//go/private:repositories.bzl", "go_name_hack") | |
maybe( | |
go_name_hack, | |
name = "io_bazel_rules_go_name_hack", | |
is_rules_go = False, | |
) | |
load("@io_kythe//:external.bzl", "kythe_dependencies") | |
kythe_dependencies() | |
load("@io_kythe//tools/build_rules/external_tools:external_tools_configure.bzl", "external_tools_configure") | |
external_tools_configure() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment