Including GRPC in Bazel project using new_http_repository

575 views
Skip to first unread message

kst...@lyft.com

unread,
Jun 22, 2018, 8:09:13 PM6/22/18
to grpc.io
I'm trying to build GRPC inside another Bazel project, per the instructions at https://github.com/grpc/grpc/tree/master/src/cpp#bazel

I created an empty directory and then added a file called WORKSPACE in it with the following contents:

workspace(name = "test_workspace") 
 
http_archive(
    name = "grpc",
    urls = [
        "https://github.com/grpc/grpc/archive/3acf8e62079e727ae1925be759fa917f10e982bb.tar.gz",
    ],
    strip_prefix = "grpc-3acf8e62079e727ae1925be759fa917f10e982bb",
)

Then I ran the command:

bazel build @grpc//:grpc

This gave an error:

WARNING: /home/lyft/.cache/bazel/_bazel_lyft/6c07f772a73c5c85819de1ca1f730e38/external/grpc/WORKSPACE:1: Workspace name in /home/lyft/.cache/bazel/_bazel_lyft/6c07f772a73c5c85819de1ca1f730e38/external/grpc/WORKSPACE (@com_github_grpc_grpc) does not match the name given in the repository's definition (@grpc); this will cause a build error in future versions
ERROR: /home/lyft/.cache/bazel/_bazel_lyft/6c07f772a73c5c85819de1ca1f730e38/external/grpc/BUILD:1752:1: no such target '//external:nanopb': target 'nanopb' not declared in package 'external' defined by /home/lyft/foo/WORKSPACE and referenced by '@grpc//:alts_proto'
ERROR: /home/lyft/.cache/bazel/_bazel_lyft/6c07f772a73c5c85819de1ca1f730e38/external/grpc/BUILD:1770:1: no such target '//external:nanopb': target 'nanopb' not declared in package 'external' defined by /home/lyft/foo/WORKSPACE and referenced by '@grpc//:alts_util'
ERROR: Analysis of target '@grpc//:grpc' failed; build aborted: Loading failed
INFO: Elapsed time: 0.175s
FAILED: Build did NOT complete successfully (0 packages loaded)

I'm guessing I need to flesh out my WORKSPACE file in some way in order to get GRPC to build, but I'm not sure what is missing. How can I make GRPC build?

Thanks,
Kerrick

George Gensure

unread,
Jun 23, 2018, 12:27:11 AM6/23/18
to kst...@lyft.com, grpc.io
Their instructions appear to be a little out of date, and they actually provide mechanisms for doing a proper repo import. Make your WORKSPACE look like this:

http_archive(
    name = "com_github_grpc_grpc",
    urls = [
    ],
    strip_prefix = "grpc-3acf8e62079e727ae1925be759fa917f10e982bb",
)

load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")

grpc_deps()

And run the command:

bazel build @com_github_grpc_grpc//:grpc

That should get you started.

-George


--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/78d9c78f-5c3b-4831-b7c7-35eca04bb820%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages