Commit Graph

63 Commits

Author SHA1 Message Date
Yannic Bonenberger
723a85f797 [bazel] Remove bootstrap hack from cc_proto_library and add interop with proto_library
Bazel had a native `cc_proto_library` for more than 2 years now.
This is the first step towards removing that rule from the Protobuf
repo.
2020-03-04 09:25:41 -08:00
Yannic
f0cb9cdb95
[bazel] Move Java runtime/toolchains into //java (#7190)
* [bazel] Move Java runtime/toolchains into //java

This change moves `java_library` targets from the top-level BUILD file
into `//java/{core,lite,util}` and declares `alias` targets to point to
their new locations (hence, this is not a breaking change).

This will allow users that don't use Java to stop depending on
`@rules_java` (e.g. as requested in
https://github.com/bazelbuild/rules_scala/pull/989#issuecomment-583405161).

Note that there is no intention to deprecate + remove the top-level
targets in the foreseeable future.

* Add BUILD files in //java to java_EXTRA_DIST
2020-02-13 13:04:14 -08:00
Brian Wignall
a104dffcb6 Fix typos (#7050)
Uses https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines to find likely typos, with https://github.com/bwignall/typochecker to help automate the checking.
2020-01-08 10:18:20 -08:00
Yannic Bonenberger
d2d6ff51a8 [bazel] Load python rules from @rules_python 2019-08-06 16:50:32 -07:00
Yannic Bonenberger
bf0c69e130 [bazel] Add fixes for --incompatible_load_{cc,java,proto}_rules_from_bzl (Part 2)
This change adds the required loads to examples and zlib.
For full compatibility with --incompatible_load_{cc,java,proto}_rules_from_bzl,
we will need to roll gtest to a newer version.
2019-07-29 14:14:04 -07:00
Benjamin Peterson
6153f80876 Treat plugins as host tools.
As a followup to ca3ead7745, treat plugin executables as well as protoc as host tools.
2019-06-06 12:48:55 -07:00
Keith Smiley
ca3ead7745 Move tool out of inputs in bazel config
This fixes compatibility with bazel when passing `--incompatible_no_support_tools_in_action_inputs` which will be flipped in an upcoming release.
2019-05-28 10:46:14 -07:00
Paul Yang
cecba296b8
Down-integrate internal changes (#5467)
* Down-integrate internal changes

* Update generated code for php, objc and csharp.

* Add missing dependency in conformance_php
2018-12-14 16:05:03 -08:00
Jon Brandvein
7b28271a61 Migrate to new ctx.actions API (#5367)
* Migrate to new `ctx.actions` API

This allows building with --incompatible_new_actions_api.

* Fix typo
2018-11-15 18:19:06 -08:00
Roger Chen
7492b56812 Import versions from @bazel_skylib//lib:versions.bzl
@bazel_skylib//:lib is supposedly deprecated. The 'versions' struct in lib.bzl was committed to bazel-skylib at the same time as //lib:versions.bzl, so there should be no backward incompatibility.
2018-11-02 23:13:17 -07:00
James Judd
d5f0dac497 Change deprecated Bazel single file attr param
This removes the need for --incompatible_disable_deprecated_attr_params
when using Protobuf
2018-08-14 21:55:35 -06:00
Adam Cozzette
2c30fa71e7
Merge pull request #3981 from fahhem/patch-3
Handle srcs in generated files by cd'ing in and out
2018-07-02 15:08:12 -07:00
Feng Xiao
91707246eb
Merge pull request #4168 from jin/master
Use versions module from Skylib for version checking
2018-06-22 17:47:17 -07:00
Ittai Zeidman
4fcb36c51c remove PACKAGE_NAME and REPOSITORY_NAME deprecated usage (#4650) 2018-05-21 13:48:10 -07:00
Fahrzin Hemmati
2cfa7612b2 Fix moving generated files onto themselves 2018-05-07 15:40:31 -07:00
Fahrzin Hemmati
d1403e58d8 Only use realpath when in gendir, and use the original ctx.action if not in gendir 2018-05-07 15:40:31 -07:00
Fahrzin Hemmati
ae638966e5 Track outputs correctly 2018-05-07 15:40:31 -07:00
Fahrzin Hemmati
b3c2ec7073 Handle multiple outs per input (for plugins) 2018-05-07 15:40:31 -07:00
Fahrzin Hemmati
a6501e4a2b Strip trailing / from path 2018-05-07 15:40:31 -07:00
Fahrzin Hemmati
800f8d66bf Handle srcs in generated files by cd'ing in and out 2018-05-07 15:40:31 -07:00
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
Jingwen Chen
b2a190832c Use versions module from Skylib for version checking 2018-01-12 18:42:22 -05: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