Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add more cases for generating new libraries #14806

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions doc/contributor/howto-guide-adding-generated-libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,31 @@ cd $HOME/google-cloud-cpp
```shell
library=... # The name of your new library in the google-cloud-cpp repository
subdir="google/cloud/${library}" # The path in googleapis repo, may not start with google/cloud/
bazel_output_base="$(bazel info output_base)"
bazel_output_base="$(bazelisk info output_base)"
```

### Verify the C++ rules exist

You may need to
[Send a PR to update the googleapis SHA to the latest version](../contributor/howto-guide-update-googleapis-sha.md).
Wait until that is submitted before proceeding any further for the following 2
cases:

1. The dependency does not exist at the pinned version of the googleapis repo.

```shell
bazel --batch query --noshow_progress --noshow_loading_progress \
bazelisk --batch query --noshow_progress --noshow_loading_progress \
"kind(cc_library, @com_google_googleapis//${subdir}/...)"
```

If the command fails, it returns something like this:
- If the command fails, it returns something like this:

```shell
ERROR: no targets found beneath 'commerce'
```

This means the dependency does not exist at the pinned version of the googleapis
repo.
[Send a PR to update the googleapis SHA to the latest version](../contributor/howto-guide-update-googleapis-sha.md).
Wait until that is submitted before proceeding any further.
2. Check `$bazel_output_base/external/googleapis~/api-index-v1.json`, if
cuiy0006 marked this conversation as resolved.
Show resolved Hide resolved
`$library` with the correct version is not in `apis` section.

### Edit the scripts and configuration

Expand Down Expand Up @@ -143,7 +148,7 @@ external/googleapis/update_libraries.sh "${library}"
Then run the micro-generator to create the scaffold and the C++ sources:

```shell
bazel run \
bazelisk run \
//generator:google-cloud-cpp-codegen -- \
--protobuf_proto_path="${bazel_output_base}"/external/protobuf~/src \
--googleapis_proto_path="${bazel_output_base}"/external/googleapis~ \
Expand Down Expand Up @@ -226,7 +231,7 @@ API. Test your changes with:

```sh
gcloud services enable --project=cloud-cpp-testing-resources "${library}.googleapis.com"
bazel run -- //google/cloud/${library}/quickstart:quickstart $params
bazelisk run -- //google/cloud/${library}/quickstart:quickstart $params
```

Edit the tests so this new quickstart receives the right command-line arguments
Expand All @@ -245,6 +250,15 @@ git add ci/abi-dumps
git commit -m "Add API baseline"
```

The following error is expected for the first run, because the command generates
the ABI dump, it fails because there is no previous ABI dump to compare to. When
cuiy0006 marked this conversation as resolved.
Show resolved Hide resolved
you run once more, the error is gone.

```
grep: cmake-out/compat_reports/google_cloud_cpp_parallelstore/src_compat_report.html: No such file or directory
2024-10-25T19:00:49Z (+57s): ABI Compliance error: google_cloud_cpp_parallelstore
```

### Update the README files

The following files probably need some light copy-editing to read less like they
Expand Down Expand Up @@ -279,7 +293,7 @@ ci/cloudbuild/build.sh -t checkers-pr
### Verify everything compiles

```shell
bazel build //google/cloud/${library}/...
bazelisk build //google/cloud/${library}/...
ci/cloudbuild/build.sh -t cmake-install-pr
```

Expand Down Expand Up @@ -359,7 +373,7 @@ git commit -am "generated changes"
### Verify everything compiles

```shell
bazel build //google/cloud/${library}/...
bazelisk build //google/cloud/${library}/...
ci/cloudbuild/build.sh -t cmake-install-pr
```

Expand Down
4 changes: 2 additions & 2 deletions external/googleapis/update_libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,12 @@ for library in "${keys[@]}"; do
if [[ -z "${rule}" ]]; then continue; fi
path="${rule%:*}"
echo "=== $library $rule $path"
bazel query --noshow_progress --noshow_loading_progress \
bazelisk query --noshow_progress --noshow_loading_progress \
"deps(${rule})" |
grep "${path}" |
grep -E '\.proto$' \
>>"external/googleapis/protolists/${library}.list" || true
bazel query --noshow_progress --noshow_loading_progress \
bazelisk query --noshow_progress --noshow_loading_progress \
"deps(${rule})" |
grep "@com_google_googleapis//" | grep _proto |
grep -v "${path}" \
Expand Down
Loading