Commit Graph

42 Commits

Author SHA1 Message Date
Mateusz Matejczyk
294b5758c3
Output *_pb2_grpc.py when use_grpc_plugin=True
Start outputting missing *_pb2_grpc.py files when  use_grpc_plugin is set to True for py_proto_library.
2018-03-11 17:48:10 -04:00
James O'Kane
950f5e4205 Replace //:protoc and similar default macro arguments with
@com_google_protobuf prefixed versions. This allows them to work in 3rd party
repositories.

Fix a bad visibility rule. :hidden does not exist, but :private does.
2018-03-08 22:30:44 -08:00
Fahrzin Hemmati
35119e39a0 Add a check_protobuf_required_bazel_version() for use in WORKSPACEs 2017-12-04 15:12:08 -08:00
Vladimir Moskva
4fc93044a5 Make .bzl files compatible with future versions of Bazel 2017-08-07 13:33:03 +02:00
Marco A. Harrendorf
dd04ffb923 Adding default shell env
I am adding default shell environment, so that protobuf compilation makes use of set
LD_LIBRARY_PATH and so on.
In this way, also non-default gcc installations (e.g. not in /usr/lib) can be used to compile protobuf.
This would fix the following issue:
https://github.com/bazelbuild/bazel/issues/2515
2017-04-03 17:01:36 +02:00
cgrushko
6fffd4adb4 Bazel can build protobuf when it's not in the root
That is, Bazel can now build protobuf when the latter resides in a subdirectory of a project.
2017-02-08 12:19:40 -05:00
Kristina Chodorow
4e7ecde15c Update genfiles paths to work with a different execroot arrangement
Bazel is changing the way the execution root is organized (see https://github.com/bazelbuild/bazel/issues/1681
for details) and this updates the protobuf path logic to work with both old
and new versions of Bazel.
2017-01-25 14:10:56 -05:00
Adam Cozzette
39f9b43219 Merge pull request #2403 from google/down-integrate-with-msvc-fix
Integrated internal changes from Google
2016-11-23 11:26:31 -08:00
Wiktor Tomczak
0fa31b2bfa Support grpc plugin in py_proto_library 2016-11-22 20:21:10 +01:00
Adam Cozzette
5d63097fc2 Merge branch 'master' into down-integrate-with-msvc-fix 2016-11-17 17:04:30 -08:00
Adam Cozzette
5a76e633ea Integrated internal changes from Google 2016-11-17 16:59:59 -08:00
Feng Xiao
993d604030 Merge pull request #1959 from abergmeier-dsfishlabs/feature/cpp
Need to expose generated protobuf C++ headers
2016-10-13 15:31:18 -07:00
Florian Weikert
c2b3e70efd Declare all inputs of protoc action
ctx.executable.plugin must be in the inputs of protoc's action when using a plugin, otherwise the action will fail.

