@@ -5,28 +5,30 @@ This document describes the steps required to add a new library to
55familiar with the existing libraries, the build systems used in those
66libraries, and which libraries are based on gRPC.
77
8+ ## Adding a new library
9+
810> :warning : For libraries that include multiple services, the scaffold README
911> files (and any other documentation) will use the ** last** service description
1012> as the description of the library. Adjust the ordering and/or fix the
1113> documentation after the fact.
1214
13- ## Set your working directory
15+ ### Set your working directory
1416
1517Go to whatever directory holds your clone of the project, for example:
1618
1719``` shell
1820cd $HOME /google-cloud-cpp
1921```
2022
21- ## Set some useful variables
23+ ### Set some useful variables
2224
2325``` shell
2426library=... # The name of your new library in the google-cloud-cpp repository
2527subdir=" google/cloud/${library} " # The path in googleapis repo, may not start with google/cloud/
2628bazel_output_base=" $( bazel info output_base) "
2729```
2830
29- ## Verify the C++ rules exist
31+ ### Verify the C++ rules exist
3032
3133``` shell
3234bazel --batch query --noshow_progress --noshow_loading_progress \
@@ -36,7 +38,7 @@ bazel --batch query --noshow_progress --noshow_loading_progress \
3638If this fails, send a CL to add the rule. Wait until that is submitted and
3739exported before proceeding any further.
3840
39- ## Edit the scripts and configuration
41+ ### Edit the scripts and configuration
4042
4143Update the ` external/googleapis/update_libraries.sh ` script.
4244
@@ -64,7 +66,7 @@ index cdaa0bc9f..b0381d72d 100755
6466
6567</details >
6668
67- ## Update the Generator Configuration
69+ ### Update the Generator Configuration
6870
6971Determine the retryable status codes by looking in the service config JSON. For
7072example, [ here] [ retryable-status-codes ] .
@@ -107,7 +109,7 @@ index ab033dde9..3753287d8 100644
107109
108110</details >
109111
110- ## Commit these changes
112+ ### Commit these changes
111113
112114Create your first commit with purely hand-crafted changes
113115
@@ -116,13 +118,13 @@ git checkout -b feat-${library}-generate-library
116118git commit -m" feat(${library} ): generate library" external/ generator/
117119```
118120
119- ## Update the list of proto files and proto dependencies
121+ ### Update the list of proto files and proto dependencies
120122
121123``` shell
122124external/googleapis/update_libraries.sh " ${library} "
123125```
124126
125- ## Run the Scaffold Generator
127+ ### Run the Scaffold Generator
126128
127129Then run the micro-generator to create the scaffold and the C++ sources:
128130
@@ -141,21 +143,21 @@ bazel run \
141143To generate a library that is initially experimental, add an
142144` --experimental_scaffold ` flag.
143145
144- ## Fix formatting of existing libraries and the generated code
146+ ### Fix formatting of existing libraries and the generated code
145147
146148``` shell
147149git add " google/cloud/${library} "
148150ci/cloudbuild/build.sh -t checkers-pr
149151```
150152
151- ## Commit all the generated files
153+ ### Commit all the generated files
152154
153155``` shell
154156git add external ci " google/cloud/${library} "
155157git commit -m" Run generators and format their outputs"
156158```
157159
158- ## Create any custom source files
160+ ### Create any custom source files
159161
160162If the ` generator/generator_config.textproto ` entry for the service does not
161163enumerate the ` retryable_status_codes ` , you need to manually create the file as
@@ -165,14 +167,14 @@ Likewise, for services using streaming operations you may need to implement the
165167streaming ` *Updater ` function. Use ` google/cloud/bigquery/internal/streaming.cc `
166168or ` google/cloud/logging/internal/streaming.cc ` for inspiration.
167169
168- ## Potentially fix the bazel build
170+ ### Potentially fix the bazel build
169171
170172The generated ` BUILD.bazel ` file may require manual editing. The scaffold will
171173add one dependency from ` @com_github_googleapis//${subdir} ` , which might not be
172174correct. You may need to modify that dependency and/or add additional
173175dependencies for more complex libraries.
174176
175- ## Potentially update the service directories
177+ ### Potentially update the service directories
176178
177179A library may contain services in several subdirectories. The scaffold only
178180knows about one such subdirectory. You may need to manually update the
@@ -183,15 +185,15 @@ knows about one such subdirectory. You may need to manually update the
183185
184186[ #10237 ] offers one way to automate this step.
185187
186- ## Update the root files
188+ ### Update the root files
187189
188190Manually edit ` cmake/GoogleCloudCppFeatures.cmake ` to include the new target.
189191If you are generating a GA library, add it to ` GOOGLE_CLOUD_CPP_GA_LIBRARIES ` .
190192Otherwise, if you are generating an experimental library, add it to
191193` GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES ` and note in a comment when the library
192194was generated.
193195
194- ## Update the quickstart
196+ ### Update the quickstart
195197
196198The generated quickstart will need some editing. Use a simple operation, maybe
197199an admin operation listing top-level resources, to demonstrate how to use the
@@ -207,7 +209,7 @@ arguments in the CI builds.
207209
208210- ` google/cloud/${library}/CMakeLists.txt `
209211
210- ## Add the API baseline
212+ ### Add the API baseline
211213
212214For new GA libraries you need to create the API baseline. You can leave this
213215running while you work on tweaks to the quickstart and documentation.
@@ -218,7 +220,7 @@ git add ci/abi-dumps
218220git commit -m" Add API baseline" ci/abi-dumps/
219221```
220222
221- ## Update the README files
223+ ### Update the README files
222224
223225The following files probably need some light copy-editing to read less like they
224226were written by a robot:
@@ -231,24 +233,24 @@ were written by a robot:
231233The Cloud documentation links (` cloud.google.com/*/docs/* ` ) in these files are
232234not always valid. Find the correct urls and update the links.
233235
234- ## Review the metadata file
236+ ### Review the metadata file
235237
236238Newer services provide all the data needed to generate this file correctly,
237239but with older services we need to edit a few places:
238240
239241- ` google/cloud/${library}/**/.repo-metadata.json `
240242
241- ## Edit the top-level CHANGELOG file
243+ ### Edit the top-level CHANGELOG file
242244
243245Announce the new library in the CHANGELOG for the next release.
244246
245- ## Fix formatting nits
247+ ### Fix formatting nits
246248
247249``` shell
248250ci/cloudbuild/build.sh -t checkers-pr
249251```
250252
251- ## Verify everything compiles
253+ ### Verify everything compiles
252254
253255``` shell
254256bazel build //google/cloud/${library} /...
@@ -280,11 +282,50 @@ index c4ce00489..1858b48dc 100755
280282
281283</details >
282284
283- ## Commit these changes
285+ ### Commit these changes
284286
285287``` shell
286288git commit -m" Manually update READMEs, quickstart, and top-level stuff" .
287289```
288290
291+ ## Expanding a library
292+
293+ > This section assumes the developer is familiar with running the generator. For
294+ > more details on any of the steps involved, see the "Adding a new library"
295+ > section.
296+
297+ Sometimes we add services to libraries that already exist. In this case we do
298+ not need to run the scaffold generator. We provide a simple checklist below.
299+
300+ ### Manual changes
301+
302+ ``` sh
303+ library=... # e.g. bigquery
304+ api_name=... # e.g. BigLake API
305+ ```
306+
307+ - Update ` generator_config.textproto `
308+ - Update and run ` external/googleapis/update_libraries.sh ${library} `
309+ - Add the new directory to ` service_dirs ` in:
310+ - ` google/cloud/${library}/CMakeLists.txt `
311+ - ` google/cloud/${library}/BUILD.bazel `
312+ - Add the new ` *_cc_grpc ` dependency to
313+ ` //google/cloud/${library}:${library}_client ` in
314+ ` google/cloud/${library}/BUILD.bazel `
315+ - Announce the new API in the ` CHANGELOG.md `
316+ - e.g. ` The library has been expanded to include the ${api_name}. `
317+ - Commit the manual changes
318+ - ` git commit -am "feat(${library}): add ${api_name}" `
319+
320+ ### Generated changes
321+
322+ ``` shell
323+ ci/cloudbuild/build.sh -t generate-libraries-pr
324+ env GOOGLE_CLOUD_CPP_CHECK_API ${library} ci/cloudbuild/build.sh -t check-api-pr
325+ git add .
326+ ci/cloudbuild/build.sh -t checkers-pr
327+ git commit -am " generated changes"
328+ ```
329+
289330[ #10237 ] : https://github.com/googleapis/google-cloud-cpp/issues/10237
290331[ retryable-status-codes ] : https://github.com/googleapis/googleapis/blob/70147caca58ebf4c8cd7b96f5d569a72723e11c1/google/cloud/secretmanager/v1/secretmanager_grpc_service_config.json#L77-L80
0 commit comments