Commit Graph

79 Commits

Author SHA1 Message Date
David L. Jones
07303d6f54
[Bazel/C++] Factor out util library (#9987)
This change creates new Bazel packages for the C++ util libraries (similar to #9980 and #9985).
2022-05-17 18:13:22 -07:00
David L. Jones
b3cbea18ea
[Bazel] Move Python rules to //python (#9952) 2022-05-12 19:48:58 -07:00
David L. Jones
d60c0d2d35
Expose generated files from proto_gen via DefaultInfo, and change to new provider syntax. (#9951)
* Switch to new provider syntax instead of structs.
* Expose files via `DefaultInfo`, and use that for `py_proto_library`.
* Several changes from buildifier.
2022-05-11 19:13:56 -07:00
FaBrand
244bbd6f95
Make genrule portable for windows (#9889)
* Make genrule portable for windows

Using this does remove a user dependency on a bash under windows

* Use portable genrule for zlib dependency
2022-04-29 10:24:10 -07:00
Derek Perez
b55c8e4084
include gen_dir irrespsective of sources_dir in protoc_gen (#9735) 2022-04-06 11:35:10 -07:00
Adam Cozzette
faa42e900c
Revert "Use repo-relative labels wherever possible (#9187)" (#9696)
This reverts commit 11de748d66.
2022-03-29 15:50:39 -04:00
Deanna Garcia
67b74dd169 Use internal kotlin gen rule 2022-02-15 22:45:56 +00:00
Ivo List
15add1af49
Selectively add source or gen dir to includes. (#9438)
When both directories are added this results in protoc emitting a
"warning: directory does not exist.". This makes sense because when
there are no inputs from the other directory, it is also not present
n the sandbox where protoc is executed.
2022-01-28 16:44:42 -08:00
Xùdōng Yáng
11de748d66
Use repo-relative labels wherever possible (#9187)
* Use repo-relative labels wherever possible

The label `@com_google_protobuf//:foo` within the protobuf repo is often synonymous with just `//:foo`. We should prefer the latter as it allows us to use a shorter name for the module in the Bazel Central Registry (so just "protobuf" instead of "com_google_protobuf").

Note that the semantics can be subtle: in a macro, plain strings are anchored to the *calling* repo, so if we just use `//:foo` as the default value of a macro argument, it will be resolved to `@myrepo//:foo` if the macro is called from the repo `@myrepo`. In this case, it's necessary to directly call the `Label()` constructor to anchor the string label to the repo where the .bzl file lives.

See https://github.com/bazelbuild/bazel-central-registry/pull/28#issuecomment-954741081 for a bit more context.

* fix protobuf_deps.bzl
2021-11-04 07:56:32 -07:00
Charles Mita
f1fe79dd12
Use cfg="exec" instead of cfg="host" in internal rules. (#8626)
Bazel has switched its protobuf rules to make them use the proto
compiler in the exec configuration instead of the host configuration.

However, if rules in protobuf still use the host configuration then
multiple copies of the compiler can end up being built.

cfg="host" is deprecated in any case and being replaced with cfg="exec"
where possible.
https://docs.bazel.build/versions/master/skylark/rules.html#configurations
2021-05-19 11:11:13 -07:00
Derek Perez
bc45f92262
Bazel powered Java testing (#8506)
* Protobuf Java/Core Tests running w/ Bazel.

Also integrates rules_jvm_external and migrates existing maven deps
in place.

* Add test_suite target that maps to rule name.

* Lite tests passing in Bazel

* util tests passing with Bazel.

* Add conformance and build testing to //java:core

* Cleanup bzl style and lock down access to failure lists.

* Adding Java Lite conformance tests.

* rm newline

* parameterize conformance_test

This makes usage of failure lists more explicit.

* restrict visibility more for newly added libs and fix formatting.

* fix formatting and visibility.

* move testing.bzl to an internal package.

* fix file formatting.

* moving conformance_test to internal.bzl
2021-04-20 11:36:32 -07:00
Adam Yi
88f3ef7d1d [bazel] Add default shell env to gen_well_known_protos_java
We may need the shell environment (potentially augmented with
`--action_env`) to invoke protoc on Windows. If protoc was built with
mingw, it probably needs .dll files in non-default locations that must be
in PATH. Previously with `--compiler=mingw-gcc`,
`bazel build //:gen_well_known_protos_java` would fail on Windows. This
CL fixes the issue.

Also we have `default_shell_env` set to True for `ProtoCompile`, this makes
the behavior consistent.

See #2933, and
585a27ad0a/proto/compiler.bzl (L130)
2020-08-19 17:01:40 -07:00
Harvey Tuch
e492e5a4ef Fix depset/list confusion in #7458.
See
https://github.com/protocolbuffers/protobuf/pull/7458#issuecomment-633147682.

release notes: no

Signed-off-by: Harvey Tuch <htuch@google.com>
2020-05-29 13:05:58 -07:00
Harvey Tuch
9482bfd22b Fix depset/list confusion for ctx.attr.deps.
Signed-off-by: Harvey Tuch <htuch@google.com>
2020-05-14 07:45:57 -07:00
Harvey Tuch
7cf3f7a649 Fix CLI "too long" issues in py_proto_library.
Envoy was experiencing failed builds due to lots of duplicate -I in the
CLI. The solution is to generally use depset() as per Starlark best
practice for this sort of thing.

Might fix other issues beyond py_proto_library, anything that depends on
proto_gen.

release notes: no

Signed-off-by: Harvey Tuch <htuch@google.com>
2020-05-14 07:45:57 -07:00
Leo
12236c6977 Fix typo on py_proto_library 2020-05-08 09:34:26 -07:00
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