Skip to content

Commit a5ad82f

Browse files
authored
doc: update howto generate library guide (#10342)
1 parent 77bf794 commit a5ad82f

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

doc/contributor/howto-guide-adding-generated-libraries.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ index ab033dde9..3753287d8 100644
8686
+# Secret Manager
8787
+service {
8888
+ service_proto_path: "google/cloud/secretmanager/v1/service.proto"
89-
+ product_path: "google/cloud/secretmanager"
89+
+ product_path: "google/cloud/secretmanager/v1"
9090
+ initial_copyright_year: "2021"
91-
+ retryable_status_codes: ["kDeadlineExceeded", "kUnavailable"]
91+
+ retryable_status_codes: ["kUnavailable"]
9292
+}
9393
+
9494
```
@@ -122,7 +122,7 @@ bazel run \
122122
--googleapis_proto_path="${bazel_output_base}"/external/com_google_googleapis \
123123
--output_path="${PWD}" \
124124
--config_file="${PWD}/generator/generator_config.textproto" \
125-
--scaffold="google/cloud/${library}"
125+
--scaffold="google/cloud/${library}/"
126126
```
127127

128128
To generate a library that is initially experimental, add an
@@ -159,6 +159,17 @@ add one dependency from `@com_github_googleapis//${subdir}`, which might not be
159159
correct. You may need to modify that dependency and/or add additional
160160
dependencies for more complex libraries.
161161

162+
## Potentially update the service directories
163+
164+
A library may contain services in several subdirectories. The scaffold only
165+
knows about one such subdirectory. You may need to manually update the
166+
`service_dirs` lists to include all subdirectories in the following files:
167+
168+
- `google/cloud/${library}/BUILD.bazel`
169+
- `google/cloud/${library}/CMakeLists.txt`
170+
171+
[#10237] offers one way to automate this step.
172+
162173
## Update the root files
163174

164175
Manually edit the top level `BUILD.bazel` to include the new target.
@@ -290,4 +301,5 @@ git commit -m"Manually update READMEs, quickstart, and top-level stuff" \
290301
"google/cloud/${library}" BUILD.bazel CHANGELOG.md ci README.md
291302
```
292303

304+
[#10237]: https://github.com/googleapis/google-cloud-cpp/issues/10237
293305
[retryable-status-codes]: https://github.com/googleapis/googleapis/blob/0fea253787a4f2769b97b0ed3a8f5b28ef17ffa7/google/cloud/secretmanager/v1/secretmanager_grpc_service_config.json#L77-L80

generator/standalone_main.cc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ ABSL_FLAG(bool, update_ci, true, "Update the CI support files.");
4646

4747
namespace {
4848

49+
using google::cloud::generator_internal::GenerateScaffold;
50+
using google::cloud::generator_internal::LibraryName;
51+
using google::cloud::generator_internal::LibraryPath;
52+
4953
google::cloud::StatusOr<google::cloud::cpp::generator::GeneratorConfiguration>
5054
GetConfig(std::string const& filepath) {
5155
std::ifstream input(filepath);
@@ -112,8 +116,7 @@ int WriteInstallDirectories(
112116
if (!service.omit_connection()) {
113117
install_directories.push_back("./include/" + product_path + "/mocks");
114118
}
115-
auto const lib =
116-
google::cloud::generator_internal::LibraryName(product_path);
119+
auto const lib = LibraryName(product_path);
117120
install_directories.push_back("./lib64/cmake/google_cloud_cpp_" + lib);
118121
}
119122
std::sort(install_directories.begin(), install_directories.end());
@@ -135,8 +138,7 @@ int WriteFeatureList(
135138
<< service.DebugString() << "\n";
136139
return 1;
137140
}
138-
features.push_back(
139-
google::cloud::generator_internal::LibraryName(service.product_path()));
141+
features.push_back(LibraryName(service.product_path()));
140142
}
141143
std::sort(features.begin(), features.end());
142144
auto const end = std::unique(features.begin(), features.end());
@@ -192,9 +194,9 @@ int main(int argc, char** argv) {
192194

193195
std::vector<std::future<google::cloud::Status>> tasks;
194196
for (auto const& service : config->service()) {
195-
if (service.product_path() == scaffold) {
196-
google::cloud::generator_internal::GenerateScaffold(
197-
googleapis_path, output_path, service, experimental_scaffold);
197+
if (LibraryPath(service.product_path()) == scaffold) {
198+
GenerateScaffold(googleapis_path, output_path, service,
199+
experimental_scaffold);
198200
}
199201
std::vector<std::string> args;
200202
// empty arg prevents first real arg from being ignored.

0 commit comments

Comments
 (0)