Commit graph

126 commits

Author SHA1 Message Date
Jason Aragorn Tobias Lunn
b2e184385f Extract Python naming helper functions into a separate names library.
PiperOrigin-RevId: 961053716
2026-08-07 12:10:27 -07:00
Ada Zhang
bff6c119b1 Introduces a public upb_MessageUnknown_Encode API to serialize const struct upb_Extension* into bytes.
PiperOrigin-RevId: 960555713
2026-08-06 16:16:08 -07:00
Jason Aragorn Tobias Lunn
713b6a4a24 Add json_options.proto and json_enumvalue_options.proto and/or gencode derived from them to release artifacts
* `protoc`: Included in zips alongside binary
* Java: Generated classes have been added to the Maven `util` artifact
* Ruby: Generated classes have been added to gems
* CMake: `.proto` files are included in installation

PiperOrigin-RevId: 957382561
2026-07-31 16:20:59 -07:00
Ada Zhang
f1b00c3245 Add new upb_Message_NextUnknown2 and upb_Message_DeleteUnknown2 functions to support non-canonical extensions in unknown field iteration/deletion.
PiperOrigin-RevId: 943010563
2026-07-05 19:52:56 -07:00
Ada Zhang
0982838348 Add a new upb_Message_Convert API that converts a upb message from one minitable type to another compatible one (e.g. they are both derived from the same proto definition via tree-shaking).
PiperOrigin-RevId: 922780263
2026-05-28 08:14:17 -07:00
Karen Wu
ced1201b2d Implement cc_namespace option
Design Doc: go/cc_namespace_option

