Commit graph

25 commits

Author SHA1 Message Date
Karen Wu
ed3c57114d Generalizing and implementing ValidateFeatureSupport for both Options and Features during proto parsing
PiperOrigin-RevId: 845387685
2025-12-16 12:28:48 -08:00
Mike Kruskal
0ce32315b1 Switch back to using absl::optional everywhere for compatibility with older versions of Abseil
Fixes #24399

PiperOrigin-RevId: 835322922
2025-11-21 12:45:34 -08:00
Yuanyuan Chen
bf565b5057 Remove absl::type_traits dependency (#21908)
Remove absl::type_traits dependency from CMake because its headers are not directly used.

Closes #21908

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/21908 from cyyever:modern_type_traits11 000ff8ff25
PiperOrigin-RevId: 823090169
2025-10-23 10:26:37 -07:00
Yuanyuan Chen
469ca55203 Use std::optional (#21864)
Use std::optional since latest ABSL has declared that abs::optional is an alias of it.

Closes #21864

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/21864 from cyyever:std_optional b33ca58677
PiperOrigin-RevId: 762044029
2025-05-22 11:19:40 -07:00
cyyever
fdf06470ca Use std::variant (#20889)
Use std::variant instead of absl variant

Closes #20889

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/20889 from cyyever:absl_variant 83b5a4b8a3
PiperOrigin-RevId: 743264998
2025-04-02 13:49:36 -07:00
Christian Blichmann
d801cbd868 Remove absl::if_constexpr from list of used Abseil targets
This is a follow-up on 0ea5ccd61c, moving to C++'s
`if constexpr`.

PiperOrigin-RevId: 729136260
2025-02-20 09:14:16 -08:00
Mike Kruskal
9cc685edf8 Breaking change: Flip default behavior for handling cmake dependencies.
Instead of fetching dependencies by default, we will first look for a local installation and only fetch as a fallback.  Two new options are added for forcing either of these behaviors.  protobuf_FORCE_FETCH_DEPENDENCIES will always fetch dependencies, and protobuf_PREVENT_FETCH_DEPENDENCIES will never do so.

#test-continuous

PiperOrigin-RevId: 693898394
2024-11-06 16:15:10 -08:00
Mike Kruskal
3f06ca4306 Breaking change: Remove CMake submodule support in favor of fetched or installed dependencies.
This flips the default behavior to "fetch", downloading local copies of required dependencies.  This can be disabled by setting `-Dprotobuf_FETCH_DEPENDENCIES=OFF`, in which case we will look for a local installation using find_package.  Setting `-Dprotobuf_ABSL_PROVIDER=package` will continue to have the same behavior as before.

See https://protobuf.dev/news/2024-10-02/#replace-cmake-submods for more details.

#test-continuous

PiperOrigin-RevId: 686649864
2024-10-16 14:52:31 -07:00
Mike Kruskal
d3735bc2a0 Support fetching CMake dependencies via -Dprotobuf_FETCH_DEPENDENCIES=ON
This ports upb's WORKSPACE scraping logic to protobuf, and allows us to dynamically fetch our dependencies at the exact same pinned version as in Bazel via protobuf_FETCH_DEPENDENCIES=ON.  This is mostly for development purposes, and is preferable to git submodules.  In a later cl we will flip the default behavior to "package"

#test-continuous

PiperOrigin-RevId: 686265348
2024-10-15 15:52:06 -07:00
Mike Kruskal
b6032d72e3 Add basic upb cmake support.
libupb will always be statically linked, and currently doesn't ever install itself.

PiperOrigin-RevId: 615136389
2024-03-12 12:43:16 -07:00
Protobuf Team Bot
f5a225597b Minor cleanup: IWYU, shoud_split() instead of ShouldSplit(...).
PiperOrigin-RevId: 604471605
2024-02-05 16:47:14 -08:00
Protobuf Team Bot
578e07e9bd Have Arena::Create support arena constructible types
Unlike Arena::CreateMessage, Arena::Create creates only the top level object
from arena even if it is arena constructalble; e.g. messages, RepeatedPtrField,
etc. This renders arenas less effective.

Instead of asking users to be aware of such nuances to use the right API for
the right type, this CL makes Arena::Create recognizes and fully supports arena
constructable types.

While extremly rare, some users try to emulate Arena::CreateMessage with
Arena::Create by passing arena parameter twice. For example,

```
auto foo = Arena::Create<Foo>(&arena, &arena);  // bad
```

This pattern is not supported and  will break after this change. The following
is recommended instead.

```
auto foo = Arena::CreateMessage<Foo>(&arena);  // recommended
auto foo = Arena::Create<Foo>(&arena);  // after this change
```

PiperOrigin-RevId: 585709990
2023-11-27 11:35:16 -08:00
Silvio Traversaro
87b3bc7c55 CMake: Fix abseil_dll target name when using find_package(absl) (#12978)
This additional if  is necessary as of abseil 20230125.3 when abseil is consumed via add_subdirectory,
the abseil_dll target  is named abseil_dll, while if abseil is consumed via find_package, the target is called `absl::abseil_dll` .

Once https://github.com/abseil/abseil-cpp/pull/1466 is merged and released in the minimum version of  abseil required by protobuf, it is possible to always link `absl::abseil_dll` and `absl::abseil_test_dll` and remove the if.

You may wonder how linking worked at all before when `protobuf_ABSL_PROVIDER STREQUAL "package"`, as `abseil_dll` was not an imported target defined by `find_package(absl)`. The reason behind this is that if a name that is not an imported target is passed to `target_link_libraries`, it is just regarded as a C++ library name. So, in the end the `abseil_dll` library was correctly linked, simply all the transitive usage requirements defined by the `absl::abseil_dll` target were not propagated, that could lead to compilation errors if abseil was compiled with the `ABSL_PROPAGATE_CXX_STD` CMake option enabled.

Closes #12978

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/12978 from traversaro:patch-1 39dd074281
PiperOrigin-RevId: 537990391
2023-06-05 15:08:55 -07:00
Mike Kruskal
a9f1ea6371 Breaking change: Migrate to Abseil's logging library.
This deletes our old branches of internal Abseil code in favor of their newly open-sourced library.  Notably, this removes the ability to turn CHECK crashes into exceptions.

PiperOrigin-RevId: 504460562
2023-01-24 21:51:03 -08:00
Mike Kruskal
7930cd1f9d Upgrade to Abseil LTS 20230117 (#11622)
Closes #11622

PiperOrigin-RevId: 503588252
2023-01-20 21:40:27 -08:00
Mike Kruskal
1aef0a4006 Add static asserts to enforce assumptions made in Map.
PiperOrigin-RevId: 499334862
2023-01-03 15:52:35 -08:00
Mike Kruskal
983fc2d065 Migrate remaining compiler code to from std::map to Swiss tables.
This cl hit an issue during the shared library cmake build from ODR violations, leading to mismatched absl hash seeds.  The problem was pre-existing but didn't manifest until now, and can be traced to the fact that in shared library builds we linked Abseil statically.  All of the cmake changes here remove the underlying ODR violation.

PiperOrigin-RevId: 485787671
2022-11-02 23:25:39 -07:00
Mike Kruskal
1595417dd3 Sync from Piper @473279986
PROTOBUF_SYNC_PIPER
2022-09-09 10:42:19 -07:00
Mike Kruskal
a3c8e2deb0
Integrate from Piper for C++, Java, and Python (#10455)
* Sync from Piper @469587494

PROTOBUF_SYNC_PIPER

* Fixing github SOT protoc builds

* Fixing typos from google

* Remove leaked util/hash reference

* Fixing bad python merge

* Fixing python C++ library order
2022-08-24 10:46:33 -07:00
Christian Blichmann
6affd51405
Update abseil-cpp.cmake (#10436) 2022-08-22 13:51:28 -07:00
Mike Kruskal
bc1b31001d
Add a real dependency on Abseil (#10416)
* Proof of concept for Abseil dependency

* Adding most common Abseil libraries

* Fixing shared library breakages

* Switching to quotes over angled brackets

* Disable install target by default

* Fixing abseil to LTS commit

* Upgrade to latest Abseil LTS

* Turning install back on by default, removing unnecessary export statements

* Add note to future self

* Fixing unsafe globals
2022-08-16 16:31:35 -07:00
Mike Kruskal
cac9765af0
Update CMake configuration to add a dependency on Abseil (#10401)
* Rolling https://github.com/protocolbuffers/protobuf/pull/9793 forward

* Removing private label on conformance linkage

* no-op comment added
2022-08-12 16:41:00 -07:00
Adam Cozzette
f7e2e0b301
Remove Abseil dependency from CMake build (#10056)
* Revert "Added cmake abseil include guard"

This reverts commit b6ee841d7c.

* Revert "Update CMake configuration to add a dependency on Abseil (#9793)"

This reverts commit e9246cd789.
2022-05-26 12:13:41 -07:00
Esun Kim
b6ee841d7c Added cmake abseil include guard 2022-05-06 15:09:13 -07:00
mkruskal-google
e9246cd789
Update CMake configuration to add a dependency on Abseil (#9793)
* Proof of concept for CMake Abseil dependency

* Hooked up Abseil linking

* Adding test binaries

* Reverting absl::string view use added for testing.  This will still be broken for automake and bazel

* Adding new cmake config to dist list

* Whitespace fixes and an attempt at fix for Windows Python Release (CMake version < 3.13)

* Hook up LTS to windows cmake

* Fix 'git cd' typo

* Adding clarifying comment for fix

* Adding abseil dependency to protobuf-lite too

* Update submodules instead of cloning abseil-cpp

* Adding explicit pointer to abseil root directory

Co-authored-by: Jason Lunn <jason.lunn@gmail.com>
Co-authored-by: Jorg Brown <jorg.brown@gmail.com>
2022-04-17 22:28:01 -04:00