Skip to content

Commit ec22823

Browse files
authored
chore: update library generation for use with bzlmod (googleapis#16006)
1 parent 91a3747 commit ec22823

15 files changed

Lines changed: 38 additions & 74 deletions

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bazel_dep(name = "rules_apple", version = "4.3.2")
4040
bazel_dep(name = "googletest", version = "1.17.0.bcr.2")
4141

4242
bazel_dep(name = "google_benchmark", version = "1.9.4", dev_dependency = True, repo_name = "com_google_benchmark")
43-
bazel_dep(name = "yaml-cpp", version = "0.8.0", dev_dependency = True, repo_name = "com_github_jbeder_yaml_cpp")
43+
bazel_dep(name = "yaml-cpp", version = "0.9.0", dev_dependency = True, repo_name = "com_github_jbeder_yaml_cpp")
4444
bazel_dep(name = "pugixml", version = "1.15", dev_dependency = True, repo_name = "com_github_zeux_pugixml")
4545

4646
# Pin this to fix a break in bazel/deps-cache.py

bazel/development0.bzl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def gl_cpp_development0(name = None):
6969
http_archive,
7070
name = "com_github_jbeder_yaml_cpp",
7171
urls = [
72-
"https://github.com/jbeder/yaml-cpp/archive/0.8.0.tar.gz",
72+
"https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.9.0.tar.gz",
7373
],
74-
sha256 = "fbe74bbdcee21d656715688706da3c8becfd946d92cd44705cc6098bb23b3a16",
75-
strip_prefix = "yaml-cpp-0.8.0",
74+
sha256 = "25cb043240f828a8c51beb830569634bc7ac603978e0f69d6b63558dadefd49a",
75+
strip_prefix = "yaml-cpp-yaml-cpp-0.9.0",
7676
)

ci/cloudbuild/builds/generate-libraries.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ source module ci/lib/io.sh
2424

2525
bazel_output_base="$(bazel info output_base)"
2626

27-
# As we support both WORKSPACE and MODULE modes for bazel, we need to determine
28-
# the path to these dependencies dynamically.
29-
read -r protobuf_proto_path < <(find "${bazel_output_base}/external" -name "empty.proto" | sed -nE 's/(.+\/src)\/google\/protobuf\/empty.proto/\1/p')
30-
read -r googleapis_proto_path < <(find "${bazel_output_base}/external" -name "api-index-v1.json" | sed -nE 's/(.+)\/api-index-v1.json/\1/p')
27+
protobuf_proto_path="${bazel_output_base}/external/protobuf+/src"
28+
googleapis_proto_path="${bazel_output_base}/external/googleapis+"
3129

3230
if [ -z "${UPDATED_DISCOVERY_DOCUMENT}" ]; then
3331
io::log_h2 "Removing previously generated golden files"

ci/cloudbuild/dockerfiles/fedora-latest-cmake.Dockerfile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ RUN dnf makecache && dnf install -y "dnf-command(debuginfo-install)"
4040
RUN dnf makecache && dnf debuginfo-install -y libstdc++
4141

4242
# These are used by the docfx tool.
43-
RUN dnf makecache && dnf install -y pugixml-devel yaml-cpp-devel
43+
RUN dnf makecache && dnf install -y pugixml-devel
4444

4545
RUN dnf install -y valgrind
4646

@@ -50,6 +50,18 @@ RUN dnf install -y valgrind
5050
# the container's /etc/passwd file.
5151
RUN echo "root:cloudcxx" | chpasswd
5252

53+
WORKDIR /var/tmp/build/
54+
RUN curl -fsSL https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.9.0.tar.gz | \
55+
tar -xzf - --strip-components=1 && \
56+
cmake \
57+
-DCMAKE_BUILD_TYPE=Release \
58+
-DCMAKE_CXX_STANDARD=17 \
59+
-DBUILD_SHARED_LIBS=ON \
60+
-DBUILD_TESTING=OFF \
61+
-S . -B cmake-out -GNinja && \
62+
cmake --build cmake-out --target install && \
63+
ldconfig && cd /var/tmp && rm -fr build
64+
5365
# Fedora's version of `pkg-config` (https://github.com/pkgconf/pkgconf) is slow
5466
# when handling `.pc` files with lots of `Requires:` deps. This problem is
5567
# triggered by the Abseil `.pc` files, which we use (indirectly) when testing