PiperOrigin-RevId: 919984787
2026-05-22 20:15:00 -07:00
Hong Shin
b0a96e39fd json: introduce plumbing & usage of (pb.enumvalue.json).string
PiperOrigin-RevId: 915427796
2026-05-14 07:48:57 -07:00
Protobuf Team Bot
2893999a3c feat: add initially-empty C# features proto
PiperOrigin-RevId: 890289024
2026-03-27 00:50:02 -07:00
Keith Smiley
f08d703292 Add support for bazel 9.x (#26201)
This doesn't flip the default bazel version, but instead makes this repo
compatible with the current version and bazel 9.x. The primary changes
for 9.x support are adding new load statements for things that were
previously built in. This cascaded into a few dep updates to pull in
their missing load statement fixes.

Closes #26201

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/26201 from keith:ks/add-support-for-bazel-9.x e8192d86b3c838f6c88d4a4adfebd07162debc0d
PiperOrigin-RevId: 878654773
2026-03-04 13:59:16 -08:00
Mike Kruskal
3a2af3510f Breaking change: make generator headers private
#test-continuous

These built-in generators are exposed in the protoc binary we release.  Using them as libraries would typically be done by someone creating a custom build of protoc mixing our generators with their own.  The supported alternative would be to build your generator as a plugin binary, and use it with the normal protoc binary.

PiperOrigin-RevId: 857982672
2026-01-18 19:42:51 -08:00
Mikita Belahlazau
4f076d951f Add metadata annotations for generated Python protobuf symbols.
The pyi generator now includes Kythe annotations for:
*   Extension field constants (e.g., `EXTENSION_FIELD`).
*   Field number constants (e.g., `STRING_FIELD_FIELD_NUMBER`).
*   `Create` methods in generated Stubby client classes.

These annotations allow the Python indexer to link these generated symbols back to their definitions in the `.proto` files.

PiperOrigin-RevId: 852971617
2026-01-06 16:05:56 -08:00
Protobuf Team Bot
ae67a4c195 Internal version update.
PiperOrigin-RevId: 852733884
2026-01-06 05:27:44 -08:00
Rachel Goldfinger
192cd6631a Create editions test_utils to fix existing brittle tests in command_line_interface_unittest and code_generator_unittest.
PiperOrigin-RevId: 836222700
2025-11-24 07:46:06 -08:00
Mike Kruskal
01331f9e51 Automated rollback of commit efacad9581.
PiperOrigin-RevId: 833991536
2025-11-18 15:24:59 -08:00
Protobuf Team Bot
efacad9581 Automated rollback of commit cdce70d4e5.
PiperOrigin-RevId: 830414655
2025-11-10 06:39:26 -08:00
Protobuf Team Bot
cdce70d4e5 Automated rollback of commit 4e5868ec4a.
PiperOrigin-RevId: 829733308
2025-11-08 00:21:09 -08:00
Protobuf Team Bot
4e5868ec4a Automated rollback of commit a531523b86.
PiperOrigin-RevId: 829708292
2025-11-07 22:29:47 -08:00
Mike Kruskal
a531523b86 Define a generated registry for tracking linked-in extensions.
#test-continuous

This behaves similarly to the generated extension registry in other languages.  A global ref-counted (lock-free thread-safe) singleton registry can be lazily constructed from the linker array data produced by gencode.  For now, this is simply used to preserve custom options on the descriptors in our DefPool.

This design makes heavy use of various non-standard C extensions.  It expands on the pre-existing linker arrays used for extensions, adding weak constructors to register all of the extensions linked into each binary.  This was tested and works with clang and gcc, and a similar approach was implemented for MSVC.  For unsupported compilers or architectures, the generated registry will be unpopulated.

PiperOrigin-RevId: 829698259
2025-11-07 21:45:59 -08:00
Joshua Haberman
1e15ce7940 Added debug printing for MiniTables.
PiperOrigin-RevId: 823763655
2025-10-24 20:11:37 -07:00
Protobuf Team Bot
1229d4adba Fix a bug in STRICT check of namespaced enums to properly check for 'reserved 1 to max'
Also refactor the visiblity checking logic into its own class and files.

PiperOrigin-RevId: 821762001
2025-10-20 12:49:59 -07:00
Hong Shin
84706d8a50 pbtk: rename php target to php_generator
PiperOrigin-RevId: 820358552
2025-10-16 12:57:38 -07:00
Keith Smiley
68220a862a bazel: add missing rules_cc loads (#23584)
This is required for use with bazel after this commit 71ca0ed111

Many files have these already

Closes #23584

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/23584 from keith:ks/bazel-add-missing-rules_cc-loads 733a0ccf6f
PiperOrigin-RevId: 817836399
2025-10-10 17:00:33 -07:00
Ivo Ristovski List
25d8081ab9 Automated Code Change
PiperOrigin-RevId: 799615263
2025-08-26 10:25:14 -07:00
Adam Cozzette
f413389da4 Move the upb minitable generator back out of protoc
PiperOrigin-RevId: 765213553
2025-05-30 09:07:47 -07:00
Joshua Haberman
3fda5918c7 Created a proper cc_dist_library() for upb.
We now use `cc_library()` deps instead of `filegroup()` so that the packaging rules can follow deps properly.

PiperOrigin-RevId: 763877244
2025-05-27 11:29:52 -07:00
Mike Kruskal
d023ab2fb4 Restore libatomic linkage workaround for 32-bit powerpc
#test-continuous

This also centralizes the logic so that it includes our upb generators, fixes #21814

PiperOrigin-RevId: 761332521
2025-05-20 20:10:41 -07:00
Mike Kruskal
07fb7b764f Refactor conformance library
PiperOrigin-RevId: 757011936
2025-05-09 20:46:35 -07:00
Joshua Haberman
f873475c76 Implemented a newly-designed scheme for enumerating fasttable function combinations.
We lean heavily on the preprocessor, but we do so in a nice and readable way that allows us to reuse our lists for several purposes:

- To create C `enum`s for each dimension.
- To count the number of possibilities for each dimension.
- To generate a cross-product of all dimension combinations, with a canonical ordering of functions that lets us address functions by index.
- To generate function names for each combination.

Unlike the initial design for fasttable, this scheme lets us generate an array of all fast field parsers, which will allow us to build fasttables at runtime from MiniDescriptors.

While I ran the tests with `--//third_party/upb:fasttable_enabled=True` and found that most of them pass (and none regress compared to HEAD), this code is not currently tested in TAP and we know that the fasttable parser has bugs. Subsequent CLs will fuzz it against the main parser so that we can make it truly robust.

#test-continuous

PiperOrigin-RevId: 755606670
2025-05-06 18:28:54 -07:00
Adam Cozzette
ab72581e55 Move LazilyBuildDependenciesTest into its own .cc file and CMake test binary
One of the test cases involves observing the lazy loading behavior of the
generated descriptor pool. Since this pool is a global, it can be influenced by
other unrelated tests, and whether the test succeeds or fails depends on the
test ordering. Moving the test into its own binary ensures that it will pass
regardless of test ordering.

Fixes #21431.

PiperOrigin-RevId: 752313710
2025-04-28 08:20:35 -07:00
Deanna Garcia
db67465af4 Bazel 8 compatibility changes to unblock bazel 8 migration for upb in the future.
PiperOrigin-RevId: 745276060
2025-04-08 13:49:58 -07:00
Joshua Haberman
f2c118e191 Locked down visibility of rules used from aspects.
This is possible to do now because Bazel 6.5+ support proper aspect visibility.

PiperOrigin-RevId: 739013200
2025-03-20 18:56:35 -07:00
Mike Kruskal
0b1a9c99c4 Restore generator headers in cmake install until the next breaking C++ release
Fixes #20647

PiperOrigin-RevId: 738463411
2025-03-19 10:59:47 -07:00
Mike Kruskal
4e98196ded Remove cc_library hack for Bazel 6 workaround
PiperOrigin-RevId: 738120919
2025-03-18 13:25:05 -07:00
Adam Cozzette
36346f57c5 Remove protoc-gen-upb_minitable from CMake build and protobuf_codegen crate
Now that the minitable generator is built into protoc, there's no need for a
separate binary.

PiperOrigin-RevId: 729244034
2025-02-20 14:07:21 -08:00
Adam Cozzette
dce6b0f14b Move upb minitable code generator into protoc
The main goal of this is to incorporate the minitable generator into our
released protoc binaries so that Rust users don't have to build it from source.

PiperOrigin-RevId: 728785507
2025-02-19 13:10:54 -08:00
Mike Kruskal
85c8f8927c Make php generator's header public for gRPC
PiperOrigin-RevId: 725788478
2025-02-11 15:14:31 -08:00
Mike Kruskal
b4b93b3624 Split protoc apart from libprotoc in our cmake configs.
This avoids installing every header required by protoc, and only installs the ones we've explicitly marked as public in bazel (and their transitive dependencies).

PiperOrigin-RevId: 709815861
2024-12-26 08:58:44 -08:00
Mike Kruskal
2887da22a1 Fix cmake installation location of java and go features
Fixes #19735, will be backported to 29.x

PiperOrigin-RevId: 708420839
2024-12-20 14:03:59 -08:00
Protobuf Team Bot
a79fbc9d32 Fixed comparison of empty repeated/map extensions.
Repeated/map extensions are semantically equivalent to an extension that is not present at all. We had code paths that were treating them differently, which led to incorrect results.

In particular, we were considering `{.repeated_ext = []}` to be different from `{}` when comparing with `upb_Message_IsEqual()`.  This change fixes this bug so that they will be considered equivalent.

PiperOrigin-RevId: 702072912
2024-12-02 13:46:27 -08:00
Protobuf Team Bot
353d726bbc Update protoc release to include editions language features proto for Go
related to https://github.com/protocolbuffers/protobuf/issues/16211

PiperOrigin-RevId: 684366194
2024-10-10 09:24:26 -07:00
Nathan Baulch
e4cbc79ab4 Fix minor typos (#17682)
Just thought I'd contribute some typo fixes that keep tripping up CI/CD checks in my projects. Nothing controversial (hopefully), just 174 simple fixes.

Use the following command to get a quick and dirty summary of the specific corrections made:
```shell
git diff HEAD^! --word-diff-regex='\w+' -U0 \
  | grep -E '\[\-.*\-\]\{\+.*\+\}' \
  | sed -r 's/.*\[\-(.*)\-\]\{\+(.*)\+\}.*/\1 \2/' \
  | sort | uniq -c | sort -n
```

FWIW, the top typos are:
* trimed → trimmed (37)
* substract → subtract (7)
* qualifed → qualified (7)
* extesion → extension (6)
* mising → missing (5)
* btye → byte (4)
* likey → likely (4)
* candicate → candidate (3)
* decriptor → descriptor (3)
* inherting → inheriting (3)
* colletion → collection (3)
* caluclated → calculated (3)
* unititialized → uninitialized (3)
* implemting → implementing (3)
* binrary → binary (3)
* descripor → descriptor (3)
* negitive → negative (3)

Closes #17682

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/17682 from NathanBaulch:typos d41762d137
PiperOrigin-RevId: 677074418
2024-09-20 20:50:06 -07:00
Joshua Haberman
5ee5891f7d Refactored the C name mangling to not depend on C++ or upb reflection.
This yields several benefits:

1. The code no longer needs to be bootstrapped (since it no longer depends on upb reflection).
2. The upb code generator no longer depends on libprotobuf at all (except for `code_generator_lite.{h,cc}`, which is just one .cc file and has no deps).

PiperOrigin-RevId: 672280579
2024-09-08 08:19:24 -07:00
Hong Shin
290f28871f Introduce upb_ByteSize
Naïve computation of a serialized upb message

PiperOrigin-RevId: 670990379
2024-09-04 09:15:58 -07:00
Joshua Haberman
ddb863c38e Moved the C code generator to its own directory.
PiperOrigin-RevId: 666928989
2024-08-23 14:48:16 -07:00
Joshua Haberman
a2fd240e0e Moved reflection codegen to its own directory.
PiperOrigin-RevId: 666132886
2024-08-21 19:23:08 -07:00
Joshua Haberman
bc394d2c6d Moved the MiniTable generator into a separate directory.
This is the first in a series of changes intended to improve the code structure of the generator.

PiperOrigin-RevId: 666093310
2024-08-21 17:10:12 -07:00
Joshua Haberman
48f2faa70e Started moving Kotlin DSL generator to its own directory.
PiperOrigin-RevId: 663760495
2024-08-16 09:57:21 -07:00
Mike Kruskal
149407e24b Internal changes
PiperOrigin-RevId: 658038844
2024-07-31 09:43:55 -07:00
Protobuf Team Bot
b14d9ee01f Automated Code Change
PiperOrigin-RevId: 651754564
2024-07-12 06:32:57 -07:00
Joshua Haberman
8e3e09937e Refactored the Java generator into separate packages and targets.
PiperOrigin-RevId: 626057584
2024-04-18 09:33:28 -07:00