Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Commit 52758be

Browse files
authored
feat: add Cloud Pub/Sub protos (#31)
1 parent 20009f5 commit 52758be

File tree

7 files changed

+129
-29
lines changed

7 files changed

+129
-29
lines changed

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ set(GOOGLEAPIS_CPP_PROTO_FILES
8787
"google/cloud/bigquery/v2/model.proto"
8888
"google/cloud/bigquery/v2/model_reference.proto"
8989
"google/cloud/bigquery/v2/standard_sql.proto"
90+
"google/pubsub/v1/pubsub.proto"
9091
"google/spanner/admin/database/v1/spanner_database_admin.proto"
9192
"google/spanner/admin/instance/v1/spanner_instance_admin.proto"
9293
"google/spanner/v1/keys.proto"
@@ -281,6 +282,18 @@ target_link_libraries(googleapis_cpp_bigtable_protos
281282
googleapis-c++::iam_v1_iam_policy_protos
282283
PRIVATE googleapis_cpp_common_flags)
283284

285+
google_cloud_cpp_grpcpp_library(
286+
googleapis_cpp_pubsub_protos
287+
"${GOOGLEAPIS_CPP_SOURCE}/google/pubsub/v1/pubsub.proto"
288+
PROTO_PATH_DIRECTORIES
289+
"${GOOGLEAPIS_CPP_SOURCE}"
290+
"${PROTO_INCLUDE_DIR}")
291+
googleapis_cpp_set_version_and_alias(pubsub_protos)
292+
target_link_libraries(googleapis_cpp_pubsub_protos
293+
PUBLIC googleapis-c++::api_annotations_protos
294+
googleapis-c++::api_client_protos
295+
PRIVATE googleapis_cpp_common_flags)
296+
284297
google_cloud_cpp_grpcpp_library(
285298
googleapis_cpp_spanner_protos
286299
"${GOOGLEAPIS_CPP_SOURCE}/google/spanner/admin/database/v1/spanner_database_admin.proto"
@@ -310,6 +323,7 @@ include(GNUInstallDirs)
310323
set(googleapis_cpp_installed_libraries_list
311324
googleapis_cpp_bigtable_protos
312325
googleapis_cpp_cloud_bigquery_protos
326+
googleapis_cpp_pubsub_protos
313327
googleapis_cpp_spanner_protos
314328
googleapis_cpp_longrunning_operations_protos
315329
googleapis_cpp_api_http_protos

ci/kokoro/install/Dockerfile.fedora-30-shared

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ RUN cmake -H. -Bcmake-out -DBUILD_SHARED_LIBS=yes
5050
RUN cmake --build cmake-out -- -j $(nproc)
5151
WORKDIR /home/build/cpp-cmakefiles/cmake-out
5252
RUN cmake --build . --target install
53+
# The share libraries will install in `/usr/local/lib64` we need that directory
54+
# in the ld.so cache:
55+
RUN echo "/usr/local/lib64" | tee /etc/ld.so.conf.d/local.conf
56+
RUN ldconfig
5357
# ```
5458

5559
## [END INSTALL.md]

ci/test-install/compile-test-projects.sh

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,27 @@ set -eu
2121

2222
# Verify the installed CMake config and pkgconfig files are actually usable.
2323

24-
# For Bigtable protos
25-
cp -R /home/build/cpp-cmakefiles/ci/test-install/bigtable \
26-
/home/build/test-install-bigtable
27-
cd /home/build/test-install-bigtable
28-
cmake -H. -Bcmake-out
29-
cmake --build cmake-out -- -j "$(nproc)"
30-
cmake-out/utilize-googleapis
31-
env PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig \
32-
make
33-
34-
# For BigQuery protos
35-
cp -R /home/build/cpp-cmakefiles/ci/test-install/bigquery \
36-
/home/build/test-install-bigquery
37-
cd /home/build/test-install-bigquery
38-
cmake -H. -Bcmake-out
39-
cmake --build cmake-out -- -j "$(nproc)"
40-
cmake-out/utilize-googleapis
41-
env PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig \
42-
make
43-
44-
# For spanner protos
45-
cp -R /home/build/cpp-cmakefiles/ci/test-install/spanner \
46-
/home/build/test-install-spanner
47-
cd /home/build/test-install-spanner
48-
cmake -H. -Bcmake-out
49-
cmake --build cmake-out -- -j "$(nproc)"
50-
cmake-out/utilize-googleapis
51-
env PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig \
52-
make
24+
for subdir in bigquery bigtable pubsub spanner; do
25+
# Compile a test program using CMake.
26+
echo "================================================================"
27+
echo "Testing ${subdir} $(date) with CMake"
28+
echo "================================================================"
29+
src_dir="/home/build/cpp-cmakefiles/ci/test-install/${subdir}"
30+
cmake_dir="/home/build/test-cmake-${subdir}"
31+
make_dir="/home/build/test-make-${subdir}"
32+
cmake -H"${src_dir}" -B"${cmake_dir}"
33+
cmake --build "${cmake_dir}" -- -j "$(nproc)"
34+
# Verify the generated program is runnable
35+
"${cmake_dir}/utilize-googleapis"
36+
echo "================================================================"
37+
echo "Testing ${subdir} $(date) with Make"
38+
echo "================================================================"
39+
cp -R "${src_dir}" "${make_dir}"
40+
cd "${make_dir}"
41+
# With Make we may need to set PKG_CONFIG_PATH because the code is installed
42+
# in /usr/local and that is not a default search location in some distros.
43+
env PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig \
44+
make
45+
# Verify the generated program is runnable
46+
"${make_dir}/main"
47+
done
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# ~~~
2+
# Copyright 2019 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ~~~
16+
17+
cmake_minimum_required(VERSION 3.5)
18+
19+
project(utilize-googleapis CXX C)
20+
21+
# Configure the compiler options, we will be using C++11 features.
22+
set(CMAKE_CXX_STANDARD 11)
23+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
24+
25+
find_package(googleapis REQUIRED)
26+
27+
add_executable(utilize-googleapis main.cc)
28+
target_link_libraries(utilize-googleapis googleapis-c++::pubsub_protos)

ci/test-install/pubsub/Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
# A simple Makefile to test the `install` target.
16+
#
17+
# This is not intended to be a demonstration of how to write good Makefiles,
18+
# nor is it a general solution on how to build Makefiles for google-cloud-cpp.
19+
# It is simply a minimal file to test the installed pkg-config support files.
20+
21+
# The CXX, CXXFLAGS and CXXLD variables are hard-coded. These values work for
22+
# our tests, but applications would typically make them configurable parameters.
23+
CXX=g++ -std=c++11
24+
CXXLD=$(CXX)
25+
26+
all: main
27+
28+
# Configuration variables to compile and link against the library.
29+
PROTOS := googleapis_cpp_pubsub_protos
30+
CXXFLAGS := $(shell pkg-config $(PROTOS) --cflags)
31+
CXXLDFLAGS := $(shell pkg-config $(PROTOS) --libs-only-L)
32+
LIBS := $(shell pkg-config $(PROTOS) --libs-only-l)
33+
34+
# A target using the Google Cloud Storage C++ client library.
35+
main: main.cc
36+
$(CXXLD) $(CXXFLAGS) $(CXXFLAGS) $(CXXLDFLAGS) -o $@ $^ $(LIBS)

ci/test-install/pubsub/main.cc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Copyright 2019 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <google/pubsub/v1/pubsub.grpc.pb.h>
16+
#include <grpcpp/grpcpp.h>
17+
18+
int main() {
19+
auto creds = grpc::InsecureChannelCredentials();
20+
auto channel = grpc::CreateChannel("localhost:12345", creds);
21+
auto stub = google::pubsub::v1::Publisher::NewStub(channel);
22+
}

cmake/config.cmake.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ foreach (_target
3434
iam_v1_options
3535
iam_v1_policy
3636
longrunning_operations
37+
pubsub
3738
rpc_error_details
3839
rpc_status
3940
spanner

0 commit comments

Comments
 (0)