Commit Graph

82 Commits (main)

Author SHA1 Message Date
Mike Kruskal b28d9d4144 Migrate bazel tests to protobuf-ci.
This will allow them to reuse our bazelrc and remote caching setup.  This also silences the non-bzlmod windows test that's hitting the windows path length.

PiperOrigin-RevId: 626390416
2024-04-19 10:00:00 -07:00
Protobuf Team Bot 8257c4469d Copy py_proto_library from rules_python to protobuf
https://github.com/bazelbuild/rules_python/blob/main/python/private/proto/py_proto_library.bzl

Contributors:
d96214f tpudlik@google.com      Wed Nov 15 02:48:06 2023 -0800  fix: py_proto_library: transitive strip_import_prefix (#1558)
85e50d2 tpudlik@gmail.com       Tue Nov 14 06:04:59 2023 -0800  fix: py_proto_library: append to PYTHONPATH less (#1553)
bee35ef zplin@uber.com  Wed Oct 11 20:59:34 2023 -0700  fix: allowing to import code generated from proto with strip_import_prefix (#1406)
1a333ce ilist@google.com        Tue Jun 20 19:36:39 2023 +0200  fix: plugin_output in py_proto_library rule (#1280)
6905e63 ignas.anikevicius@woven-planet.global   Sat Feb 11 14:02:33 2023 +0900  fix: make py_proto_library respect PyInfo imports (#1046)
0d3c4f7 ilist@google.com        Wed Jan 18 23:15:52 2023 +0000  Implement py_proto_library (#832)
PiperOrigin-RevId: 623401031
2024-04-10 00:35:29 -07:00
Protobuf Team Bot 21d75f861c Remove references to rules_proto
They are not needed after the rules are move into protobuf repo.
Except for the reference to toolchain type, which is currently in rules_proto and can be moved after the implementation is moved into protobuf repo.

PiperOrigin-RevId: 622176865
2024-04-05 07:50:25 -07:00
Alex Eagle 71e4061ace feat: test bzlmod usage on CI (#16319)
Closes #16319

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/16319 from protocolbuffers:bcr d66845cfcb
PiperOrigin-RevId: 619939078
2024-03-28 08:33:48 -07:00
aiuto 3ab1276bbb Update Bazel references to rules_pkg to the supported file locations. (#15780)
WIP:  I want to see this pass CI first.

Fixes: #15779

3 scripted transforms:
```
  -load("@rules_pkg//:mappings.bzl", ...)
  +load("@rules_pkg//pkg:mappings.bzl", ...)
```
```
  -load("@rules_pkg//:pkg.bzl", "pkg_tar")
  +load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
```
```
  -load("@rules_pkg//:pkg.bzl", "pkg_zip")
  +load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
```

Closes #15780

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/15780 from aiuto:rules_pkg a630276341
PiperOrigin-RevId: 606641398
2024-02-13 09:08:42 -08:00
Adam Cozzette a7b0421c78 Breaking change: make protobuf comply with the C++ layering check
This check enforces that each C++ build target has the correct dependencies for
all headers that it includes. We have many targets that were not correct with
respect to this check, so I fixed them up.

I also cleaned up the C++ targets related to the well-known types. I created a
cc_proto_library() target for each one and removed the :wkt_cc_protos target,
since this was necessary to satisfy the layering check. I deleted the
//src/google/protobuf:protobuf_nowkt target and deprecated :protobuf_nowkt,
because the distinction between the :protobuf and :protobuf_nowkt targets was
not really correct. Neither one exposed the headers for the well-known types in
a way that was valid with respect to the layering check, and the idea of
bundling all the well-known types together is not idiomatic in Bazel anyway.
This is a breaking change, because the //:protobuf target no longer bundles the
well-known types. From now on they should be accessed through the new
//:*_cc_proto aliases in our top-level package.

I renamed the :port_def target to :port, which simplifies things a bit by
matching our internal name.

The original motivation for this change was that to move utf8_range onto our CI
infrastructure, we needed to make its dependency rules_fuzzing compatible with
Bazel 6. The rules_fuzzing project builds with the layering check, and I found
that the process of upgrading it to Bazel 6 made it take a dependency on
protobuf, which caused it to break due to layering violations. I was able to
work around this, but it would still be nice to comply with the layering check
so that we don't have to worry about this kind of thing in the future.

PiperOrigin-RevId: 595516736
2024-01-03 15:20:05 -08:00
Mike Kruskal f51923041d Remove ODR violation from WKT codegen (#12406)
Closes #12406

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12406 from mkruskal-google:wkt 1c6748e6aa
PiperOrigin-RevId: 522418175
2023-04-06 13:19:50 -07:00
Maciej Litwiniuk ff5007f929 Add example in ruby (#11717)
examples directory was missing an example in ruby, this PR aims to fix this.

Closes #11717

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/11717 from mlitwiniuk:ruby_example 14a5d1a34a
PiperOrigin-RevId: 514756892
2023-03-07 09:33:59 -08:00
Hai Hoang Dang 3be642b71e
Correct the link name for BUILD.bazel file (#10662)
* Correct the link name for BUILD file

* Correct BUILD.bazel text
2022-09-27 12:41:03 -07:00
Mike Kruskal e18aa2eda7
Fix broken examples build (#10614)
* Add .bazelrc for examples repo

* Include examples in some of our basic tests
2022-09-16 18:56:59 -07:00
Joseph Livesey 683349c2e3
correct minor grammatical issue (#10481) 2022-08-29 13:19:03 -07:00
Adam Cozzette 500cbd7b90
Upgrade third_party/googletest submodule to current main branch (#10393)
* Upgrade third_party/googletest submodule to current main branch

We can finally do this upgrade now that we have dropped our autotools
build. Googletest recommends living at head, so let's go straight to the
most recent commit on main. For some reason the googletest archive is
not present in the Bazel build mirror, so I removed that entry and just
left the GitHub download link in our WORKSPACE file.

Googletest now requires C++14, so I updated all the C++11 flags I could
find to C++14 instead. I added a .bazelrc file to add -std=c++14 for all
our Bazel builds.

* Delete the empty //src/google/protobuf:protobuf_test target

* Avoid building C++ unit tests in aarch64 jobs for Python and Ruby
2022-08-11 18:22:15 -07:00
Mike Kruskal ed5c57a574
Remove all autotools usage (#10132)
* Bazelfying conformance tests

Adding infrastructure to "Bazelify" languages other than Java and C++

* Delete benchmarks for languages supported by other repositories

* Bazelfying benchmark tests

* Bazelfying python

Use upb's system python rule instead of branching tensorflow

* Bazelfying Ruby

* Bazelfying C#

* Bazelfying Objective-c

* Bazelfying Kokoro mac builds

* Bazelfying Kokoro linux builds

* Deleting all deprecated files from autotools cleanup

This boils down to Makefile.am and tests.sh and all of their remaining references

* Cleanup after PR reorganizing

- Enable 32 bit tests
- Move conformance tests back
- Use select statements to select alternate runtimes
- Add internal prefixes to proto library macros

* Updating READMEs to use bazel instead of autotools.

* Bazelfying Kokoro release builds

* First round of review fixes

* Second round of review fixes

* Third round of review fixes

* Filtering out conformance tests from Bazel on Windows (b/241484899)

* Add version metadata that was previously scraped from configure.ac

* fixing typo from previous fix

* Adding ruby version tests

* Bumping pinned upb version, and adding tests to python CI
2022-08-10 22:51:29 -07:00
Kiyoshi Mizumaru 9c02fff255 Fix rule for java target in examples/Makefile 2022-08-06 03:17:23 +09:00
Chenwei Xiao 1bbf6f37cc
Correct file extention of README (#10125) 2022-06-09 15:52:50 -07:00
David L. Jones 95da0ba5b4
Rename all BUILD files to BUILD.bazel (#9892)
This avoids conflicting names in a couple of cases.

1. Within google, we want to sync files but not name them BUILD (since the structure doesn't match).
2. On case-insensitive filesystems, `build` may be used for a build directory. Naming `BUILD.bazel` avoids potentioal conflicts.
2022-04-29 17:57:55 -07:00
David L. Jones d76f8c868c
Add source distribution packaging rules (#9835)
This change adds `rules_pkg`-based targets that will produce source distribution archives, similar to `make dist`.

These rules produce nearly the same outputs as `make dist`. However, there are some differences and caveats:

1. The outputs do not contain vendored googletest sources.
2. You have to run `autogen.sh` before `blaze build pkg:all`. This produces several autotools-related files directly into the source tree.
3. The output .zip files do not have a directory prefix like `protobuf-3.20.1-rc-1` (this will be addressed after [Substitute package variables in `pkg_zip#package_dir`. bazelbuild/rules_pkg#577](https://github.com/bazelbuild/rules_pkg/pull/577); the tar files do have this prefix, though.)
4. One file is missing from the archives, which is produced during the `make` build: benchmarks/gogo/cpp_no_group/cpp_benchmark.cc
5. In several places, I have explicitly excluded some files that are not in the autotools distribution outputs. I think most of those files should probably be included, but for now, I'm aiming for parity with `make dist`. These are marked with comments, so it should be easy to clean them up later.
2022-04-22 16:58:16 -07:00
noahdietz 5abf802bc2 Replace master with main in URLs & docs 2022-04-12 10:25:08 -07:00
Damien Neil c8dfe32b5a
examples: update Go example (#7217)
Update the Go example to use Go modules: Move the example into a
directory containing a go.mod file, change the installation instructions
to use "go install".

Update the go_package option in addressbook.proto to an actual module path.

Update examples to use the google.golang.org/protobuf/proto module.
2021-10-21 13:27:40 -07:00
Jiamin Shen 0fd835893f
Fix protobuf version in the example (#8509)
The version variable should be `protobuf_VERSION` in `CMakeLists.txt`.
2021-04-20 15:15:30 -07:00
Dan Kortschak 32af37aa38
Make Go example work out of the box (#8486) 2021-04-20 08:25:58 -07:00
Chris Rebert 9d175493a3 addressbook.proto: Enable java_multiple_files option
And update the java_package value accordingly.
Enabling java_multiple_files is preferred nowadays.
Refs CL 348101638 which updates the tutorial accordingly.
2021-04-06 10:07:52 -07:00
Joshua Haberman c649397029
Set execute bit on files if and only if they begin with (#!). (#7347)
* Set execute bit on files if and only if they begin with (#!).

Git only tracks the 'x' (executable) bit on each file. Prior to this
CL, our files were a random mix of executable and non-executable.
This change imposes some order by making files executable if and only
if they have shebang (#!) lines at the beginning.

We don't have any executable binaries checked into the repo, so
we shouldn't need to worry about that case.

* Added fix_permissions.sh script to set +x iff a file begins with (#!).
2020-04-01 15:28:25 -07: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
Zhao Junwang c562c93ad6 add `-std=c++11` to make it compile
make cpp won't compile since it requires `-std=c++11` com
2019-12-06 11:15:57 -08:00
Rafi Kamal e6c5a3b57d
Add a proto_lang_toolchain for javalite (#6882)
* Add a proto_lang_toolchain for javalite

* fix toolchain. Swap javalite example to master repo
2019-11-27 11:10:45 -08:00
Roman Kamyk dc974d22c5 Fix small style issues in the dart example, following Effective Dart:
- use final instead of obvious types for local variables
- add missing `void` return type
- make the comments doccomments (///)
2019-09-04 12:30:57 -07: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
Phani Rithvij 39c6b58a9b
fix dart example readme typo 2019-07-07 09:10:41 +05:30
Wang Kirin 74f4f594cf fix typos in examples/README.md 2019-05-31 14:26:20 -07:00
Kent Ross b6375e03aa create importable function for defining zlib 2019-02-26 11:27:20 -08:00
Xiang Dai e479410564 delete all duplicate empty blanks (#5758)
Signed-off-by: Xiang Dai <764524258@qq.com>
2019-02-20 19:28:50 -08:00
Adam Cozzette e03c0d22a7 Updated Bazel workspace in examples/ to handle zlib dependency
To make this work, I created a symlink to the existing zlib.BUILD file.
Maybe there is a better way to do this, but this is at least a quick
workaround to fix the build.
2018-12-11 16:52:50 -08:00
Jonathan White b017ac4b87
Update add_person.dart
Fixed typo in a function name.
2018-11-20 18:45:25 -08:00
Adam Cozzette 1c2eba3eac
Merge pull request #5298 from rogerhub/patch-1
Import versions from @bazel_skylib//lib:versions.bzl
2018-11-12 13:36:15 -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
Sarah Zakarias f075cacaf4 comments 2018-10-23 10:36:46 +02:00
Sarah Zakarias bc00484bf7 comments and formatting 2018-10-23 09:52:44 +02:00
Sarah Zakarias 969397b719 Add Dart example. 2018-10-15 09:30:34 +02:00
Feng Xiao afe98de32a Replace repo links. 2018-08-22 11:55:30 -07:00
Yilun Chong 517190a7d9 fix golang kokoro linux build 2018-07-12 16:52:16 -07:00
Feng Xiao 1a7ce04be7 Fix bazel build of examples. 2018-07-03 11:00:15 -07:00
Yilun Chong 805174eda2 Add script for run and upload the benchmark result to bq 2018-04-10 13:26:17 -07:00
Fahrzin Hemmati 35119e39a0 Add a check_protobuf_required_bazel_version() for use in WORKSPACEs 2017-12-04 15:12:08 -08:00
Feng Xiao 8136ccb296 Fix go example test.
It needs "-I" flag to find imported file google/protobuf/timestamp.proto
2017-09-13 17:04:13 -07:00
Feng Xiao 74bf45f379 Add bazel support for examples.
The example utilizes native bazel rules (proto_library, cc_proto_library,
java_proto_library, java_lite_proto_library) to show how easy it is to
build protobuf with bazel's native support. It also makes use of well
known types which was not possible until the latest bazel 0.5.4 release
and https://github.com/google/protobuf/pull/3594 .
2017-09-08 16:01:49 -07:00
cclauss 067543cd6d from __future__ import print_function
The future import is required to support the print(x, end=" ") parameter in Python 2.
2017-08-18 01:14:48 +02:00
cclauss 7daedbd8ca print() function & define raw_input() for Python 3 2017-08-18 01:09:14 +02:00