Build complains "No such file or directory" without adding copts

915 views
Skip to first unread message

lian...@deepmap.ai

unread,
Mar 17, 2017, 2:00:31 PM3/17/17
to bazel-discuss
Hi,
My project depends on grpc, which is another bazel project.
The WORKSPACE file has:
git_repository(
    name
= "grpc_git",
    remote
= "https://github.com/grpc/grpc.git",
    commit
= "c6a4539f80a6f3b97b29628c413c7f7eb62d9420",
    init_submodules
= 1,
)

bind
(
    name
= "grpc++_reflection",
    actual
= "@grpc_git//:grpc++_reflection",
)


When I tried to build:
bazel build //external:grpc++_reflection, it complains:
bazel
-out/local-fastbuild/genfiles/external/grpc_git/src/proto/grpc/reflection/v1alpha/reflection.pb.cc:5:79: fatal error: external/grpc_git/src/proto/grpc/reflection/v1alpha/reflection.pb.h: No such file or directory



I had to add copts=["-Ibazel-out/local-fastbuild/genfiles"] in GRPC's bazel/grpc_build_system.bzl and cc_grpc_library.bzl files to make it build.

Is this a bug or how can I add the genfiles to the include path automatically? Thanks a lot in advance!

László Csomor

unread,
Mar 20, 2017, 5:18:21 AM3/20/17
to lian...@deepmap.ai, bazel-discuss, Jakob Buchgraber
+buchgr: you were trying to build the latest gRPC with Bazel, right? Does this issue look familiar?



--
László Csomor | Software Engineer | laszlo...@google.com

Google Germany GmbH | Erika-Mann-Str. 33 | 80636 München | Germany
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/e7763f8a-8e84-4edd-b58e-9568843b2afc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jakob Buchgraber

unread,
Mar 20, 2017, 6:46:42 AM3/20/17
to László Csomor, lian...@deepmap.ai, bazel-discuss
Hi,

no I haven't had this issue. Sorry :\.

- Jakob

To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.

Marcel Hlopko

unread,
Mar 20, 2017, 6:49:27 AM3/20/17
to Jakob Buchgraber, László Csomor, lian...@deepmap.ai, ca...@google.com, bazel-discuss
+Carmi Grushko Carmi, anything relevant from the top of your head?


For more options, visit https://groups.google.com/d/optout.
--
-- 
Marcel Hlopko | Software Engineer | hlo...@google.com | 

Google Germany GmbH | Erika-Mann-Str. 33  | 80636 München | Germany | Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle | Registergericht und -nummer: Hamburg, HRB 86891

Carmi Grushko

unread,
Mar 20, 2017, 10:27:46 AM3/20/17
to Marcel Hlopko, Nicolas Noble, grpc-...@google.com, bazel-discuss, lian...@deepmap.ai, Jakob Buchgraber, László Csomor
+nnoble, grpc-c-team

On Mar 20, 2017 6:49 AM, "Marcel Hlopko" <hlo...@google.com> wrote:
+Carmi Grushko Carmi, anything relevant from the top of your head?

To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discuss+unsubscribe@googlegroups.com.

lian...@deepmap.ai

unread,
Mar 20, 2017, 6:55:33 PM3/20/17
to bazel-discuss, hlo...@google.com, nno...@google.com, grpc-...@google.com, lian...@deepmap.ai, buc...@google.com, laszlo...@google.com, ca...@google.com
I made the change to grpc project file: bazel/cc_grpc_library.bzl and grpc_build_system.bzl file:
diff --git a/bazel/cc_grpc_library.bzl b/bazel/cc_grpc_library.bzl
index ab1add476
..dd637b52e 100644
--- a/bazel/cc_grpc_library.bzl
+++ b/bazel/cc_grpc_library.bzl
@@ -42,6 +42,10 @@ def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, use_externa
       
**kwargs
   
)

+  # When another project depends on the grpc project as an external project,
+  # the $(GENFILES) path must be added.
+  copts = ["-I$(GENDIR)"]
+
   
if not proto_only:
     
if use_external:
       
# when this file is used by non-grpc projects
@@ -69,6 +73,7 @@ def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, use_externa
         srcs
= [":" + codegen_grpc_target, ":" + codegen_target],
         hdrs
= [":" + codegen_grpc_target, ":" + codegen_target],
         deps
= deps + grpc_deps,
+        copts = copts,
         
**kwargs
     
)
   
else:
@@ -77,5 +82,6 @@ def cc_grpc_library(name, srcs, deps, proto_only, well_known_protos, use_externa
         srcs
= [":" + codegen_target],
         hdrs
= [":" + codegen_target],
         deps
= deps + ["//external:protobuf"],
+        copts = copts,
         
**kwargs
     
)
diff
--git a/bazel/grpc_build_system.bzl b/bazel/grpc_build_system.bzl
index
8b524bd0e..9836130a0 100644
--- a/bazel/grpc_build_system.bzl
+++ b/bazel/grpc_build_system.bzl
@@ -34,9 +34,9 @@
 
#

 
def grpc_cc_library(name, srcs = [], public_hdrs = [], hdrs = [], external_deps = [], deps = [], standalone = False, language = "C++"):
-  copts = []
+  copts = ["-I$(GENDIR)"]
   
if language.upper() == "C":
-    copts = ["-std=c99"]
+    copts += ["-std=c99"]
   
native.cc_library(
     name
= name,
     srcs
= srcs,
@@ -68,4 +68,3 @@ def grpc_proto_library(name, srcs = [], deps = [], well_known_protos = None,
     proto_only
= not has_services,
     use_external
= use_external,
   
)
-

Also I need to bazel 0.4.5 to make it work.



On Monday, March 20, 2017 at 7:27:46 AM UTC-7, Carmi Grushko wrote:
+nnoble, grpc-c-team

On Mar 20, 2017 6:49 AM, "Marcel Hlopko" <hlo...@google.com> wrote:
+Carmi Grushko Carmi, anything relevant from the top of your head?

To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.

Nicolas Noble

unread,
Mar 21, 2017, 11:29:15 AM3/21/17
to lian...@deepmap.ai, bazel-discuss, László Csomor, buc...@google.com, ca...@google.com, grpc-...@google.com, hlo...@google.com
Huh that's odd. Thanks for the heads up. 
Reply all
Reply to author
Forward
0 new messages