ci/cloudbuild/dockerfiles/fedora-latest-publish-docs.Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ RUN dnf makecache && \
3333
libcurl-devel \
3434
openssl-devel \
3535
protobuf-devel \
36-
pugixml-devel \
37-
yaml-cpp-devel
36+
pugixml-devel
3837

3938
# This is used in the `publish-docs` build
4039
RUN dnf makecache && dnf install -y libxslt
@@ -45,6 +44,18 @@ RUN dnf makecache && dnf install -y libxslt
4544
# the container's /etc/passwd file.
4645
RUN echo 'root:cloudcxx' | chpasswd
4746

47+
WORKDIR /var/tmp/build/
48+
RUN curl -fsSL https://github.com/jbeder/yaml-cpp/archive/refs/tags/yaml-cpp-0.9.0.tar.gz | \
49+
tar -xzf - --strip-components=1 && \
50+
cmake \
51+
-DCMAKE_BUILD_TYPE=Release \
52+
-DCMAKE_CXX_STANDARD=17 \
53+
-DBUILD_SHARED_LIBS=ON \
54+
-DBUILD_TESTING=OFF \
55+
-S . -B cmake-out -GNinja && \
56+
cmake --build cmake-out --target install && \
57+
ldconfig && cd /var/tmp && rm -fr build
58+
4859
# We would prefer to say `dnf install -y doxygen`, but Fedora 40 ships with
4960
# Doxygen 1.10.0 and we need fixes that were released in Doxygen 1.11.0. Also,
5061
# we cannot use the binary, as it was built with clang support, which does not

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ cases:
4242

4343
```shell
4444
bazelisk --batch query --noshow_progress --noshow_loading_progress \
45+
--enable_workspace --noenable_bzlmod --incompatible_disallow_empty_glob=no \
4546
"kind(cc_library, @com_google_googleapis//${subdir}/...)"
4647
```
4748

@@ -150,8 +151,8 @@ Then run the micro-generator to create the scaffold and the C++ sources:
150151
```shell
151152
bazelisk run \
152153
//generator:google-cloud-cpp-codegen -- \
153-
--protobuf_proto_path="${bazel_output_base}"/external/protobuf~/src \
154-
--googleapis_proto_path="${bazel_output_base}"/external/googleapis~ \
154+
--protobuf_proto_path="${bazel_output_base}"/external/protobuf+/src \
155+
--googleapis_proto_path="${bazel_output_base}"/external/googleapis+ \
155156
--discovery_proto_path="${PWD}/protos" \
156157
--output_path="${PWD}" \
157158
--config_file="${PWD}/generator/generator_config.textproto" \

docfx/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,11 @@ add_library(
7272
toc_entry.cc
7373
toc_entry.h
7474
yaml_context.cc
75-
yaml_context.h
76-
yaml_emit.cc
77-
yaml_emit.h)
75+
yaml_context.h)
7876
google_cloud_cpp_add_common_options(docfx)
7977
target_include_directories(docfx PUBLIC "${PROJECT_SOURCE_DIR}")
8078
target_compile_features(docfx PUBLIC cxx_std_17)
81-
target_link_libraries(docfx PUBLIC pugixml::pugixml yaml-cpp
79+
target_link_libraries(docfx PUBLIC pugixml::pugixml yaml-cpp::yaml-cpp
8280
nlohmann_json::nlohmann_json)
8381
create_bazel_config(docfx YEAR "2023")
8482

docfx/docfx.bzl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ docfx_hdrs = [
3535
"public_docs.h",
3636
"toc_entry.h",
3737
"yaml_context.h",
38-
"yaml_emit.h",
3938
]
4039

4140
docfx_srcs = [
@@ -56,5 +55,4 @@ docfx_srcs = [
5655
"public_docs.cc",
5756
"toc_entry.cc",
5857
"yaml_context.cc",
59-
"yaml_emit.cc",
6058
]

docfx/doxygen2children.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
#include "docfx/doxygen2children.h"
1616
#include "docfx/public_docs.h"
17-
#include "docfx/yaml_emit.h"
1817
#include <iterator>
1918
#include <string_view>
2019

docfx/doxygen2references.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "docfx/doxygen2references.h"
1616
#include "docfx/node_name.h"
1717
#include "docfx/public_docs.h"
18-
#include "docfx/yaml_emit.h"
1918
#include <iterator>
2019

2120
namespace docfx {

0 commit comments

Comments
 (0)