60 Commits

Author SHA1 Message Date
Craig Tiller
339906443b [clang-format] Match include file ordering to internal clang-format (#40905)
gRPC is currently getting formatted with two different clang-format implementations, and due to some weirdness they have different include file orderings. This change introduces clang-format configuration to ensure that the two systems align - it's *highly* expected that this will need some maintenance going forward as the two systems evolve.

Closes #40905

PiperOrigin-RevId: 819606209
2025-10-15 00:24:11 -07:00
Qucheng Jiang
93971c4b57 [cpp/route_guide] Fix JSON minification removing spaces inside string values (#38954) (#38955)
[cpp/route_guide] Fix JSON minification removing spaces inside string values (#38954)

The existing JSON minification logic removes all whitespace characters using 'std::remove_if(db_.begin(), db_.end(), isspace);'. This approach inadvertently strips spaces inside JSON string values, leading to incorrect data parsing.

This commit introduces a new JSON minification function that:
- Removes spaces **outside** JSON string values.
- Preserves spaces **inside** JSON string values (`"..."`).
- Correctly handles escaped quotes (`\"`).

Fixes #38954

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->
## Verification

### Before Fix
```bash
> ./cmake/build/route_guide_client
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1741496886.397564  341105 helper.cc:201] DB parsed, loaded 100 features.
-------------- GetFeature --------------
Found feature called BerkshireValleyManagementAreaTrail,Jefferson,NJ,USA at 40.9146, -74.6189
Found no feature at 0, 0
-------------- ListFeatures --------------
Looking for features between 40, -75 and 42, -73
Found feature called PatriotsPath,Mendham,NJ07945,USA at 40.7838, -74.6144
Found feature called 101NewJersey10,Whippany,NJ07981,USA at 40.8123, -74.3999
Found feature called U.S.6,Shohola,PA18458,USA at 41.3628, -74.9016
Found feature called 5ConnersRoad,Kingston,NY12401,USA at 42, -74.0371
Found feature called MidHudsonPsychiatricCenter,NewHampton,NY10958,USA at 41.4008, -74.3951
Found feature called 287FlugertownRoad,LivingstonManor,NY12758,USA at 41.9611, -74.6525
Found feature called 4001TremleyPointRoad,Linden,NJ07036,USA at 40.611, -74.2187
Found feature called 352SouthMountainRoad,Wallkill,NY12589,USA at 41.6802, -74.237
Found feature called BaileyTurnRoad,Harriman,NY10926,USA at 41.295, -74.1077
Found feature called 193-199WawayandaRoad,Hewitt,NJ07421,USA at 41.2145, -74.395
Found feature called 406-496WardAvenue,PineBush,NY12566,USA at 41.5737, -74.2848
...
```

### After Fix
```bash
> ./cmake/build/route_guide_client
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1741496644.493263  337350 helper.cc:203] DB parsed, loaded 100 features.
-------------- GetFeature --------------
Found feature called Berkshire Valley Management Area Trail, Jefferson, NJ, USA at 40.9146, -74.6189
Found no feature at 0, 0
-------------- ListFeatures --------------
Looking for features between 40, -75 and 42, -73
Found feature called Patriots Path, Mendham, NJ 07945, USA at 40.7838, -74.6144
Found feature called 101 New Jersey 10, Whippany, NJ 07981, USA at 40.8123, -74.3999
Found feature called U.S. 6, Shohola, PA 18458, USA at 41.3628, -74.9016
Found feature called 5 Conners Road, Kingston, NY 12401, USA at 42, -74.0371
Found feature called Mid Hudson Psychiatric Center, New Hampton, NY 10958, USA at 41.4008, -74.3951
Found feature called 287 Flugertown Road, Livingston Manor, NY 12758, USA at 41.9611, -74.6525
Found feature called 4001 Tremley Point Road, Linden, NJ 07036, USA at 40.611, -74.2187
Found feature called 352 South Mountain Road, Wallkill, NY 12589, USA at 41.6802, -74.237
Found feature called Bailey Turn Road, Harriman, NY 10926, USA at 41.295, -74.1077
Found feature called 193-199 Wawayanda Road, Hewitt, NJ 07421, USA at 41.2145, -74.395
Found feature called 406-496 Ward Avenue, Pine Bush, NY 12566, USA at 41.5737, -74.2848
...
```

Closes #38955

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/38955 from jiangqucheng:master 54089ec53b547f9c90e672104a668c12930f43b7
PiperOrigin-RevId: 744962894
2025-04-07 21:14:15 -07:00
Yash Tibrewal
95a1de4935 [examples] Initialize logging (#39095)
Closes #39095

PiperOrigin-RevId: 741352357
2025-03-27 18:49:43 -07:00
Amit Mehra
f008ce280a [examples/cpp/route_guide] Fix callback client command line arg parsing (#38891)
route_guide_callback_client only works if started from the grpc/ directory. If started from other directories, it fails with the following error:
```
grpc/examples/cpp/route_guide
› ../../. /bazel-bin/examples/cpp/route_guide/route_guide_callback_client -db_path ./route_guide_db.json WARNING: All log messages before absl:: InitializeLog() is called are written to STDERR E0000 00:00:1740838254.946166 3533952 helper.cc:49] Failed to open examples/cpp/route_guide/route_guide_db.json
[1]    21202 abort ../../../bazel-bin/examples/cpp/route_guide/route_guide_callback_client
```

Add 'absl::ParseCommandLine(argc, argv)' to route_guide_callback_client so that the db_path argument is parsed.

Closes #38891

PiperOrigin-RevId: 733357751
2025-03-04 09:31:00 -08:00
RomantsovS
9b77138b71 examples/cpp/route_guide add missing command line parsing (#37857)
The gRPC basic turorial says to call the following command to run the server `./route_guide_server --db_path=path/to/route_guide_db.json`

But the server and client do not parse command line arguments and they always use default value `route_guide_db.json`. Thus the example only works if we run it from `examples/cpp/route_guide` dir. Otherwise we get the following error: `helper.cc:49] Failed to open route_guide_db.json
Aborted (core dumped)`

Add
`absl::ParseCommandLine(argc, argv);`
to both server and client `main` similar to `route_guide_callback_server.cc`

Closes #37857

PiperOrigin-RevId: 709154601
2024-12-23 14:41:20 -08:00
Esun Kim
93b29607cc [C++] Transition to C++17 (#37919)
This bumps the minimum version of C++ to 17 from 14 per https://github.com/grpc/proposal/blob/master/L120-requiring-cpp17.md

Changes:
- Used C++17 instead of C++14 when building gRPC.
- Disabled `modernize-unary-static-assert` clang-tidy rule for the smooth transition. This rule will be re-enabled in a future update, along with a fix to address any identified issues.
- Added a post-install script for XCode/Cocoapod examples to enforce the use of C++17 across all projects, preventing build errors. (I'd like to have a better solution here but couldn't find it)

Closes #37919

PiperOrigin-RevId: 709073401
2024-12-23 08:53:24 -08:00
Craig Tiller
dbb5164ac7 [clang-format] Remove custom clang-format rules for include ordering (#37820)
Closes #37820

PiperOrigin-RevId: 682352913
2024-10-04 09:44:20 -07:00
Esun Kim
a49d450a54 [Build] Bumped the minimum version of cmake (#37702)
Per https://github.com/google/oss-policies-info/blob/main/foundational-cxx-support-matrix.md, the minimum version of cmake to support is 3.16 so let's change our cmake builds' requirements accordingly.

Closes #37702

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37702 from veblush:cmake316 bb4ed1a1be5e9374980c922aac3dc1ccd27d1266
PiperOrigin-RevId: 680639191
2024-09-30 10:55:14 -07:00
Eugene Ostroukhov
e97d83ca8a [examples] Add route guide callback server/client to CMakeLists.txt (#37369)
Closes #37369

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/37369 from eugeneo:fix-route-guide-callback-cmake 6c6696f2e5f732e29708ac4df82b2035966216f8
PiperOrigin-RevId: 658558458
2024-08-01 15:28:21 -07:00
Yash Tibrewal
57fb13dfc2 [example] Update RouteGuide example (#36958)
Simple change to stop writing if `ok` is false in `OnWriteDone()`

Closes #36958

COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/36958 from yashykt:UpdateRouteGuideExample cd5b066350a6b479caeb375b2c47cd387fb8f6a6
PiperOrigin-RevId: 644471350
2024-06-18 12:18:31 -07:00
Yash Tibrewal
1071ada87c [Example] Update route_guide example (#36930)
The intention behind this PR is to improve the example to aid the upcoming callback API guide.

Also fixes #25823

Closes #36930

PiperOrigin-RevId: 644166441
2024-06-17 16:20:44 -07:00
Jan Tattermusch
0f1afec5a8 [protobuf] Upgrade third_party/protobuf to 22.x (#32606)
The very non-trivial upgrade of third_party/protobuf to 22.x
This PR strives to be as small as possible and many changes that were
compatible with protobuf 21.x and didn't have to be merged atomically
with the upgrade were already merged.
Due to the complexity of the upgrade, this PR wasn't created
automatically by a tool, but manually. Subsequent upgraded of
third_party/protobuf with our OSS release script should work again once
this change is merged.

This is best reviewed commit-by-commit, I tried to group changes in
logical areas.

Notable changes:
- the upgrade of third_party/protobuf submodule, the bazel protobuf
dependency itself
- upgrade of UPB dependency to 22.x (in the past, we used to always
upgrade upb to "main", but upb now has release branch as well). UPB
needs to be upgraded atomically with protobuf since there's a de-facto
circular dependency (new protobuf depends on new upb, which depends on
new protobuf for codegen).
- some protobuf and upb bazel rules are now aliases, so `
extract_metadata_from_bazel_xml.py` and `gen_upb_api_from_bazel_xml.py`
had to be modified to be able to follow aliases and reach the actual
aliased targets.
- some protobuf public headers were renamed, so especially
`src/compiler` needed to be updated to use the new headers.
- protobuf and upb now both depend on utf8_range project, so since we
bundle upb with grpc in some languages, we now have to bundle utf8_range
as well (hence changes in build for python, PHP, objC, cmake etc).
- protoc now depends on absl and utf8_range (previously protobuf had
absl dependency, but not for the codegen part), so python's
make_grpcio_tools.py required partial rewrite to be able to handle those
dependencies in the grpcio_tools build.
- many updates and fixes required for C++ distribtests (currently they
all pass, but we'll probably need to follow up, make protobuf's and
grpc's handling of dependencies more aligned and revisit the
distribtests)
- bunch of other changes mostly due to overhaul of protobuf's and upb's
internal build layout.

TODOs:
- [DONE] make sure IWYU and clang_tidy_code pass
- create a list of followups (e.g. work to reenable the few tests I had
to disable and to remove workaround I had to use)
- [DONE in cl/523706129] figure out problem(s) with internal import

---------

Co-authored-by: Craig Tiller <ctiller@google.com>
2023-04-12 18:43:58 +02:00
Esun Kim
b64d623f24 CMake's better handling c++14 requirement (#31916)
* Bumped the cmake version version to 3.8

* Switch to target_compile_features for cxx_std_14

* Regen
2023-01-27 09:51:31 -08:00
Ilya Lukin
06faf44d0b Fix missed override specifier (#31489) 2023-01-06 18:07:04 -08:00
Esun Kim
5fb4c2364d Clean-up pkgconfig (#31660)
* Clean-up pkgconfig

* Removed run_distrib_test_cmake_module_install_pkgconfig.sh

* Proper re2

* Clean up pkgconfig.sh test script
2022-11-22 10:51:17 -08:00
Esun Kim
03e9ac6f1f Requiring C++14 (#29589) 2022-05-12 21:17:32 -07:00
Nicolas Noble
eb2ae7a0cc Fixing RouteGuide's C++ Reactor example. (#29404)
* Fixing RouteGuide's C++ Reactor example.

The current method involves locking and unlocking a mutex from different
threads, which isn't allowed. Changing the strategy a bit to address
this.

* Automated change: Fix sanity tests

* Switching to absl::Mutex to annotate usage properly.

* Actually, let's not cover the examples with sanity checks.
2022-04-21 10:03:28 -07:00
Yash Tibrewal
7fb4998029 RouteGuide example: Abort if database file not found (#29398) 2022-04-14 15:13:33 -07:00
AJ Heller
1f03bbab39 Small cleanup (#29125)
The std::moves of temporaries prevented copy elision, and the functions
were unused (one with a TODO to re-enable later)
2022-03-16 18:26:41 -07:00
Craig Tiller
d1e01ac139 Add a test for a (now-illegal) build file construct (#27602)
* Add a test for a (now-illegal) build file construct

* add to test suite!

* fix

* fix

* fix syntax
2021-10-06 07:43:59 -07:00
Craig Tiller
ea389c00c2 Adjust include order per style guide (#27175)
Introduce clang-format configuration to sort includes closer to our rules.
2021-09-08 12:14:44 -07:00
Nicolas Noble
a325d7f77a Pointing the protobuf submodule to the new URL (#26811)
* Pointing the protobuf submodule to the new URL

* Also changing WORKSPACE dependencies

* More references to the old URL...
2021-07-29 10:19:16 -07:00
Vijay Pai
8aff94558c De-experimentalize C++ callback API (#25728)
* De-experimentalize callback API

* Make FromServerContext based on ServerContextBase

* Fix lambda

* Fix headers

* De-experimentalize tests

* clang-format

* Fix consistency checks

* wip

* Fix const-ness of callback client read RPC requests

* Fix golden file

* Give full route_guide callback client example with Hold etc

* Complete example route-guide server

* De-experimentalize test services

* Omit unneeded using

* Remove some uses of non-experimental macro from test

* clang-format examples

* De-experimentalize async stub calls

* Remove experimental namespace use in qps, ubms

* De-experimentalize alarms, generic stubs, and context allocator

* De-experimentalize SetContextAllocator

* clang-format

* Fix conflicts

* Leave obsolete API in place until users can be migrated
2021-05-27 14:55:25 -07:00
Vijay Pai
ce16365421 clang-format C++ examples (#25764) 2021-03-22 10:23:52 -07:00
Esun Kim
b941a771e2 Merge pull request #25046 from veblush/route_guide_example
Added CMakeLists for route_guide example
2021-01-20 10:32:25 -08:00
Esun Kim
e7afadc255 Refactor examples BUILD files 2020-12-23 09:23:32 -08:00
Esun Kim
69bb5e328e Added CMakeLists for route_guide example 2020-12-22 13:44:35 -08:00
Patrice Chalin
5ac3aa789f Docs: fix links to grpc.io tutorial pages 2020-06-16 08:47:24 -04:00
Tariq Ramlall
efee7d4677 [Docs] Updated link to CPP example on grpc.io website. 2019-12-20 18:15:36 -05:00
Hao Nguyen
7f787bd083 Link against pthread in examples 2019-06-11 12:12:33 -07:00
Juanli Shen
68a2277121 Merge pull request #18460 from AspirinSJL/fix_route_guide
Fix route guide example
2019-04-03 14:34:13 -07:00
Prashant Jaikumar
4f2d8a0014 Fix bazel build for examples
Fixed the bazel build for some code in the examples directory.
2019-03-28 18:59:14 -07:00
Juanli Shen
3f3f177222 Fix route guide example 2019-03-20 16:15:37 -07:00
Jan Tattermusch
db53a61b8f deduplicate C++ routeguide 2018-06-20 15:06:51 +02:00
Jan Tattermusch
a26aecc03b reimplement distance calculation in routeguide 2018-03-23 07:44:30 +01:00
Vijay Pai
c90a85649b Change grpc++ references in names to grpcpp 2018-03-08 22:04:59 -08:00
Toshihito Kikuchi
351506688d Update compiler/linker options to use pkg-config in C++ examples 2017-06-13 16:15:04 -07:00
Jan Tattermusch
7897ae9308 auto-fix most of licenses 2017-06-08 11:22:41 +02:00
Nicolas "Pixel" Noble
7f074e0e20 Merge branch 'v1.0.x' into manual-upmerge 2016-08-11 21:00:08 +02:00
Jorge Canizales
7a2bc14fc0 Merge commit '5e623b8d8d8d106bd4ab9a6d77ef43b1a134d8ec' into p0-advance-protobuf-version 2016-07-29 15:45:02 -07:00
Jorge Canizales
4343c904e2 Update Protobuf submodule to v3.0.0 (GA) 2016-07-29 15:39:45 -07:00
Muxi Yan
cd0d8aed65 Identify system and remove --no-as-need if it is Mac OS 2016-07-26 14:13:46 -07:00
Muxi Yan
4e3df00f00 Removed --no-as-needed options from Makefile of HelloWorld and RouteGuide 2016-07-26 13:28:54 -07:00
Nicolas Noble
7645fdc4f0 Merge pull request #7393 from y-zeng/example_makefile
Enable server reflection in c++ examples
2016-07-21 14:28:55 -07:00
Jorge Canizales
9e6372380d Update protobuf submodule to 3.0.0-beta-4
Which has the fix for oneofs when using dynamic frameworks in ObjectiveC
2016-07-19 17:35:06 -07:00
Yuchen Zeng
1c58bd221d Enable server reflection in c++ examples 2016-07-07 14:19:04 -07:00
Jorge Canizales
f29e364168 Bump protobuf version to beta-3.3
It’s just the merge of beta-3.1 and beta-3.2, both of which we need.
2016-07-01 15:56:57 -07:00
Nicolas "Pixel" Noble
81159e5adc Fixing examples. 2016-04-23 01:30:12 +02:00
Craig Tiller
6169d5f7b0 Update copyrights 2016-03-31 07:46:18 -07:00
Jan Tattermusch
e7c2566252 Merge pull request #4913 from pszemus/master
Update protobuf version to v3.0.0-beta-2
2016-02-11 11:27:19 -08:00