├── .cmake-format.py ├── .dockerignore ├── .editorconfig ├── .gitignore ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── ci ├── check-style.sh ├── colors.sh ├── install-grpc.sh ├── kokoro │ ├── Dockerfile.centos │ ├── Dockerfile.fedora │ ├── Dockerfile.ubuntu-16.04 │ ├── Dockerfile.ubuntu-18.04 │ ├── docker │ │ ├── build-in-docker-cmake.sh │ │ ├── build.sh │ │ ├── clang-3.8-presubmit.cfg │ │ ├── clang-3.8.cfg │ │ ├── clang-tidy-presubmit.cfg │ │ ├── clang-tidy.cfg │ │ ├── common.cfg │ │ ├── gcc-4.8-presubmit.cfg │ │ ├── gcc-4.8.cfg │ │ ├── ninja-presubmit.cfg │ │ ├── ninja.cfg │ │ ├── ubuntu-16.04-presubmit.cfg │ │ ├── ubuntu-16.04.cfg │ │ ├── ubuntu-18.04-presubmit.cfg │ │ └── ubuntu-18.04.cfg │ └── install │ │ ├── Dockerfile.centos-7 │ │ ├── Dockerfile.fedora-30 │ │ ├── Dockerfile.fedora-30-shared │ │ ├── Dockerfile.opensuse-leap │ │ ├── Dockerfile.opensuse-tumbleweed │ │ ├── Dockerfile.ubuntu-16.04 │ │ ├── Dockerfile.ubuntu-18.04 │ │ ├── build.sh │ │ ├── centos-7-presubmit.cfg │ │ ├── centos-7.cfg │ │ ├── common.cfg │ │ ├── fedora-30-presubmit.cfg │ │ ├── fedora-30-shared-presubmit.cfg │ │ ├── fedora-30-shared.cfg │ │ ├── fedora-30.cfg │ │ ├── opensuse-leap-presubmit.cfg │ │ ├── opensuse-leap.cfg │ │ ├── opensuse-tumbleweed-presubmit.cfg │ │ ├── opensuse-tumbleweed.cfg │ │ ├── ubuntu-16.04-presubmit.cfg │ │ ├── ubuntu-16.04.cfg │ │ ├── ubuntu-18.04-presubmit.cfg │ │ └── ubuntu-18.04.cfg ├── retry-command.sh └── test-install │ ├── bigquery │ ├── CMakeLists.txt │ ├── Makefile │ └── main.cc │ ├── bigtable │ ├── CMakeLists.txt │ ├── Makefile │ └── main.cc │ ├── compile-test-projects.sh │ ├── pubsub │ ├── CMakeLists.txt │ ├── Makefile │ └── main.cc │ └── spanner │ ├── CMakeLists.txt │ ├── Makefile │ └── main.cc └── cmake ├── CompileProtos.cmake ├── FindProtobufTargets.cmake ├── FindgRPC.cmake ├── SelectMSVCRuntime.cmake ├── config-version.cmake.in ├── config.cmake.in └── config.pc.in /.cmake-format.py: -------------------------------------------------------------------------------- 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 | tab_size = 4 16 | separate_ctrl_name_with_space = True 17 | 18 | additional_commands = { 19 | "externalproject_add": { 20 | "flags": [ 21 | ], 22 | "kwargs": { 23 | "BUILD_COMMAND": "+", 24 | "BUILD_BYPRODUCTS": "+", 25 | "CMAKE_ARGS": "+", 26 | "COMMAND": "+", 27 | "CONFIGURE_COMMAND": "+", 28 | "DEPENDS": "+", 29 | "DOWNLOAD_COMMAND": "+", 30 | "EXCLUDE_FROM_ALL": 1, 31 | "INSTALL_COMMAND": "+", 32 | "INSTALL_DIR": 1, 33 | "LOG_BUILD": 1, 34 | "LOG_CONFIGURE": 1, 35 | "LOG_DOWNLOAD": 1, 36 | "LOG_INSTALL": 1, 37 | "PREFIX": 1, 38 | "URL": 1, 39 | "URL_HASH": 1, 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | # Common build output directory names 2 | .build/ 3 | _build/ 4 | build-output/ 5 | cmake-out/ 6 | 7 | # Common bazel output directories 8 | bazel-* 9 | 10 | # Backup files for Emacs 11 | *~ 12 | 13 | # Ignore IDEA / IntelliJ files 14 | .idea/ 15 | cmake-build-*/ 16 | 17 | # This is a staging directory used to upload the documents to gihub.io 18 | github-io-staging/ 19 | 20 | # Ignore Visual Studio Code files 21 | .vsbuild/ 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | charset = utf-8 7 | indent_style = space 8 | 9 | [BUILD] 10 | indent_size = 4 11 | 12 | [CMakeLists.*] 13 | indent_size = 4 14 | 15 | [*.h,*.cc] 16 | indent_size = 2 17 | 18 | [*.md] 19 | indent_size = 2 20 | 21 | [*.sh] 22 | indent_size = 2 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Common build output directory names 2 | .build/ 3 | _build/ 4 | build-output/ 5 | cmake-out/ 6 | 7 | # Common bazel output directories 8 | bazel-* 9 | 10 | # Backup files for Emacs 11 | *~ 12 | 13 | # Ignore IDEA / IntelliJ files 14 | .idea/ 15 | cmake-build-*/ 16 | 17 | # This is a staging directory used to upload the documents to gihub.io 18 | github-io-staging/ 19 | 20 | # Ignore Visual Studio Code files 21 | .vsbuild/ 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 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 | # Define the project name and where to report bugs. 20 | set(PACKAGE_BUGREPORT "https://github.com/googleapis/google-cloud-cpp/issues") 21 | project(googleapis-cpp-protos CXX C) 22 | 23 | set(GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR 0) 24 | set(GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR 11) 25 | set(GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH 0) 26 | 27 | string( 28 | CONCAT GOOGLE_APIS_CPP_PROTOS_VERSION 29 | "${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR}" 30 | "." 31 | "${GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR}" 32 | "." 33 | "${GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH}") 34 | 35 | # Configure the compiler options, we will be using C++11 features. 36 | set(CMAKE_CXX_STANDARD 11) 37 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 38 | 39 | # Give application developers a hook to configure the version and hash 40 | # downloaded from GitHub. 41 | set(GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL 42 | "https://github.com/googleapis/googleapis/archive/abd6b709a5533ba5d0bc435189ffda7f2445cd4b.tar.gz" 43 | ) 44 | set(GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256 45 | "c45d0e135ac7ad54c34546404d5338e4980d0b397f093e1e2cb185ec8813430f") 46 | 47 | set(GOOGLEAPIS_CPP_SOURCE 48 | "${CMAKE_BINARY_DIR}/external/googleapis/src/googleapis_download") 49 | 50 | set(GOOGLEAPIS_CPP_PROTO_FILES 51 | "google/api/http.proto" 52 | "google/api/annotations.proto" 53 | "google/api/auth.proto" 54 | "google/api/client.proto" 55 | "google/api/field_behavior.proto" 56 | "google/api/label.proto" 57 | "google/api/launch_stage.proto" 58 | "google/api/metric.proto" 59 | "google/api/monitored_resource.proto" 60 | "google/api/resource.proto" 61 | "google/devtools/cloudtrace/v2/trace.proto" 62 | "google/devtools/cloudtrace/v2/tracing.proto" 63 | "google/type/expr.proto" 64 | "google/rpc/error_details.proto" 65 | "google/rpc/status.proto" 66 | "google/iam/v1/options.proto" 67 | "google/iam/v1/policy.proto" 68 | "google/iam/v1/iam_policy.proto" 69 | "google/longrunning/operations.proto" 70 | "google/bigtable/admin/v2/bigtable_instance_admin.proto" 71 | "google/bigtable/admin/v2/bigtable_table_admin.proto" 72 | "google/bigtable/admin/v2/common.proto" 73 | "google/bigtable/admin/v2/instance.proto" 74 | "google/bigtable/admin/v2/table.proto" 75 | "google/bigtable/v2/bigtable.proto" 76 | "google/bigtable/v2/data.proto" 77 | "google/cloud/bigquery/connection/v1beta1/connection.proto" 78 | "google/cloud/bigquery/datatransfer/v1/datatransfer.proto" 79 | "google/cloud/bigquery/datatransfer/v1/transfer.proto" 80 | "google/cloud/bigquery/logging/v1/audit_data.proto" 81 | "google/cloud/bigquery/storage/v1beta1/arrow.proto" 82 | "google/cloud/bigquery/storage/v1beta1/avro.proto" 83 | "google/cloud/bigquery/storage/v1beta1/read_options.proto" 84 | "google/cloud/bigquery/storage/v1beta1/storage.proto" 85 | "google/cloud/bigquery/storage/v1beta1/table_reference.proto" 86 | "google/cloud/bigquery/v2/encryption_config.proto" 87 | "google/cloud/bigquery/v2/model.proto" 88 | "google/cloud/bigquery/v2/model_reference.proto" 89 | "google/cloud/bigquery/v2/standard_sql.proto" 90 | "google/pubsub/v1/pubsub.proto" 91 | "google/spanner/admin/database/v1/backup.proto" 92 | "google/spanner/admin/database/v1/common.proto" 93 | "google/spanner/admin/database/v1/spanner_database_admin.proto" 94 | "google/spanner/admin/instance/v1/spanner_instance_admin.proto" 95 | "google/spanner/v1/keys.proto" 96 | "google/spanner/v1/mutation.proto" 97 | "google/spanner/v1/query_plan.proto" 98 | "google/spanner/v1/result_set.proto" 99 | "google/spanner/v1/spanner.proto" 100 | "google/spanner/v1/transaction.proto" 101 | "google/spanner/v1/type.proto" 102 | "google/storage/v1/storage.proto" 103 | "google/storage/v1/storage_resources.proto") 104 | 105 | set(GOOGLEAPIS_CPP_BYPRODUCTS) 106 | foreach (proto ${GOOGLEAPIS_CPP_PROTO_FILES}) 107 | list(APPEND GOOGLEAPIS_CPP_BYPRODUCTS "${GOOGLEAPIS_CPP_SOURCE}/${proto}") 108 | endforeach () 109 | 110 | include(ExternalProject) 111 | ExternalProject_Add( 112 | googleapis_download 113 | EXCLUDE_FROM_ALL ON 114 | PREFIX "${CMAKE_BINARY_DIR}/external/googleapis" 115 | URL ${GOOGLE_CLOUD_CPP_GOOGLEAPIS_URL} 116 | URL_HASH SHA256=${GOOGLE_CLOUD_CPP_GOOGLEAPIS_SHA256} 117 | CONFIGURE_COMMAND "" 118 | BUILD_COMMAND "" 119 | INSTALL_COMMAND "" 120 | BUILD_BYPRODUCTS ${GOOGLEAPIS_CPP_BYPRODUCTS} 121 | LOG_DOWNLOAD OFF) 122 | 123 | list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") 124 | find_package(ProtobufTargets REQUIRED) 125 | find_package(gRPC REQUIRED) 126 | 127 | # Sometimes (this happens often with vcpkg) protobuf is installed in a non- 128 | # standard directory. We need to find out where, and then add that directory to 129 | # the search path for protos. 130 | find_path(PROTO_INCLUDE_DIR google/protobuf/descriptor.proto) 131 | if (PROTO_INCLUDE_DIR) 132 | list(INSERT PROTOBUF_IMPORT_DIRS 0 "${PROTO_INCLUDE_DIR}") 133 | endif () 134 | 135 | add_library(googleapis_cpp_common_flags INTERFACE) 136 | 137 | include(SelectMSVCRuntime) 138 | 139 | # Include the functions to compile proto files. 140 | include(CompileProtos) 141 | 142 | google_cloud_cpp_add_protos_property() 143 | 144 | function (googleapis_cpp_short_name var proto) 145 | string(REPLACE "google/" "" short_name "${proto}") 146 | string(REPLACE "/" "_" short_name "${short_name}") 147 | string(REPLACE ".proto" "_protos" short_name "${short_name}") 148 | set("${var}" 149 | "${short_name}" 150 | PARENT_SCOPE) 151 | endfunction () 152 | 153 | # Create a single source proto library. 154 | # 155 | # * proto: the filename for the proto source. 156 | # * (optional) ARGN: proto libraries the new library depends on. 157 | function (googleapis_cpp_add_library proto) 158 | googleapis_cpp_short_name(short_name "${proto}") 159 | google_cloud_cpp_grpcpp_library( 160 | googleapis_cpp_${short_name} "${GOOGLEAPIS_CPP_SOURCE}/${proto}" 161 | PROTO_PATH_DIRECTORIES "${GOOGLEAPIS_CPP_SOURCE}" 162 | "${PROTO_INCLUDE_DIR}") 163 | 164 | googleapis_cpp_set_version_and_alias("${short_name}") 165 | 166 | set(public_deps) 167 | foreach (dep_short_name ${ARGN}) 168 | list(APPEND public_deps "googleapis-c++::${dep_short_name}") 169 | endforeach () 170 | list(LENGTH public_deps public_deps_length) 171 | if (public_deps_length EQUAL 0) 172 | target_link_libraries("googleapis_cpp_${short_name}" 173 | PRIVATE googleapis_cpp_common_flags) 174 | else () 175 | target_link_libraries( 176 | "googleapis_cpp_${short_name}" 177 | PUBLIC ${public_deps} 178 | PRIVATE googleapis_cpp_common_flags) 179 | endif () 180 | endfunction () 181 | 182 | function (googleapis_cpp_set_version_and_alias short_name) 183 | add_dependencies("googleapis_cpp_${short_name}" googleapis_download) 184 | set_target_properties( 185 | "googleapis_cpp_${short_name}" 186 | PROPERTIES VERSION "${GOOGLE_APIS_CPP_PROTOS_VERSION}" 187 | SOVERSION ${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR}) 188 | add_library("googleapis-c++::${short_name}" ALIAS 189 | "googleapis_cpp_${short_name}") 190 | endfunction () 191 | 192 | googleapis_cpp_add_library("google/api/http.proto") 193 | googleapis_cpp_add_library("google/api/metric.proto" api_launch_stage_protos 194 | api_label_protos) 195 | googleapis_cpp_add_library("google/api/monitored_resource.proto" 196 | api_launch_stage_protos api_label_protos) 197 | googleapis_cpp_add_library("google/api/annotations.proto" api_http_protos) 198 | googleapis_cpp_add_library("google/api/auth.proto" api_annotations_protos) 199 | googleapis_cpp_add_library("google/api/client.proto") 200 | googleapis_cpp_add_library("google/api/field_behavior.proto") 201 | googleapis_cpp_add_library("google/api/label.proto") 202 | googleapis_cpp_add_library("google/api/launch_stage.proto") 203 | googleapis_cpp_add_library("google/api/resource.proto") 204 | 205 | googleapis_cpp_add_library("google/type/expr.proto") 206 | 207 | googleapis_cpp_add_library("google/rpc/error_details.proto") 208 | googleapis_cpp_add_library("google/rpc/status.proto" rpc_error_details_protos) 209 | 210 | googleapis_cpp_add_library("google/iam/v1/options.proto" api_annotations_protos) 211 | googleapis_cpp_add_library("google/iam/v1/policy.proto" api_annotations_protos 212 | type_expr_protos) 213 | 214 | googleapis_cpp_add_library( 215 | "google/iam/v1/iam_policy.proto" 216 | api_annotations_protos 217 | api_client_protos 218 | api_field_behavior_protos 219 | api_resource_protos 220 | iam_v1_options_protos 221 | iam_v1_policy_protos) 222 | 223 | googleapis_cpp_add_library( 224 | "google/longrunning/operations.proto" api_annotations_protos 225 | api_client_protos rpc_status_protos) 226 | 227 | googleapis_cpp_add_library( 228 | "google/devtools/cloudtrace/v2/trace.proto" api_annotations_protos 229 | api_field_behavior_protos api_resource_protos rpc_status_protos) 230 | googleapis_cpp_add_library( 231 | "google/devtools/cloudtrace/v2/tracing.proto" 232 | devtools_cloudtrace_v2_trace_protos api_annotations_protos 233 | api_client_protos api_field_behavior_protos rpc_status_protos) 234 | 235 | google_cloud_cpp_grpcpp_library( 236 | googleapis_cpp_cloud_bigquery_protos 237 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/connection/v1beta1/connection.proto" 238 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/datatransfer/v1/datatransfer.proto" 239 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/datatransfer/v1/transfer.proto" 240 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/logging/v1/audit_data.proto" 241 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/storage/v1beta1/arrow.proto" 242 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/storage/v1beta1/avro.proto" 243 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/storage/v1beta1/read_options.proto" 244 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/storage/v1beta1/storage.proto" 245 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/storage/v1beta1/table_reference.proto" 246 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/v2/encryption_config.proto" 247 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/v2/model.proto" 248 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/v2/model_reference.proto" 249 | "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/v2/standard_sql.proto" 250 | PROTO_PATH_DIRECTORIES 251 | "${GOOGLEAPIS_CPP_SOURCE}" 252 | "${PROTO_INCLUDE_DIR}") 253 | googleapis_cpp_set_version_and_alias(cloud_bigquery_protos) 254 | target_link_libraries( 255 | googleapis_cpp_cloud_bigquery_protos 256 | PUBLIC googleapis-c++::api_annotations_protos 257 | googleapis-c++::api_client_protos 258 | googleapis-c++::api_field_behavior_protos 259 | googleapis-c++::api_resource_protos 260 | googleapis-c++::iam_v1_iam_policy_protos 261 | googleapis-c++::iam_v1_policy_protos 262 | googleapis-c++::rpc_status_protos 263 | googleapis-c++::api_http_protos 264 | PRIVATE googleapis_cpp_common_flags) 265 | 266 | google_cloud_cpp_grpcpp_library( 267 | googleapis_cpp_bigtable_protos 268 | "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/admin/v2/bigtable_instance_admin.proto" 269 | "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/admin/v2/bigtable_table_admin.proto" 270 | "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/admin/v2/common.proto" 271 | "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/admin/v2/instance.proto" 272 | "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/admin/v2/table.proto" 273 | "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/v2/bigtable.proto" 274 | "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/v2/data.proto" 275 | PROTO_PATH_DIRECTORIES 276 | "${GOOGLEAPIS_CPP_SOURCE}" 277 | "${PROTO_INCLUDE_DIR}") 278 | googleapis_cpp_set_version_and_alias(bigtable_protos) 279 | target_link_libraries( 280 | googleapis_cpp_bigtable_protos 281 | PUBLIC googleapis-c++::api_annotations_protos 282 | googleapis-c++::api_client_protos 283 | googleapis-c++::api_field_behavior_protos 284 | googleapis-c++::api_resource_protos 285 | googleapis-c++::iam_v1_iam_policy_protos 286 | googleapis-c++::iam_v1_policy_protos 287 | googleapis-c++::longrunning_operations_protos 288 | googleapis-c++::rpc_status_protos 289 | googleapis-c++::api_auth_protos 290 | PRIVATE googleapis_cpp_common_flags) 291 | 292 | google_cloud_cpp_grpcpp_library( 293 | googleapis_cpp_pubsub_protos 294 | "${GOOGLEAPIS_CPP_SOURCE}/google/pubsub/v1/pubsub.proto" 295 | PROTO_PATH_DIRECTORIES "${GOOGLEAPIS_CPP_SOURCE}" "${PROTO_INCLUDE_DIR}") 296 | googleapis_cpp_set_version_and_alias(pubsub_protos) 297 | target_link_libraries( 298 | googleapis_cpp_pubsub_protos 299 | PUBLIC googleapis-c++::api_annotations_protos 300 | googleapis-c++::api_client_protos 301 | googleapis-c++::api_field_behavior_protos 302 | googleapis-c++::api_resource_protos 303 | PRIVATE googleapis_cpp_common_flags) 304 | 305 | google_cloud_cpp_grpcpp_library( 306 | googleapis_cpp_spanner_protos 307 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/admin/database/v1/backup.proto" 308 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/admin/database/v1/common.proto" 309 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/admin/database/v1/spanner_database_admin.proto" 310 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/admin/instance/v1/spanner_instance_admin.proto" 311 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/keys.proto" 312 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/mutation.proto" 313 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/query_plan.proto" 314 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/result_set.proto" 315 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/spanner.proto" 316 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/transaction.proto" 317 | "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/type.proto" 318 | PROTO_PATH_DIRECTORIES 319 | "${GOOGLEAPIS_CPP_SOURCE}" 320 | "${PROTO_INCLUDE_DIR}") 321 | googleapis_cpp_set_version_and_alias(spanner_protos) 322 | target_link_libraries( 323 | googleapis_cpp_spanner_protos 324 | PUBLIC googleapis-c++::api_annotations_protos 325 | googleapis-c++::api_client_protos 326 | googleapis-c++::api_field_behavior_protos 327 | googleapis-c++::api_resource_protos 328 | googleapis-c++::iam_v1_iam_policy_protos 329 | googleapis-c++::iam_v1_policy_protos 330 | googleapis-c++::longrunning_operations_protos 331 | googleapis-c++::rpc_status_protos 332 | PRIVATE googleapis_cpp_common_flags) 333 | 334 | google_cloud_cpp_grpcpp_library( 335 | googleapis_cpp_storage_protos 336 | "${GOOGLEAPIS_CPP_SOURCE}/google/storage/v1/storage.proto" 337 | "${GOOGLEAPIS_CPP_SOURCE}/google/storage/v1/storage_resources.proto" 338 | PROTO_PATH_DIRECTORIES 339 | "${GOOGLEAPIS_CPP_SOURCE}" 340 | "${PROTO_INCLUDE_DIR}") 341 | googleapis_cpp_set_version_and_alias(storage_protos) 342 | target_link_libraries( 343 | googleapis_cpp_storage_protos 344 | PUBLIC googleapis-c++::api_annotations_protos 345 | googleapis-c++::api_client_protos 346 | googleapis-c++::api_field_behavior_protos 347 | googleapis-c++::iam_v1_iam_policy_protos 348 | googleapis-c++::iam_v1_policy_protos 349 | PRIVATE googleapis_cpp_common_flags) 350 | 351 | # Install the libraries and headers in the locations determined by 352 | # GNUInstallDirs 353 | include(GNUInstallDirs) 354 | 355 | set(googleapis_cpp_installed_libraries_list 356 | googleapis_cpp_bigtable_protos 357 | googleapis_cpp_cloud_bigquery_protos 358 | googleapis_cpp_pubsub_protos 359 | googleapis_cpp_spanner_protos 360 | googleapis_cpp_storage_protos 361 | googleapis_cpp_longrunning_operations_protos 362 | googleapis_cpp_api_http_protos 363 | googleapis_cpp_api_annotations_protos 364 | googleapis_cpp_api_auth_protos 365 | googleapis_cpp_api_client_protos 366 | googleapis_cpp_api_field_behavior_protos 367 | googleapis_cpp_api_resource_protos 368 | googleapis_cpp_devtools_cloudtrace_v2_trace_protos 369 | googleapis_cpp_devtools_cloudtrace_v2_tracing_protos 370 | googleapis_cpp_iam_v1_options_protos 371 | googleapis_cpp_iam_v1_policy_protos 372 | googleapis_cpp_iam_v1_iam_policy_protos 373 | googleapis_cpp_rpc_error_details_protos 374 | googleapis_cpp_rpc_status_protos 375 | googleapis_cpp_type_expr_protos) 376 | 377 | install( 378 | TARGETS ${googleapis_cpp_installed_libraries_list} 379 | googleapis_cpp_common_flags 380 | EXPORT googleapis-targets 381 | RUNTIME DESTINATION bin 382 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 383 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) 384 | 385 | foreach (target ${googleapis_cpp_installed_libraries_list}) 386 | google_cloud_cpp_install_proto_library_headers("${target}") 387 | google_cloud_cpp_install_proto_library_protos("${target}" 388 | "${GOOGLEAPIS_CPP_SOURCE}") 389 | endforeach () 390 | 391 | # Export the CMake targets to make it easy to create configuration files. 392 | install(EXPORT googleapis-targets 393 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/googleapis") 394 | 395 | # Setup global variables used in the following *.in files. 396 | set(GOOGLE_CLOUD_CPP_CONFIG_VERSION_MAJOR 397 | ${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR}) 398 | set(GOOGLE_CLOUD_CPP_CONFIG_VERSION_MINOR 399 | ${GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR}) 400 | set(GOOGLE_CLOUD_CPP_CONFIG_VERSION_PATCH 401 | ${GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH}) 402 | 403 | # Use a function to create a scope for the variables. 404 | function (googleapis_cpp_install_pc target) 405 | string(REPLACE "googleapis_cpp_" "" _short_name ${target}) 406 | string(REPLACE "_protos" "" _short_name ${_short_name}) 407 | set(GOOGLE_CLOUD_CPP_PC_NAME 408 | "The Google APIS C++ ${_short_name} Proto Library") 409 | set(GOOGLE_CLOUD_CPP_PC_DESCRIPTION "Compiled proto for C++.") 410 | # Examine the target LINK_LIBRARIES property, use that to pull the 411 | # dependencies between the googleapis-c++::* libraries. 412 | set(_target_pc_requires) 413 | get_target_property(_target_deps ${target} LINK_LIBRARIES) 414 | foreach (dep ${_target_deps}) 415 | if ("${dep}" MATCHES "^googleapis-c\\+\\+::") 416 | string(REPLACE "googleapis-c++::" "googleapis_cpp_" dep "${dep}") 417 | list(APPEND _target_pc_requires " " "${dep}") 418 | endif () 419 | endforeach () 420 | # These dependencies are required for all the googleapis-c++::* libraries. 421 | list( 422 | APPEND 423 | _target_pc_requires 424 | " grpc++" 425 | " grpc" 426 | " openssl" 427 | " protobuf" 428 | " zlib" 429 | " libcares") 430 | string(CONCAT GOOGLE_CLOUD_CPP_PC_REQUIRES ${_target_pc_requires}) 431 | set(GOOGLE_CLOUD_CPP_PC_LIBS "-l${target}") 432 | configure_file("cmake/config.pc.in" "${target}.pc" @ONLY) 433 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${target}.pc" 434 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") 435 | endfunction () 436 | 437 | # Create and install the pkg-config files. 438 | foreach (target ${googleapis_cpp_installed_libraries_list}) 439 | googleapis_cpp_install_pc("${target}") 440 | endforeach () 441 | 442 | # Create and install the googleapis pkg-config file for backwards compatibility. 443 | set(GOOGLE_CLOUD_CPP_PC_NAME "The Google APIS C++ Proto Library") 444 | set(GOOGLE_CLOUD_CPP_PC_DESCRIPTION 445 | "Provides C++ APIs to access Google Cloud Platforms.") 446 | # Note the use of spaces, `string(JOIN)` is not available in cmake-3.5, so we 447 | # need to add the separator ourselves. 448 | string( 449 | CONCAT GOOGLE_CLOUD_CPP_PC_REQUIRES 450 | "googleapis_cpp_bigtable_protos" 451 | " googleapis_cpp_cloud_bigquery_protos" 452 | " googleapis_pubsub_protos" 453 | " googleapis_cpp_storage_protos" 454 | " googleapis_cpp_iam_v1_iam_policy_protos" 455 | " googleapis_cpp_iam_v1_options_protos" 456 | " googleapis_cpp_iam_v1_policy_protos" 457 | " googleapis_cpp_longrunning_operations_protos" 458 | " googleapis_cpp_api_auth_protos" 459 | " googleapis_cpp_api_annotations_protos" 460 | " googleapis_cpp_api_client_protos" 461 | " googleapis_cpp_api_field_behavior_protos" 462 | " googleapis_cpp_api_http_protos" 463 | " googleapis_cpp_rpc_status_protos" 464 | " googleapis_cpp_rpc_error_details_protos" 465 | " grpc++" 466 | " grpc" 467 | " openssl" 468 | " protobuf" 469 | " zlib" 470 | " libcares") 471 | set(GOOGLE_CLOUD_CPP_PC_LIBS "") 472 | configure_file("cmake/config.pc.in" "googleapis.pc" @ONLY) 473 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/googleapis.pc" 474 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") 475 | 476 | # Create and install the CMake configuration files. 477 | configure_file("cmake/config.cmake.in" "googleapis-config.cmake" @ONLY) 478 | configure_file("cmake/config-version.cmake.in" 479 | "googleapis-config-version.cmake" @ONLY) 480 | install( 481 | FILES "${CMAKE_CURRENT_BINARY_DIR}/googleapis-config.cmake" 482 | "${CMAKE_CURRENT_BINARY_DIR}/googleapis-config-version.cmake" 483 | "${PROJECT_SOURCE_DIR}/cmake/FindgRPC.cmake" 484 | "${PROJECT_SOURCE_DIR}/cmake/FindProtobufTargets.cmake" 485 | "${PROJECT_SOURCE_DIR}/cmake/CompileProtos.cmake" 486 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/googleapis") 487 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | ## Contributor License Agreements 4 | 5 | We'd love to accept your patches! Before we can take them, we 6 | have to jump a couple of legal hurdles. 7 | 8 | Please fill out either the individual or corporate Contributor License Agreement 9 | (CLA). 10 | 11 | * If you are an individual writing original source code and you're sure you 12 | own the intellectual property, then you'll need to sign an 13 | [individual CLA](https://developers.google.com/open-source/cla/individual). 14 | * If you work for a company that wants to allow you to contribute your work, 15 | then you'll need to sign a 16 | [corporate CLA](https://developers.google.com/open-source/cla/corporate). 17 | 18 | Follow either of the two links above to access the appropriate CLA and 19 | instructions for how to sign and return it. Once we receive it, we'll be able to 20 | accept your pull requests. 21 | 22 | ## Contributing A Patch 23 | 24 | 1. Submit an issue describing your proposed change to the repo in question. 25 | 1. The repo owner will respond to your issue promptly. 26 | 1. If your proposed change is accepted, and you haven't already done so, sign a 27 | Contributor License Agreement (see details above). 28 | 1. Fork the desired repo, develop and test your code changes. 29 | 1. Ensure that your code adheres to the existing style in the sample to which 30 | you are contributing. 31 | 1. Ensure that your code has an appropriate set of unit tests which all pass. 32 | 1. Submit a pull request. 33 | 34 | ## Style 35 | 36 | This repository follow the [Google C++ Style Guide]( 37 | https://google.github.io/styleguide/cppguide.html). 38 | Please make sure your contributions adhere to the style guide. 39 | 40 | ### Formatting 41 | 42 | The code in this project is formatted with `clang-format(1)`, and our CI builds 43 | will check that the code matches the format generated by this tool before 44 | accepting a pull request. Please configure your editor or IDE to use the Google 45 | style for indentation and other whitespace. If you need to reformat one or more 46 | files, you can simply run `clang-format` manually: 47 | 48 | ```console 49 | $ clang-format -i .... 50 | ``` 51 | 52 | If you need to reformat one of the files to match the Google style. Please be 53 | advised that `clang-format` has been known to generate slightly different 54 | formatting in different versions. We use version 7; use the same version if you 55 | run into problems. 56 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This repo has moved 2 | 3 | It now lives in the https://github.com/googleapis/google-cloud-cpp monorepo. 4 | -------------------------------------------------------------------------------- /ci/check-style.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 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 | set -eu 17 | 18 | if [[ "${CHECK_STYLE}" != "yes" ]]; then 19 | echo "Skipping code style check as it is disabled for this build." 20 | exit 0 21 | fi 22 | 23 | # This script assumes it is running the top-level google-cloud-cpp directory. 24 | 25 | readonly BINDIR="$(dirname "$0")" 26 | 27 | # Build paths to ignore in find(1) commands by reading .gitignore. 28 | declare -a ignore=( -path ./.git ) 29 | if [[ -f .gitignore ]]; then 30 | while read -r line; do 31 | case "${line}" in 32 | [^#]*/*) ignore+=( -o -path "./$(expr "${line}" : '\(.*\)/')" ) ;; 33 | [^#]*) ignore+=( -o -name "${line}" ) ;; 34 | esac 35 | done < .gitignore 36 | fi 37 | 38 | replace_original_if_changed() { 39 | if [[ $# != 2 ]]; then 40 | return 1 41 | fi 42 | 43 | local original="$1" 44 | local reformatted="$2" 45 | 46 | if cmp -s "${original}" "${reformatted}"; then 47 | rm -f "${reformatted}" 48 | else 49 | chmod --reference="${original}" "${reformatted}" 50 | mv -f "${reformatted}" "${original}" 51 | fi 52 | } 53 | 54 | # Apply cmake_format to all the CMake list files. 55 | # https://github.com/cheshirekow/cmake_format 56 | find . \( "${ignore[@]}" \) -prune -o \ 57 | \( -name 'CMakeLists.txt' -o -name '*.cmake' \) \ 58 | -print0 | 59 | while IFS= read -r -d $'\0' file; do 60 | cmake-format "${file}" >"${file}.tmp" 61 | replace_original_if_changed "${file}" "${file}.tmp" 62 | done 63 | 64 | # Apply buildifier to fix the BUILD and .bzl formatting rules. 65 | # https://github.com/bazelbuild/buildtools/tree/master/buildifier 66 | find . \( "${ignore[@]}" \) -prune -o \ 67 | \( -name BUILD -o -name '*.bzl' \) \ 68 | -print0 | 69 | xargs -0 buildifier -mode=fix 70 | 71 | # Apply shellcheck(1) to emit warnings for common scripting mistakes. 72 | find . \( "${ignore[@]}" \) -prune -o \ 73 | -iname '*.sh' -exec shellcheck \ 74 | --exclude=SC1090 \ 75 | --exclude=SC2034 \ 76 | --exclude=SC2153 \ 77 | --exclude=SC2181 \ 78 | '{}' \; 79 | 80 | # Report any differences created by running the formatting tools. 81 | git diff --ignore-submodules=all --color --exit-code . 82 | -------------------------------------------------------------------------------- /ci/colors.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 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 | if [ -z "${COLOR_RESET+x}" ]; then 17 | if type tput >/dev/null 2>&1; then 18 | readonly COLOR_RED="$(tput setaf 1)" 19 | readonly COLOR_GREEN="$(tput setaf 2)" 20 | readonly COLOR_YELLOW="$(tput setaf 3)" 21 | readonly COLOR_RESET="$(tput sgr0)" 22 | else 23 | readonly COLOR_RED="" 24 | readonly COLOR_GREEN="" 25 | readonly COLOR_YELLOW="" 26 | readonly COLOR_RESET="" 27 | fi 28 | fi 29 | -------------------------------------------------------------------------------- /ci/install-grpc.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 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 | set -eu 17 | 18 | mkdir -p /var/tmp/Downloads 19 | cd /var/tmp/Downloads 20 | 21 | # Install protobuf 22 | wget -q https://github.com/google/protobuf/archive/v3.8.0.tar.gz 23 | tar -xf v3.8.0.tar.gz 24 | (cd protobuf-3.8.0/cmake; 25 | cmake \ 26 | -DCMAKE_BUILD_TYPE=Release \ 27 | -DBUILD_SHARED_LIBS=yes \ 28 | -Dprotobuf_BUILD_TESTS=OFF \ 29 | -H. -Bcmake-out 30 | cmake --build cmake-out --target install -- -j "$(nproc)" 31 | ldconfig 32 | ) 33 | 34 | # Install grpc 35 | wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz 36 | tar -xf v1.22.0.tar.gz 37 | (cd grpc-1.22.0; 38 | make -j "$(nproc)" 39 | make install 40 | ldconfig 41 | ) 42 | -------------------------------------------------------------------------------- /ci/kokoro/Dockerfile.centos: -------------------------------------------------------------------------------- 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 | ARG DISTRO_VERSION=7 16 | FROM centos:${DISTRO_VERSION} 17 | 18 | # Add /usr/local/lib 19 | 20 | # Search paths tweak for the build 21 | ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig 22 | ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 23 | ENV PATH=/usr/local/bin:${PATH} 24 | 25 | # First install the development tools and OpenSSL. The development tools 26 | # distributed with CentOS (notably CMake) are too old to build 27 | # `google-cloud-cpp`. In these instructions, we use `cmake3` obtained from 28 | # [Software Collections](https://www.softwarecollections.org/). 29 | 30 | RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 31 | RUN yum install -y centos-release-scl 32 | RUN yum-config-manager --enable rhel-server-rhscl-7-rpms 33 | RUN yum makecache && \ 34 | yum install -y automake cmake3 curl-devel gcc gcc-c++ git libtool \ 35 | make openssl-devel pkgconfig tar wget which zlib-devel 36 | RUN ln -sf /usr/bin/cmake3 /usr/bin/cmake && ln -sf /usr/bin/ctest3 /usr/bin/ctest 37 | 38 | # Install c-ares 39 | RUN mkdir -p /var/tmp/Downloads; \ 40 | cd /var/tmp/Downloads; \ 41 | wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz; \ 42 | tar -xf cares-1_15_0.tar.gz; \ 43 | cd /var/tmp/Downloads/c-ares-cares-1_15_0; \ 44 | ./buildconf && ./configure && make -j $(nproc); \ 45 | make install; \ 46 | ldconfig 47 | 48 | # Install grpc from source 49 | WORKDIR /var/tmp/ci 50 | COPY install-grpc.sh /var/tmp/ci 51 | RUN /var/tmp/ci/install-grpc.sh 52 | -------------------------------------------------------------------------------- /ci/kokoro/Dockerfile.fedora: -------------------------------------------------------------------------------- 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 | ARG DISTRO_VERSION=30 16 | FROM fedora:${DISTRO_VERSION} 17 | 18 | # Fedora includes packages for gRPC, libcurl, and OpenSSL that are recent enough 19 | # for `google-cloud-cpp`. Install these packages and additional development 20 | # tools to compile the dependencies: 21 | RUN dnf makecache && \ 22 | dnf install -y clang clang-tools-extra cmake doxygen findutils gcc-c++ git \ 23 | grpc-devel grpc-plugins libcxx-devel libcxxabi-devel libcurl-devel \ 24 | make openssl-devel pkgconfig protobuf-compiler python-pip ShellCheck \ 25 | tar wget zlib-devel 26 | 27 | # Install the the buildifier tool, which does not compile with the default 28 | # golang compiler for Ubuntu 16.04 and Ubuntu 18.04. 29 | RUN wget -q -O /usr/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/0.17.2/buildifier 30 | RUN chmod 755 /usr/bin/buildifier 31 | 32 | # Install cmake_format to automatically format the CMake list files. 33 | # https://github.com/cheshirekow/cmake_format 34 | # Pin this to an specific version because the formatting changes when the 35 | # "latest" version is updated, and we do not want the builds to break just 36 | # because some third party changed something. 37 | RUN pip install --upgrade pip 38 | RUN pip install numpy cmake_format==0.6.9 39 | -------------------------------------------------------------------------------- /ci/kokoro/Dockerfile.ubuntu-16.04: -------------------------------------------------------------------------------- 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 | FROM ubuntu:16.04 16 | 17 | RUN apt update && \ 18 | apt install -y \ 19 | automake \ 20 | build-essential \ 21 | clang \ 22 | cmake \ 23 | curl \ 24 | doxygen \ 25 | gawk \ 26 | git \ 27 | gcc \ 28 | golang \ 29 | g++ \ 30 | libssl-dev \ 31 | libtool \ 32 | make \ 33 | ninja-build \ 34 | pkg-config \ 35 | python-pip \ 36 | shellcheck \ 37 | tar \ 38 | unzip \ 39 | wget \ 40 | zlib1g-dev 41 | 42 | WORKDIR /var/tmp/Downloads 43 | RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz && \ 44 | tar -xf cares-1_15_0.tar.gz && \ 45 | cd /var/tmp/Downloads/c-ares-cares-1_15_0 && \ 46 | ./buildconf && ./configure && make -j $(nproc) && \ 47 | make install && \ 48 | ldconfig 49 | 50 | # Install grpc from source 51 | WORKDIR /var/tmp/ci 52 | COPY install-grpc.sh /var/tmp/ci 53 | RUN /var/tmp/ci/install-grpc.sh 54 | -------------------------------------------------------------------------------- /ci/kokoro/Dockerfile.ubuntu-18.04: -------------------------------------------------------------------------------- 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 | FROM ubuntu:18.04 16 | 17 | RUN apt update && \ 18 | apt install -y \ 19 | build-essential \ 20 | clang \ 21 | cmake \ 22 | curl \ 23 | doxygen \ 24 | gawk \ 25 | git \ 26 | gcc \ 27 | golang \ 28 | g++ \ 29 | libc-ares-dev \ 30 | libc-ares2 \ 31 | libssl-dev \ 32 | make \ 33 | ninja-build \ 34 | pkg-config \ 35 | python-pip \ 36 | shellcheck \ 37 | tar \ 38 | unzip \ 39 | wget \ 40 | zlib1g-dev 41 | 42 | # Install grpc from source 43 | WORKDIR /var/tmp/ci 44 | COPY install-grpc.sh /var/tmp/ci 45 | RUN /var/tmp/ci/install-grpc.sh 46 | -------------------------------------------------------------------------------- /ci/kokoro/docker/build-in-docker-cmake.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 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 | set -eu 17 | 18 | if [[ $# != 2 ]]; then 19 | echo "Usage: $(basename "$0") " 20 | exit 1 21 | fi 22 | 23 | readonly SOURCE_DIR="$1" 24 | readonly BINARY_DIR="$2" 25 | 26 | # This script is supposed to run inside a Docker container, see 27 | # ci/kokoro/cmake/installed-dependencies/build.sh for the expected setup. The 28 | # /v directory is a volume pointing to a (clean-ish) checkout of the project: 29 | if [[ -z "${PROJECT_ROOT+x}" ]]; then 30 | readonly PROJECT_ROOT="/v" 31 | fi 32 | source "${PROJECT_ROOT}/ci/colors.sh" 33 | 34 | echo 35 | echo "${COLOR_YELLOW}Starting docker build $(date) with $(nproc) cores${COLOR_RESET}" 36 | echo 37 | 38 | echo "================================================================" 39 | echo "Verify formatting $(date)" 40 | (cd "${PROJECT_ROOT}" ; ./ci/check-style.sh) 41 | echo "================================================================" 42 | 43 | echo "================================================================" 44 | echo "Compiling on $(date)" 45 | echo "================================================================" 46 | cd "${PROJECT_ROOT}" 47 | cmake_flags=() 48 | if [[ "${CLANG_TIDY:-}" = "yes" ]]; then 49 | cmake_flags+=("-DGOOGLE_CLOUD_CPP_CLANG_TIDY=yes") 50 | fi 51 | if [[ "${GOOGLE_CLOUD_CPP_CXX_STANDARD:-}" != "" ]]; then 52 | cmake_flags+=( 53 | "-DGOOGLE_CLOUD_CPP_CXX_STANDARD=${GOOGLE_CLOUD_CPP_CXX_STANDARD}") 54 | fi 55 | 56 | if [[ "${CODE_COVERAGE:-}" == "yes" ]]; then 57 | cmake_flags+=( 58 | "-DCMAKE_BUILD_TYPE=Coverage") 59 | fi 60 | 61 | if [[ "${USE_NINJA:-}" == "yes" ]]; then 62 | cmake_flags+=( "-GNinja" ) 63 | fi 64 | 65 | # Avoid unbound variable error with older bash 66 | if [[ "${#cmake_flags[@]}" == 0 ]]; then 67 | cmake "-H${SOURCE_DIR}" "-B${BINARY_DIR}" 68 | else 69 | cmake "-H${SOURCE_DIR}" "-B${BINARY_DIR}" "${cmake_flags[@]}" 70 | fi 71 | cmake --build "${BINARY_DIR}" -- -j "$(nproc)" 72 | 73 | # When user a super-build the tests are hidden in a subdirectory. We can tell 74 | # that ${BINARY_DIR} does not have the tests by checking for this file: 75 | if [[ -r "${BINARY_DIR}/CTestTestfile.cmake" ]]; then 76 | echo "================================================================" 77 | # It is Okay to skip the tests in this case because the super build 78 | # automatically runs them. 79 | echo "Running the unit tests $(date)" 80 | env -C "${BINARY_DIR}" ctest \ 81 | -LE integration-tests \ 82 | --output-on-failure -j "$(nproc)" 83 | echo "================================================================" 84 | fi 85 | 86 | if [[ "${GENERATE_DOCS:-}" = "yes" ]]; then 87 | echo "================================================================" 88 | echo "Validate Doxygen documentation $(date)" 89 | cmake --build "${BINARY_DIR}" --target doxygen-docs 90 | echo "================================================================" 91 | fi 92 | 93 | if [[ ${RUN_INTEGRATION_TESTS} == "yes" ]]; then 94 | echo "================================================================" 95 | echo "Running the integration tests $(date)" 96 | echo "================================================================" 97 | # shellcheck disable=SC1091 98 | source /c/spanner-integration-tests-config.sh 99 | export GOOGLE_APPLICATION_CREDENTIALS=/c/spanner-credentials.json 100 | 101 | # Run the integration tests too. 102 | env -C "${BINARY_DIR}" ctest \ 103 | -L integration-tests \ 104 | --output-on-failure 105 | echo "================================================================" 106 | fi 107 | 108 | echo "================================================================" 109 | echo "Build finished at $(date)" 110 | echo "================================================================" 111 | 112 | exit 0 113 | -------------------------------------------------------------------------------- /ci/kokoro/docker/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 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 | set -eu 17 | 18 | export CC=gcc 19 | export CXX=g++ 20 | export DISTRO=ubuntu 21 | export DISTRO_VERSION=18.04 22 | export CMAKE_SOURCE_DIR="." 23 | 24 | in_docker_script="ci/kokoro/docker/build-in-docker-cmake.sh" 25 | 26 | if [[ $# -eq 1 ]]; then 27 | export BUILD_NAME="${1}" 28 | elif [[ -n "${KOKORO_JOB_NAME:-}" ]]; then 29 | # Kokoro injects the KOKORO_JOB_NAME environment variable, the value of this 30 | # variable is cloud-cpp/spanner/ (or more 31 | # generally ). By convention we name these 32 | # files `$foo.cfg` for continuous builds and `$foo-presubmit.cfg` for 33 | # presubmit builds. Here we extract the value of "foo" and use it as the build 34 | # name. 35 | BUILD_NAME="$(basename "${KOKORO_JOB_NAME}" "-presubmit")" 36 | export BUILD_NAME 37 | else 38 | echo "Aborting build as the build name is not defined." 39 | echo "If you are invoking this script via the command line use:" 40 | echo " $0 " 41 | echo 42 | echo "If this script is invoked by Kokoro, the CI system is expected to set" 43 | echo "the KOKORO_JOB_NAME environment variable." 44 | exit 1 45 | fi 46 | 47 | if [[ "${BUILD_NAME}" = "clang-tidy" ]]; then 48 | # Compile with clang-tidy(1) turned on. The build treats clang-tidy warnings 49 | # as errors. 50 | export DISTRO=fedora 51 | export DISTRO_VERSION=30 52 | export CC=clang 53 | export CXX=clang++ 54 | export CHECK_STYLE=yes 55 | export CLANG_TIDY=yes 56 | elif [[ "${BUILD_NAME}" = "ubuntu-18.04" ]]; then 57 | export CC=gcc 58 | export CXX=g++ 59 | elif [[ "${BUILD_NAME}" = "ubuntu-16.04" ]]; then 60 | export DISTRO_VERSION=16.04 61 | export CC=gcc 62 | export CXX=g++ 63 | elif [[ "${BUILD_NAME}" = "gcc-4.8" ]]; then 64 | # The oldest version of GCC we support is 4.8, this build checks the code 65 | # against that version. The use of CentOS 7 for that build is not a 66 | # coincidence: the reason we support GCC 4.8 is to support this distribution 67 | # (and its commercial cousin: RHEL 7). 68 | export CC=gcc 69 | export CXX=g++ 70 | export DISTRO=centos 71 | export DISTRO_VERSION=7 72 | elif [[ "${BUILD_NAME}" = "clang-3.8" ]]; then 73 | # The oldest version of Clang we actively test is 3.8. There is nothing 74 | # particularly interesting about that version. It is simply the version 75 | # included with Ubuntu:16.04, and the oldest version tested by 76 | # google-cloud-cpp. 77 | export DISTRO=ubuntu 78 | export DISTRO_VERSION=16.04 79 | export CC=clang 80 | export CXX=clang++ 81 | elif [[ "${BUILD_NAME}" = "ninja" ]]; then 82 | # Compiling with Ninja can catch bugs that may not be caught using Make. 83 | export USE_NINJA=yes 84 | else 85 | echo "Unknown BUILD_NAME (${BUILD_NAME}). Fix the Kokoro .cfg file." 86 | exit 1 87 | fi 88 | 89 | if [[ -z "${PROJECT_ROOT+x}" ]]; then 90 | readonly PROJECT_ROOT="$(cd "$(dirname "$0")/../../.."; pwd)" 91 | fi 92 | 93 | if [[ -z "${PROJECT_ID+x}" ]]; then 94 | readonly PROJECT_ID="cloud-devrel-kokoro-resources" 95 | fi 96 | 97 | # Determine the image name. 98 | readonly IMAGE="gcr.io/${PROJECT_ID}/cpp-cmakefiles/${DISTRO}-${DISTRO_VERSION}" 99 | readonly BUILD_OUTPUT="cmake-out/${BUILD_NAME}" 100 | readonly BUILD_HOME="cmake-out/home/${BUILD_NAME}" 101 | 102 | echo "================================================================" 103 | cd "${PROJECT_ROOT}" 104 | echo "Building with $(nproc) cores $(date) on ${PWD}." 105 | 106 | echo "================================================================" 107 | echo "Capture Docker version to troubleshoot $(date)." 108 | docker version 109 | echo "================================================================" 110 | 111 | has_cache="false" 112 | 113 | if [[ -n "${KOKORO_JOB_NAME:-}" ]]; then 114 | # Download the docker image from the previous build on kokoro for speed. 115 | echo "================================================================" 116 | echo "Downloading Docker image $(date)." 117 | gcloud auth configure-docker 118 | if docker pull "${IMAGE}:latest"; then 119 | echo "Existing image successfully downloaded." 120 | has_cache="true" 121 | fi 122 | echo "================================================================" 123 | fi 124 | 125 | docker_build_flags=( 126 | "-t" "${IMAGE}:latest" 127 | ) 128 | 129 | if [[ -f "ci/kokoro/Dockerfile.${DISTRO}-${DISTRO_VERSION}" ]]; then 130 | docker_build_flags+=("-f" "ci/kokoro/Dockerfile.${DISTRO}-${DISTRO_VERSION}") 131 | else 132 | docker_build_flags+=( 133 | "-f" "ci/kokoro/Dockerfile.${DISTRO}" 134 | "--build-arg" "DISTRO_VERSION=${DISTRO_VERSION}" 135 | ) 136 | fi 137 | 138 | if "${has_cache}"; then 139 | docker_build_flags+=("--cache-from=${IMAGE}:latest") 140 | fi 141 | 142 | update_cache="false" 143 | echo "================================================================" 144 | echo "Creating Docker image with all the development tools $(date)." 145 | if ci/retry-command.sh docker build "${docker_build_flags[@]}" ci; then 146 | update_cache="true" 147 | echo "Docker image created $(date)." 148 | docker image ls | grep "${IMAGE}" 149 | else 150 | echo "Failed creating Docker image $(date)." 151 | if "${has_cache}"; then 152 | echo "Continue the build with the cache." 153 | else 154 | exit 1 155 | fi 156 | fi 157 | echo "================================================================" 158 | 159 | if [[ -n "${KOKORO_JOB_NAME:-}" ]]; then 160 | # Upload the docker image for speeding up the future builds. 161 | echo "================================================================" 162 | echo "Uploading Docker image $(date)." 163 | docker push "${IMAGE}:latest" || true 164 | echo "================================================================" 165 | fi 166 | 167 | 168 | echo "================================================================" 169 | echo "Running the full build $(date)." 170 | # The default user for a Docker container has uid 0 (root). To avoid creating 171 | # root-owned files in the build directory we tell docker to use the current 172 | # user ID, if known. 173 | docker_uid="${UID:-0}" 174 | docker_user="${USER:-root}" 175 | docker_home_prefix="${PWD}/cmake-out/home" 176 | if [[ "${docker_uid}" == "0" ]]; then 177 | docker_home_prefix="${PWD}/cmake-out/root" 178 | fi 179 | 180 | # Make sure the user has a $HOME directory inside the Docker container. 181 | mkdir -p "${BUILD_HOME}" 182 | mkdir -p "${BUILD_OUTPUT}" 183 | 184 | # We use an array for the flags so they are easier to document. 185 | docker_flags=( 186 | # Grant the PTRACE capability to the Docker container running the build, 187 | # this is needed by tools like AddressSanitizer. 188 | "--cap-add" "SYS_PTRACE" 189 | 190 | # The name and version of the distribution, this is used to call 191 | # define-docker-variables.sh and determine the Docker image built, and the 192 | # output directory for any artifacts. 193 | "--env" "DISTRO=${DISTRO}" 194 | "--env" "DISTRO_VERSION=${DISTRO_VERSION}" 195 | 196 | # The C++ and C compiler, both Bazel and CMake use this environment variable 197 | # to select the compiler binary. 198 | "--env" "CXX=${CXX}" 199 | "--env" "CC=${CC}" 200 | 201 | # If set to 'yes', the build script will run the style checks, including 202 | # clang-format, cmake-format, and buildifier. 203 | "--env" "CHECK_STYLE=${CHECK_STYLE:-}" 204 | 205 | # If set to 'yes', the build script will configure clang-tidy. Currently 206 | # only the CMake builds use this flag. 207 | "--env" "CLANG_TIDY=${CLANG_TIDY:-}" 208 | 209 | # If set to 'yes', run the integration tests. Currently only the Bazel 210 | # builds use this flag. 211 | "--env" "RUN_INTEGRATION_TESTS=${RUN_INTEGRATION_TESTS:-}" 212 | 213 | # If set to 'yes', run compile with code coverage flags. Currently only the 214 | # CMake builds use this flag. 215 | "--env" "CODE_COVERAGE=${CODE_COVERAGE:-}" 216 | 217 | # If set to 'yes', use Ninja as the CMake generator. Ninja is more strict 218 | # that Make and can detect errors in your CMake files, it is also faster. 219 | "--env" "USE_NINJA=${USE_NINJA:-}" 220 | 221 | # If set, pass -DGOOGLE_CLOUD_CPP_CXX_STANDARD= to CMake. 222 | "--env" "GOOGLE_CLOUD_CPP_CXX_STANDARD=${GOOGLE_CLOUD_CPP_CXX_STANDARD:-}" 223 | 224 | # When running the integration tests this directory contains the 225 | # configuration files needed to run said tests. Make it available inside 226 | # the Docker container. 227 | "--volume" "${KOKORO_GFILE_DIR:-/dev/shm}:/c" 228 | 229 | # Let the Docker image script know what kind of terminal we are using, that 230 | # produces properly colorized error messages. 231 | "--env" "TERM=${TERM:-dumb}" 232 | 233 | # Run the docker script and this user id. Because the docker image gets to 234 | # write in ${PWD} you typically want this to be your user id. 235 | "--user" "${docker_uid}" 236 | 237 | # Bazel needs this environment variable to work correctly. 238 | "--env" "USER=${docker_user}" 239 | 240 | # We give Bazel and CMake a fake $HOME inside the docker image. Bazel caches 241 | # build byproducts in this directory. CMake (when ccache is enabled) uses 242 | # it to store $HOME/.ccache 243 | "--env" "HOME=/h" 244 | "--volume" "${PWD}/${BUILD_HOME}:/h" 245 | 246 | # Mount the current directory (which is the top-level directory for the 247 | # project) as `/v` inside the docker image, and move to that directory. 248 | "--volume" "${PWD}:/v" 249 | "--workdir" "/v" 250 | 251 | # Mask any other builds that may exist at the same time. That is, these 252 | # directories appear as empty inside the Docker container, this prevents the 253 | # container from writing into other builds, or to get confused by the output 254 | # of other builds. In the CI system this does not matter, as each build runs 255 | # on a completely separate VM. This is useful when running multiple builds 256 | # in your workstation. 257 | "--volume" "/v/cmake-out/home" 258 | "--volume" "/v/cmake-out" 259 | "--volume" "${PWD}/${BUILD_OUTPUT}:/v/${BUILD_OUTPUT}" 260 | ) 261 | 262 | # When running the builds from the command-line they get a tty, and the scripts 263 | # running inside the Docker container can produce nicer output. On Kokoro the 264 | # script does not get a tty, and Docker terminates the program if we pass the 265 | # `-it` flag. 266 | if [[ -t 0 ]]; then 267 | docker_flags+=("-it") 268 | fi 269 | 270 | docker run "${docker_flags[@]}" "${IMAGE}:latest" \ 271 | "/v/${in_docker_script}" "${CMAKE_SOURCE_DIR}" \ 272 | "${BUILD_OUTPUT}" 273 | -------------------------------------------------------------------------------- /ci/kokoro/docker/clang-3.8-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/clang-3.8-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/clang-3.8.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/clang-3.8.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/clang-tidy-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/clang-tidy-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/clang-tidy.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/clang-tidy.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 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 | build_file: "cpp-cmakefiles/ci/kokoro/docker/build.sh" 17 | timeout_mins: 120 18 | -------------------------------------------------------------------------------- /ci/kokoro/docker/gcc-4.8-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/gcc-4.8-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/gcc-4.8.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/gcc-4.8.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/ninja-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/ninja-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/ninja.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/ninja.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/ubuntu-16.04-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/ubuntu-16.04-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/ubuntu-16.04.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/ubuntu-16.04.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/ubuntu-18.04-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/ubuntu-18.04-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/docker/ubuntu-18.04.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/docker/ubuntu-18.04.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/Dockerfile.centos-7: -------------------------------------------------------------------------------- 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 | FROM centos:7 AS devtools 16 | 17 | # Please keep the formatting in these commands, it is optimized to cut & paste 18 | # into the INSTALL.md file. 19 | 20 | ## [START INSTALL.md] 21 | 22 | # First install the development tools and OpenSSL. The development tools 23 | # distributed with CentOS (notably CMake) are too old to build 24 | # `cpp-cmakefiles`. In these instructions, we use `cmake3` obtained from 25 | # [Software Collections](https://www.softwarecollections.org/). 26 | 27 | # ```bash 28 | RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 29 | RUN yum install -y centos-release-scl 30 | RUN yum-config-manager --enable rhel-server-rhscl-7-rpms 31 | RUN yum makecache && \ 32 | yum install -y automake cmake3 curl-devel gcc gcc-c++ git libtool \ 33 | make openssl-devel pkgconfig tar wget which zlib-devel 34 | RUN ln -sf /usr/bin/cmake3 /usr/bin/cmake && ln -sf /usr/bin/ctest3 /usr/bin/ctest 35 | # ``` 36 | 37 | # #### Protobuf 38 | 39 | # Likewise, manually install protobuf: 40 | 41 | # ```bash 42 | WORKDIR /var/tmp/build 43 | RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz 44 | RUN tar -xf v3.9.0.tar.gz 45 | WORKDIR /var/tmp/build/protobuf-3.9.0/cmake 46 | RUN cmake \ 47 | -DCMAKE_BUILD_TYPE=Release \ 48 | -DBUILD_SHARED_LIBS=yes \ 49 | -Dprotobuf_BUILD_TESTS=OFF \ 50 | -H. -Bcmake-out 51 | RUN cmake --build cmake-out --target install -- -j $(nproc) 52 | RUN ldconfig 53 | # ``` 54 | 55 | # #### c-ares 56 | 57 | # Recent versions of gRPC require c-ares >= 1.11, while CentOS-7 58 | # distributes c-ares-1.10. Manually install a newer version: 59 | 60 | # ```bash 61 | WORKDIR /var/tmp/build 62 | RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz 63 | RUN tar -xf cares-1_15_0.tar.gz 64 | WORKDIR /var/tmp/build/c-ares-cares-1_15_0 65 | RUN ./buildconf && ./configure && make -j $(nproc) 66 | RUN make install 67 | RUN ldconfig 68 | # ``` 69 | 70 | # #### gRPC 71 | 72 | # Can be manually installed using: 73 | 74 | # ```bash 75 | WORKDIR /var/tmp/build 76 | RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz 77 | RUN tar -xf v1.22.0.tar.gz 78 | WORKDIR /var/tmp/build/grpc-1.22.0 79 | ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig 80 | ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 81 | ENV PATH=/usr/local/bin:${PATH} 82 | RUN make -j $(nproc) 83 | RUN make install 84 | RUN ldconfig 85 | # ``` 86 | 87 | FROM devtools AS install 88 | 89 | # #### googleapis 90 | 91 | # Finally we can install `googleapis`. 92 | 93 | # ```bash 94 | WORKDIR /home/build/cpp-cmakefiles 95 | COPY . /home/build/cpp-cmakefiles 96 | RUN cmake -H. -Bcmake-out 97 | RUN cmake --build cmake-out -- -j $(nproc) 98 | WORKDIR /home/build/cpp-cmakefiles/cmake-out 99 | RUN cmake --build . --target install 100 | # ``` 101 | 102 | ## [END INSTALL.md] 103 | 104 | # Verify that the installed files are actually usable 105 | RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh 106 | -------------------------------------------------------------------------------- /ci/kokoro/install/Dockerfile.fedora-30: -------------------------------------------------------------------------------- 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 | FROM fedora:30 AS devtools 16 | 17 | # Please keep the formatting below, it is used by `extract-install.md` 18 | # to generate the contents of the top-level INSTALL.md. 19 | 20 | ## [START INSTALL.md] 21 | 22 | # Install the minimal development tools: 23 | 24 | # ```bash 25 | RUN dnf makecache && \ 26 | dnf install -y cmake gcc-c++ git make openssl-devel pkgconfig \ 27 | zlib-devel 28 | # ``` 29 | 30 | # Fedora includes packages for gRPC, libcurl, and OpenSSL that are recent enough 31 | # for `cpp-cmakefiles`. Install these packages and additional development 32 | # tools to compile the dependencies: 33 | 34 | # ```bash 35 | RUN dnf makecache && \ 36 | dnf install -y grpc-devel grpc-plugins \ 37 | libcurl-devel protobuf-compiler tar wget zlib-devel 38 | # ``` 39 | 40 | FROM devtools AS install 41 | 42 | # #### googleapis 43 | 44 | # We can now compile and install `googleapis`. 45 | 46 | # ```bash 47 | WORKDIR /home/build/cpp-cmakefiles 48 | COPY . /home/build/cpp-cmakefiles 49 | RUN cmake -H. -Bcmake-out 50 | RUN cmake --build cmake-out -- -j $(nproc) 51 | WORKDIR /home/build/cpp-cmakefiles/cmake-out 52 | RUN cmake --build . --target install 53 | # ``` 54 | 55 | ## [END INSTALL.md] 56 | 57 | # Verify that the installed files are actually usable 58 | RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh 59 | -------------------------------------------------------------------------------- /ci/kokoro/install/Dockerfile.fedora-30-shared: -------------------------------------------------------------------------------- 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 | FROM fedora:30 AS devtools 16 | 17 | # Please keep the formatting below, it is used by `extract-install.md` 18 | # to generate the contents of the top-level INSTALL.md. 19 | 20 | ## [START INSTALL.md] 21 | 22 | # Install the minimal development tools: 23 | 24 | # ```bash 25 | RUN dnf makecache && \ 26 | dnf install -y cmake gcc-c++ git make openssl-devel pkgconfig \ 27 | zlib-devel 28 | # ``` 29 | 30 | # Fedora includes packages for gRPC, libcurl, and OpenSSL that are recent enough 31 | # for `cpp-cmakefiles`. Install these packages and additional development 32 | # tools to compile the dependencies: 33 | 34 | # ```bash 35 | RUN dnf makecache && \ 36 | dnf install -y grpc-devel grpc-plugins \ 37 | libcurl-devel protobuf-compiler tar wget zlib-devel 38 | # ``` 39 | 40 | FROM devtools AS install 41 | 42 | # #### googleapis 43 | 44 | # We can now compile and install `googleapis` as shared library. 45 | 46 | # ```bash 47 | WORKDIR /home/build/cpp-cmakefiles 48 | COPY . /home/build/cpp-cmakefiles 49 | RUN cmake -H. -Bcmake-out -DBUILD_SHARED_LIBS=yes 50 | RUN cmake --build cmake-out -- -j $(nproc) 51 | WORKDIR /home/build/cpp-cmakefiles/cmake-out 52 | 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 57 | # ``` 58 | 59 | ## [END INSTALL.md] 60 | 61 | # Verify that the installed files are actually usable 62 | RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh 63 | -------------------------------------------------------------------------------- /ci/kokoro/install/Dockerfile.opensuse-leap: -------------------------------------------------------------------------------- 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 | FROM opensuse/leap:latest AS devtools 16 | 17 | ## [START INSTALL.md] 18 | 19 | # Install the minimal development tools: 20 | 21 | # ```bash 22 | RUN zypper refresh && \ 23 | zypper install --allow-downgrade -y cmake gcc gcc-c++ git gzip \ 24 | libcurl-devel libopenssl-devel make tar wget 25 | # ``` 26 | 27 | # #### Protobuf 28 | 29 | # OpenSUSE Leap includes a package for protobuf-2.6, but this is too old to 30 | # support the Google Cloud Platform proto files, or to support gRPC for that 31 | # matter. Manually install protobuf: 32 | 33 | # ```bash 34 | WORKDIR /var/tmp/build 35 | RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz 36 | RUN tar -xf v3.9.0.tar.gz 37 | WORKDIR /var/tmp/build/protobuf-3.9.0/cmake 38 | RUN cmake \ 39 | -DCMAKE_BUILD_TYPE=Release \ 40 | -DBUILD_SHARED_LIBS=yes \ 41 | -Dprotobuf_BUILD_TESTS=OFF \ 42 | -H. -Bcmake-out 43 | RUN cmake --build cmake-out --target install -- -j $(nproc) 44 | RUN ldconfig 45 | # ``` 46 | 47 | # #### c-ares 48 | 49 | # Recent versions of gRPC require c-ares >= 1.11, while OpenSUSE Leap 50 | # distributes c-ares-1.9. We need some additional development tools to compile 51 | # this library: 52 | 53 | # ```bash 54 | RUN zypper refresh && \ 55 | zypper install -y automake libtool 56 | # ``` 57 | 58 | # Manually install a newer version: 59 | 60 | # ```bash 61 | WORKDIR /var/tmp/build 62 | RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz 63 | RUN tar -xf cares-1_15_0.tar.gz 64 | WORKDIR /var/tmp/build/c-ares-cares-1_15_0 65 | RUN ./buildconf && ./configure && make -j $(nproc) 66 | RUN make install 67 | RUN ldconfig 68 | # ``` 69 | 70 | # #### gRPC 71 | 72 | # The gRPC Makefile uses `which` to determine whether the compiler is available. 73 | # Install this command for the extremely rare case where it may be missing from 74 | # your workstation or build server: 75 | 76 | # ```bash 77 | RUN zypper refresh && \ 78 | zypper install -y which 79 | # ``` 80 | 81 | # Then gRPC can be manually installed using: 82 | 83 | # ```bash 84 | WORKDIR /var/tmp/build 85 | RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz 86 | RUN tar -xf v1.22.0.tar.gz 87 | WORKDIR /var/tmp/build/grpc-1.22.0 88 | ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig 89 | ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 90 | ENV PATH=/usr/local/bin:${PATH} 91 | RUN make -j $(nproc) 92 | RUN make install 93 | RUN ldconfig 94 | # ``` 95 | 96 | FROM devtools AS install 97 | 98 | # #### googleapis 99 | 100 | # We can now compile and install `googleapis`. 101 | 102 | # ```bash 103 | WORKDIR /home/build/cpp-cmakefiles 104 | COPY . /home/build/cpp-cmakefiles 105 | RUN cmake -H. -Bcmake-out 106 | RUN cmake --build cmake-out -- -j $(nproc) 107 | WORKDIR /home/build/cpp-cmakefiles/cmake-out 108 | RUN cmake --build . --target install 109 | # ``` 110 | 111 | ## [END INSTALL.md] 112 | 113 | # Verify that the installed files are actually usable 114 | RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh 115 | -------------------------------------------------------------------------------- /ci/kokoro/install/Dockerfile.opensuse-tumbleweed: -------------------------------------------------------------------------------- 1 | # Copyright 2018 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 | FROM opensuse/tumbleweed:latest AS devtools 16 | 17 | ## [START INSTALL.md] 18 | 19 | # Install the minimal development tools: 20 | 21 | # ```bash 22 | RUN zypper refresh && \ 23 | zypper install --allow-downgrade -y cmake gcc gcc-c++ git gzip \ 24 | libcurl-devel libopenssl-devel make tar wget zlib-devel 25 | # ``` 26 | 27 | # OpenSUSE:tumbleweed provides packages for gRPC, libcurl, and protobuf, and the 28 | # versions of these packages are recent enough to support the Google Cloud 29 | # Platform proto files. 30 | 31 | # ```bash 32 | RUN zypper refresh && \ 33 | zypper install -y grpc-devel gzip libcurl-devel tar wget 34 | # ``` 35 | 36 | FROM devtools AS install 37 | 38 | # #### googleapis 39 | 40 | # We can now compile and install `googleapis`. 41 | 42 | # ```bash 43 | WORKDIR /home/build/cpp-cmakefiles 44 | COPY . /home/build/cpp-cmakefiles 45 | RUN cmake -H. -Bcmake-out 46 | RUN cmake --build cmake-out -- -j $(nproc) 47 | WORKDIR /home/build/cpp-cmakefiles/cmake-out 48 | RUN cmake --build . --target install 49 | # ``` 50 | 51 | ## [END INSTALL.md] 52 | 53 | # Verify that the installed files are actually usable 54 | RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh 55 | -------------------------------------------------------------------------------- /ci/kokoro/install/Dockerfile.ubuntu-16.04: -------------------------------------------------------------------------------- 1 | # Copyright 2018 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 | FROM ubuntu:16.04 AS devtools 16 | 17 | # Please keep the formatting in these commands, it is optimized to cut & paste 18 | # into the README.md file. 19 | 20 | ## [START INSTALL.md] 21 | 22 | # Install the minimal development tools: 23 | 24 | # ```bash 25 | RUN apt update && \ 26 | apt install -y automake build-essential cmake git gcc g++ cmake \ 27 | libcurl4-openssl-dev libssl-dev libtool make pkg-config tar wget \ 28 | zlib1g-dev 29 | # ``` 30 | 31 | # #### c-ares 32 | 33 | # Recent versions of gRPC require c-ares >= 1.11, while Ubuntu-16.04 34 | # distributes c-ares-1.10. We can manually install a newer version 35 | # of c-ares: 36 | 37 | # ```bash 38 | WORKDIR /var/tmp/build 39 | RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz 40 | RUN tar -xf cares-1_15_0.tar.gz 41 | WORKDIR /var/tmp/build/c-ares-cares-1_15_0 42 | RUN ./buildconf && ./configure && make -j $(nproc) 43 | RUN make install 44 | RUN ldconfig 45 | # ``` 46 | 47 | # #### Protobuf 48 | 49 | # While protobuf-3.0 is distributed with Ubuntu, the Google Cloud Plaform proto 50 | # files require more recent versions (circa 3.4.x). To manually install a more 51 | # recent version use: 52 | 53 | # ```bash 54 | WORKDIR /var/tmp/build 55 | RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz 56 | RUN tar -xf v3.9.0.tar.gz 57 | WORKDIR /var/tmp/build/protobuf-3.9.0/cmake 58 | RUN cmake \ 59 | -DCMAKE_BUILD_TYPE=Release \ 60 | -DBUILD_SHARED_LIBS=yes \ 61 | -Dprotobuf_BUILD_TESTS=OFF \ 62 | -H. -Bcmake-out 63 | RUN cmake --build cmake-out --target install -- -j $(nproc) 64 | RUN ldconfig 65 | # ``` 66 | 67 | # #### gRPC 68 | 69 | # Likewise, Ubuntu has packages for grpc-1.3.x, but this version is too old for 70 | # the Google Cloud Platform APIs: 71 | 72 | # ```bash 73 | WORKDIR /var/tmp/build 74 | RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz 75 | RUN tar -xf v1.22.0.tar.gz 76 | WORKDIR /var/tmp/build/grpc-1.22.0 77 | RUN make -j $(nproc) 78 | RUN make install 79 | RUN ldconfig 80 | # ``` 81 | 82 | FROM devtools AS install 83 | 84 | # #### googleapis 85 | 86 | # Finally we can install `googleapis`. 87 | 88 | # ```bash 89 | WORKDIR /home/build/cpp-cmakefiles 90 | COPY . /home/build/cpp-cmakefiles 91 | RUN cmake -H. -Bcmake-out 92 | RUN cmake --build cmake-out -- -j $(nproc) 93 | WORKDIR /home/build/cpp-cmakefiles/cmake-out 94 | RUN cmake --build . --target install 95 | # ``` 96 | 97 | ## [END INSTALL.md] 98 | 99 | # Verify that the installed files are actually usable 100 | RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh 101 | -------------------------------------------------------------------------------- /ci/kokoro/install/Dockerfile.ubuntu-18.04: -------------------------------------------------------------------------------- 1 | # Copyright 2018 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 | FROM ubuntu:18.04 AS devtools 16 | 17 | # Please keep the formatting in these commands, it is optimized to cut & paste 18 | # into the README.md file. 19 | 20 | ## [START INSTALL.md] 21 | 22 | # Install the minimal development tools: 23 | 24 | # ```bash 25 | RUN apt update && \ 26 | apt install -y build-essential cmake git gcc g++ cmake \ 27 | libc-ares-dev libc-ares2 libcurl4-openssl-dev libssl-dev make \ 28 | pkg-config tar wget zlib1g-dev 29 | # ``` 30 | 31 | # #### Protobuf 32 | 33 | # While protobuf-3.0 is distributed with Ubuntu, the Google Cloud Plaform proto 34 | # files require more recent versions (circa 3.4.x). To manually install a more 35 | # recent version use: 36 | 37 | # ```bash 38 | WORKDIR /var/tmp/build 39 | RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz 40 | RUN tar -xf v3.9.0.tar.gz 41 | WORKDIR /var/tmp/build/protobuf-3.9.0/cmake 42 | RUN cmake \ 43 | -DCMAKE_BUILD_TYPE=Release \ 44 | -DBUILD_SHARED_LIBS=yes \ 45 | -Dprotobuf_BUILD_TESTS=OFF \ 46 | -H. -Bcmake-out 47 | RUN cmake --build cmake-out --target install -- -j $(nproc) 48 | RUN ldconfig 49 | # ``` 50 | 51 | # #### gRPC 52 | 53 | # Likewise, Ubuntu has packages for grpc-1.3.x, but this version is too old for 54 | # the Google Cloud Platform APIs: 55 | 56 | # ```bash 57 | WORKDIR /var/tmp/build 58 | RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz 59 | RUN tar -xf v1.22.0.tar.gz 60 | WORKDIR /var/tmp/build/grpc-1.22.0 61 | RUN make -j $(nproc) 62 | RUN make install 63 | RUN ldconfig 64 | # ``` 65 | 66 | FROM devtools AS install 67 | 68 | # #### googleapis 69 | 70 | # Finally we can install `googleapis`. 71 | 72 | # ```bash 73 | WORKDIR /home/build/cpp-cmakefiles 74 | COPY . /home/build/cpp-cmakefiles 75 | RUN cmake -H. -Bcmake-out 76 | RUN cmake --build cmake-out -- -j $(nproc) 77 | WORKDIR /home/build/cpp-cmakefiles/cmake-out 78 | RUN cmake --build . --target install 79 | # ``` 80 | 81 | ## [END INSTALL.md] 82 | 83 | # Verify that the installed files are actually usable 84 | RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh 85 | -------------------------------------------------------------------------------- /ci/kokoro/install/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # Copyright 2019 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eu 18 | 19 | if [[ $# -eq 1 ]]; then 20 | export TEST_TARGET="${1}" 21 | elif [[ -n "${KOKORO_JOB_NAME:-}" ]]; then 22 | # Kokoro injects the KOKORO_JOB_NAME environment variable, the value of this 23 | # variable is cloud-cpp/spanner/ (or more 24 | # generally ). By convention we name these 25 | # files `$foo.cfg` for continuous builds and `$foo-presubmit.cfg` for 26 | # presubmit builds. Here we extract the value of "foo" and use it as the build 27 | # name. 28 | TEST_TARGET="$(basename "${KOKORO_JOB_NAME}" "-presubmit")" 29 | export TEST_TARGET 30 | else 31 | echo "Aborting build as the distribution name is not defined." 32 | echo "If you are invoking this script via the command line use:" 33 | echo " $0 " 34 | echo 35 | echo "If this script is invoked by Kokoro, the CI system is expected to set" 36 | echo "the KOKORO_JOB_NAME environment variable." 37 | exit 1 38 | fi 39 | 40 | echo "================================================================" 41 | echo "Change working directory to project root $(date)." 42 | cd "$(dirname "$0")/../../.." 43 | 44 | if [[ -z "${PROJECT_ID+x}" ]]; then 45 | readonly PROJECT_ID="cloud-devrel-kokoro-resources" 46 | fi 47 | 48 | readonly DEV_IMAGE="gcr.io/${PROJECT_ID}/cpp-cmakefiles/test-install-dev-${TEST_TARGET}" 49 | readonly IMAGE="gcr.io/${PROJECT_ID}/cpp-cmakefiles/test-install-${TEST_TARGET}" 50 | 51 | has_cache="false" 52 | 53 | # We download the cached dev image for pull requests on kokoro. For continuous 54 | # jobs, we don't download the cached image. This means we build from scratch and 55 | # upload the image for future builds for pull requests. 56 | if [[ -n "${KOKORO_JOB_NAME:-}" ]] \ 57 | && [[ -n "${KOKORO_GITHUB_PULL_REQUEST_NUMBER:-}" ]]; then 58 | echo "================================================================" 59 | echo "Download existing image (if available) for ${TEST_TARGET} $(date)." 60 | if docker pull "${DEV_IMAGE}:latest"; then 61 | echo "Existing image successfully downloaded." 62 | has_cache="true" 63 | fi 64 | echo "================================================================" 65 | fi 66 | 67 | echo "================================================================" 68 | echo "Build base image with minimal development tools for ${TEST_TARGET} $(date)." 69 | update_cache="false" 70 | 71 | devtools_flags=( 72 | # Only build up to the stage that installs the minimal development tools, but 73 | # does not compile any of our code. 74 | "--target" "devtools" 75 | # Create the image with the same tag as the cache we are using, so we can 76 | # upload it. 77 | "-t" "${DEV_IMAGE}:latest" 78 | "-f" "ci/kokoro/install/Dockerfile.${TEST_TARGET}" 79 | ) 80 | 81 | if "${has_cache}"; then 82 | devtools_flags+=("--cache-from=${DEV_IMAGE}:latest") 83 | fi 84 | 85 | echo "Running docker build with " "${devtools_flags[@]}" 86 | if docker build "${devtools_flags[@]}" ci; then 87 | update_cache="true" 88 | fi 89 | 90 | # We upload the cached image for continuous builds. 91 | if "${update_cache}" && [[ -z "${KOKORO_GITHUB_PULL_REQUEST_NUMBER:-}" ]] \ 92 | && [[ -n "${KOKORO_JOB_NAME:-}" ]]; then 93 | echo "================================================================" 94 | echo "Uploading updated base image for ${TEST_TARGET} $(date)." 95 | # Do not stop the build on a failure to update the cache. 96 | docker push "${DEV_IMAGE}:latest" || true 97 | fi 98 | 99 | echo "================================================================" 100 | echo "Run validation script for INSTALL instructions on ${TEST_TARGET}." 101 | docker build \ 102 | "--cache-from=${DEV_IMAGE}:latest" \ 103 | "--target=install" \ 104 | -t "${IMAGE}" \ 105 | -f "ci/kokoro/install/Dockerfile.${TEST_TARGET}" . 106 | echo "================================================================" 107 | -------------------------------------------------------------------------------- /ci/kokoro/install/centos-7-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/centos-7-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/centos-7.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/centos-7.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 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 | build_file: "cpp-cmakefiles/ci/kokoro/install/build.sh" 17 | timeout_mins: 120 18 | -------------------------------------------------------------------------------- /ci/kokoro/install/fedora-30-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/fedora-30-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/fedora-30-shared-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/fedora-30-shared-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/fedora-30-shared.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/fedora-30-shared.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/fedora-30.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/fedora-30.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/opensuse-leap-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/opensuse-leap-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/opensuse-leap.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/opensuse-leap.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/opensuse-tumbleweed-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/opensuse-tumbleweed-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/opensuse-tumbleweed.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/opensuse-tumbleweed.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/ubuntu-16.04-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/ubuntu-16.04-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/ubuntu-16.04.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/ubuntu-16.04.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/ubuntu-18.04-presubmit.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/ubuntu-18.04-presubmit.cfg -------------------------------------------------------------------------------- /ci/kokoro/install/ubuntu-18.04.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/cpp-cmakefiles/699915bed4b2b34c140492bb7a1cb34518069ce4/ci/kokoro/install/ubuntu-18.04.cfg -------------------------------------------------------------------------------- /ci/retry-command.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 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 | set -eu 17 | 18 | # Make three attempts to install the dependencies. It is rare, but from time to 19 | # time the downloading the packages, building the Docker images, or an installer 20 | # Bazel, or the Google Cloud SDK fails. To make the CI build more robust, try 21 | # again when that happens. 22 | 23 | if (( $# < 1 )); then 24 | echo "Usage: $(basename "$0") program [arguments]" 25 | exit 1 26 | fi 27 | readonly PROGRAM=${1} 28 | shift 29 | 30 | # Initially, wait at least 2 minutes (the times are in seconds), because it 31 | # makes no sense to try faster. This used to be 180 seconds, but that ends with 32 | # sleeps close to 10 minutes, and Travis aborts builds that do not output in 33 | # 10m. 34 | min_wait=120 35 | # Do not exit on failures for this loop. 36 | set +e 37 | for i in 1 2 3; do 38 | if "${PROGRAM}" "$@"; then 39 | exit 0 40 | fi 41 | # Sleep for a few minutes before trying again. 42 | period=$(( (RANDOM % 60) + min_wait )) 43 | echo "${PROGRAM} failed (attempt ${i}); trying again in ${period} seconds." 44 | sleep ${period}s 45 | min_wait=$(( min_wait * 2 )) 46 | done 47 | 48 | exit 1 49 | -------------------------------------------------------------------------------- /ci/test-install/bigquery/CMakeLists.txt: -------------------------------------------------------------------------------- 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++::cloud_bigquery_protos) 29 | -------------------------------------------------------------------------------- /ci/test-install/bigquery/Makefile: -------------------------------------------------------------------------------- 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_cloud_bigquery_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) 37 | -------------------------------------------------------------------------------- /ci/test-install/bigquery/main.cc: -------------------------------------------------------------------------------- 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 16 | #include 17 | 18 | int main() { 19 | auto creds = grpc::InsecureChannelCredentials(); 20 | auto channel = grpc::CreateChannel("localhost:12345", creds); 21 | auto stub = google::cloud::bigquery::storage::v1beta1::BigQueryStorage::NewStub(channel); 22 | } 23 | -------------------------------------------------------------------------------- /ci/test-install/bigtable/CMakeLists.txt: -------------------------------------------------------------------------------- 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++::bigtable_protos) 29 | -------------------------------------------------------------------------------- /ci/test-install/bigtable/Makefile: -------------------------------------------------------------------------------- 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_bigtable_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) 37 | -------------------------------------------------------------------------------- /ci/test-install/bigtable/main.cc: -------------------------------------------------------------------------------- 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 16 | #include 17 | 18 | int main() { 19 | auto creds = grpc::InsecureChannelCredentials(); 20 | auto channel = grpc::CreateChannel("localhost:12345", creds); 21 | auto stub = google::bigtable::v2::Bigtable::NewStub(channel); 22 | } 23 | -------------------------------------------------------------------------------- /ci/test-install/compile-test-projects.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 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 | # Compile projects that utilize the cpp-cmakefiles header files and libraries 17 | # installed to the system. This script expects that the entire source tree is 18 | # copied to /home/build/cpp-cmakefiles. Don't try to run this locally. 19 | 20 | set -eu 21 | 22 | # Verify the installed CMake config and pkgconfig files are actually usable. 23 | 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 48 | -------------------------------------------------------------------------------- /ci/test-install/pubsub/CMakeLists.txt: -------------------------------------------------------------------------------- 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) 29 | -------------------------------------------------------------------------------- /ci/test-install/pubsub/Makefile: -------------------------------------------------------------------------------- 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) 37 | -------------------------------------------------------------------------------- /ci/test-install/pubsub/main.cc: -------------------------------------------------------------------------------- 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 16 | #include 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 | } 23 | -------------------------------------------------------------------------------- /ci/test-install/spanner/CMakeLists.txt: -------------------------------------------------------------------------------- 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++::spanner_protos) 29 | -------------------------------------------------------------------------------- /ci/test-install/spanner/Makefile: -------------------------------------------------------------------------------- 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_spanner_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) 37 | -------------------------------------------------------------------------------- /ci/test-install/spanner/main.cc: -------------------------------------------------------------------------------- 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 16 | #include 17 | 18 | int main() { 19 | auto creds = grpc::InsecureChannelCredentials(); 20 | auto channel = grpc::CreateChannel("localhost:12345", creds); 21 | auto stub = google::spanner::v1::Spanner::NewStub(channel); 22 | } 23 | -------------------------------------------------------------------------------- /cmake/CompileProtos.cmake: -------------------------------------------------------------------------------- 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 | # Introduce a new TARGET property to associate proto files with a target. 18 | # 19 | # We use a function to define the property so it can be called multiple times 20 | # without introducing the property over and over. 21 | function (google_cloud_cpp_add_protos_property) 22 | set_property( 23 | TARGET 24 | PROPERTY PROTO_SOURCES BRIEF_DOCS 25 | "The list of .proto files for a target." FULL_DOCS 26 | "List of .proto files specified for a target.") 27 | endfunction () 28 | 29 | # Generate C++ for .proto files preserving the directory hierarchy 30 | # 31 | # Receives a list of `.proto` file names and (a) creates the runs to convert 32 | # these files to `.pb.h` and `.pb.cc` output files, (b) returns the list of 33 | # `.pb.cc` files and `.pb.h` files in @p HDRS, and (c) creates the list of files 34 | # preserving the directory hierarchy, such that if a `.proto` file says: 35 | # 36 | # import "foo/bar/baz.proto" 37 | # 38 | # the resulting C++ code says: 39 | # 40 | # #include 41 | # 42 | # Use the `PROTO_PATH` option to provide one or more directories to search for 43 | # proto files in the import. 44 | # 45 | # @par Example 46 | # 47 | # google_cloud_cpp_generate_proto( MY_PB_FILES "foo/bar/baz.proto" 48 | # "foo/bar/qux.proto" PROTO_PATH_DIRECTORIES "another/dir/with/protos") 49 | # 50 | # Note that `protoc` the protocol buffer compiler requires your protos to be 51 | # somewhere in the search path defined by the `--proto_path` (aka -I) options. 52 | # For example, if you want to generate the `.pb.{h,cc}` files for 53 | # `foo/bar/baz.proto` then the directory containing `foo` must be in the search 54 | # path. 55 | function (google_cloud_cpp_generate_proto SRCS) 56 | cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN}) 57 | if (NOT _opt_UNPARSED_ARGUMENTS) 58 | message(SEND_ERROR "Error: google_cloud_cpp_generate_proto() called" 59 | " without any proto files") 60 | return() 61 | endif () 62 | 63 | # Build the list of `--proto_path` options. Use the absolute path for each 64 | # option given, and do not include any path more than once. 65 | set(protobuf_include_path) 66 | foreach (dir ${_opt_PROTO_PATH_DIRECTORIES}) 67 | get_filename_component(absolute_path ${dir} ABSOLUTE) 68 | list(FIND protobuf_include_path "${absolute_path}" 69 | already_in_search_path) 70 | if (${already_in_search_path} EQUAL -1) 71 | list(APPEND protobuf_include_path "--proto_path" "${absolute_path}") 72 | endif () 73 | endforeach () 74 | 75 | set(${SRCS}) 76 | foreach (filename ${_opt_UNPARSED_ARGUMENTS}) 77 | get_filename_component(file_directory "${filename}" DIRECTORY) 78 | # This gets the filename without the extension, analogous to $(basename 79 | # "${filename}" .proto) 80 | get_filename_component(file_stem "${filename}" NAME_WE) 81 | 82 | # Strip all the prefixes in ${_opt_PROTO_PATH_DIRECTORIES} from the 83 | # source proto directory 84 | set(D "${file_directory}") 85 | if (DEFINED _opt_PROTO_PATH_DIRECTORIES) 86 | foreach (P ${_opt_PROTO_PATH_DIRECTORIES}) 87 | string(REGEX REPLACE "^${P}" "" T "${D}") 88 | set(D ${T}) 89 | endforeach () 90 | endif () 91 | set(pb_cc "${CMAKE_CURRENT_BINARY_DIR}/${D}/${file_stem}.pb.cc") 92 | set(pb_h "${CMAKE_CURRENT_BINARY_DIR}/${D}/${file_stem}.pb.h") 93 | list(APPEND ${SRCS} "${pb_cc}" "${pb_h}") 94 | add_custom_command( 95 | OUTPUT "${pb_cc}" "${pb_h}" 96 | COMMAND 97 | $ ARGS --cpp_out 98 | "${CMAKE_CURRENT_BINARY_DIR}" ${protobuf_include_path} 99 | "${filename}" 100 | DEPENDS "${filename}" protobuf::protoc 101 | COMMENT "Running C++ protocol buffer compiler on ${filename}" 102 | VERBATIM) 103 | endforeach () 104 | 105 | set_source_files_properties(${${SRCS}} PROPERTIES GENERATED TRUE) 106 | set(${SRCS} 107 | ${${SRCS}} 108 | PARENT_SCOPE) 109 | endfunction () 110 | 111 | # Generate gRPC C++ files from .proto files preserving the directory hierarchy. 112 | # 113 | # Receives a list of `.proto` file names and (a) creates the runs to convert 114 | # these files to `.grpc.pb.h` and `.grpc.pb.cc` output files, (b) returns the 115 | # list of `.grpc.pb.cc` and `.pb.h` files in @p SRCS, and (c) creates the list 116 | # of files preserving the directory hierarchy, such that if a `.proto` file says 117 | # 118 | # import "foo/bar/baz.proto" 119 | # 120 | # the resulting C++ code says: 121 | # 122 | # #include 123 | # 124 | # Use the `PROTO_PATH` option to provide one or more directories to search for 125 | # proto files in the import. 126 | # 127 | # @par Example 128 | # 129 | # google_cloud_cpp_generate_grpc( MY_GRPC_PB_FILES "foo/bar/baz.proto" 130 | # "foo/bar/qux.proto" PROTO_PATH_DIRECTORIES "another/dir/with/protos") 131 | # 132 | # Note that `protoc` the protocol buffer compiler requires your protos to be 133 | # somewhere in the search path defined by the `--proto_path` (aka -I) options. 134 | # For example, if you want to generate the `.pb.{h,cc}` files for 135 | # `foo/bar/baz.proto` then the directory containing `foo` must be in the search 136 | # path. 137 | function (google_cloud_cpp_generate_grpcpp SRCS) 138 | cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN}) 139 | if (NOT _opt_UNPARSED_ARGUMENTS) 140 | message( 141 | SEND_ERROR "Error: google_cloud_cpp_generate_grpc() called without" 142 | " any proto files") 143 | return() 144 | endif () 145 | 146 | # Build the list of `--proto_path` options. Use the absolute path for each 147 | # option given, and do not include any path more than once. 148 | set(protobuf_include_path) 149 | foreach (dir ${_opt_PROTO_PATH_DIRECTORIES}) 150 | get_filename_component(absolute_path ${dir} ABSOLUTE) 151 | list(FIND protobuf_include_path "${absolute_path}" 152 | already_in_search_path) 153 | if (${already_in_search_path} EQUAL -1) 154 | list(APPEND protobuf_include_path "--proto_path" "${absolute_path}") 155 | endif () 156 | endforeach () 157 | 158 | set(${SRCS}) 159 | foreach (filename ${_opt_UNPARSED_ARGUMENTS}) 160 | get_filename_component(file_directory "${filename}" DIRECTORY) 161 | # This gets the filename without the extension, analogous to $(basename 162 | # "${filename}" .proto) 163 | get_filename_component(file_stem "${filename}" NAME_WE) 164 | 165 | # Strip all the prefixes in ${_opt_PROTO_PATH_DIRECTORIES} from the 166 | # source proto directory 167 | set(D "${file_directory}") 168 | if (DEFINED _opt_PROTO_PATH_DIRECTORIES) 169 | foreach (P ${_opt_PROTO_PATH_DIRECTORIES}) 170 | string(REGEX REPLACE "^${P}" "" T "${D}") 171 | set(D ${T}) 172 | endforeach () 173 | endif () 174 | set(grpc_pb_cc 175 | "${CMAKE_CURRENT_BINARY_DIR}/${D}/${file_stem}.grpc.pb.cc") 176 | set(grpc_pb_h "${CMAKE_CURRENT_BINARY_DIR}/${D}/${file_stem}.grpc.pb.h") 177 | list(APPEND ${SRCS} "${grpc_pb_cc}" "${grpc_pb_h}") 178 | add_custom_command( 179 | OUTPUT "${grpc_pb_cc}" "${grpc_pb_h}" 180 | COMMAND 181 | $ ARGS 182 | --plugin=protoc-gen-grpc=$ 183 | "--grpc_out=${CMAKE_CURRENT_BINARY_DIR}" 184 | "--cpp_out=${CMAKE_CURRENT_BINARY_DIR}" ${protobuf_include_path} 185 | "${filename}" 186 | DEPENDS "${filename}" protobuf::protoc gRPC::grpc_cpp_plugin 187 | COMMENT "Running gRPC C++ protocol buffer compiler on ${filename}" 188 | VERBATIM) 189 | endforeach () 190 | 191 | set_source_files_properties(${${SRCS}} PROPERTIES GENERATED TRUE) 192 | set(${SRCS} 193 | ${${SRCS}} 194 | PARENT_SCOPE) 195 | endfunction () 196 | 197 | include(GNUInstallDirs) 198 | 199 | # Install headers for a C++ proto library. 200 | function (google_cloud_cpp_install_proto_library_headers target) 201 | get_target_property(target_sources ${target} SOURCES) 202 | foreach (header ${target_sources}) 203 | # Skip anything that is not a header file. 204 | if (NOT "${header}" MATCHES "\\.h$") 205 | continue() 206 | endif () 207 | string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" relative "${header}") 208 | get_filename_component(dir "${relative}" DIRECTORY) 209 | install(FILES "${header}" 210 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${dir}") 211 | endforeach () 212 | endfunction () 213 | 214 | # Install protos for a C++ proto library. 215 | function (google_cloud_cpp_install_proto_library_protos target strip_prefix) 216 | get_target_property(target_protos ${target} PROTO_SOURCES) 217 | foreach (proto ${target_protos}) 218 | # Skip anything that is not a header file. 219 | if (NOT "${proto}" MATCHES "\\.proto$") 220 | continue() 221 | endif () 222 | string(REPLACE "${strip_prefix}/" "" relative "${proto}") 223 | get_filename_component(dir "${relative}" DIRECTORY) 224 | # This is modeled after the Protobuf library, it installs the basic 225 | # protos (think google/protobuf/any.proto) in the include directory for 226 | # C/C++ code. :shrug: 227 | install(FILES "${proto}" 228 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${dir}") 229 | endforeach () 230 | endfunction () 231 | 232 | function (google_cloud_cpp_proto_library libname) 233 | cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN}) 234 | if (NOT _opt_UNPARSED_ARGUMENTS) 235 | message(SEND_ERROR "Error: google_cloud_cpp_proto_library() called" 236 | " without any proto files") 237 | return() 238 | endif () 239 | 240 | google_cloud_cpp_generate_proto( 241 | proto_sources ${_opt_UNPARSED_ARGUMENTS} PROTO_PATH_DIRECTORIES 242 | ${_opt_PROTO_PATH_DIRECTORIES}) 243 | 244 | add_library(${libname} ${proto_sources}) 245 | set_property(TARGET ${libname} PROPERTY PROTO_SOURCES 246 | ${_opt_UNPARSED_ARGUMENTS}) 247 | target_link_libraries(${libname} PUBLIC gRPC::grpc++ gRPC::grpc 248 | protobuf::libprotobuf) 249 | target_include_directories( 250 | ${libname} 251 | PUBLIC $ 252 | $ 253 | $) 254 | endfunction () 255 | 256 | function (google_cloud_cpp_grpcpp_library libname) 257 | cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN}) 258 | if (NOT _opt_UNPARSED_ARGUMENTS) 259 | message(SEND_ERROR "Error: google_cloud_cpp_proto_library() called" 260 | " without any proto files") 261 | return() 262 | endif () 263 | 264 | google_cloud_cpp_generate_grpcpp( 265 | grpcpp_sources ${_opt_UNPARSED_ARGUMENTS} PROTO_PATH_DIRECTORIES 266 | ${_opt_PROTO_PATH_DIRECTORIES}) 267 | google_cloud_cpp_proto_library( 268 | ${libname} ${_opt_UNPARSED_ARGUMENTS} PROTO_PATH_DIRECTORIES 269 | ${_opt_PROTO_PATH_DIRECTORIES}) 270 | target_sources(${libname} PRIVATE ${grpcpp_sources}) 271 | endfunction () 272 | -------------------------------------------------------------------------------- /cmake/FindProtobufTargets.cmake: -------------------------------------------------------------------------------- 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 | #[=======================================================================[.rst: 18 | FindProtobufTargets 19 | ------------------- 20 | 21 | A module to use `Protobuf` with less complications. 22 | 23 | Using ``find_package(Protobuf)`` should be simple, but it is not. 24 | 25 | CMake provides a ``FindProtobuf`` module. Unfortunately it does not generate 26 | `protobuf::*` targets until CMake-3.9, and `protobuf::protoc` does not 27 | appear until CMake-3.10. 28 | 29 | The CMake-config files generated by `protobuf` always create these targets, 30 | but on some Linux distributions (e.g. Fedora>=29, and openSUSE-Tumbleweed) there 31 | are system packages for protobuf, but these packages are installed without the 32 | CMake-config files. One must either use the ``FindProtobuf`` module, find the 33 | libraries via `pkg-config`, or find the libraries manually. 34 | 35 | When the CMake-config files are installed they produce the same targets as 36 | recent versions of ``FindProtobuf``. However, they do not produce the 37 | `Protobuf_LIBRARY`, `Protobuf_INCLUDE_DIR`, etc. that are generated by the 38 | module. Furthermore, the `protobuf::protoc` library is not usable when loaded 39 | from the CMake-config files: its ``IMPORTED_LOCATION`` variable is not defined. 40 | 41 | This module is designed to provide a single, uniform, ``find_package()`` 42 | module that always produces the same outputs: 43 | 44 | - It always generates the ``protobuf::*`` targets. 45 | - It always defines ``ProtobufTargets_FOUND`` and ``ProtobufTargets_VERSION``. 46 | - It *prefers* using the CMake config files if they are available. 47 | - It fallsback on the ``FindProtobuf`` module if the config files are not found. 48 | - It populates any missing targets and their properties. 49 | 50 | The following :prop_tgt:`IMPORTED` targets are defined: 51 | 52 | ``protobuf::libprotobuf`` 53 | The protobuf library. 54 | ``protobuf::libprotobuf-lite`` 55 | The protobuf lite library. 56 | ``protobuf::libprotoc`` 57 | The protoc library. 58 | ``protobuf::protoc`` 59 | The protoc compiler. 60 | 61 | Example: 62 | 63 | .. code-block:: cmake 64 | 65 | find_package(ProtobufTargets REQUIRED) 66 | add_executable(bar bar.cc) 67 | target_link_libraries(bar PRIVATE protobuf::libprotobuf) 68 | 69 | #]=======================================================================] 70 | 71 | if (protobuf_DEBUG) 72 | message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 73 | "protobuf_USE_STATIC_LIBS = ${protobuf_USE_STATIC_LIBS}" 74 | " ProtobufTargets = ${ProtobufTargets_FOUND}") 75 | endif () 76 | 77 | # Always load thread support, even on Windows. 78 | find_package(Threads REQUIRED) 79 | 80 | # First try to use the ``protobufConfig.cmake`` or ``protobuf-config.cmake`` 81 | # file if it was installed. This is common on systems (or package managers) 82 | # where protobuf was compiled and installed with `CMake`. Note that on Linux 83 | # this *must* be all lowercase ``protobuf``, while on Windows it does not 84 | # matter. 85 | find_package(protobuf CONFIG) 86 | 87 | if (protobuf_DEBUG) 88 | message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 89 | "protobuf_FOUND = ${protobuf_FOUND}" 90 | " protobuf_VERSION = ${protobuf_VERSION}") 91 | endif () 92 | 93 | if (protobuf_FOUND) 94 | set(ProtobufTargets_FOUND 1) 95 | set(ProtobufTargets_VERSION ${protobuf_VERSION}) 96 | if (protobuf_DEBUG) 97 | message( 98 | STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 99 | "ProtobufTargets_FOUND = ${ProtobufTargets_FOUND}" 100 | " ProtobufTargets_VERSION = ${ProtobufTargets_VERSION}") 101 | endif () 102 | else () 103 | find_package(Protobuf QUIET) 104 | if (Protobuf_FOUND) 105 | set(ProtobufTargets_FOUND 1) 106 | set(ProtobufTargets_VERSION ${Protobuf_VERSION}) 107 | 108 | if (NOT TARGET protobuf::libprotobuf) 109 | add_library(protobuf::libprotobuf IMPORTED INTERFACE) 110 | set_property( 111 | TARGET protobuf::libprotobuf 112 | PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Protobuf_INCLUDE_DIR}) 113 | set_property( 114 | TARGET protobuf::libprotobuf APPEND 115 | PROPERTY INTERFACE_LINK_LIBRARIES ${Protobuf_LIBRARY} 116 | Threads::Threads) 117 | endif () 118 | 119 | if (NOT TARGET protobuf::libprotobuf-lite) 120 | add_library(protobuf::libprotobuf-lite IMPORTED INTERFACE) 121 | set_property( 122 | TARGET protobuf::libprotobuf-lite 123 | PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Protobuf_INCLUDE_DIR}) 124 | set_property( 125 | TARGET protobuf::libprotobuf-lite APPEND 126 | PROPERTY INTERFACE_LINK_LIBRARIES ${Protobuf_LITE_LIBRARY} 127 | Threads::Threads) 128 | endif () 129 | 130 | if (NOT TARGET protobuf::libprotoc) 131 | add_library(protobuf::libprotoc IMPORTED INTERFACE) 132 | set_property( 133 | TARGET protobuf::libprotoc 134 | PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Protobuf_INCLUDE_DIR}) 135 | set_property( 136 | TARGET protobuf::libprotoc APPEND 137 | PROPERTY INTERFACE_LINK_LIBRARIES ${Protobuf_PROTOC_LIBRARY} 138 | Threads::Threads) 139 | endif () 140 | endif () 141 | endif () 142 | 143 | if (protobuf_DEBUG) 144 | message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 145 | "ProtobufTargets_FOUND = ${ProtobufTargets_FOUND}" 146 | " ProtobufTargets_VERSION = ${ProtobufTargets_VERSION}") 147 | endif () 148 | 149 | # We also should try to find the protobuf C++ plugin for the protocol buffers 150 | # compiler. 151 | if (ProtobufTargets_FOUND AND NOT TARGET protobuf::protoc) 152 | add_executable(protobuf::protoc IMPORTED) 153 | 154 | # Discover the protoc compiler location. 155 | find_program( 156 | _protobuf_PROTOC_EXECUTABLE 157 | NAMES protoc 158 | DOC "The Google Protocol Buffers Compiler") 159 | if (protobuf_DEBUG) 160 | message( 161 | STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 162 | "ProtobufTargets_FOUND = ${ProtobufTargets_FOUND}" 163 | " ProtobufTargets_VERSION = ${ProtobufTargets_VERSION}" 164 | " EXE = ${_protobuf_PROTOC_EXECUTABLE}") 165 | endif () 166 | set_property(TARGET protobuf::protoc 167 | PROPERTY IMPORTED_LOCATION ${_protobuf_PROTOC_EXECUTABLE}) 168 | set_property( 169 | TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION_DEBUG 170 | ${_protobuf_PROTOC_EXECUTABLE}) 171 | set_property( 172 | TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION_RELEASE 173 | ${_protobuf_PROTOC_EXECUTABLE}) 174 | unset(_protobuf_PROTOC_EXECUTABLE) 175 | 176 | if (protobuf_DEBUG) 177 | get_target_property(_protobuf_PROTOC_EXECUTABLE protobuf::protoc 178 | IMPORTED_LOCATION) 179 | message( 180 | STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 181 | "LOCATION=${_protobuf_PROTOC_EXECUTABLE}") 182 | endif () 183 | endif () 184 | 185 | if (protobuf_DEBUG) 186 | message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 187 | "ProtobufTargets_FOUND = ${ProtobufTargets_FOUND}" 188 | " ProtobufTargets_VERSION = ${ProtobufTargets_VERSION}") 189 | if (ProtobufTargets_FOUND) 190 | foreach (_target protobuf::libprotobuf protobuf::libprotobuf-lite 191 | protobuf::libprotoc) 192 | if (NOT TARGET ${_target}) 193 | message( 194 | STATUS 195 | "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 196 | "target=${_target} is NOT a target") 197 | endif () 198 | endforeach () 199 | unset(_target) 200 | endif () 201 | endif () 202 | 203 | find_package_handle_standard_args(ProtobufTargets REQUIRED_VARS 204 | ProtobufTargets_FOUND ProtobufTargets_VERSION) 205 | -------------------------------------------------------------------------------- /cmake/FindgRPC.cmake: -------------------------------------------------------------------------------- 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 | #[=======================================================================[.rst: 18 | FindgRPC 19 | -------- 20 | 21 | Locate and configure the gRPC library. 22 | 23 | The following variables can be set and are optional: 24 | 25 | ``gRPC_DEBUG`` 26 | Show debug messages. 27 | ``gRPC_USE_STATIC_LIBS`` 28 | Set to ON to force the use of the static libraries. 29 | Default is OFF. 30 | 31 | Defines the following variables: 32 | 33 | ``gRPC_FOUND`` 34 | Found the gRPC library 35 | ``gRPC_VERSION`` 36 | Version of package found. 37 | 38 | The following :prop_tgt:`IMPORTED` targets are also defined: 39 | 40 | ``gRPC::grpc++`` 41 | The gRPC C++ library. 42 | ``gRPC::grpc`` 43 | The gRPC C core library. 44 | ``gRPC::cpp_plugin`` 45 | The C++ plugin for the Protobuf protoc compiler. 46 | 47 | The following cache variables are also available to set or use: 48 | 49 | Example: 50 | 51 | .. code-block:: cmake 52 | 53 | find_package(gRPC REQUIRED) 54 | add_executable(bar bar.cc) 55 | target_link_libraries(bar PRIVATE gRPC::grpc++) 56 | 57 | #]=======================================================================] 58 | 59 | if (gRPC_DEBUG) 60 | message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 61 | "gRPC_USE_STATIC_LIBS = ${gRPC_USE_STATIC_LIBS}" 62 | " gRPC_FOUND = ${gRPC_FOUND}") 63 | endif () 64 | 65 | # gRPC always requires Thread support. 66 | find_package(Threads REQUIRED) 67 | 68 | # Load the module to find protobuf with proper targets. Do not use 69 | # `find_package()` because we (have to) install this module in non-standard 70 | # locations. 71 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") 72 | find_package(ProtobufTargets) 73 | 74 | # The gRPC::grpc_cpp_plugin target is sometimes defined, but without a 75 | # IMPORTED_LOCATION 76 | function (_grpc_fix_grpc_cpp_plugin_target) 77 | # The target may already exist, do not create it again if it does. 78 | if (NOT TARGET gRPC::grpc_cpp_plugin) 79 | add_executable(gRPC::grpc_cpp_plugin IMPORTED) 80 | endif () 81 | get_target_property(_gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin 82 | IMPORTED_LOCATION) 83 | if (gRPC_DEBUG) 84 | message( 85 | STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 86 | "LOCATION=${_gRPC_CPP_PLUGIN_EXECUTABLE}") 87 | endif () 88 | # Even if the target exists, gRPC CMake support files do not define the 89 | # executable for the imported target (at least they do not in v1.19.1), so 90 | # we need to define it ourselves. 91 | if (NOT _gRPC_CPP_PLUGIN_EXECUTABLE) 92 | find_program(_gRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin 93 | DOC "The gRPC C++ plugin for protoc") 94 | mark_as_advanced(_gRPC_CPP_PLUGIN_EXECUTABLE) 95 | if (_gRPC_CPP_PLUGIN_EXECUTABLE) 96 | set_property( 97 | TARGET gRPC::grpc_cpp_plugin 98 | PROPERTY IMPORTED_LOCATION ${_gRPC_CPP_PLUGIN_EXECUTABLE}) 99 | else () 100 | set(gRPC_FOUND "grpc_cpp_plugin-NOTFOUND") 101 | endif () 102 | endif () 103 | endfunction () 104 | 105 | # The gRPC::* targets sometimes lack the right definitions to compile cleanly on 106 | # WIN32 107 | function (_grpc_fix_grpc_target_definitions) 108 | # Including gRPC headers without this definition results in a build error. 109 | if (WIN32) 110 | set_property(TARGET gRPC::grpc APPEND 111 | PROPERTY INTERFACE_COMPILE_DEFINITIONS _WIN32_WINNT=0x600) 112 | set_property(TARGET gRPC::grpc++ APPEND 113 | PROPERTY INTERFACE_COMPILE_DEFINITIONS _WIN32_WINNT=0x600) 114 | endif () 115 | endfunction () 116 | 117 | # First try to use the `gRPCConfig.cmake` or `grpc-config.cmake` file if it was 118 | # installed. This is common on systems (or package managers) where gRPC was 119 | # compiled and installed with `CMake`. 120 | find_package(gRPC NO_MODULE QUIET) 121 | 122 | if (gRPC_DEBUG) 123 | message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 124 | "NO_MODULE result gRPC_FOUND = ${gRPC_FOUND}") 125 | endif () 126 | 127 | if (gRPC_FOUND) 128 | _grpc_fix_grpc_cpp_plugin_target() 129 | _grpc_fix_grpc_target_definitions() 130 | return() 131 | endif () 132 | 133 | include(SelectLibraryConfigurations) 134 | 135 | # Internal function: search for normal library as well as a debug one if the 136 | # debug one is specified also include debug/optimized keywords in *_LIBRARIES 137 | # variable 138 | function (_gRPC_find_library name filename) 139 | if (${name}_LIBRARY) 140 | # Use result recorded by a previous call. 141 | return() 142 | else () 143 | find_library(${name}_LIBRARY_RELEASE NAMES ${filename}) 144 | mark_as_advanced(${name}_LIBRARY_RELEASE) 145 | 146 | find_library(${name}_LIBRARY_DEBUG NAMES ${filename}d ${filename}) 147 | mark_as_advanced(${name}_LIBRARY_DEBUG) 148 | 149 | select_library_configurations(${name}) 150 | 151 | if (gRPC_DEBUG) 152 | message( 153 | STATUS 154 | "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 155 | "${name} ${filename} RELEASE=${${name}_LIBRARY}" 156 | " DEBUG=${${name}_LIBRARY_DEBUG} DEFAULT=${${name}_LIBRARY}" 157 | ) 158 | endif () 159 | 160 | set(${name}_LIBRARY 161 | "${${name}_LIBRARY}" 162 | PARENT_SCOPE) 163 | endif () 164 | endfunction () 165 | 166 | # 167 | # Main 168 | # 169 | 170 | # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES 171 | if (_gRPC_USE_STATIC_LIBS) 172 | set(_gRPC_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) 173 | if (WIN32) 174 | set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) 175 | else () 176 | set(CMAKE_FIND_LIBRARY_SUFFIXES .a) 177 | endif () 178 | endif () 179 | 180 | _grpc_find_library(_gRPC_grpc grpc) 181 | _grpc_find_library(_gRPC_grpc++ grpc++) 182 | 183 | if (NOT _gRPC_INCLUDE_DIR) 184 | find_path(_gRPC_INCLUDE_DIR grpcpp/grpcpp.h) 185 | mark_as_advanced(_gRPC_INCLUDE_DIR) 186 | endif () 187 | 188 | if (gRPC_DEBUG) 189 | message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 190 | " _gRPC_grpc_LIBRARY = ${_gRPC_grpc_LIBRARY}") 191 | message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 192 | " _gRPC_grpc++_LIBRARY = ${_gRPC_grpc++_LIBRARY}") 193 | message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 194 | " _gRPC_INCLUDE_DIR = ${_gRPC_INCLUDE_DIR}") 195 | endif () 196 | 197 | if (_gRPC_grpc_LIBRARY) 198 | if (NOT TARGET gRPC::grpc) 199 | add_library(gRPC::grpc IMPORTED UNKNOWN) 200 | set_target_properties( 201 | gRPC::grpc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES 202 | "${_gRPC_INCLUDE_DIR}") 203 | if (EXISTS "${_gRPC_grpc_LIBRARY}") 204 | set_target_properties(gRPC::grpc PROPERTIES IMPORTED_LOCATION 205 | "${_gRPC_grpc_LIBRARY}") 206 | endif () 207 | if (EXISTS "${_gRPC_grpc_LIBRARY_RELEASE}") 208 | set_property(TARGET gRPC::grpc APPEND 209 | PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 210 | set_target_properties( 211 | gRPC::grpc PROPERTIES IMPORTED_LOCATION_RELEASE 212 | "${_gRPC_grpc_LIBRARY_RELEASE}") 213 | endif () 214 | if (EXISTS "${_gRPC_grpc_LIBRARY_DEBUG}") 215 | set_property(TARGET gRPC::grpc APPEND 216 | PROPERTY IMPORTED_CONFIGURATIONS DEBUG) 217 | set_target_properties( 218 | gRPC::grpc PROPERTIES IMPORTED_LOCATION_DEBUG 219 | "${_gRPC_grpc_LIBRARY_DEBUG}") 220 | endif () 221 | set_property( 222 | TARGET gRPC::grpc APPEND 223 | PROPERTY INTERFACE_LINK_LIBRARIES protobuf::libprotobuf 224 | Threads::Threads) 225 | endif () 226 | endif () 227 | 228 | if (_gRPC_grpc++_LIBRARY) 229 | if (NOT TARGET gRPC::grpc++) 230 | add_library(gRPC::grpc++ IMPORTED UNKNOWN) 231 | set_target_properties( 232 | gRPC::grpc++ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES 233 | "${_gRPC++_INCLUDE_DIR}") 234 | if (EXISTS "${_gRPC_grpc++_LIBRARY}") 235 | set_target_properties( 236 | gRPC::grpc++ PROPERTIES IMPORTED_LOCATION 237 | "${_gRPC_grpc++_LIBRARY}") 238 | endif () 239 | if (EXISTS "${_gRPC_grpc++_LIBRARY_RELEASE}") 240 | set_property(TARGET gRPC::grpc++ APPEND 241 | PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 242 | set_target_properties( 243 | gRPC::grpc++ PROPERTIES IMPORTED_LOCATION_RELEASE 244 | "${_gRPC_grpc++_LIBRARY_RELEASE}") 245 | endif () 246 | if (EXISTS "${_gRPC_grpc++_LIBRARY_DEBUG}") 247 | set_property(TARGET gRPC::grpc++ APPEND 248 | PROPERTY IMPORTED_CONFIGURATIONS DEBUG) 249 | set_target_properties( 250 | gRPC::grpc++ PROPERTIES IMPORTED_LOCATION_DEBUG 251 | "${_gRPC_grpc++_LIBRARY_DEBUG}") 252 | endif () 253 | set_property( 254 | TARGET gRPC::grpc++ APPEND 255 | PROPERTY INTERFACE_LINK_LIBRARIES gRPC::grpc protobuf::libprotobuf 256 | Threads::Threads) 257 | if (CMAKE_VERSION VERSION_GREATER 3.8) 258 | # gRPC++ requires C++11, but only CMake-3.8 introduced a target 259 | # compiler feature to meet that requirement. 260 | set_property(TARGET gRPC::grpc++ APPEND 261 | PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_11) 262 | elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") 263 | # CMake 3.5 is still alive and kicking in some older distros, use 264 | # the compiler-specific versions in these cases. 265 | set_property(TARGET gRPC::grpc++ APPEND 266 | PROPERTY INTERFACE_COMPILE_OPTIONS "-std=c++11") 267 | elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 268 | set_property(TARGET gRPC::grpc++ APPEND 269 | PROPERTY INTERFACE_COMPILE_OPTIONS "-std=c++11") 270 | else () 271 | message( 272 | WARNING 273 | "gRPC::grpc++ requires C++11, but this module" 274 | " (${CMAKE_CURRENT_LIST_FILE})" 275 | " cannot enable it for the library target in your CMake and" 276 | " compiler versions. You need to enable C++11 in the" 277 | " CMakeLists.txt for your project. Consider filing a bug" 278 | " so we can fix this problem.") 279 | endif () 280 | endif () 281 | endif () 282 | 283 | # Restore original find library prefixes 284 | if (_gRPC_USE_STATIC_LIBS) 285 | set(CMAKE_FIND_LIBRARY_PREFIXES "${_gRPC_ORIG_FIND_LIBRARY_PREFIXES}") 286 | endif () 287 | 288 | file( 289 | WRITE "${CMAKE_BINARY_DIR}/get_gRPC_version.cc" 290 | [====[ 291 | #include 292 | #include 293 | int main() { 294 | std::cout << grpc::Version(); // no newline to simplify CMake module 295 | return 0; 296 | } 297 | ]====]) 298 | 299 | try_run( 300 | _gRPC_GET_VERSION_STATUS 301 | _gRPC_GET_VERSION_COMPILE_STATUS 302 | "${CMAKE_BINARY_DIR}" 303 | "${CMAKE_BINARY_DIR}/get_gRPC_version.cc" 304 | LINK_LIBRARIES 305 | gRPC::grpc++ 306 | gRPC::grpc 307 | COMPILE_OUTPUT_VARIABLE _gRPC_GET_VERSION_COMPILE_OUTPUT 308 | RUN_OUTPUT_VARIABLE gRPC_VERSION) 309 | 310 | file(REMOVE "${CMAKE_BINARY_DIR}/get_gRPC_version.cc") 311 | 312 | _grpc_fix_grpc_cpp_plugin_target() 313 | 314 | if (gRPC_DEBUG) 315 | foreach ( 316 | _var 317 | _gRPC_CPP_PLUGIN_EXECUTABLE 318 | _gRPC_VERSION_RAW 319 | _gRPC_GET_VERSION_STATUS 320 | _gRPC_GET_VERSION_COMPILE_STATUS 321 | _gRPC_GET_VERSION_COMPILE_OUTPUT 322 | _gRPC_grpc_LIBRARY 323 | _gRPC_grpc++_LIBRARY 324 | _gRPC_INCLUDE_DIR) 325 | message( 326 | STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " 327 | "${_var} = ${${_var}}") 328 | endforeach () 329 | unset(_var) 330 | endif () 331 | 332 | include(FindPackageHandleStandardArgs) 333 | find_package_handle_standard_args(gRPC REQUIRED_VARS _gRPC_grpc_LIBRARY 334 | _gRPC_INCLUDE_DIR VERSION_VAR gRPC_VERSION) 335 | -------------------------------------------------------------------------------- /cmake/SelectMSVCRuntime.cmake: -------------------------------------------------------------------------------- 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 | # When compiling against *-static vcpkg packages we need to use the static C++ 18 | # runtime with MSVC. The default is to use the dynamic runtime, which does not 19 | # work in this case. This seems to be the recommended way to change the 20 | # runtime: 21 | # 22 | # ~~~ 23 | # https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-can-i-build-my-msvc-application-with-a-static-runtime 24 | # ~~~ 25 | # 26 | # Note that currently we use VCPKG_TARGET_TRIPLET to determine if the static 27 | # runtime is needed. In the future we may need to use a more complex expression 28 | # to determine this, but this is a good start. 29 | # 30 | if (MSVC AND VCPKG_TARGET_TRIPLET MATCHES "-static$") 31 | foreach (flag_var 32 | CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE 33 | CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) 34 | if (${flag_var} MATCHES "/MD") 35 | string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") 36 | endif () 37 | endforeach (flag_var) 38 | unset(flag_var) 39 | endif () 40 | -------------------------------------------------------------------------------- /cmake/config-version.cmake.in: -------------------------------------------------------------------------------- 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 | set(PACKAGE_VERSION @DOXYGEN_PROJECT_NUMBER@) 16 | 17 | # This package has not reached 1.0, there are no compatibility guarantees 18 | # before then. 19 | if (@GOOGLE_CLOUD_CPP_CONFIG_VERSION_MAJOR@ EQUAL 0) 20 | if ("${PACKAGE_FIND_VERSION}" STREQUAL "") 21 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 22 | elseif ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 23 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 24 | set(PACKAGE_VERSION_EXACT TRUE) 25 | else () 26 | set(PACKAGE_VERSION_UNSUITABLE TRUE) 27 | endif () 28 | elseif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 29 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 30 | else() 31 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 32 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 33 | set(PACKAGE_VERSION_EXACT TRUE) 34 | endif() 35 | endif() 36 | -------------------------------------------------------------------------------- /cmake/config.cmake.in: -------------------------------------------------------------------------------- 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 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") 18 | find_package(ProtobufTargets) 19 | find_package(gRPC) 20 | 21 | include("${CMAKE_CURRENT_LIST_DIR}/googleapis-targets.cmake") 22 | 23 | foreach (_target 24 | api_annotations 25 | api_auth 26 | api_client 27 | api_field_behavior 28 | api_http 29 | api_resource 30 | bigtable 31 | cloud_bigquery 32 | devtools_cloudtrace_v2_trace 33 | devtools_cloudtrace_v2_tracing 34 | iam_v1_iam_policy 35 | iam_v1_options 36 | iam_v1_policy 37 | longrunning_operations 38 | pubsub 39 | rpc_error_details 40 | rpc_status 41 | spanner 42 | storage 43 | type_expr) 44 | set(scoped_name "googleapis-c++::${_target}_protos") 45 | set(imported_name "googleapis_cpp_${_target}_protos") 46 | if (NOT TARGET ${scoped_name}) 47 | add_library(${scoped_name} IMPORTED INTERFACE) 48 | set_target_properties(${scoped_name} 49 | PROPERTIES INTERFACE_LINK_LIBRARIES 50 | ${imported_name}) 51 | endif () 52 | endforeach () 53 | -------------------------------------------------------------------------------- /cmake/config.pc.in: -------------------------------------------------------------------------------- 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 | prefix=@CMAKE_INSTALL_PREFIX@ 16 | exec_prefix=${prefix}/@CMAKE_INSTALL_BINDIR@ 17 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ 18 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 19 | 20 | Name: @GOOGLE_CLOUD_CPP_PC_NAME@ 21 | Description: @GOOGLE_CLOUD_CPP_PC_DESCRIPTION@ 22 | Requires: @GOOGLE_CLOUD_CPP_PC_REQUIRES@ 23 | Version: @DOXYGEN_PROJECT_NUMBER@ 24 | 25 | Libs: -L${libdir} @GOOGLE_CLOUD_CPP_PC_LIBS@ 26 | Cflags: -I${includedir} 27 | --------------------------------------------------------------------------------