diff options
Diffstat (limited to 'third_party/cpp')
75 files changed, 3814 insertions, 0 deletions
diff --git a/third_party/cpp/googleapis/.cmake-format.py b/third_party/cpp/googleapis/.cmake-format.py new file mode 100644 index 000000000000..f6ceafc1aa93 --- /dev/null +++ b/third_party/cpp/googleapis/.cmake-format.py @@ -0,0 +1,42 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +tab_size = 4 +separate_ctrl_name_with_space = True + +additional_commands = { + "externalproject_add": { + "flags": [ + ], + "kwargs": { + "BUILD_COMMAND": "+", + "BUILD_BYPRODUCTS": "+", + "CMAKE_ARGS": "+", + "COMMAND": "+", + "CONFIGURE_COMMAND": "+", + "DEPENDS": "+", + "DOWNLOAD_COMMAND": "+", + "EXCLUDE_FROM_ALL": 1, + "INSTALL_COMMAND": "+", + "INSTALL_DIR": 1, + "LOG_BUILD": 1, + "LOG_CONFIGURE": 1, + "LOG_DOWNLOAD": 1, + "LOG_INSTALL": 1, + "PREFIX": 1, + "URL": 1, + "URL_HASH": 1, + } + } +} diff --git a/third_party/cpp/googleapis/.dockerignore b/third_party/cpp/googleapis/.dockerignore new file mode 100644 index 000000000000..4b7b2c0bd276 --- /dev/null +++ b/third_party/cpp/googleapis/.dockerignore @@ -0,0 +1,22 @@ +# Common build output directory names +.build/ +_build/ +build-output/ +cmake-out/ + +# Common bazel output directories +bazel-* + +# Backup files for Emacs +*~ + +# Ignore IDEA / IntelliJ files +.idea/ +cmake-build-*/ + +# This is a staging directory used to upload the documents to gihub.io +github-io-staging/ + +# Ignore Visual Studio Code files +.vsbuild/ +.vscode/ diff --git a/third_party/cpp/googleapis/.editorconfig b/third_party/cpp/googleapis/.editorconfig new file mode 100644 index 000000000000..0983572c6549 --- /dev/null +++ b/third_party/cpp/googleapis/.editorconfig @@ -0,0 +1,22 @@ +# http://editorconfig.org + +root = true + +[*] +charset = utf-8 +indent_style = space + +[BUILD] +indent_size = 4 + +[CMakeLists.*] +indent_size = 4 + +[*.h,*.cc] +indent_size = 2 + +[*.md] +indent_size = 2 + +[*.sh] +indent_size = 2 diff --git a/third_party/cpp/googleapis/.gitignore b/third_party/cpp/googleapis/.gitignore new file mode 100644 index 000000000000..4b7b2c0bd276 --- /dev/null +++ b/third_party/cpp/googleapis/.gitignore @@ -0,0 +1,22 @@ +# Common build output directory names +.build/ +_build/ +build-output/ +cmake-out/ + +# Common bazel output directories +bazel-* + +# Backup files for Emacs +*~ + +# Ignore IDEA / IntelliJ files +.idea/ +cmake-build-*/ + +# This is a staging directory used to upload the documents to gihub.io +github-io-staging/ + +# Ignore Visual Studio Code files +.vsbuild/ +.vscode/ diff --git a/third_party/cpp/googleapis/CMakeLists.txt b/third_party/cpp/googleapis/CMakeLists.txt new file mode 100644 index 000000000000..90db9c71d8f7 --- /dev/null +++ b/third_party/cpp/googleapis/CMakeLists.txt @@ -0,0 +1,521 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +cmake_minimum_required(VERSION 3.5) + +# Define the project name and where to report bugs. +set(PACKAGE_BUGREPORT "https://github.com/googleapis/google-cloud-cpp/issues") +project(googleapis-cpp-protos CXX C) + +set(GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR 0) +set(GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR 5) +set(GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH 0) + +string( + CONCAT GOOGLE_APIS_CPP_PROTOS_VERSION + "${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR}" + "." + "${GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR}" + "." + "${GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH}") + +# Configure the compiler options, we will be using C++11 features. +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +set(GOOGLEAPIS_CPP_SOURCE + "${CMAKE_BINARY_DIR}/external/googleapis/src/googleapis_download") + +set(GOOGLEAPIS_CPP_PROTO_FILES + "google/api/http.proto" + "google/api/annotations.proto" + "google/api/auth.proto" + "google/api/client.proto" + "google/api/field_behavior.proto" + "google/api/label.proto" + "google/api/launch_stage.proto" + "google/api/metric.proto" + "google/api/monitored_resource.proto" + "google/api/resource.proto" + "google/devtools/cloudtrace/v2/trace.proto" + "google/devtools/cloudtrace/v2/tracing.proto" + "google/type/expr.proto" + "google/rpc/error_details.proto" + "google/rpc/status.proto" + "google/iam/v1/options.proto" + "google/iam/v1/policy.proto" + "google/iam/v1/iam_policy.proto" + "google/longrunning/operations.proto" + "google/bigtable/admin/v2/bigtable_instance_admin.proto" + "google/bigtable/admin/v2/bigtable_table_admin.proto" + "google/bigtable/admin/v2/common.proto" + "google/bigtable/admin/v2/instance.proto" + "google/bigtable/admin/v2/table.proto" + "google/bigtable/v2/bigtable.proto" + "google/bigtable/v2/data.proto" + "google/cloud/bigquery/connection/v1beta1/connection.proto" + "google/cloud/bigquery/datatransfer/v1/datatransfer.proto" + "google/cloud/bigquery/datatransfer/v1/transfer.proto" + "google/cloud/bigquery/logging/v1/audit_data.proto" + "google/cloud/bigquery/storage/v1beta1/arrow.proto" + "google/cloud/bigquery/storage/v1beta1/avro.proto" + "google/cloud/bigquery/storage/v1beta1/read_options.proto" + "google/cloud/bigquery/storage/v1beta1/storage.proto" + "google/cloud/bigquery/storage/v1beta1/table_reference.proto" + "google/cloud/bigquery/v2/encryption_config.proto" + "google/cloud/bigquery/v2/model.proto" + "google/cloud/bigquery/v2/model_reference.proto" + "google/cloud/bigquery/v2/standard_sql.proto" + "google/pubsub/v1/pubsub.proto" + "google/spanner/admin/database/v1/spanner_database_admin.proto" + "google/spanner/admin/instance/v1/spanner_instance_admin.proto" + "google/spanner/v1/keys.proto" + "google/spanner/v1/mutation.proto" + "google/spanner/v1/query_plan.proto" + "google/spanner/v1/result_set.proto" + "google/spanner/v1/spanner.proto" + "google/spanner/v1/transaction.proto" + "google/spanner/v1/type.proto" + "google/storage/v1/storage.proto" + "google/storage/v1/storage_resources.proto" + "google/logging/type/http_request.proto" + "google/logging/type/log_severity.proto" + "google/logging/v2/log_entry.proto" + "google/logging/v2/logging.proto" + "google/logging/v2/logging_config.proto" + "google/logging/v2/logging_metrics.proto" +) + +set(GOOGLEAPIS_CPP_BYPRODUCTS) +foreach (proto ${GOOGLEAPIS_CPP_PROTO_FILES}) + list(APPEND GOOGLEAPIS_CPP_BYPRODUCTS "${GOOGLEAPIS_CPP_SOURCE}/${proto}") +endforeach () + +include(ExternalProject) +ExternalProject_Add( + googleapis_download + EXCLUDE_FROM_ALL ON + PREFIX "${CMAKE_BINARY_DIR}/external/googleapis" + URL $ENV{GOOGLEAPIS_DIR} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + BUILD_BYPRODUCTS ${GOOGLEAPIS_CPP_BYPRODUCTS} + LOG_DOWNLOAD OFF) + +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") +find_package(ProtobufTargets REQUIRED) +find_package(gRPC REQUIRED) + +# Define the project name and where to report bugs. +set(PACKAGE_BUGREPORT "https://github.com/googleapis/google-cloud-cpp/issues") +project(googleapis-cpp-protos CXX C) + +set(GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR 0) +set(GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR 5) +set(GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH 0) + +string( + CONCAT GOOGLE_APIS_CPP_PROTOS_VERSION + "${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR}" + "." + "${GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR}" + "." + "${GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH}") + +# Sometimes (this happens often with vcpkg) protobuf is installed in a non- +# standard directory. We need to find out where, and then add that directory to +# the search path for protos. +find_path(PROTO_INCLUDE_DIR google/protobuf/descriptor.proto) +if (PROTO_INCLUDE_DIR) + list(INSERT PROTOBUF_IMPORT_DIRS 0 "${PROTO_INCLUDE_DIR}") +endif () + +add_library(googleapis_cpp_common_flags INTERFACE) + +include(SelectMSVCRuntime) + +# Include the functions to compile proto files. +include(CompileProtos) + +google_cloud_cpp_add_protos_property() + +function (googleapis_cpp_short_name var proto) + string(REPLACE "google/" "" short_name "${proto}") + string(REPLACE "/" "_" short_name "${short_name}") + string(REPLACE ".proto" "_protos" short_name "${short_name}") + set("${var}" + "${short_name}" + PARENT_SCOPE) +endfunction () + +# Create a single source proto library. +# +# * proto: the filename for the proto source. +# * (optional) ARGN: proto libraries the new library depends on. +function (googleapis_cpp_add_library proto) + googleapis_cpp_short_name(short_name "${proto}") + google_cloud_cpp_grpcpp_library( + googleapis_cpp_${short_name} "${GOOGLEAPIS_CPP_SOURCE}/${proto}" + PROTO_PATH_DIRECTORIES "${GOOGLEAPIS_CPP_SOURCE}" + "${PROTO_INCLUDE_DIR}") + + googleapis_cpp_set_version_and_alias("${short_name}") + + set(public_deps) + foreach (dep_short_name ${ARGN}) + list(APPEND public_deps "googleapis-c++::${dep_short_name}") + endforeach () + list(LENGTH public_deps public_deps_length) + if (public_deps_length EQUAL 0) + target_link_libraries("googleapis_cpp_${short_name}" + PRIVATE googleapis_cpp_common_flags) + else () + target_link_libraries( + "googleapis_cpp_${short_name}" + PUBLIC ${public_deps} + PRIVATE googleapis_cpp_common_flags) + endif () +endfunction () + +function (googleapis_cpp_set_version_and_alias short_name) + add_dependencies("googleapis_cpp_${short_name}" googleapis_download) + set_target_properties( + "googleapis_cpp_${short_name}" + PROPERTIES VERSION "${GOOGLE_APIS_CPP_PROTOS_VERSION}" + SOVERSION ${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR}) + add_library("googleapis-c++::${short_name}" ALIAS + "googleapis_cpp_${short_name}") +endfunction () + +googleapis_cpp_add_library("google/api/http.proto") +googleapis_cpp_add_library("google/api/metric.proto" api_launch_stage_protos + api_label_protos) +googleapis_cpp_add_library("google/api/monitored_resource.proto" + api_launch_stage_protos api_label_protos) +googleapis_cpp_add_library("google/api/annotations.proto" api_http_protos) +googleapis_cpp_add_library("google/api/auth.proto" api_annotations_protos) +googleapis_cpp_add_library("google/api/client.proto") +googleapis_cpp_add_library("google/api/distribution.proto" api_distribution_protos) +googleapis_cpp_add_library("google/api/field_behavior.proto") +googleapis_cpp_add_library("google/api/label.proto") +googleapis_cpp_add_library("google/api/launch_stage.proto") +googleapis_cpp_add_library("google/api/resource.proto") + +googleapis_cpp_add_library("google/type/expr.proto") + +googleapis_cpp_add_library("google/rpc/error_details.proto") +googleapis_cpp_add_library("google/rpc/status.proto" rpc_error_details_protos) + +googleapis_cpp_add_library("google/iam/v1/options.proto" api_annotations_protos) +googleapis_cpp_add_library("google/iam/v1/policy.proto" api_annotations_protos + type_expr_protos) + +googleapis_cpp_add_library( + "google/iam/v1/iam_policy.proto" + api_annotations_protos + api_client_protos + api_field_behavior_protos + api_resource_protos + iam_v1_options_protos + iam_v1_policy_protos) + +googleapis_cpp_add_library( + "google/longrunning/operations.proto" api_annotations_protos + api_client_protos rpc_status_protos) + +googleapis_cpp_add_library( + "google/devtools/cloudtrace/v2/trace.proto" api_annotations_protos + api_field_behavior_protos api_resource_protos rpc_status_protos) +googleapis_cpp_add_library( + "google/devtools/cloudtrace/v2/tracing.proto" + devtools_cloudtrace_v2_trace_protos api_annotations_protos + api_client_protos api_field_behavior_protos rpc_status_protos) + +google_cloud_cpp_grpcpp_library( + googleapis_cpp_cloud_bigquery_protos + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/connection/v1beta1/connection.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/datatransfer/v1/datatransfer.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/datatransfer/v1/transfer.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/logging/v1/audit_data.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/storage/v1beta1/arrow.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/storage/v1beta1/avro.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/storage/v1beta1/read_options.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/storage/v1beta1/storage.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/storage/v1beta1/table_reference.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/v2/encryption_config.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/v2/model.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/v2/model_reference.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/cloud/bigquery/v2/standard_sql.proto" + PROTO_PATH_DIRECTORIES + "${GOOGLEAPIS_CPP_SOURCE}" + "${PROTO_INCLUDE_DIR}") +googleapis_cpp_set_version_and_alias(cloud_bigquery_protos) +target_link_libraries( + googleapis_cpp_cloud_bigquery_protos + PUBLIC googleapis-c++::api_annotations_protos + googleapis-c++::api_client_protos + googleapis-c++::api_field_behavior_protos + googleapis-c++::api_resource_protos + googleapis-c++::iam_v1_iam_policy_protos + googleapis-c++::iam_v1_policy_protos + googleapis-c++::rpc_status_protos + googleapis-c++::api_http_protos + PRIVATE googleapis_cpp_common_flags) + +google_cloud_cpp_grpcpp_library( + googleapis_cpp_bigtable_protos + "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/admin/v2/bigtable_instance_admin.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/admin/v2/bigtable_table_admin.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/admin/v2/common.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/admin/v2/instance.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/admin/v2/table.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/v2/bigtable.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/bigtable/v2/data.proto" + PROTO_PATH_DIRECTORIES + "${GOOGLEAPIS_CPP_SOURCE}" + "${PROTO_INCLUDE_DIR}") +googleapis_cpp_set_version_and_alias(bigtable_protos) +target_link_libraries( + googleapis_cpp_bigtable_protos + PUBLIC googleapis-c++::api_annotations_protos + googleapis-c++::api_client_protos + googleapis-c++::api_field_behavior_protos + googleapis-c++::api_resource_protos + googleapis-c++::iam_v1_iam_policy_protos + googleapis-c++::iam_v1_policy_protos + googleapis-c++::longrunning_operations_protos + googleapis-c++::rpc_status_protos + googleapis-c++::api_auth_protos + PRIVATE googleapis_cpp_common_flags) + +google_cloud_cpp_grpcpp_library( + googleapis_cpp_pubsub_protos + "${GOOGLEAPIS_CPP_SOURCE}/google/pubsub/v1/pubsub.proto" + PROTO_PATH_DIRECTORIES "${GOOGLEAPIS_CPP_SOURCE}" "${PROTO_INCLUDE_DIR}") +googleapis_cpp_set_version_and_alias(pubsub_protos) +target_link_libraries( + googleapis_cpp_pubsub_protos + PUBLIC googleapis-c++::api_annotations_protos + googleapis-c++::api_client_protos + googleapis-c++::api_field_behavior_protos + googleapis-c++::api_resource_protos + PRIVATE googleapis_cpp_common_flags) + +google_cloud_cpp_grpcpp_library( + googleapis_cpp_spanner_protos + "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/admin/database/v1/spanner_database_admin.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/admin/instance/v1/spanner_instance_admin.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/keys.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/mutation.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/query_plan.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/result_set.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/spanner.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/transaction.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/spanner/v1/type.proto" + PROTO_PATH_DIRECTORIES + "${GOOGLEAPIS_CPP_SOURCE}" + "${PROTO_INCLUDE_DIR}") +googleapis_cpp_set_version_and_alias(spanner_protos) +target_link_libraries( + googleapis_cpp_spanner_protos + PUBLIC googleapis-c++::api_annotations_protos + googleapis-c++::api_client_protos + googleapis-c++::api_field_behavior_protos + googleapis-c++::api_resource_protos + googleapis-c++::iam_v1_iam_policy_protos + googleapis-c++::iam_v1_policy_protos + googleapis-c++::longrunning_operations_protos + googleapis-c++::rpc_status_protos + PRIVATE googleapis_cpp_common_flags) + +google_cloud_cpp_grpcpp_library( + googleapis_cpp_storage_protos + "${GOOGLEAPIS_CPP_SOURCE}/google/storage/v1/storage.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/storage/v1/storage_resources.proto" + PROTO_PATH_DIRECTORIES + "${GOOGLEAPIS_CPP_SOURCE}" + "${PROTO_INCLUDE_DIR}") +googleapis_cpp_set_version_and_alias(storage_protos) +target_link_libraries( + googleapis_cpp_storage_protos + PUBLIC googleapis-c++::api_annotations_protos + googleapis-c++::api_client_protos + googleapis-c++::api_field_behavior_protos + googleapis-c++::iam_v1_iam_policy_protos + googleapis-c++::iam_v1_policy_protos + PRIVATE googleapis_cpp_common_flags) + +google_cloud_cpp_grpcpp_library( + googleapis_cpp_logging_protos + "${GOOGLEAPIS_CPP_SOURCE}/google/logging/type/http_request.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/logging/type/log_severity.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/logging/v2/log_entry.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/logging/v2/logging.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/logging/v2/logging_config.proto" + "${GOOGLEAPIS_CPP_SOURCE}/google/logging/v2/logging_metrics.proto" + PROTO_PATH_DIRECTORIES + "${GOOGLEAPIS_CPP_SOURCE}" + "${PROTO_INCLUDE_DIR}") + +googleapis_cpp_set_version_and_alias(logging_protos) + +target_link_libraries( + googleapis_cpp_logging_protos + # TODO + PUBLIC googleapis-c++::api_annotations_protos + googleapis-c++::api_distribution_protos + PRIVATE googleapis_cpp_common_flags) + +# Install the libraries and headers in the locations determined by +# GNUInstallDirs +include(GNUInstallDirs) + +set(googleapis_cpp_installed_libraries_list + googleapis_cpp_bigtable_protos + googleapis_cpp_cloud_bigquery_protos + googleapis_cpp_pubsub_protos + googleapis_cpp_spanner_protos + googleapis_cpp_storage_protos + googleapis_cpp_logging_protos + googleapis_cpp_longrunning_operations_protos + googleapis_cpp_api_http_protos + googleapis_cpp_api_annotations_protos + googleapis_cpp_api_distribution_protos + googleapis_cpp_api_auth_protos + googleapis_cpp_api_client_protos + googleapis_cpp_api_field_behavior_protos + googleapis_cpp_api_resource_protos + googleapis_cpp_devtools_cloudtrace_v2_trace_protos + googleapis_cpp_devtools_cloudtrace_v2_tracing_protos + googleapis_cpp_iam_v1_options_protos + googleapis_cpp_iam_v1_policy_protos + googleapis_cpp_iam_v1_iam_policy_protos + googleapis_cpp_rpc_error_details_protos + googleapis_cpp_rpc_status_protos + googleapis_cpp_type_expr_protos) + +install( + TARGETS ${googleapis_cpp_installed_libraries_list} + googleapis_cpp_common_flags + EXPORT googleapis-targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +foreach (target ${googleapis_cpp_installed_libraries_list}) + google_cloud_cpp_install_proto_library_headers("${target}") + google_cloud_cpp_install_proto_library_protos("${target}" + "${GOOGLEAPIS_CPP_SOURCE}") +endforeach () + +# Export the CMake targets to make it easy to create configuration files. +install(EXPORT googleapis-targets + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/googleapis") + +# Setup global variables used in the following *.in files. +set(GOOGLE_CLOUD_CPP_CONFIG_VERSION_MAJOR + ${GOOGLEAPIS_CPP_PROTOS_VERSION_MAJOR}) +set(GOOGLE_CLOUD_CPP_CONFIG_VERSION_MINOR + ${GOOGLEAPIS_CPP_PROTOS_VERSION_MINOR}) +set(GOOGLE_CLOUD_CPP_CONFIG_VERSION_PATCH + ${GOOGLEAPIS_CPP_PROTOS_VERSION_PATCH}) + +# Use a function to create a scope for the variables. +function (googleapis_cpp_install_pc target) + string(REPLACE "googleapis_cpp_" "" _short_name ${target}) + string(REPLACE "_protos" "" _short_name ${_short_name}) + set(GOOGLE_CLOUD_CPP_PC_NAME + "The Google APIS C++ ${_short_name} Proto Library") + set(GOOGLE_CLOUD_CPP_PC_DESCRIPTION "Compiled proto for C++.") + # Examine the target LINK_LIBRARIES property, use that to pull the + # dependencies between the googleapis-c++::* libraries. + set(_target_pc_requires) + get_target_property(_target_deps ${target} LINK_LIBRARIES) + foreach (dep ${_target_deps}) + if ("${dep}" MATCHES "^googleapis-c\\+\\+::") + string(REPLACE "googleapis-c++::" "googleapis_cpp_" dep "${dep}") + list(APPEND _target_pc_requires " " "${dep}") + endif () + endforeach () + # These dependencies are required for all the googleapis-c++::* libraries. + list( + APPEND + _target_pc_requires + " grpc++" + " grpc" + " openssl" + " protobuf" + " zlib" + " libcares") + string(CONCAT GOOGLE_CLOUD_CPP_PC_REQUIRES ${_target_pc_requires}) + set(GOOGLE_CLOUD_CPP_PC_LIBS "-l${target}") + configure_file("cmake/config.pc.in" "${target}.pc" @ONLY) + install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${target}.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") +endfunction () + +# Create and install the pkg-config files. +foreach (target ${googleapis_cpp_installed_libraries_list}) + googleapis_cpp_install_pc("${target}") +endforeach () + +# Create and install the googleapis pkg-config file for backwards compatibility. +set(GOOGLE_CLOUD_CPP_PC_NAME "The Google APIS C++ Proto Library") +set(GOOGLE_CLOUD_CPP_PC_DESCRIPTION + "Provides C++ APIs to access Google Cloud Platforms.") +# Note the use of spaces, `string(JOIN)` is not available in cmake-3.5, so we +# need to add the separator ourselves. +string( + CONCAT GOOGLE_CLOUD_CPP_PC_REQUIRES + "googleapis_cpp_bigtable_protos" + " googleapis_cpp_cloud_bigquery_protos" + " googleapis_pubsub_protos" + " googleapis_cpp_storage_protos" + " googleapis_cpp_iam_v1_iam_policy_protos" + " googleapis_cpp_iam_v1_options_protos" + " googleapis_cpp_iam_v1_policy_protos" + " googleapis_cpp_logging_protos" + " googleapis_cpp_longrunning_operations_protos" + " googleapis_cpp_api_auth_protos" + " googleapis_cpp_api_annotations_protos" + " googleapis_cpp_api_client_protos" + " googleapis_cpp_api_field_behavior_protos" + " googleapis_cpp_api_http_protos" + " googleapis_cpp_rpc_status_protos" + " googleapis_cpp_rpc_error_details_protos" + " grpc++" + " grpc" + " openssl" + " protobuf" + " zlib" + " libcares") +set(GOOGLE_CLOUD_CPP_PC_LIBS "") +configure_file("cmake/config.pc.in" "googleapis.pc" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/googleapis.pc" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + +# Create and install the CMake configuration files. +configure_file("cmake/config.cmake.in" "googleapis-config.cmake" @ONLY) +configure_file("cmake/config-version.cmake.in" + "googleapis-config-version.cmake" @ONLY) +install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/googleapis-config.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/googleapis-config-version.cmake" + "${PROJECT_SOURCE_DIR}/cmake/FindgRPC.cmake" + "${PROJECT_SOURCE_DIR}/cmake/FindProtobufTargets.cmake" + "${PROJECT_SOURCE_DIR}/cmake/CompileProtos.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/googleapis") diff --git a/third_party/cpp/googleapis/CONTRIBUTING.md b/third_party/cpp/googleapis/CONTRIBUTING.md new file mode 100644 index 000000000000..33497a37985f --- /dev/null +++ b/third_party/cpp/googleapis/CONTRIBUTING.md @@ -0,0 +1,55 @@ +# How to become a contributor and submit your own code + +## Contributor License Agreements + +We'd love to accept your patches! Before we can take them, we +have to jump a couple of legal hurdles. + +Please fill out either the individual or corporate Contributor License Agreement +(CLA). + + * If you are an individual writing original source code and you're sure you + own the intellectual property, then you'll need to sign an + [individual CLA](https://developers.google.com/open-source/cla/individual). + * If you work for a company that wants to allow you to contribute your work, + then you'll need to sign a + [corporate CLA](https://developers.google.com/open-source/cla/corporate). + +Follow either of the two links above to access the appropriate CLA and +instructions for how to sign and return it. Once we receive it, we'll be able to +accept your pull requests. + +## Contributing A Patch + +1. Submit an issue describing your proposed change to the repo in question. +1. The repo owner will respond to your issue promptly. +1. If your proposed change is accepted, and you haven't already done so, sign a + Contributor License Agreement (see details above). +1. Fork the desired repo, develop and test your code changes. +1. Ensure that your code adheres to the existing style in the sample to which + you are contributing. +1. Ensure that your code has an appropriate set of unit tests which all pass. +1. Submit a pull request. + +## Style + +This repository follow the [Google C++ Style Guide]( +https://google.github.io/styleguide/cppguide.html). +Please make sure your contributions adhere to the style guide. + +### Formatting + +The code in this project is formatted with `clang-format(1)`, and our CI builds +will check that the code matches the format generated by this tool before +accepting a pull request. Please configure your editor or IDE to use the Google +style for indentation and other whitespace. If you need to reformat one or more +files, you can simply run `clang-format` manually: + +```console +$ clang-format -i <file>.... +``` + +If you need to reformat one of the files to match the Google style. Please be +advised that `clang-format` has been known to generate slightly different +formatting in different versions. We use version 7; use the same version if you +run into problems. diff --git a/third_party/cpp/googleapis/LICENSE b/third_party/cpp/googleapis/LICENSE new file mode 100644 index 000000000000..261eeb9e9f8b --- /dev/null +++ b/third_party/cpp/googleapis/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/third_party/cpp/googleapis/README.md b/third_party/cpp/googleapis/README.md new file mode 100644 index 000000000000..5c2a71193808 --- /dev/null +++ b/third_party/cpp/googleapis/README.md @@ -0,0 +1,68 @@ +# Google Cloud Platform C++ Proto Libraries + +Compile the protocol buffer definitions into C++ libraries. + +## Requirements + +#### Compiler + +The Google Cloud C++ libraries are tested with the following compilers: + +| Compiler | Minimum Version | +| ----------- | --------------- | +| GCC | 4.8 | +| Clang | 3.8 | +| MSVC++ | 14.1 | +| Apple Clang | 8.1 | + +#### Build Tools + +The Google Cloud C++ Client Libraries can be built with +[CMake](https://cmake.org) or [Bazel](https://bazel.io). The minimal versions +of these tools we test with are: + +| Tool | Minimum Version | +| ---------- | --------------- | +| CMake | 3.5 | +| Bazel | 0.24.0 | + +#### Libraries + +The libraries also depend on gRPC, libcurl, and the dependencies of those +libraries. The Google Cloud C++ Client libraries are tested with the following +versions of these dependencies: + +| Library | Minimum version | +| ------- | --------------- | +| gRPC | v1.16.x | +| libcurl | 7.47.0 | + + +## Versioning + +Please note that the Google Cloud C++ client libraries do **not** follow +[Semantic Versioning](http://semver.org/). + +**GA**: Libraries defined at a GA quality level are expected to be stable and +any backwards-incompatible changes will be noted in the documentation. Major +changes to the API will signaled by changing major version number +(e.g. 1.x.y -> 2.0.0). + +**Beta**: Libraries defined at a Beta quality level are expected to be mostly +stable and we're working towards their release candidate. We will address issues +and requests with a higher priority. + +**Alpha**: Libraries defined at an Alpha quality level are still a +work-in-progress and are more likely to get backwards-incompatible updates. +Additionally, it's possible for Alpha libraries to get deprecated and deleted +before ever being promoted to Beta or GA. + +## Contributing changes + +See [`CONTRIBUTING.md`](CONTRIBUTING.md) for details on how to contribute to +this project, including how to build and test your changes as well as how to +properly format your code. + +## Licensing + +Apache 2.0; see [`LICENSE`](LICENSE) for details. diff --git a/third_party/cpp/googleapis/ci/check-style.sh b/third_party/cpp/googleapis/ci/check-style.sh new file mode 100755 index 000000000000..9fe61bf0343f --- /dev/null +++ b/third_party/cpp/googleapis/ci/check-style.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +if [[ "${CHECK_STYLE}" != "yes" ]]; then + echo "Skipping code style check as it is disabled for this build." + exit 0 +fi + +# This script assumes it is running the top-level google-cloud-cpp directory. + +readonly BINDIR="$(dirname "$0")" + +# Build paths to ignore in find(1) commands by reading .gitignore. +declare -a ignore=( -path ./.git ) +if [[ -f .gitignore ]]; then + while read -r line; do + case "${line}" in + [^#]*/*) ignore+=( -o -path "./$(expr "${line}" : '\(.*\)/')" ) ;; + [^#]*) ignore+=( -o -name "${line}" ) ;; + esac + done < .gitignore +fi + +replace_original_if_changed() { + if [[ $# != 2 ]]; then + return 1 + fi + + local original="$1" + local reformatted="$2" + + if cmp -s "${original}" "${reformatted}"; then + rm -f "${reformatted}" + else + chmod --reference="${original}" "${reformatted}" + mv -f "${reformatted}" "${original}" + fi +} + +# Apply cmake_format to all the CMake list files. +# https://github.com/cheshirekow/cmake_format +find . \( "${ignore[@]}" \) -prune -o \ + \( -name 'CMakeLists.txt' -o -name '*.cmake' \) \ + -print0 | + while IFS= read -r -d $'\0' file; do + cmake-format "${file}" >"${file}.tmp" + replace_original_if_changed "${file}" "${file}.tmp" + done + +# Apply buildifier to fix the BUILD and .bzl formatting rules. +# https://github.com/bazelbuild/buildtools/tree/master/buildifier +find . \( "${ignore[@]}" \) -prune -o \ + \( -name BUILD -o -name '*.bzl' \) \ + -print0 | + xargs -0 buildifier -mode=fix + +# Apply shellcheck(1) to emit warnings for common scripting mistakes. +find . \( "${ignore[@]}" \) -prune -o \ + -iname '*.sh' -exec shellcheck \ + --exclude=SC1090 \ + --exclude=SC2034 \ + --exclude=SC2153 \ + --exclude=SC2181 \ + '{}' \; + +# Report any differences created by running the formatting tools. +git diff --ignore-submodules=all --color --exit-code . diff --git a/third_party/cpp/googleapis/ci/colors.sh b/third_party/cpp/googleapis/ci/colors.sh new file mode 100755 index 000000000000..23acd8e03d37 --- /dev/null +++ b/third_party/cpp/googleapis/ci/colors.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +if [ -z "${COLOR_RESET+x}" ]; then + if type tput >/dev/null 2>&1; then + readonly COLOR_RED="$(tput setaf 1)" + readonly COLOR_GREEN="$(tput setaf 2)" + readonly COLOR_YELLOW="$(tput setaf 3)" + readonly COLOR_RESET="$(tput sgr0)" + else + readonly COLOR_RED="" + readonly COLOR_GREEN="" + readonly COLOR_YELLOW="" + readonly COLOR_RESET="" + fi +fi diff --git a/third_party/cpp/googleapis/ci/install-grpc.sh b/third_party/cpp/googleapis/ci/install-grpc.sh new file mode 100755 index 000000000000..759b355bb569 --- /dev/null +++ b/third_party/cpp/googleapis/ci/install-grpc.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +mkdir -p /var/tmp/Downloads +cd /var/tmp/Downloads + +# Install protobuf +wget -q https://github.com/google/protobuf/archive/v3.8.0.tar.gz +tar -xf v3.8.0.tar.gz +(cd protobuf-3.8.0/cmake; + cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=yes \ + -Dprotobuf_BUILD_TESTS=OFF \ + -H. -Bcmake-out + cmake --build cmake-out --target install -- -j "$(nproc)" + ldconfig +) + +# Install grpc +wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz +tar -xf v1.22.0.tar.gz +(cd grpc-1.22.0; + make -j "$(nproc)" + make install + ldconfig +) diff --git a/third_party/cpp/googleapis/ci/kokoro/Dockerfile.centos b/third_party/cpp/googleapis/ci/kokoro/Dockerfile.centos new file mode 100644 index 000000000000..2982dae0e165 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/Dockerfile.centos @@ -0,0 +1,51 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG DISTRO_VERSION=7 +FROM centos:${DISTRO_VERSION} + +# Add /usr/local/lib + +# Search paths tweak for the build +ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig +ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 +ENV PATH=/usr/local/bin:${PATH} + +# First install the development tools and OpenSSL. The development tools +# distributed with CentOS (notably CMake) are too old to build +# `google-cloud-cpp`. In these instructions, we use `cmake3` obtained from +# [Software Collections](https://www.softwarecollections.org/). + +RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +RUN yum install -y centos-release-scl +RUN yum-config-manager --enable rhel-server-rhscl-7-rpms +RUN yum makecache && \ + yum install -y automake cmake3 curl-devel gcc gcc-c++ git libtool \ + make openssl-devel pkgconfig tar wget which zlib-devel +RUN ln -sf /usr/bin/cmake3 /usr/bin/cmake && ln -sf /usr/bin/ctest3 /usr/bin/ctest + +# Install c-ares +RUN mkdir -p /var/tmp/Downloads; \ + cd /var/tmp/Downloads; \ + wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz; \ + tar -xf cares-1_15_0.tar.gz; \ + cd /var/tmp/Downloads/c-ares-cares-1_15_0; \ + ./buildconf && ./configure && make -j $(nproc); \ + make install; \ + ldconfig + +# Install grpc from source +WORKDIR /var/tmp/ci +COPY install-grpc.sh /var/tmp/ci +RUN /var/tmp/ci/install-grpc.sh diff --git a/third_party/cpp/googleapis/ci/kokoro/Dockerfile.fedora b/third_party/cpp/googleapis/ci/kokoro/Dockerfile.fedora new file mode 100644 index 000000000000..c56ace3b1aaf --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/Dockerfile.fedora @@ -0,0 +1,38 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG DISTRO_VERSION=30 +FROM fedora:${DISTRO_VERSION} + +# Fedora includes packages for gRPC, libcurl, and OpenSSL that are recent enough +# for `google-cloud-cpp`. Install these packages and additional development +# tools to compile the dependencies: +RUN dnf makecache && \ + dnf install -y clang clang-tools-extra cmake doxygen findutils gcc-c++ git \ + grpc-devel grpc-plugins libcxx-devel libcxxabi-devel libcurl-devel \ + make openssl-devel pkgconfig protobuf-compiler python-pip ShellCheck \ + tar wget zlib-devel + +# Install the the buildifier tool, which does not compile with the default +# golang compiler for Ubuntu 16.04 and Ubuntu 18.04. +RUN wget -q -O /usr/bin/buildifier https://github.com/bazelbuild/buildtools/releases/download/0.17.2/buildifier +RUN chmod 755 /usr/bin/buildifier + +# Install cmake_format to automatically format the CMake list files. +# https://github.com/cheshirekow/cmake_format +# Pin this to an specific version because the formatting changes when the +# "latest" version is updated, and we do not want the builds to break just +# because some third party changed something. +RUN pip install --upgrade pip +RUN pip install numpy cmake_format==0.6.9 diff --git a/third_party/cpp/googleapis/ci/kokoro/Dockerfile.ubuntu-16.04 b/third_party/cpp/googleapis/ci/kokoro/Dockerfile.ubuntu-16.04 new file mode 100644 index 000000000000..8ef65dd9b2e6 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/Dockerfile.ubuntu-16.04 @@ -0,0 +1,53 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:16.04 + +RUN apt update && \ + apt install -y \ + automake \ + build-essential \ + clang \ + cmake \ + curl \ + doxygen \ + gawk \ + git \ + gcc \ + golang \ + g++ \ + libssl-dev \ + libtool \ + make \ + ninja-build \ + pkg-config \ + python-pip \ + shellcheck \ + tar \ + unzip \ + wget \ + zlib1g-dev + +WORKDIR /var/tmp/Downloads +RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz && \ + tar -xf cares-1_15_0.tar.gz && \ + cd /var/tmp/Downloads/c-ares-cares-1_15_0 && \ + ./buildconf && ./configure && make -j $(nproc) && \ + make install && \ + ldconfig + +# Install grpc from source +WORKDIR /var/tmp/ci +COPY install-grpc.sh /var/tmp/ci +RUN /var/tmp/ci/install-grpc.sh diff --git a/third_party/cpp/googleapis/ci/kokoro/Dockerfile.ubuntu-18.04 b/third_party/cpp/googleapis/ci/kokoro/Dockerfile.ubuntu-18.04 new file mode 100644 index 000000000000..d3660dafa25a --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/Dockerfile.ubuntu-18.04 @@ -0,0 +1,45 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:18.04 + +RUN apt update && \ + apt install -y \ + build-essential \ + clang \ + cmake \ + curl \ + doxygen \ + gawk \ + git \ + gcc \ + golang \ + g++ \ + libc-ares-dev \ + libc-ares2 \ + libssl-dev \ + make \ + ninja-build \ + pkg-config \ + python-pip \ + shellcheck \ + tar \ + unzip \ + wget \ + zlib1g-dev + +# Install grpc from source +WORKDIR /var/tmp/ci +COPY install-grpc.sh /var/tmp/ci +RUN /var/tmp/ci/install-grpc.sh diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/build-in-docker-cmake.sh b/third_party/cpp/googleapis/ci/kokoro/docker/build-in-docker-cmake.sh new file mode 100755 index 000000000000..4dd9e7eb3dff --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/build-in-docker-cmake.sh @@ -0,0 +1,112 @@ +#!/usr/bin/env bash +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +if [[ $# != 2 ]]; then + echo "Usage: $(basename "$0") <source-directory> <binary-directory>" + exit 1 +fi + +readonly SOURCE_DIR="$1" +readonly BINARY_DIR="$2" + +# This script is supposed to run inside a Docker container, see +# ci/kokoro/cmake/installed-dependencies/build.sh for the expected setup. The +# /v directory is a volume pointing to a (clean-ish) checkout of the project: +if [[ -z "${PROJECT_ROOT+x}" ]]; then + readonly PROJECT_ROOT="/v" +fi +source "${PROJECT_ROOT}/ci/colors.sh" + +echo +echo "${COLOR_YELLOW}Starting docker build $(date) with $(nproc) cores${COLOR_RESET}" +echo + +echo "================================================================" +echo "Verify formatting $(date)" +(cd "${PROJECT_ROOT}" ; ./ci/check-style.sh) +echo "================================================================" + +echo "================================================================" +echo "Compiling on $(date)" +echo "================================================================" +cd "${PROJECT_ROOT}" +cmake_flags=() +if [[ "${CLANG_TIDY:-}" = "yes" ]]; then + cmake_flags+=("-DGOOGLE_CLOUD_CPP_CLANG_TIDY=yes") +fi +if [[ "${GOOGLE_CLOUD_CPP_CXX_STANDARD:-}" != "" ]]; then + cmake_flags+=( + "-DGOOGLE_CLOUD_CPP_CXX_STANDARD=${GOOGLE_CLOUD_CPP_CXX_STANDARD}") +fi + +if [[ "${CODE_COVERAGE:-}" == "yes" ]]; then + cmake_flags+=( + "-DCMAKE_BUILD_TYPE=Coverage") +fi + +if [[ "${USE_NINJA:-}" == "yes" ]]; then + cmake_flags+=( "-GNinja" ) +fi + +# Avoid unbound variable error with older bash +if [[ "${#cmake_flags[@]}" == 0 ]]; then + cmake "-H${SOURCE_DIR}" "-B${BINARY_DIR}" +else + cmake "-H${SOURCE_DIR}" "-B${BINARY_DIR}" "${cmake_flags[@]}" +fi +cmake --build "${BINARY_DIR}" -- -j "$(nproc)" + +# When user a super-build the tests are hidden in a subdirectory. We can tell +# that ${BINARY_DIR} does not have the tests by checking for this file: +if [[ -r "${BINARY_DIR}/CTestTestfile.cmake" ]]; then + echo "================================================================" + # It is Okay to skip the tests in this case because the super build + # automatically runs them. + echo "Running the unit tests $(date)" + env -C "${BINARY_DIR}" ctest \ + -LE integration-tests \ + --output-on-failure -j "$(nproc)" + echo "================================================================" +fi + +if [[ "${GENERATE_DOCS:-}" = "yes" ]]; then + echo "================================================================" + echo "Validate Doxygen documentation $(date)" + cmake --build "${BINARY_DIR}" --target doxygen-docs + echo "================================================================" +fi + +if [[ ${RUN_INTEGRATION_TESTS} == "yes" ]]; then + echo "================================================================" + echo "Running the integration tests $(date)" + echo "================================================================" + # shellcheck disable=SC1091 + source /c/spanner-integration-tests-config.sh + export GOOGLE_APPLICATION_CREDENTIALS=/c/spanner-credentials.json + + # Run the integration tests too. + env -C "${BINARY_DIR}" ctest \ + -L integration-tests \ + --output-on-failure + echo "================================================================" +fi + +echo "================================================================" +echo "Build finished at $(date)" +echo "================================================================" + +exit 0 diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/build.sh b/third_party/cpp/googleapis/ci/kokoro/docker/build.sh new file mode 100755 index 000000000000..fbd886f02852 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/build.sh @@ -0,0 +1,272 @@ +#!/usr/bin/env bash +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +export CC=gcc +export CXX=g++ +export DISTRO=ubuntu +export DISTRO_VERSION=18.04 +export CMAKE_SOURCE_DIR="." + +in_docker_script="ci/kokoro/docker/build-in-docker-cmake.sh" + +if [[ $# -eq 1 ]]; then + export BUILD_NAME="${1}" +elif [[ -n "${KOKORO_JOB_NAME:-}" ]]; then + # Kokoro injects the KOKORO_JOB_NAME environment variable, the value of this + # variable is cloud-cpp/spanner/<config-file-name-without-cfg> (or more + # generally <path/to/config-file-without-cfg>). By convention we name these + # files `$foo.cfg` for continuous builds and `$foo-presubmit.cfg` for + # presubmit builds. Here we extract the value of "foo" and use it as the build + # name. + BUILD_NAME="$(basename "${KOKORO_JOB_NAME}" "-presubmit")" + export BUILD_NAME +else + echo "Aborting build as the build name is not defined." + echo "If you are invoking this script via the command line use:" + echo " $0 <build-name>" + echo + echo "If this script is invoked by Kokoro, the CI system is expected to set" + echo "the KOKORO_JOB_NAME environment variable." + exit 1 +fi + +if [[ "${BUILD_NAME}" = "clang-tidy" ]]; then + # Compile with clang-tidy(1) turned on. The build treats clang-tidy warnings + # as errors. + export DISTRO=fedora + export DISTRO_VERSION=30 + export CC=clang + export CXX=clang++ + export CHECK_STYLE=yes + export CLANG_TIDY=yes +elif [[ "${BUILD_NAME}" = "ubuntu-18.04" ]]; then + export CC=gcc + export CXX=g++ +elif [[ "${BUILD_NAME}" = "ubuntu-16.04" ]]; then + export DISTRO_VERSION=16.04 + export CC=gcc + export CXX=g++ +elif [[ "${BUILD_NAME}" = "gcc-4.8" ]]; then + # The oldest version of GCC we support is 4.8, this build checks the code + # against that version. The use of CentOS 7 for that build is not a + # coincidence: the reason we support GCC 4.8 is to support this distribution + # (and its commercial cousin: RHEL 7). + export CC=gcc + export CXX=g++ + export DISTRO=centos + export DISTRO_VERSION=7 +elif [[ "${BUILD_NAME}" = "clang-3.8" ]]; then + # The oldest version of Clang we actively test is 3.8. There is nothing + # particularly interesting about that version. It is simply the version + # included with Ubuntu:16.04, and the oldest version tested by + # google-cloud-cpp. + export DISTRO=ubuntu + export DISTRO_VERSION=16.04 + export CC=clang + export CXX=clang++ +elif [[ "${BUILD_NAME}" = "ninja" ]]; then + # Compiling with Ninja can catch bugs that may not be caught using Make. + export USE_NINJA=yes +else + echo "Unknown BUILD_NAME (${BUILD_NAME}). Fix the Kokoro .cfg file." + exit 1 +fi + +if [[ -z "${PROJECT_ROOT+x}" ]]; then + readonly PROJECT_ROOT="$(cd "$(dirname "$0")/../../.."; pwd)" +fi + +if [[ -z "${PROJECT_ID+x}" ]]; then + readonly PROJECT_ID="cloud-devrel-kokoro-resources" +fi + +# Determine the image name. +readonly IMAGE="gcr.io/${PROJECT_ID}/cpp-cmakefiles/${DISTRO}-${DISTRO_VERSION}" +readonly BUILD_OUTPUT="cmake-out/${BUILD_NAME}" +readonly BUILD_HOME="cmake-out/home/${BUILD_NAME}" + +echo "================================================================" +cd "${PROJECT_ROOT}" +echo "Building with $(nproc) cores $(date) on ${PWD}." + +echo "================================================================" +echo "Capture Docker version to troubleshoot $(date)." +docker version +echo "================================================================" + +has_cache="false" + +if [[ -n "${KOKORO_JOB_NAME:-}" ]]; then + # Download the docker image from the previous build on kokoro for speed. + echo "================================================================" + echo "Downloading Docker image $(date)." + gcloud auth configure-docker + if docker pull "${IMAGE}:latest"; then + echo "Existing image successfully downloaded." + has_cache="true" + fi + echo "================================================================" +fi + +docker_build_flags=( + "-t" "${IMAGE}:latest" +) + +if [[ -f "ci/kokoro/Dockerfile.${DISTRO}-${DISTRO_VERSION}" ]]; then + docker_build_flags+=("-f" "ci/kokoro/Dockerfile.${DISTRO}-${DISTRO_VERSION}") +else + docker_build_flags+=( + "-f" "ci/kokoro/Dockerfile.${DISTRO}" + "--build-arg" "DISTRO_VERSION=${DISTRO_VERSION}" + ) +fi + +if "${has_cache}"; then + docker_build_flags+=("--cache-from=${IMAGE}:latest") +fi + +update_cache="false" +echo "================================================================" +echo "Creating Docker image with all the development tools $(date)." +if ci/retry-command.sh docker build "${docker_build_flags[@]}" ci; then + update_cache="true" + echo "Docker image created $(date)." + docker image ls | grep "${IMAGE}" +else + echo "Failed creating Docker image $(date)." + if "${has_cache}"; then + echo "Continue the build with the cache." + else + exit 1 + fi +fi +echo "================================================================" + +if [[ -n "${KOKORO_JOB_NAME:-}" ]]; then + # Upload the docker image for speeding up the future builds. + echo "================================================================" + echo "Uploading Docker image $(date)." + docker push "${IMAGE}:latest" || true + echo "================================================================" +fi + + +echo "================================================================" +echo "Running the full build $(date)." +# The default user for a Docker container has uid 0 (root). To avoid creating +# root-owned files in the build directory we tell docker to use the current +# user ID, if known. +docker_uid="${UID:-0}" +docker_user="${USER:-root}" +docker_home_prefix="${PWD}/cmake-out/home" +if [[ "${docker_uid}" == "0" ]]; then + docker_home_prefix="${PWD}/cmake-out/root" +fi + +# Make sure the user has a $HOME directory inside the Docker container. +mkdir -p "${BUILD_HOME}" +mkdir -p "${BUILD_OUTPUT}" + +# We use an array for the flags so they are easier to document. +docker_flags=( + # Grant the PTRACE capability to the Docker container running the build, + # this is needed by tools like AddressSanitizer. + "--cap-add" "SYS_PTRACE" + + # The name and version of the distribution, this is used to call + # define-docker-variables.sh and determine the Docker image built, and the + # output directory for any artifacts. + "--env" "DISTRO=${DISTRO}" + "--env" "DISTRO_VERSION=${DISTRO_VERSION}" + + # The C++ and C compiler, both Bazel and CMake use this environment variable + # to select the compiler binary. + "--env" "CXX=${CXX}" + "--env" "CC=${CC}" + + # If set to 'yes', the build script will run the style checks, including + # clang-format, cmake-format, and buildifier. + "--env" "CHECK_STYLE=${CHECK_STYLE:-}" + + # If set to 'yes', the build script will configure clang-tidy. Currently + # only the CMake builds use this flag. + "--env" "CLANG_TIDY=${CLANG_TIDY:-}" + + # If set to 'yes', run the integration tests. Currently only the Bazel + # builds use this flag. + "--env" "RUN_INTEGRATION_TESTS=${RUN_INTEGRATION_TESTS:-}" + + # If set to 'yes', run compile with code coverage flags. Currently only the + # CMake builds use this flag. + "--env" "CODE_COVERAGE=${CODE_COVERAGE:-}" + + # If set to 'yes', use Ninja as the CMake generator. Ninja is more strict + # that Make and can detect errors in your CMake files, it is also faster. + "--env" "USE_NINJA=${USE_NINJA:-}" + + # If set, pass -DGOOGLE_CLOUD_CPP_CXX_STANDARD=<value> to CMake. + "--env" "GOOGLE_CLOUD_CPP_CXX_STANDARD=${GOOGLE_CLOUD_CPP_CXX_STANDARD:-}" + + # When running the integration tests this directory contains the + # configuration files needed to run said tests. Make it available inside + # the Docker container. + "--volume" "${KOKORO_GFILE_DIR:-/dev/shm}:/c" + + # Let the Docker image script know what kind of terminal we are using, that + # produces properly colorized error messages. + "--env" "TERM=${TERM:-dumb}" + + # Run the docker script and this user id. Because the docker image gets to + # write in ${PWD} you typically want this to be your user id. + "--user" "${docker_uid}" + + # Bazel needs this environment variable to work correctly. + "--env" "USER=${docker_user}" + + # We give Bazel and CMake a fake $HOME inside the docker image. Bazel caches + # build byproducts in this directory. CMake (when ccache is enabled) uses + # it to store $HOME/.ccache + "--env" "HOME=/h" + "--volume" "${PWD}/${BUILD_HOME}:/h" + + # Mount the current directory (which is the top-level directory for the + # project) as `/v` inside the docker image, and move to that directory. + "--volume" "${PWD}:/v" + "--workdir" "/v" + + # Mask any other builds that may exist at the same time. That is, these + # directories appear as empty inside the Docker container, this prevents the + # container from writing into other builds, or to get confused by the output + # of other builds. In the CI system this does not matter, as each build runs + # on a completely separate VM. This is useful when running multiple builds + # in your workstation. + "--volume" "/v/cmake-out/home" + "--volume" "/v/cmake-out" + "--volume" "${PWD}/${BUILD_OUTPUT}:/v/${BUILD_OUTPUT}" +) + +# When running the builds from the command-line they get a tty, and the scripts +# running inside the Docker container can produce nicer output. On Kokoro the +# script does not get a tty, and Docker terminates the program if we pass the +# `-it` flag. +if [[ -t 0 ]]; then + docker_flags+=("-it") +fi + +docker run "${docker_flags[@]}" "${IMAGE}:latest" \ + "/v/${in_docker_script}" "${CMAKE_SOURCE_DIR}" \ + "${BUILD_OUTPUT}" diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/clang-3.8-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/clang-3.8-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/clang-3.8-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/clang-3.8.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/clang-3.8.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/clang-3.8.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/clang-tidy-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/clang-tidy-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/clang-tidy-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/clang-tidy.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/clang-tidy.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/clang-tidy.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/common.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/common.cfg new file mode 100644 index 000000000000..213d93419a12 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/common.cfg @@ -0,0 +1,17 @@ +# Format: //devtools/kokoro/config/proto/build.proto +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +build_file: "cpp-cmakefiles/ci/kokoro/docker/build.sh" +timeout_mins: 120 diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/gcc-4.8-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/gcc-4.8-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/gcc-4.8-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/gcc-4.8.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/gcc-4.8.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/gcc-4.8.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/ninja-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/ninja-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/ninja-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/ninja.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/ninja.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/ninja.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-16.04-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-16.04-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-16.04-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-16.04.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-16.04.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-16.04.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-18.04-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-18.04-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-18.04-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-18.04.cfg b/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-18.04.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/docker/ubuntu-18.04.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.centos-7 b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.centos-7 new file mode 100644 index 000000000000..21b8908134d4 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.centos-7 @@ -0,0 +1,105 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM centos:7 AS devtools + +# Please keep the formatting in these commands, it is optimized to cut & paste +# into the INSTALL.md file. + +## [START INSTALL.md] + +# First install the development tools and OpenSSL. The development tools +# distributed with CentOS (notably CMake) are too old to build +# `cpp-cmakefiles`. In these instructions, we use `cmake3` obtained from +# [Software Collections](https://www.softwarecollections.org/). + +# ```bash +RUN rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm +RUN yum install -y centos-release-scl +RUN yum-config-manager --enable rhel-server-rhscl-7-rpms +RUN yum makecache && \ + yum install -y automake cmake3 curl-devel gcc gcc-c++ git libtool \ + make openssl-devel pkgconfig tar wget which zlib-devel +RUN ln -sf /usr/bin/cmake3 /usr/bin/cmake && ln -sf /usr/bin/ctest3 /usr/bin/ctest +# ``` + +# #### Protobuf + +# Likewise, manually install protobuf: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz +RUN tar -xf v3.9.0.tar.gz +WORKDIR /var/tmp/build/protobuf-3.9.0/cmake +RUN cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=yes \ + -Dprotobuf_BUILD_TESTS=OFF \ + -H. -Bcmake-out +RUN cmake --build cmake-out --target install -- -j $(nproc) +RUN ldconfig +# ``` + +# #### c-ares + +# Recent versions of gRPC require c-ares >= 1.11, while CentOS-7 +# distributes c-ares-1.10. Manually install a newer version: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz +RUN tar -xf cares-1_15_0.tar.gz +WORKDIR /var/tmp/build/c-ares-cares-1_15_0 +RUN ./buildconf && ./configure && make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +# #### gRPC + +# Can be manually installed using: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz +RUN tar -xf v1.22.0.tar.gz +WORKDIR /var/tmp/build/grpc-1.22.0 +ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig +ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 +ENV PATH=/usr/local/bin:${PATH} +RUN make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +FROM devtools AS install + +# #### googleapis + +# Finally we can install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.fedora-30 b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.fedora-30 new file mode 100644 index 000000000000..d6e57b91e232 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.fedora-30 @@ -0,0 +1,58 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM fedora:30 AS devtools + +# Please keep the formatting below, it is used by `extract-install.md` +# to generate the contents of the top-level INSTALL.md. + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN dnf makecache && \ + dnf install -y cmake gcc-c++ git make openssl-devel pkgconfig \ + zlib-devel +# ``` + +# Fedora includes packages for gRPC, libcurl, and OpenSSL that are recent enough +# for `cpp-cmakefiles`. Install these packages and additional development +# tools to compile the dependencies: + +# ```bash +RUN dnf makecache && \ + dnf install -y grpc-devel grpc-plugins \ + libcurl-devel protobuf-compiler tar wget zlib-devel +# ``` + +FROM devtools AS install + +# #### googleapis + +# We can now compile and install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.fedora-30-shared b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.fedora-30-shared new file mode 100644 index 000000000000..572018f994dc --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.fedora-30-shared @@ -0,0 +1,62 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM fedora:30 AS devtools + +# Please keep the formatting below, it is used by `extract-install.md` +# to generate the contents of the top-level INSTALL.md. + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN dnf makecache && \ + dnf install -y cmake gcc-c++ git make openssl-devel pkgconfig \ + zlib-devel +# ``` + +# Fedora includes packages for gRPC, libcurl, and OpenSSL that are recent enough +# for `cpp-cmakefiles`. Install these packages and additional development +# tools to compile the dependencies: + +# ```bash +RUN dnf makecache && \ + dnf install -y grpc-devel grpc-plugins \ + libcurl-devel protobuf-compiler tar wget zlib-devel +# ``` + +FROM devtools AS install + +# #### googleapis + +# We can now compile and install `googleapis` as shared library. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out -DBUILD_SHARED_LIBS=yes +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# The share libraries will install in `/usr/local/lib64` we need that directory +# in the ld.so cache: +RUN echo "/usr/local/lib64" | tee /etc/ld.so.conf.d/local.conf +RUN ldconfig +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.opensuse-leap b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.opensuse-leap new file mode 100644 index 000000000000..ea2dda5ec4e6 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.opensuse-leap @@ -0,0 +1,114 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM opensuse/leap:latest AS devtools + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN zypper refresh && \ + zypper install --allow-downgrade -y cmake gcc gcc-c++ git gzip \ + libcurl-devel libopenssl-devel make tar wget +# ``` + +# #### Protobuf + +# OpenSUSE Leap includes a package for protobuf-2.6, but this is too old to +# support the Google Cloud Platform proto files, or to support gRPC for that +# matter. Manually install protobuf: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz +RUN tar -xf v3.9.0.tar.gz +WORKDIR /var/tmp/build/protobuf-3.9.0/cmake +RUN cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=yes \ + -Dprotobuf_BUILD_TESTS=OFF \ + -H. -Bcmake-out +RUN cmake --build cmake-out --target install -- -j $(nproc) +RUN ldconfig +# ``` + +# #### c-ares + +# Recent versions of gRPC require c-ares >= 1.11, while OpenSUSE Leap +# distributes c-ares-1.9. We need some additional development tools to compile +# this library: + +# ```bash +RUN zypper refresh && \ + zypper install -y automake libtool +# ``` + +# Manually install a newer version: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz +RUN tar -xf cares-1_15_0.tar.gz +WORKDIR /var/tmp/build/c-ares-cares-1_15_0 +RUN ./buildconf && ./configure && make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +# #### gRPC + +# The gRPC Makefile uses `which` to determine whether the compiler is available. +# Install this command for the extremely rare case where it may be missing from +# your workstation or build server: + +# ```bash +RUN zypper refresh && \ + zypper install -y which +# ``` + +# Then gRPC can be manually installed using: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz +RUN tar -xf v1.22.0.tar.gz +WORKDIR /var/tmp/build/grpc-1.22.0 +ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig +ENV LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64 +ENV PATH=/usr/local/bin:${PATH} +RUN make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +FROM devtools AS install + +# #### googleapis + +# We can now compile and install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.opensuse-tumbleweed b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.opensuse-tumbleweed new file mode 100644 index 000000000000..9a87337870e3 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.opensuse-tumbleweed @@ -0,0 +1,54 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM opensuse/tumbleweed:latest AS devtools + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN zypper refresh && \ + zypper install --allow-downgrade -y cmake gcc gcc-c++ git gzip \ + libcurl-devel libopenssl-devel make tar wget zlib-devel +# ``` + +# OpenSUSE:tumbleweed provides packages for gRPC, libcurl, and protobuf, and the +# versions of these packages are recent enough to support the Google Cloud +# Platform proto files. + +# ```bash +RUN zypper refresh && \ + zypper install -y grpc-devel gzip libcurl-devel tar wget +# ``` + +FROM devtools AS install + +# #### googleapis + +# We can now compile and install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.ubuntu-16.04 b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.ubuntu-16.04 new file mode 100644 index 000000000000..030ed4a2aa85 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.ubuntu-16.04 @@ -0,0 +1,100 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:16.04 AS devtools + +# Please keep the formatting in these commands, it is optimized to cut & paste +# into the README.md file. + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN apt update && \ + apt install -y automake build-essential cmake git gcc g++ cmake \ + libcurl4-openssl-dev libssl-dev libtool make pkg-config tar wget \ + zlib1g-dev +# ``` + +# #### c-ares + +# Recent versions of gRPC require c-ares >= 1.11, while Ubuntu-16.04 +# distributes c-ares-1.10. We can manually install a newer version +# of c-ares: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/c-ares/c-ares/archive/cares-1_15_0.tar.gz +RUN tar -xf cares-1_15_0.tar.gz +WORKDIR /var/tmp/build/c-ares-cares-1_15_0 +RUN ./buildconf && ./configure && make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +# #### Protobuf + +# While protobuf-3.0 is distributed with Ubuntu, the Google Cloud Plaform proto +# files require more recent versions (circa 3.4.x). To manually install a more +# recent version use: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz +RUN tar -xf v3.9.0.tar.gz +WORKDIR /var/tmp/build/protobuf-3.9.0/cmake +RUN cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=yes \ + -Dprotobuf_BUILD_TESTS=OFF \ + -H. -Bcmake-out +RUN cmake --build cmake-out --target install -- -j $(nproc) +RUN ldconfig +# ``` + +# #### gRPC + +# Likewise, Ubuntu has packages for grpc-1.3.x, but this version is too old for +# the Google Cloud Platform APIs: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz +RUN tar -xf v1.22.0.tar.gz +WORKDIR /var/tmp/build/grpc-1.22.0 +RUN make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +FROM devtools AS install + +# #### googleapis + +# Finally we can install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.ubuntu-18.04 b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.ubuntu-18.04 new file mode 100644 index 000000000000..486d24aa47db --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/Dockerfile.ubuntu-18.04 @@ -0,0 +1,84 @@ +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM ubuntu:18.04 AS devtools + +# Please keep the formatting in these commands, it is optimized to cut & paste +# into the README.md file. + +## [START INSTALL.md] + +# Install the minimal development tools: + +# ```bash +RUN apt update && \ + apt install -y build-essential cmake git gcc g++ cmake \ + libc-ares-dev libc-ares2 libcurl4-openssl-dev libssl-dev make \ + pkg-config tar wget zlib1g-dev +# ``` + +# #### Protobuf + +# While protobuf-3.0 is distributed with Ubuntu, the Google Cloud Plaform proto +# files require more recent versions (circa 3.4.x). To manually install a more +# recent version use: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/google/protobuf/archive/v3.9.0.tar.gz +RUN tar -xf v3.9.0.tar.gz +WORKDIR /var/tmp/build/protobuf-3.9.0/cmake +RUN cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=yes \ + -Dprotobuf_BUILD_TESTS=OFF \ + -H. -Bcmake-out +RUN cmake --build cmake-out --target install -- -j $(nproc) +RUN ldconfig +# ``` + +# #### gRPC + +# Likewise, Ubuntu has packages for grpc-1.3.x, but this version is too old for +# the Google Cloud Platform APIs: + +# ```bash +WORKDIR /var/tmp/build +RUN wget -q https://github.com/grpc/grpc/archive/v1.22.0.tar.gz +RUN tar -xf v1.22.0.tar.gz +WORKDIR /var/tmp/build/grpc-1.22.0 +RUN make -j $(nproc) +RUN make install +RUN ldconfig +# ``` + +FROM devtools AS install + +# #### googleapis + +# Finally we can install `googleapis`. + +# ```bash +WORKDIR /home/build/cpp-cmakefiles +COPY . /home/build/cpp-cmakefiles +RUN cmake -H. -Bcmake-out +RUN cmake --build cmake-out -- -j $(nproc) +WORKDIR /home/build/cpp-cmakefiles/cmake-out +RUN cmake --build . --target install +# ``` + +## [END INSTALL.md] + +# Verify that the installed files are actually usable +RUN /home/build/cpp-cmakefiles/ci/test-install/compile-test-projects.sh diff --git a/third_party/cpp/googleapis/ci/kokoro/install/build.sh b/third_party/cpp/googleapis/ci/kokoro/install/build.sh new file mode 100755 index 000000000000..42e85f39b6fc --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/build.sh @@ -0,0 +1,106 @@ +#!/usr/bin/env bash +# +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +if [[ $# -eq 1 ]]; then + export TEST_TARGET="${1}" +elif [[ -n "${KOKORO_JOB_NAME:-}" ]]; then + # Kokoro injects the KOKORO_JOB_NAME environment variable, the value of this + # variable is cloud-cpp/spanner/<config-file-name-without-cfg> (or more + # generally <path/to/config-file-without-cfg>). By convention we name these + # files `$foo.cfg` for continuous builds and `$foo-presubmit.cfg` for + # presubmit builds. Here we extract the value of "foo" and use it as the build + # name. + TEST_TARGET="$(basename "${KOKORO_JOB_NAME}" "-presubmit")" + export TEST_TARGET +else + echo "Aborting build as the distribution name is not defined." + echo "If you are invoking this script via the command line use:" + echo " $0 <distro-name>" + echo + echo "If this script is invoked by Kokoro, the CI system is expected to set" + echo "the KOKORO_JOB_NAME environment variable." + exit 1 +fi + +echo "================================================================" +echo "Change working directory to project root $(date)." +cd "$(dirname "$0")/../../.." + +if [[ -z "${PROJECT_ID+x}" ]]; then + readonly PROJECT_ID="cloud-devrel-kokoro-resources" +fi + +readonly DEV_IMAGE="gcr.io/${PROJECT_ID}/cpp-cmakefiles/test-install-dev-${TEST_TARGET}" +readonly IMAGE="gcr.io/${PROJECT_ID}/cpp-cmakefiles/test-install-${TEST_TARGET}" + +has_cache="false" + +# We download the cached dev image for pull requests on kokoro. For continuous +# jobs, we don't download the cached image. This means we build from scratch and +# upload the image for future builds for pull requests. +if [[ -n "${KOKORO_JOB_NAME:-}" ]] \ + && [[ -n "${KOKORO_GITHUB_PULL_REQUEST_NUMBER:-}" ]]; then + echo "================================================================" + echo "Download existing image (if available) for ${TEST_TARGET} $(date)." + if docker pull "${DEV_IMAGE}:latest"; then + echo "Existing image successfully downloaded." + has_cache="true" + fi + echo "================================================================" +fi + +echo "================================================================" +echo "Build base image with minimal development tools for ${TEST_TARGET} $(date)." +update_cache="false" + +devtools_flags=( + # Only build up to the stage that installs the minimal development tools, but + # does not compile any of our code. + "--target" "devtools" + # Create the image with the same tag as the cache we are using, so we can + # upload it. + "-t" "${DEV_IMAGE}:latest" + "-f" "ci/kokoro/install/Dockerfile.${TEST_TARGET}" +) + +if "${has_cache}"; then + devtools_flags+=("--cache-from=${DEV_IMAGE}:latest") +fi + +echo "Running docker build with " "${devtools_flags[@]}" +if docker build "${devtools_flags[@]}" ci; then + update_cache="true" +fi + +# We upload the cached image for continuous builds. +if "${update_cache}" && [[ -z "${KOKORO_GITHUB_PULL_REQUEST_NUMBER:-}" ]] \ + && [[ -n "${KOKORO_JOB_NAME:-}" ]]; then + echo "================================================================" + echo "Uploading updated base image for ${TEST_TARGET} $(date)." + # Do not stop the build on a failure to update the cache. + docker push "${DEV_IMAGE}:latest" || true +fi + +echo "================================================================" +echo "Run validation script for INSTALL instructions on ${TEST_TARGET}." +docker build \ + "--cache-from=${DEV_IMAGE}:latest" \ + "--target=install" \ + -t "${IMAGE}" \ + -f "ci/kokoro/install/Dockerfile.${TEST_TARGET}" . +echo "================================================================" diff --git a/third_party/cpp/googleapis/ci/kokoro/install/centos-7-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/install/centos-7-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/centos-7-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/centos-7.cfg b/third_party/cpp/googleapis/ci/kokoro/install/centos-7.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/centos-7.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/common.cfg b/third_party/cpp/googleapis/ci/kokoro/install/common.cfg new file mode 100644 index 000000000000..77a3a1f9fefe --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/common.cfg @@ -0,0 +1,17 @@ +# Format: //devtools/kokoro/config/proto/build.proto +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +build_file: "cpp-cmakefiles/ci/kokoro/install/build.sh" +timeout_mins: 120 diff --git a/third_party/cpp/googleapis/ci/kokoro/install/fedora-30-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/install/fedora-30-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/fedora-30-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/fedora-30-shared-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/install/fedora-30-shared-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/fedora-30-shared-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/fedora-30-shared.cfg b/third_party/cpp/googleapis/ci/kokoro/install/fedora-30-shared.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/fedora-30-shared.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/fedora-30.cfg b/third_party/cpp/googleapis/ci/kokoro/install/fedora-30.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/fedora-30.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/opensuse-leap-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/install/opensuse-leap-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/opensuse-leap-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/opensuse-leap.cfg b/third_party/cpp/googleapis/ci/kokoro/install/opensuse-leap.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/opensuse-leap.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/opensuse-tumbleweed-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/install/opensuse-tumbleweed-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/opensuse-tumbleweed-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/opensuse-tumbleweed.cfg b/third_party/cpp/googleapis/ci/kokoro/install/opensuse-tumbleweed.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/opensuse-tumbleweed.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-16.04-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-16.04-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-16.04-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-16.04.cfg b/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-16.04.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-16.04.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-18.04-presubmit.cfg b/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-18.04-presubmit.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-18.04-presubmit.cfg diff --git a/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-18.04.cfg b/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-18.04.cfg new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/third_party/cpp/googleapis/ci/kokoro/install/ubuntu-18.04.cfg diff --git a/third_party/cpp/googleapis/ci/retry-command.sh b/third_party/cpp/googleapis/ci/retry-command.sh new file mode 100755 index 000000000000..190bce481712 --- /dev/null +++ b/third_party/cpp/googleapis/ci/retry-command.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +# Make three attempts to install the dependencies. It is rare, but from time to +# time the downloading the packages, building the Docker images, or an installer +# Bazel, or the Google Cloud SDK fails. To make the CI build more robust, try +# again when that happens. + +if (( $# < 1 )); then + echo "Usage: $(basename "$0") program [arguments]" + exit 1 +fi +readonly PROGRAM=${1} +shift + +# Initially, wait at least 2 minutes (the times are in seconds), because it +# makes no sense to try faster. This used to be 180 seconds, but that ends with +# sleeps close to 10 minutes, and Travis aborts builds that do not output in +# 10m. +min_wait=120 +# Do not exit on failures for this loop. +set +e +for i in 1 2 3; do + if "${PROGRAM}" "$@"; then + exit 0 + fi + # Sleep for a few minutes before trying again. + period=$(( (RANDOM % 60) + min_wait )) + echo "${PROGRAM} failed (attempt ${i}); trying again in ${period} seconds." + sleep ${period}s + min_wait=$(( min_wait * 2 )) +done + +exit 1 diff --git a/third_party/cpp/googleapis/ci/test-install/bigquery/CMakeLists.txt b/third_party/cpp/googleapis/ci/test-install/bigquery/CMakeLists.txt new file mode 100644 index 000000000000..3086ef4617f4 --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/bigquery/CMakeLists.txt @@ -0,0 +1,28 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +cmake_minimum_required(VERSION 3.5) + +project(utilize-googleapis CXX C) + +# Configure the compiler options, we will be using C++11 features. +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(googleapis REQUIRED) + +add_executable(utilize-googleapis main.cc) +target_link_libraries(utilize-googleapis googleapis-c++::cloud_bigquery_protos) diff --git a/third_party/cpp/googleapis/ci/test-install/bigquery/Makefile b/third_party/cpp/googleapis/ci/test-install/bigquery/Makefile new file mode 100644 index 000000000000..bca2a7dc57fc --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/bigquery/Makefile @@ -0,0 +1,36 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A simple Makefile to test the `install` target. +# +# This is not intended to be a demonstration of how to write good Makefiles, +# nor is it a general solution on how to build Makefiles for google-cloud-cpp. +# It is simply a minimal file to test the installed pkg-config support files. + +# The CXX, CXXFLAGS and CXXLD variables are hard-coded. These values work for +# our tests, but applications would typically make them configurable parameters. +CXX=g++ -std=c++11 +CXXLD=$(CXX) + +all: main + +# Configuration variables to compile and link against the library. +PROTOS := googleapis_cpp_cloud_bigquery_protos +CXXFLAGS := $(shell pkg-config $(PROTOS) --cflags) +CXXLDFLAGS := $(shell pkg-config $(PROTOS) --libs-only-L) +LIBS := $(shell pkg-config $(PROTOS) --libs-only-l) + +# A target using the Google Cloud Storage C++ client library. +main: main.cc + $(CXXLD) $(CXXFLAGS) $(CXXFLAGS) $(CXXLDFLAGS) -o $@ $^ $(LIBS) diff --git a/third_party/cpp/googleapis/ci/test-install/bigquery/main.cc b/third_party/cpp/googleapis/ci/test-install/bigquery/main.cc new file mode 100644 index 000000000000..bd00013eddb8 --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/bigquery/main.cc @@ -0,0 +1,22 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include <google/cloud/bigquery/storage/v1beta1/storage.grpc.pb.h> +#include <grpcpp/grpcpp.h> + +int main() { + auto creds = grpc::InsecureChannelCredentials(); + auto channel = grpc::CreateChannel("localhost:12345", creds); + auto stub = google::cloud::bigquery::storage::v1beta1::BigQueryStorage::NewStub(channel); +} diff --git a/third_party/cpp/googleapis/ci/test-install/bigtable/CMakeLists.txt b/third_party/cpp/googleapis/ci/test-install/bigtable/CMakeLists.txt new file mode 100644 index 000000000000..7aed05ff1d8d --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/bigtable/CMakeLists.txt @@ -0,0 +1,28 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +cmake_minimum_required(VERSION 3.5) + +project(utilize-googleapis CXX C) + +# Configure the compiler options, we will be using C++11 features. +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(googleapis REQUIRED) + +add_executable(utilize-googleapis main.cc) +target_link_libraries(utilize-googleapis googleapis-c++::bigtable_protos) diff --git a/third_party/cpp/googleapis/ci/test-install/bigtable/Makefile b/third_party/cpp/googleapis/ci/test-install/bigtable/Makefile new file mode 100644 index 000000000000..5643b234d7fd --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/bigtable/Makefile @@ -0,0 +1,36 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A simple Makefile to test the `install` target. +# +# This is not intended to be a demonstration of how to write good Makefiles, +# nor is it a general solution on how to build Makefiles for google-cloud-cpp. +# It is simply a minimal file to test the installed pkg-config support files. + +# The CXX, CXXFLAGS and CXXLD variables are hard-coded. These values work for +# our tests, but applications would typically make them configurable parameters. +CXX=g++ -std=c++11 +CXXLD=$(CXX) + +all: main + +# Configuration variables to compile and link against the library. +PROTOS := googleapis_cpp_bigtable_protos +CXXFLAGS := $(shell pkg-config $(PROTOS) --cflags) +CXXLDFLAGS := $(shell pkg-config $(PROTOS) --libs-only-L) +LIBS := $(shell pkg-config $(PROTOS) --libs-only-l) + +# A target using the Google Cloud Storage C++ client library. +main: main.cc + $(CXXLD) $(CXXFLAGS) $(CXXFLAGS) $(CXXLDFLAGS) -o $@ $^ $(LIBS) diff --git a/third_party/cpp/googleapis/ci/test-install/bigtable/main.cc b/third_party/cpp/googleapis/ci/test-install/bigtable/main.cc new file mode 100644 index 000000000000..08fce3c7bc68 --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/bigtable/main.cc @@ -0,0 +1,22 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include <google/bigtable/v2/bigtable.grpc.pb.h> +#include <grpcpp/grpcpp.h> + +int main() { + auto creds = grpc::InsecureChannelCredentials(); + auto channel = grpc::CreateChannel("localhost:12345", creds); + auto stub = google::bigtable::v2::Bigtable::NewStub(channel); +} diff --git a/third_party/cpp/googleapis/ci/test-install/compile-test-projects.sh b/third_party/cpp/googleapis/ci/test-install/compile-test-projects.sh new file mode 100755 index 000000000000..25eea82ffc7f --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/compile-test-projects.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Compile projects that utilize the cpp-cmakefiles header files and libraries +# installed to the system. This script expects that the entire source tree is +# copied to /home/build/cpp-cmakefiles. Don't try to run this locally. + +set -eu + +# Verify the installed CMake config and pkgconfig files are actually usable. + +for subdir in bigquery bigtable pubsub spanner; do + # Compile a test program using CMake. + echo "================================================================" + echo "Testing ${subdir} $(date) with CMake" + echo "================================================================" + src_dir="/home/build/cpp-cmakefiles/ci/test-install/${subdir}" + cmake_dir="/home/build/test-cmake-${subdir}" + make_dir="/home/build/test-make-${subdir}" + cmake -H"${src_dir}" -B"${cmake_dir}" + cmake --build "${cmake_dir}" -- -j "$(nproc)" + # Verify the generated program is runnable + "${cmake_dir}/utilize-googleapis" + echo "================================================================" + echo "Testing ${subdir} $(date) with Make" + echo "================================================================" + cp -R "${src_dir}" "${make_dir}" + cd "${make_dir}" + # With Make we may need to set PKG_CONFIG_PATH because the code is installed + # in /usr/local and that is not a default search location in some distros. + env PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig:/usr/local/lib/pkgconfig \ + make + # Verify the generated program is runnable + "${make_dir}/main" +done diff --git a/third_party/cpp/googleapis/ci/test-install/pubsub/CMakeLists.txt b/third_party/cpp/googleapis/ci/test-install/pubsub/CMakeLists.txt new file mode 100644 index 000000000000..cc8d59e187af --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/pubsub/CMakeLists.txt @@ -0,0 +1,28 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +cmake_minimum_required(VERSION 3.5) + +project(utilize-googleapis CXX C) + +# Configure the compiler options, we will be using C++11 features. +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(googleapis REQUIRED) + +add_executable(utilize-googleapis main.cc) +target_link_libraries(utilize-googleapis googleapis-c++::pubsub_protos) diff --git a/third_party/cpp/googleapis/ci/test-install/pubsub/Makefile b/third_party/cpp/googleapis/ci/test-install/pubsub/Makefile new file mode 100644 index 000000000000..a5cbdcf78911 --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/pubsub/Makefile @@ -0,0 +1,36 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A simple Makefile to test the `install` target. +# +# This is not intended to be a demonstration of how to write good Makefiles, +# nor is it a general solution on how to build Makefiles for google-cloud-cpp. +# It is simply a minimal file to test the installed pkg-config support files. + +# The CXX, CXXFLAGS and CXXLD variables are hard-coded. These values work for +# our tests, but applications would typically make them configurable parameters. +CXX=g++ -std=c++11 +CXXLD=$(CXX) + +all: main + +# Configuration variables to compile and link against the library. +PROTOS := googleapis_cpp_pubsub_protos +CXXFLAGS := $(shell pkg-config $(PROTOS) --cflags) +CXXLDFLAGS := $(shell pkg-config $(PROTOS) --libs-only-L) +LIBS := $(shell pkg-config $(PROTOS) --libs-only-l) + +# A target using the Google Cloud Storage C++ client library. +main: main.cc + $(CXXLD) $(CXXFLAGS) $(CXXFLAGS) $(CXXLDFLAGS) -o $@ $^ $(LIBS) diff --git a/third_party/cpp/googleapis/ci/test-install/pubsub/main.cc b/third_party/cpp/googleapis/ci/test-install/pubsub/main.cc new file mode 100644 index 000000000000..05549169dafc --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/pubsub/main.cc @@ -0,0 +1,22 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include <google/pubsub/v1/pubsub.grpc.pb.h> +#include <grpcpp/grpcpp.h> + +int main() { + auto creds = grpc::InsecureChannelCredentials(); + auto channel = grpc::CreateChannel("localhost:12345", creds); + auto stub = google::pubsub::v1::Publisher::NewStub(channel); +} diff --git a/third_party/cpp/googleapis/ci/test-install/spanner/CMakeLists.txt b/third_party/cpp/googleapis/ci/test-install/spanner/CMakeLists.txt new file mode 100644 index 000000000000..2a4577ace91f --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/spanner/CMakeLists.txt @@ -0,0 +1,28 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +cmake_minimum_required(VERSION 3.5) + +project(utilize-googleapis CXX C) + +# Configure the compiler options, we will be using C++11 features. +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +find_package(googleapis REQUIRED) + +add_executable(utilize-googleapis main.cc) +target_link_libraries(utilize-googleapis googleapis-c++::spanner_protos) diff --git a/third_party/cpp/googleapis/ci/test-install/spanner/Makefile b/third_party/cpp/googleapis/ci/test-install/spanner/Makefile new file mode 100644 index 000000000000..74bf292ce6ab --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/spanner/Makefile @@ -0,0 +1,36 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A simple Makefile to test the `install` target. +# +# This is not intended to be a demonstration of how to write good Makefiles, +# nor is it a general solution on how to build Makefiles for google-cloud-cpp. +# It is simply a minimal file to test the installed pkg-config support files. + +# The CXX, CXXFLAGS and CXXLD variables are hard-coded. These values work for +# our tests, but applications would typically make them configurable parameters. +CXX=g++ -std=c++11 +CXXLD=$(CXX) + +all: main + +# Configuration variables to compile and link against the library. +PROTOS := googleapis_cpp_spanner_protos +CXXFLAGS := $(shell pkg-config $(PROTOS) --cflags) +CXXLDFLAGS := $(shell pkg-config $(PROTOS) --libs-only-L) +LIBS := $(shell pkg-config $(PROTOS) --libs-only-l) + +# A target using the Google Cloud Storage C++ client library. +main: main.cc + $(CXXLD) $(CXXFLAGS) $(CXXFLAGS) $(CXXLDFLAGS) -o $@ $^ $(LIBS) diff --git a/third_party/cpp/googleapis/ci/test-install/spanner/main.cc b/third_party/cpp/googleapis/ci/test-install/spanner/main.cc new file mode 100644 index 000000000000..f1866655ac7f --- /dev/null +++ b/third_party/cpp/googleapis/ci/test-install/spanner/main.cc @@ -0,0 +1,22 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include <google/spanner/v1/spanner.grpc.pb.h> +#include <grpcpp/grpcpp.h> + +int main() { + auto creds = grpc::InsecureChannelCredentials(); + auto channel = grpc::CreateChannel("localhost:12345", creds); + auto stub = google::spanner::v1::Spanner::NewStub(channel); +} diff --git a/third_party/cpp/googleapis/cmake/CompileProtos.cmake b/third_party/cpp/googleapis/cmake/CompileProtos.cmake new file mode 100644 index 000000000000..788267c8d99e --- /dev/null +++ b/third_party/cpp/googleapis/cmake/CompileProtos.cmake @@ -0,0 +1,271 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +# Introduce a new TARGET property to associate proto files with a target. +# +# We use a function to define the property so it can be called multiple times +# without introducing the property over and over. +function (google_cloud_cpp_add_protos_property) + set_property( + TARGET + PROPERTY PROTO_SOURCES BRIEF_DOCS + "The list of .proto files for a target." FULL_DOCS + "List of .proto files specified for a target.") +endfunction () + +# Generate C++ for .proto files preserving the directory hierarchy +# +# Receives a list of `.proto` file names and (a) creates the runs to convert +# these files to `.pb.h` and `.pb.cc` output files, (b) returns the list of +# `.pb.cc` files and `.pb.h` files in @p HDRS, and (c) creates the list of files +# preserving the directory hierarchy, such that if a `.proto` file says: +# +# import "foo/bar/baz.proto" +# +# the resulting C++ code says: +# +# #include <foo/bar/baz.pb.h> +# +# Use the `PROTO_PATH` option to provide one or more directories to search for +# proto files in the import. +# +# @par Example +# +# google_cloud_cpp_generate_proto( MY_PB_FILES "foo/bar/baz.proto" +# "foo/bar/qux.proto" PROTO_PATH_DIRECTORIES "another/dir/with/protos") +# +# Note that `protoc` the protocol buffer compiler requires your protos to be +# somewhere in the search path defined by the `--proto_path` (aka -I) options. +# For example, if you want to generate the `.pb.{h,cc}` files for +# `foo/bar/baz.proto` then the directory containing `foo` must be in the search +# path. +function (google_cloud_cpp_generate_proto SRCS) + cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN}) + if (NOT _opt_UNPARSED_ARGUMENTS) + message(SEND_ERROR "Error: google_cloud_cpp_generate_proto() called" + " without any proto files") + return() + endif () + + # Build the list of `--proto_path` options. Use the absolute path for each + # option given, and do not include any path more than once. + set(protobuf_include_path) + foreach (dir ${_opt_PROTO_PATH_DIRECTORIES}) + get_filename_component(absolute_path ${dir} ABSOLUTE) + list(FIND protobuf_include_path "${absolute_path}" + already_in_search_path) + if (${already_in_search_path} EQUAL -1) + list(APPEND protobuf_include_path "--proto_path" "${absolute_path}") + endif () + endforeach () + + set(${SRCS}) + foreach (filename ${_opt_UNPARSED_ARGUMENTS}) + get_filename_component(file_directory "${filename}" DIRECTORY) + # This gets the filename without the extension, analogous to $(basename + # "${filename}" .proto) + get_filename_component(file_stem "${filename}" NAME_WE) + + # Strip all the prefixes in ${_opt_PROTO_PATH_DIRECTORIES} from the + # source proto directory + set(D "${file_directory}") + if (DEFINED _opt_PROTO_PATH_DIRECTORIES) + foreach (P ${_opt_PROTO_PATH_DIRECTORIES}) + string(REGEX REPLACE "^${P}" "" T "${D}") + set(D ${T}) + endforeach () + endif () + set(pb_cc "${CMAKE_CURRENT_BINARY_DIR}/${D}/${file_stem}.pb.cc") + set(pb_h "${CMAKE_CURRENT_BINARY_DIR}/${D}/${file_stem}.pb.h") + list(APPEND ${SRCS} "${pb_cc}" "${pb_h}") + add_custom_command( + OUTPUT "${pb_cc}" "${pb_h}" + COMMAND + $<TARGET_FILE:protobuf::protoc> ARGS --cpp_out + "${CMAKE_CURRENT_BINARY_DIR}" ${protobuf_include_path} + "${filename}" + DEPENDS "${filename}" protobuf::protoc + COMMENT "Running C++ protocol buffer compiler on ${filename}" + VERBATIM) + endforeach () + + set_source_files_properties(${${SRCS}} PROPERTIES GENERATED TRUE) + set(${SRCS} + ${${SRCS}} + PARENT_SCOPE) +endfunction () + +# Generate gRPC C++ files from .proto files preserving the directory hierarchy. +# +# Receives a list of `.proto` file names and (a) creates the runs to convert +# these files to `.grpc.pb.h` and `.grpc.pb.cc` output files, (b) returns the +# list of `.grpc.pb.cc` and `.pb.h` files in @p SRCS, and (c) creates the list +# of files preserving the directory hierarchy, such that if a `.proto` file says +# +# import "foo/bar/baz.proto" +# +# the resulting C++ code says: +# +# #include <foo/bar/baz.pb.h> +# +# Use the `PROTO_PATH` option to provide one or more directories to search for +# proto files in the import. +# +# @par Example +# +# google_cloud_cpp_generate_grpc( MY_GRPC_PB_FILES "foo/bar/baz.proto" +# "foo/bar/qux.proto" PROTO_PATH_DIRECTORIES "another/dir/with/protos") +# +# Note that `protoc` the protocol buffer compiler requires your protos to be +# somewhere in the search path defined by the `--proto_path` (aka -I) options. +# For example, if you want to generate the `.pb.{h,cc}` files for +# `foo/bar/baz.proto` then the directory containing `foo` must be in the search +# path. +function (google_cloud_cpp_generate_grpcpp SRCS) + cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN}) + if (NOT _opt_UNPARSED_ARGUMENTS) + message( + SEND_ERROR "Error: google_cloud_cpp_generate_grpc() called without" + " any proto files") + return() + endif () + + # Build the list of `--proto_path` options. Use the absolute path for each + # option given, and do not include any path more than once. + set(protobuf_include_path) + foreach (dir ${_opt_PROTO_PATH_DIRECTORIES}) + get_filename_component(absolute_path ${dir} ABSOLUTE) + list(FIND protobuf_include_path "${absolute_path}" + already_in_search_path) + if (${already_in_search_path} EQUAL -1) + list(APPEND protobuf_include_path "--proto_path" "${absolute_path}") + endif () + endforeach () + + set(${SRCS}) + foreach (filename ${_opt_UNPARSED_ARGUMENTS}) + get_filename_component(file_directory "${filename}" DIRECTORY) + # This gets the filename without the extension, analogous to $(basename + # "${filename}" .proto) + get_filename_component(file_stem "${filename}" NAME_WE) + + # Strip all the prefixes in ${_opt_PROTO_PATH_DIRECTORIES} from the + # source proto directory + set(D "${file_directory}") + if (DEFINED _opt_PROTO_PATH_DIRECTORIES) + foreach (P ${_opt_PROTO_PATH_DIRECTORIES}) + string(REGEX REPLACE "^${P}" "" T "${D}") + set(D ${T}) + endforeach () + endif () + set(grpc_pb_cc + "${CMAKE_CURRENT_BINARY_DIR}/${D}/${file_stem}.grpc.pb.cc") + set(grpc_pb_h "${CMAKE_CURRENT_BINARY_DIR}/${D}/${file_stem}.grpc.pb.h") + list(APPEND ${SRCS} "${grpc_pb_cc}" "${grpc_pb_h}") + add_custom_command( + OUTPUT "${grpc_pb_cc}" "${grpc_pb_h}" + COMMAND + $<TARGET_FILE:protobuf::protoc> ARGS + --plugin=protoc-gen-grpc=$<TARGET_FILE:gRPC::grpc_cpp_plugin> + "--grpc_out=${CMAKE_CURRENT_BINARY_DIR}" + "--cpp_out=${CMAKE_CURRENT_BINARY_DIR}" ${protobuf_include_path} + "${filename}" + DEPENDS "${filename}" protobuf::protoc gRPC::grpc_cpp_plugin + COMMENT "Running gRPC C++ protocol buffer compiler on ${filename}" + VERBATIM) + endforeach () + + set_source_files_properties(${${SRCS}} PROPERTIES GENERATED TRUE) + set(${SRCS} + ${${SRCS}} + PARENT_SCOPE) +endfunction () + +include(GNUInstallDirs) + +# Install headers for a C++ proto library. +function (google_cloud_cpp_install_proto_library_headers target) + get_target_property(target_sources ${target} SOURCES) + foreach (header ${target_sources}) + # Skip anything that is not a header file. + if (NOT "${header}" MATCHES "\\.h$") + continue() + endif () + string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" relative "${header}") + get_filename_component(dir "${relative}" DIRECTORY) + install(FILES "${header}" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${dir}") + endforeach () +endfunction () + +# Install protos for a C++ proto library. +function (google_cloud_cpp_install_proto_library_protos target strip_prefix) + get_target_property(target_protos ${target} PROTO_SOURCES) + foreach (proto ${target_protos}) + # Skip anything that is not a header file. + if (NOT "${proto}" MATCHES "\\.proto$") + continue() + endif () + string(REPLACE "${strip_prefix}/" "" relative "${proto}") + get_filename_component(dir "${relative}" DIRECTORY) + # This is modeled after the Protobuf library, it installs the basic + # protos (think google/protobuf/any.proto) in the include directory for + # C/C++ code. :shrug: + install(FILES "${proto}" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${dir}") + endforeach () +endfunction () + +function (google_cloud_cpp_proto_library libname) + cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN}) + if (NOT _opt_UNPARSED_ARGUMENTS) + message(SEND_ERROR "Error: google_cloud_cpp_proto_library() called" + " without any proto files") + return() + endif () + + google_cloud_cpp_generate_proto( + proto_sources ${_opt_UNPARSED_ARGUMENTS} PROTO_PATH_DIRECTORIES + ${_opt_PROTO_PATH_DIRECTORIES}) + + add_library(${libname} ${proto_sources}) + set_property(TARGET ${libname} PROPERTY PROTO_SOURCES + ${_opt_UNPARSED_ARGUMENTS}) + target_link_libraries(${libname} PUBLIC gRPC::grpc++ gRPC::grpc + protobuf::libprotobuf) + target_include_directories( + ${libname} + PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}> + $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}> + $<INSTALL_INTERFACE:include>) +endfunction () + +function (google_cloud_cpp_grpcpp_library libname) + cmake_parse_arguments(_opt "" "" "PROTO_PATH_DIRECTORIES" ${ARGN}) + if (NOT _opt_UNPARSED_ARGUMENTS) + message(SEND_ERROR "Error: google_cloud_cpp_proto_library() called" + " without any proto files") + return() + endif () + + google_cloud_cpp_generate_grpcpp( + grpcpp_sources ${_opt_UNPARSED_ARGUMENTS} PROTO_PATH_DIRECTORIES + ${_opt_PROTO_PATH_DIRECTORIES}) + google_cloud_cpp_proto_library( + ${libname} ${_opt_UNPARSED_ARGUMENTS} PROTO_PATH_DIRECTORIES + ${_opt_PROTO_PATH_DIRECTORIES}) + target_sources(${libname} PRIVATE ${grpcpp_sources}) +endfunction () diff --git a/third_party/cpp/googleapis/cmake/FindProtobufTargets.cmake b/third_party/cpp/googleapis/cmake/FindProtobufTargets.cmake new file mode 100644 index 000000000000..ab196118d731 --- /dev/null +++ b/third_party/cpp/googleapis/cmake/FindProtobufTargets.cmake @@ -0,0 +1,204 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +#[=======================================================================[.rst: +FindProtobufTargets +------------------- + +A module to use `Protobuf` with less complications. + +Using ``find_package(Protobuf)`` should be simple, but it is not. + +CMake provides a ``FindProtobuf`` module. Unfortunately it does not generate +`protobuf::*` targets until CMake-3.9, and `protobuf::protoc` does not +appear until CMake-3.10. + +The CMake-config files generated by `protobuf` always create these targets, +but on some Linux distributions (e.g. Fedora>=29, and openSUSE-Tumbleweed) there +are system packages for protobuf, but these packages are installed without the +CMake-config files. One must either use the ``FindProtobuf`` module, find the +libraries via `pkg-config`, or find the libraries manually. + +When the CMake-config files are installed they produce the same targets as +recent versions of ``FindProtobuf``. However, they do not produce the +`Protobuf_LIBRARY`, `Protobuf_INCLUDE_DIR`, etc. that are generated by the +module. Furthermore, the `protobuf::protoc` library is not usable when loaded +from the CMake-config files: its ``IMPORTED_LOCATION`` variable is not defined. + +This module is designed to provide a single, uniform, ``find_package()`` +module that always produces the same outputs: + +- It always generates the ``protobuf::*`` targets. +- It always defines ``ProtobufTargets_FOUND`` and ``ProtobufTargets_VERSION``. +- It *prefers* using the CMake config files if they are available. +- It fallsback on the ``FindProtobuf`` module if the config files are not found. +- It populates any missing targets and their properties. + +The following :prop_tgt:`IMPORTED` targets are defined: + +``protobuf::libprotobuf`` + The protobuf library. +``protobuf::libprotobuf-lite`` + The protobuf lite library. +``protobuf::libprotoc`` + The protoc library. +``protobuf::protoc`` + The protoc compiler. + +Example: + +.. code-block:: cmake + + find_package(ProtobufTargets REQUIRED) + add_executable(bar bar.cc) + target_link_libraries(bar PRIVATE protobuf::libprotobuf) + +#]=======================================================================] + +if (protobuf_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "protobuf_USE_STATIC_LIBS = ${protobuf_USE_STATIC_LIBS}" + " ProtobufTargets = ${ProtobufTargets_FOUND}") +endif () + +# Always load thread support, even on Windows. +find_package(Threads REQUIRED) + +# First try to use the ``protobufConfig.cmake`` or ``protobuf-config.cmake`` +# file if it was installed. This is common on systems (or package managers) +# where protobuf was compiled and installed with `CMake`. Note that on Linux +# this *must* be all lowercase ``protobuf``, while on Windows it does not +# matter. +find_package(protobuf CONFIG) + +if (protobuf_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "protobuf_FOUND = ${protobuf_FOUND}" + " protobuf_VERSION = ${protobuf_VERSION}") +endif () + +if (protobuf_FOUND) + set(ProtobufTargets_FOUND 1) + set(ProtobufTargets_VERSION ${protobuf_VERSION}) + if (protobuf_DEBUG) + message( + STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "ProtobufTargets_FOUND = ${ProtobufTargets_FOUND}" + " ProtobufTargets_VERSION = ${ProtobufTargets_VERSION}") + endif () +else () + find_package(Protobuf QUIET) + if (Protobuf_FOUND) + set(ProtobufTargets_FOUND 1) + set(ProtobufTargets_VERSION ${Protobuf_VERSION}) + + if (NOT TARGET protobuf::libprotobuf) + add_library(protobuf::libprotobuf IMPORTED INTERFACE) + set_property( + TARGET protobuf::libprotobuf + PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Protobuf_INCLUDE_DIR}) + set_property( + TARGET protobuf::libprotobuf APPEND + PROPERTY INTERFACE_LINK_LIBRARIES ${Protobuf_LIBRARY} + Threads::Threads) + endif () + + if (NOT TARGET protobuf::libprotobuf-lite) + add_library(protobuf::libprotobuf-lite IMPORTED INTERFACE) + set_property( + TARGET protobuf::libprotobuf-lite + PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Protobuf_INCLUDE_DIR}) + set_property( + TARGET protobuf::libprotobuf-lite APPEND + PROPERTY INTERFACE_LINK_LIBRARIES ${Protobuf_LITE_LIBRARY} + Threads::Threads) + endif () + + if (NOT TARGET protobuf::libprotoc) + add_library(protobuf::libprotoc IMPORTED INTERFACE) + set_property( + TARGET protobuf::libprotoc + PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${Protobuf_INCLUDE_DIR}) + set_property( + TARGET protobuf::libprotoc APPEND + PROPERTY INTERFACE_LINK_LIBRARIES ${Protobuf_PROTOC_LIBRARY} + Threads::Threads) + endif () + endif () +endif () + +if (protobuf_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "ProtobufTargets_FOUND = ${ProtobufTargets_FOUND}" + " ProtobufTargets_VERSION = ${ProtobufTargets_VERSION}") +endif () + +# We also should try to find the protobuf C++ plugin for the protocol buffers +# compiler. +if (ProtobufTargets_FOUND AND NOT TARGET protobuf::protoc) + add_executable(protobuf::protoc IMPORTED) + + # Discover the protoc compiler location. + find_program( + _protobuf_PROTOC_EXECUTABLE + NAMES protoc + DOC "The Google Protocol Buffers Compiler") + if (protobuf_DEBUG) + message( + STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "ProtobufTargets_FOUND = ${ProtobufTargets_FOUND}" + " ProtobufTargets_VERSION = ${ProtobufTargets_VERSION}" + " EXE = ${_protobuf_PROTOC_EXECUTABLE}") + endif () + set_property(TARGET protobuf::protoc + PROPERTY IMPORTED_LOCATION ${_protobuf_PROTOC_EXECUTABLE}) + set_property( + TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION_DEBUG + ${_protobuf_PROTOC_EXECUTABLE}) + set_property( + TARGET protobuf::protoc PROPERTY IMPORTED_LOCATION_RELEASE + ${_protobuf_PROTOC_EXECUTABLE}) + unset(_protobuf_PROTOC_EXECUTABLE) + + if (protobuf_DEBUG) + get_target_property(_protobuf_PROTOC_EXECUTABLE protobuf::protoc + IMPORTED_LOCATION) + message( + STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "LOCATION=${_protobuf_PROTOC_EXECUTABLE}") + endif () +endif () + +if (protobuf_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "ProtobufTargets_FOUND = ${ProtobufTargets_FOUND}" + " ProtobufTargets_VERSION = ${ProtobufTargets_VERSION}") + if (ProtobufTargets_FOUND) + foreach (_target protobuf::libprotobuf protobuf::libprotobuf-lite + protobuf::libprotoc) + if (NOT TARGET ${_target}) + message( + STATUS + "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "target=${_target} is NOT a target") + endif () + endforeach () + unset(_target) + endif () +endif () + +find_package_handle_standard_args(ProtobufTargets REQUIRED_VARS + ProtobufTargets_FOUND ProtobufTargets_VERSION) diff --git a/third_party/cpp/googleapis/cmake/FindgRPC.cmake b/third_party/cpp/googleapis/cmake/FindgRPC.cmake new file mode 100644 index 000000000000..358285b6200a --- /dev/null +++ b/third_party/cpp/googleapis/cmake/FindgRPC.cmake @@ -0,0 +1,333 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +#[=======================================================================[.rst: +FindgRPC +-------- + +Locate and configure the gRPC library. + +The following variables can be set and are optional: + +``gRPC_DEBUG`` + Show debug messages. +``gRPC_USE_STATIC_LIBS`` + Set to ON to force the use of the static libraries. + Default is OFF. + +Defines the following variables: + +``gRPC_FOUND`` + Found the gRPC library +``gRPC_VERSION`` + Version of package found. + +The following :prop_tgt:`IMPORTED` targets are also defined: + +``gRPC::grpc++`` + The gRPC C++ library. +``gRPC::grpc`` + The gRPC C core library. +``gRPC::cpp_plugin`` + The C++ plugin for the Protobuf protoc compiler. + +The following cache variables are also available to set or use: + +Example: + +.. code-block:: cmake + + find_package(gRPC REQUIRED) + add_executable(bar bar.cc) + target_link_libraries(bar PRIVATE gRPC::grpc++) + +#]=======================================================================] + +if (gRPC_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "gRPC_USE_STATIC_LIBS = ${gRPC_USE_STATIC_LIBS}" + " gRPC_FOUND = ${gRPC_FOUND}") +endif () + +# gRPC always requires Thread support. +find_package(Threads REQUIRED) + +# Load the module to find protobuf with proper targets. Do not use +# `find_package()` because we (have to) install this module in non-standard +# locations. +include(${CMAKE_CURRENT_LIST_DIR}/FindProtobufTargets.cmake) + +# The gRPC::grpc_cpp_plugin target is sometimes defined, but without a +# IMPORTED_LOCATION +function (_grpc_fix_grpc_cpp_plugin_target) + # The target may already exist, do not create it again if it does. + if (NOT TARGET gRPC::grpc_cpp_plugin) + add_executable(gRPC::grpc_cpp_plugin IMPORTED) + endif () + get_target_property(_gRPC_CPP_PLUGIN_EXECUTABLE gRPC::grpc_cpp_plugin + IMPORTED_LOCATION) + if (gRPC_DEBUG) + message( + STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "LOCATION=${_gRPC_CPP_PLUGIN_EXECUTABLE}") + endif () + # Even if the target exists, gRPC CMake support files do not define the + # executable for the imported target (at least they do not in v1.19.1), so + # we need to define it ourselves. + if (NOT _gRPC_CPP_PLUGIN_EXECUTABLE) + find_program(_gRPC_CPP_PLUGIN_EXECUTABLE grpc_cpp_plugin + DOC "The gRPC C++ plugin for protoc") + mark_as_advanced(_gRPC_CPP_PLUGIN_EXECUTABLE) + if (_gRPC_CPP_PLUGIN_EXECUTABLE) + set_property( + TARGET gRPC::grpc_cpp_plugin + PROPERTY IMPORTED_LOCATION ${_gRPC_CPP_PLUGIN_EXECUTABLE}) + else () + set(gRPC_FOUND "grpc_cpp_plugin-NOTFOUND") + endif () + endif () +endfunction () + +# The gRPC::* targets sometimes lack the right definitions to compile cleanly on +# WIN32 +function (_grpc_fix_grpc_target_definitions) + # Including gRPC headers without this definition results in a build error. + if (WIN32) + set_property(TARGET gRPC::grpc APPEND + PROPERTY INTERFACE_COMPILE_DEFINITIONS _WIN32_WINNT=0x600) + set_property(TARGET gRPC::grpc++ APPEND + PROPERTY INTERFACE_COMPILE_DEFINITIONS _WIN32_WINNT=0x600) + endif () +endfunction () + +# First try to use the `gRPCConfig.cmake` or `grpc-config.cmake` file if it was +# installed. This is common on systems (or package managers) where gRPC was +# compiled and installed with `CMake`. +find_package(gRPC NO_MODULE QUIET) + +if (gRPC_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "NO_MODULE result gRPC_FOUND = ${gRPC_FOUND}") +endif () + +if (gRPC_FOUND) + _grpc_fix_grpc_cpp_plugin_target() + _grpc_fix_grpc_target_definitions() + return() +endif () + +include(SelectLibraryConfigurations) + +# Internal function: search for normal library as well as a debug one if the +# debug one is specified also include debug/optimized keywords in *_LIBRARIES +# variable +function (_gRPC_find_library name filename) + if (${name}_LIBRARY) + # Use result recorded by a previous call. + return() + else () + find_library(${name}_LIBRARY_RELEASE NAMES ${filename}) + mark_as_advanced(${name}_LIBRARY_RELEASE) + + find_library(${name}_LIBRARY_DEBUG NAMES ${filename}d ${filename}) + mark_as_advanced(${name}_LIBRARY_DEBUG) + + select_library_configurations(${name}) + + if (gRPC_DEBUG) + message( + STATUS + "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "${name} ${filename} RELEASE=${${name}_LIBRARY}" + " DEBUG=${${name}_LIBRARY_DEBUG} DEFAULT=${${name}_LIBRARY}" + ) + endif () + + set(${name}_LIBRARY + "${${name}_LIBRARY}" + PARENT_SCOPE) + endif () +endfunction () + +# +# Main +# + +# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES +if (_gRPC_USE_STATIC_LIBS) + set(_gRPC_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if (WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else () + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) + endif () +endif () + +_grpc_find_library(_gRPC_grpc grpc) +_grpc_find_library(_gRPC_grpc++ grpc++) + +if (NOT _gRPC_INCLUDE_DIR) + find_path(_gRPC_INCLUDE_DIR grpcpp/grpcpp.h) + mark_as_advanced(_gRPC_INCLUDE_DIR) +endif () + +if (gRPC_DEBUG) + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + " _gRPC_grpc_LIBRARY = ${_gRPC_grpc_LIBRARY}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + " _gRPC_grpc++_LIBRARY = ${_gRPC_grpc++_LIBRARY}") + message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + " _gRPC_INCLUDE_DIR = ${_gRPC_INCLUDE_DIR}") +endif () + +if (_gRPC_grpc_LIBRARY) + if (NOT TARGET gRPC::grpc) + add_library(gRPC::grpc IMPORTED UNKNOWN) + set_target_properties( + gRPC::grpc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${_gRPC_INCLUDE_DIR}") + if (EXISTS "${_gRPC_grpc_LIBRARY}") + set_target_properties(gRPC::grpc PROPERTIES IMPORTED_LOCATION + "${_gRPC_grpc_LIBRARY}") + endif () + if (EXISTS "${_gRPC_grpc_LIBRARY_RELEASE}") + set_property(TARGET gRPC::grpc APPEND + PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties( + gRPC::grpc PROPERTIES IMPORTED_LOCATION_RELEASE + "${_gRPC_grpc_LIBRARY_RELEASE}") + endif () + if (EXISTS "${_gRPC_grpc_LIBRARY_DEBUG}") + set_property(TARGET gRPC::grpc APPEND + PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties( + gRPC::grpc PROPERTIES IMPORTED_LOCATION_DEBUG + "${_gRPC_grpc_LIBRARY_DEBUG}") + endif () + set_property( + TARGET gRPC::grpc APPEND + PROPERTY INTERFACE_LINK_LIBRARIES protobuf::libprotobuf + Threads::Threads) + endif () +endif () + +if (_gRPC_grpc++_LIBRARY) + if (NOT TARGET gRPC::grpc++) + add_library(gRPC::grpc++ IMPORTED UNKNOWN) + set_target_properties( + gRPC::grpc++ PROPERTIES INTERFACE_INCLUDE_DIRECTORIES + "${_gRPC++_INCLUDE_DIR}") + if (EXISTS "${_gRPC_grpc++_LIBRARY}") + set_target_properties( + gRPC::grpc++ PROPERTIES IMPORTED_LOCATION + "${_gRPC_grpc++_LIBRARY}") + endif () + if (EXISTS "${_gRPC_grpc++_LIBRARY_RELEASE}") + set_property(TARGET gRPC::grpc++ APPEND + PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties( + gRPC::grpc++ PROPERTIES IMPORTED_LOCATION_RELEASE + "${_gRPC_grpc++_LIBRARY_RELEASE}") + endif () + if (EXISTS "${_gRPC_grpc++_LIBRARY_DEBUG}") + set_property(TARGET gRPC::grpc++ APPEND + PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties( + gRPC::grpc++ PROPERTIES IMPORTED_LOCATION_DEBUG + "${_gRPC_grpc++_LIBRARY_DEBUG}") + endif () + set_property( + TARGET gRPC::grpc++ APPEND + PROPERTY INTERFACE_LINK_LIBRARIES gRPC::grpc protobuf::libprotobuf + Threads::Threads) + if (CMAKE_VERSION VERSION_GREATER 3.8) + # gRPC++ requires C++11, but only CMake-3.8 introduced a target + # compiler feature to meet that requirement. + set_property(TARGET gRPC::grpc++ APPEND + PROPERTY INTERFACE_COMPILE_FEATURES cxx_std_11) + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # CMake 3.5 is still alive and kicking in some older distros, use + # the compiler-specific versions in these cases. + set_property(TARGET gRPC::grpc++ APPEND + PROPERTY INTERFACE_COMPILE_OPTIONS "-std=c++11") + elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + set_property(TARGET gRPC::grpc++ APPEND + PROPERTY INTERFACE_COMPILE_OPTIONS "-std=c++11") + else () + message( + WARNING + "gRPC::grpc++ requires C++11, but this module" + " (${CMAKE_CURRENT_LIST_FILE})" + " cannot enable it for the library target in your CMake and" + " compiler versions. You need to enable C++11 in the" + " CMakeLists.txt for your project. Consider filing a bug" + " so we can fix this problem.") + endif () + endif () +endif () + +# Restore original find library prefixes +if (_gRPC_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_PREFIXES "${_gRPC_ORIG_FIND_LIBRARY_PREFIXES}") +endif () + +file( + WRITE "${CMAKE_BINARY_DIR}/get_gRPC_version.cc" + [====[ +#include <grpcpp/grpcpp.h> +#include <iostream> +int main() { + std::cout << grpc::Version(); // no newline to simplify CMake module + return 0; +} + ]====]) + +try_run( + _gRPC_GET_VERSION_STATUS + _gRPC_GET_VERSION_COMPILE_STATUS + "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}/get_gRPC_version.cc" + LINK_LIBRARIES + gRPC::grpc++ + gRPC::grpc + COMPILE_OUTPUT_VARIABLE _gRPC_GET_VERSION_COMPILE_OUTPUT + RUN_OUTPUT_VARIABLE gRPC_VERSION) + +file(REMOVE "${CMAKE_BINARY_DIR}/get_gRPC_version.cc") + +_grpc_fix_grpc_cpp_plugin_target() + +if (gRPC_DEBUG) + foreach ( + _var + _gRPC_CPP_PLUGIN_EXECUTABLE + _gRPC_VERSION_RAW + _gRPC_GET_VERSION_STATUS + _gRPC_GET_VERSION_COMPILE_STATUS + _gRPC_GET_VERSION_COMPILE_OUTPUT + _gRPC_grpc_LIBRARY + _gRPC_grpc++_LIBRARY + _gRPC_INCLUDE_DIR) + message( + STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] " + "${_var} = ${${_var}}") + endforeach () + unset(_var) +endif () + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(gRPC REQUIRED_VARS _gRPC_grpc_LIBRARY + _gRPC_INCLUDE_DIR VERSION_VAR gRPC_VERSION) diff --git a/third_party/cpp/googleapis/cmake/SelectMSVCRuntime.cmake b/third_party/cpp/googleapis/cmake/SelectMSVCRuntime.cmake new file mode 100644 index 000000000000..feb2fe46c381 --- /dev/null +++ b/third_party/cpp/googleapis/cmake/SelectMSVCRuntime.cmake @@ -0,0 +1,39 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +# When compiling against *-static vcpkg packages we need to use the static C++ +# runtime with MSVC. The default is to use the dynamic runtime, which does not +# work in this case. This seems to be the recommended way to change the +# runtime: +# +# ~~~ +# https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-can-i-build-my-msvc-application-with-a-static-runtime +# ~~~ +# +# Note that currently we use VCPKG_TARGET_TRIPLET to determine if the static +# runtime is needed. In the future we may need to use a more complex expression +# to determine this, but this is a good start. +# +if (MSVC AND VCPKG_TARGET_TRIPLET MATCHES "-static$") + foreach (flag_var + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if (${flag_var} MATCHES "/MD") + string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + endif () + endforeach (flag_var) + unset(flag_var) +endif () diff --git a/third_party/cpp/googleapis/cmake/config-version.cmake.in b/third_party/cpp/googleapis/cmake/config-version.cmake.in new file mode 100644 index 000000000000..29891a6bde62 --- /dev/null +++ b/third_party/cpp/googleapis/cmake/config-version.cmake.in @@ -0,0 +1,35 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set(PACKAGE_VERSION @DOXYGEN_PROJECT_NUMBER@) + +# This package has not reached 1.0, there are no compatibility guarantees +# before then. +if (@GOOGLE_CLOUD_CPP_CONFIG_VERSION_MAJOR@ EQUAL 0) + if ("${PACKAGE_FIND_VERSION}" STREQUAL "") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + elseif ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE TRUE) + set(PACKAGE_VERSION_EXACT TRUE) + else () + set(PACKAGE_VERSION_UNSUITABLE TRUE) + endif () +elseif("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_COMPATIBLE FALSE) +else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") + set(PACKAGE_VERSION_EXACT TRUE) + endif() +endif() diff --git a/third_party/cpp/googleapis/cmake/config.cmake.in b/third_party/cpp/googleapis/cmake/config.cmake.in new file mode 100644 index 000000000000..25b324050c83 --- /dev/null +++ b/third_party/cpp/googleapis/cmake/config.cmake.in @@ -0,0 +1,52 @@ +# ~~~ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ~~~ + +include("${CMAKE_CURRENT_LIST_DIR}/FindProtobufTargets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/FindgRPC.cmake") + +include("${CMAKE_CURRENT_LIST_DIR}/googleapis-targets.cmake") + +foreach (_target + api_annotations + api_auth + api_client + api_field_behavior + api_http + api_resource + bigtable + cloud_bigquery + devtools_cloudtrace_v2_trace + devtools_cloudtrace_v2_tracing + iam_v1_iam_policy + iam_v1_options + iam_v1_policy + longrunning_operations + pubsub + rpc_error_details + rpc_status + spanner + storage + logging + type_expr) + set(scoped_name "googleapis-c++::${_target}_protos") + set(imported_name "googleapis_cpp_${_target}_protos") + if (NOT TARGET ${scoped_name}) + add_library(${scoped_name} IMPORTED INTERFACE) + set_target_properties(${scoped_name} + PROPERTIES INTERFACE_LINK_LIBRARIES + ${imported_name}) + endif () +endforeach () diff --git a/third_party/cpp/googleapis/cmake/config.pc.in b/third_party/cpp/googleapis/cmake/config.pc.in new file mode 100644 index 000000000000..af068beb74a0 --- /dev/null +++ b/third_party/cpp/googleapis/cmake/config.pc.in @@ -0,0 +1,26 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix}/@CMAKE_INSTALL_BINDIR@ +libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @GOOGLE_CLOUD_CPP_PC_NAME@ +Description: @GOOGLE_CLOUD_CPP_PC_DESCRIPTION@ +Requires: @GOOGLE_CLOUD_CPP_PC_REQUIRES@ +Version: @DOXYGEN_PROJECT_NUMBER@ + +Libs: -L${libdir} @GOOGLE_CLOUD_CPP_PC_LIBS@ +Cflags: -I${includedir} diff --git a/third_party/cpp/googleapis/default.nix b/third_party/cpp/googleapis/default.nix new file mode 100644 index 000000000000..bb1737bb92fa --- /dev/null +++ b/third_party/cpp/googleapis/default.nix @@ -0,0 +1,24 @@ +# This library contains generated gRPC implementations for Google's +# public libraries. +{ pkgs, ... }: + +let + inherit (pkgs) fetchFromGitHub; + stdenv = with pkgs; overrideCC pkgs.stdenv clang_10; +in stdenv.mkDerivation { + name = "googleapis-cpp"; + src = ./.; + + GOOGLEAPIS_DIR = fetchFromGitHub { + owner = "googleapis"; + repo = "googleapis"; + rev = "0aba1900ffef672ec5f0da677cf590ee5686e13b"; + sha256 = "1174mvipmzap4h8as1cl44y1kq7ikipdicnmnswv5yswgkwla84c"; + }; + + buildInputs = with pkgs; [ + c-ares c-ares.cmake-config grpc protobuf openssl zlib + ]; + + nativeBuildInputs = with pkgs; [ cmake pkgconfig ]; +} |