This bug has been hidden by a bug in Bazel: for every ctx.action, Bazel used to automatically add the runfiles of all executable inputs of the RULE instead of using the inputs of the specific ACTION. Consequently, we could get away with underspecifying the inputs of the action.
2016-10-12 14:03:07 +02:00
Vladimir Moskva
5caf516976 Resolved a conflict 2016-09-12 11:27:28 +02:00
Vladimir Moskva
a86e6d8db2 Compatibility with the new version of Bazel.
Global variable HOST_CFG is deprecated and will not be supported soon.
2016-09-09 13:21:35 +02:00
Andreas Bergmeier
bbeb983bac Need to expose generated protobuf C++ headers so they can actually be accessed from other libraries. 2016-08-15 16:57:30 +02:00
Yuki Yugui Sonoda
5977fb0a05 Generalize plugin support in Bazel Skylark rule
It helps users to support their own plugins in a manner consistent to
cc_proto_library and py_proto_libary in their skylark rules
2016-06-01 16:23:15 +09:00
David Z. Chen
02cd45ca35 Bazel build: Keep generated sources and Python runtime in the same directory.
Users often encounter a Python import error when trying to build Python
protos if protobuf is installed locally on the machine. In this case,
Python ends up looking in the wrong directory when importing files (see
bazelbuild/bazel#1209 and tensorflow/tensorflow#2021). It seems that the
problem is caused by Python getting confused when there are Python
source files that are meant to be part of the same package but are
in separate directories.

Prior to #1233, the Bazel build setup would copy the Python
runtime sources and all generated sources for the builtin protos into
the root directory (assuming that the protobuf tree is vendored in a
google/protobuf directory).

With #1233, the two sets of sources are kept in their respective
directories but both `src/` and `python/` are added to the `PYTHONPATH`
using the new `imports` attribute of the Bazel Python rules. However,
both the runtime sources and the generated sources are under the same
package: `google.protobuf`, causing Python to become confused when
trying to import modules that are in the other directory.

This patch adds a workaround to the Bazel build to add a modified
version of the original `internal_copied_filegroup` macro to copy the
`.proto` files under `src/` to `python/` before building the
`py_proto_library` targets for the builtin protos. This ensures that the
generated sources for the builtin protos will be in the same directory
as the corresponding runtime sources.

This patch was tested with the following:
* All Python tests in protobuf
* All Python tests in tensorflow
* All tests in [Skydoc](https://github.com/bazelbuild/skydoc)
* Importing protobuf as `//google/protobuf`
* Importing and binding targets under `//external`
* Importing protobuf as `//third_party/protobuf`
2016-05-25 18:02:09 -07:00
Steven Parkes
ea1886661e pass correct args to protoc for java wellknown protos when used as an external repository 2016-03-10 15:04:46 -08:00
David Z. Chen
985c968443 Remove hack for building Python support with Bazel.
This change makes use of new imports attribute for Bazel's Python rules, which
enable adding directories to the PYTHONPATH. This allows us to remove
the hack for building protobuf's Python support with Bazel and now
allows projects to include protobuf using a Bazel external repository
rather than requiring it to be imported directly into the source tree as
//google/protobuf.

This change also updates the protobuf BUILD file to use a named
repository, @python//, for including Python headers rather than
//util/python. This allows projects to specify their own package for
Python headers when including protobuf with an external repository.

Fixes #1230
2016-02-25 12:52:21 -08:00
Manjunath Kudlur
f5c736352e Fixed grpc C++ plugin support.
grpc C++ plugin generates additional files, namely .grpc.pb.cc and
.grpc.pb.h. Adding these files to the outs of the _proto_gen rule, so
dependents don't complain about undeclared inclusions. Also, compiling
the .grpc.pb.cc requires additional header files from the grpc library,
so added //external:grpc_lib to the deps of the
cc_library. Clients are expected to declare that in their bazel
WORKSPACE, pointing it to @grpc//:grpc++{_unsecure}.
2016-02-25 08:50:50 -08:00
Manjunath Kudlur
f0966a746e Added grpc plugin support to cc_proto_library.
cc_proto_library now supports use_grpc_plugin flag that passes
--plugin=protoc-gen-grpc=grpc_cpp_plugin to protoc compiler
invocation. grpc_cpp_plugin is assumed to be present as
//external:grpc_cpp_plugin, so clients can setup their WORKSPACE files
appropriately to point to grpc location using bind.
2016-02-22 14:30:43 -08:00
Damien Martin-Guillerez
76547e5190 Make protobuf Skylark extension appends the workspace root
This change make protobuf skylark extension works when using
remote repository.

Note that this make the Skylark extension unusable prior
to Bazel 0.1.4 because the workspace_root is not available
on prior version.

Tested with Bazel 0.1.4rc2.

Fixes https://github.com/bazelbuild/bazel/issues/784.
2016-01-15 23:12:09 +01:00
Martin Maly
8e0c9a3f11 Making _genproto rules public.
This enables other xx_proto_library targets to depend on xx_proto_library
targets in different packages, and specifically on xx_wkt_protos.
2015-12-04 17:53:07 -08:00
Andrew Harp
38f131fd8c Build protoc for host platform to enable cross-compilation.
This is necessary to run protoc on the host as a dependency for Android BUILD targets with Bazel.
2015-11-03 16:39:32 -05:00
Jisi Liu
d4bef7d41b add warning notes for cc|py_proto_library rules.
To mention that the interface may change or be removed when bazel has
support it natively.
2015-11-02 12:24:32 -08:00
Jisi Liu
be92ffbf74 add default_runtime attribute to cc|py rules.
This adds implicit dependencies to the coressponding runtime libraries.
2015-10-27 15:11:38 -07:00
Jisi Liu
6ddcae225c Use && for internal_copied_filegroup.
So that the rule fails if one or more files cannot be copied.
2015-10-21 10:48:33 -07:00
Jisi Liu
bc4fd15209 Rename copeid_src to internal_copied_filegroup 2015-10-20 16:02:58 -07:00
Jisi Liu
a33fa8eddc fix sources for python target and add needed dependencies. 2015-10-20 15:30:44 -07:00
Jisi Liu
53a56be4c4 Change the impl rule include to includes.
We need to use the list to indicate field presense.
The field must only contain 0 or 1 string element.
2015-10-20 15:18:20 -07:00
Jisi Liu
04658a3c24 Change default value of protoc on xx_proto_library rules. 2015-10-20 15:00:13 -07:00
Jisi Liu
7b948cc7c5 Support python for bazel. 2015-10-19 17:56:27 -07:00
Jisi Liu
993fb7013e Python bazel support. 2015-10-19 17:19:49 -07:00
Jisi Liu
6dac0822c4 Allow include to be None.
This enables the use case where all the paths are relative to the
workspace root, e.g.

foo/bar/BUILD
       /foo.proto -- package foo.bar

would generate the message correctly.
2015-10-19 14:41:00 -07:00
Jisi Liu
3101e7337c Change prefix to include, and add docs 2015-10-16 12:46:26 -07:00
Jisi Liu
d8701b5741 Rename deps/proto_deps to cc_libs/deps 2015-10-16 11:44:21 -07:00
Jisi Liu
9c7d9c0925 style/naming fix 2015-10-15 10:51:32 -07:00
Jisi Liu
25d75b5665 make cc_out and py_out internal. 2015-10-14 17:41:14 -07:00
Jisi Liu
125a91be08 Format code. 2015-10-14 17:37:39 -07:00
Jisi Liu
ee8131a62f buildifier the file 2015-10-14 17:20:05 -07:00
Jisi Liu
39362b35b2 Extract protoc action into .bzl for cc.
This is needed to support python bazel build.
2015-10-14 17:12:11 -07:00