Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(beyondcorp): generate library #9555

Merged
merged 6 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ exports_files([
])

EXPERIMENTAL_LIBRARIES = [
# Introduced circa 2022-07-22
"beyondcorp",
# Introduced circa 2022-07-12
"batch",
"run",
Expand Down
14 changes: 14 additions & 0 deletions ci/etc/expected_install_directories
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@
./include/google/cloud/batch/internal
./include/google/cloud/batch/mocks
./include/google/cloud/batch/v1
./include/google/cloud/beyondcorp
./include/google/cloud/beyondcorp/appconnections
./include/google/cloud/beyondcorp/appconnections/v1
./include/google/cloud/beyondcorp/appconnectors
./include/google/cloud/beyondcorp/appconnectors/v1
./include/google/cloud/beyondcorp/appgateways
./include/google/cloud/beyondcorp/appgateways/v1
./include/google/cloud/beyondcorp/clientconnectorservices
./include/google/cloud/beyondcorp/clientconnectorservices/v1
./include/google/cloud/beyondcorp/clientgateways
./include/google/cloud/beyondcorp/clientgateways/v1
./include/google/cloud/beyondcorp/internal
./include/google/cloud/beyondcorp/mocks
./include/google/cloud/bigquery
./include/google/cloud/bigquery/connection
./include/google/cloud/bigquery/connection/v1
Expand Down Expand Up @@ -431,6 +444,7 @@
./lib64/cmake/google_cloud_cpp_automl
./lib64/cmake/google_cloud_cpp_baremetalsolution
./lib64/cmake/google_cloud_cpp_batch
./lib64/cmake/google_cloud_cpp_beyondcorp
./lib64/cmake/google_cloud_cpp_bigquery
./lib64/cmake/google_cloud_cpp_bigtable
./lib64/cmake/google_cloud_cpp_billing
Expand Down
1 change: 1 addition & 0 deletions ci/etc/full_feature_list
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ assuredworkloads
automl
baremetalsolution
batch
beyondcorp
bigquery
bigtable
billing
Expand Down
7 changes: 7 additions & 0 deletions external/googleapis/protodeps/beyondcorp.deps
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@com_google_googleapis//google/api:annotations_proto
@com_google_googleapis//google/api:client_proto
@com_google_googleapis//google/api:field_behavior_proto
@com_google_googleapis//google/api:http_proto
@com_google_googleapis//google/api:resource_proto
@com_google_googleapis//google/longrunning:operations_proto
@com_google_googleapis//google/rpc:status_proto
7 changes: 7 additions & 0 deletions external/googleapis/protolists/beyondcorp.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@com_google_googleapis//google/cloud/beyondcorp/appconnections/v1:app_connections_service.proto
@com_google_googleapis//google/cloud/beyondcorp/appconnectors/v1:app_connector_instance_config.proto
@com_google_googleapis//google/cloud/beyondcorp/appconnectors/v1:app_connectors_service.proto
@com_google_googleapis//google/cloud/beyondcorp/appconnectors/v1:resource_info.proto
@com_google_googleapis//google/cloud/beyondcorp/appgateways/v1:app_gateways_service.proto
@com_google_googleapis//google/cloud/beyondcorp/clientconnectorservices/v1:client_connector_services_service.proto
@com_google_googleapis//google/cloud/beyondcorp/clientgateways/v1:client_gateways_service.proto
8 changes: 8 additions & 0 deletions external/googleapis/update_libraries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ declare -A -r LIBRARIES=(
["automl"]="@com_google_googleapis//google/cloud/automl/v1:automl_cc_grpc"
["baremetalsolution"]="@com_google_googleapis//google/cloud/baremetalsolution/v2:baremetalsolution_cc_grpc"
["batch"]="@com_google_googleapis//google/cloud/batch/v1:batch_cc_grpc"
["beyondcorp"]="$(
printf ",%s" \
"@com_google_googleapis//google/cloud/beyondcorp/appconnections/v1:appconnections_cc_grpc" \
"@com_google_googleapis//google/cloud/beyondcorp/appconnectors/v1:appconnectors_cc_grpc" \
"@com_google_googleapis//google/cloud/beyondcorp/appgateways/v1:appgateways_cc_grpc" \
"@com_google_googleapis//google/cloud/beyondcorp/clientconnectorservices/v1:clientconnectorservices_cc_grpc" \
"@com_google_googleapis//google/cloud/beyondcorp/clientgateways/v1:clientgateways_cc_grpc"
)"
["bigquery"]="$(
printf ",%s" \
"@com_google_googleapis//google/cloud/bigquery/v2:bigquery_cc_grpc" \
Expand Down
48 changes: 42 additions & 6 deletions generator/generator_config.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,42 @@ service {
retryable_status_codes: ["kUnavailable"]
}

# BeyondCorp
service {
service_proto_path: "google/cloud/beyondcorp/clientconnectorservices/v1/client_connector_services_service.proto"
product_path: "google/cloud/beyondcorp"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/beyondcorp/clientgateways/v1/client_gateways_service.proto"
product_path: "google/cloud/beyondcorp"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/beyondcorp/appconnectors/v1/app_connectors_service.proto"
product_path: "google/cloud/beyondcorp"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/beyondcorp/appgateways/v1/app_gateways_service.proto"
product_path: "google/cloud/beyondcorp"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}

service {
service_proto_path: "google/cloud/beyondcorp/appconnections/v1/app_connections_service.proto"
product_path: "google/cloud/beyondcorp"
initial_copyright_year: "2022"
retryable_status_codes: ["kUnavailable"]
}

# BigQuery
service {
service_proto_path: "google/cloud/bigquery/storage/v1/storage.proto"
Expand Down Expand Up @@ -169,12 +205,12 @@ service {
omit_connection: true
omit_stub_factory: true
gen_async_rpcs: [
"CheckAndMutateRow",
"MutateRow",
"MutateRows",
"ReadModifyWriteRow",
"ReadRows",
"SampleRowKeys"
"CheckAndMutateRow",
"MutateRow",
"MutateRows",
"ReadModifyWriteRow",
"ReadRows",
"SampleRowKeys"
]
}

Expand Down
68 changes: 68 additions & 0 deletions google/cloud/beyondcorp/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Copyright 2022 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
#
# https://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.

package(default_visibility = ["//visibility:private"])

licenses(["notice"]) # Apache 2.0

SOURCE_GLOB = "**/*.cc"

MOCK_SOURCE_GLOB = "mocks/*.cc"

HEADER_GLOB = "**/*.h"

MOCK_HEADER_GLOB = "mocks/*.h"

cc_library(
name = "google_cloud_cpp_beyondcorp",
srcs = glob(
include = [SOURCE_GLOB],
exclude = [MOCK_SOURCE_GLOB],
),
hdrs = glob(
include = [HEADER_GLOB],
exclude = [MOCK_HEADER_GLOB],
),
# TODO(#9340): fix the Windows builds.
target_compatible_with = select({
"@platforms//os:windows": ["@platforms//:incompatible"],
"//conditions:default": [],
}),
visibility = ["//:__pkg__"],
deps = [
"//:common",
"//:grpc_utils",
"@com_google_googleapis//google/cloud/beyondcorp/appconnections/v1:appconnections_cc_grpc",
"@com_google_googleapis//google/cloud/beyondcorp/appconnectors/v1:appconnectors_cc_grpc",
"@com_google_googleapis//google/cloud/beyondcorp/appgateways/v1:appgateways_cc_grpc",
"@com_google_googleapis//google/cloud/beyondcorp/clientconnectorservices/v1:clientconnectorservices_cc_grpc",
"@com_google_googleapis//google/cloud/beyondcorp/clientgateways/v1:clientgateways_cc_grpc",
],
)

cc_library(
name = "google_cloud_cpp_beyondcorp_mocks",
srcs = glob(
include = [MOCK_SOURCE_GLOB],
),
hdrs = glob(
include = [MOCK_HEADER_GLOB],
),
visibility = ["//:__pkg__"],
deps = [
":google_cloud_cpp_beyondcorp",
"//:common",
"//:grpc_utils",
],
)
188 changes: 188 additions & 0 deletions google/cloud/beyondcorp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
# ~~~
# Copyright 2022 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
#
# https://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(GoogleapisConfig)
set(DOXYGEN_PROJECT_NAME "BeyondCorp API C++ Client")
set(DOXYGEN_PROJECT_BRIEF "A C++ Client Library for the BeyondCorp API")
set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION} (Experimental)")
set(DOXYGEN_EXCLUDE_SYMBOLS "internal" "beyondcorp_internal"
"beyondcorp_testing" "examples")
set(DOXYGEN_EXAMPLE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/quickstart)

# Creates the proto headers needed by doxygen.
set(GOOGLE_CLOUD_CPP_DOXYGEN_DEPS google-cloud-cpp::beyondcorp_protos)

include(GoogleCloudCppCommon)

set(EXTERNAL_GOOGLEAPIS_SOURCE
"${PROJECT_BINARY_DIR}/external/googleapis/src/googleapis_download")
find_path(PROTO_INCLUDE_DIR google/protobuf/descriptor.proto)
if (PROTO_INCLUDE_DIR)
list(INSERT PROTOBUF_IMPORT_DIRS 0 "${PROTO_INCLUDE_DIR}")
endif ()

include(CompileProtos)
google_cloud_cpp_load_protolist(
proto_list
"${PROJECT_SOURCE_DIR}/external/googleapis/protolists/beyondcorp.list")
google_cloud_cpp_load_protodeps(
proto_deps
"${PROJECT_SOURCE_DIR}/external/googleapis/protodeps/beyondcorp.deps")
google_cloud_cpp_grpcpp_library(
google_cloud_cpp_beyondcorp_protos # cmake-format: sort
${proto_list} PROTO_PATH_DIRECTORIES "${EXTERNAL_GOOGLEAPIS_SOURCE}"
"${PROTO_INCLUDE_DIR}")
external_googleapis_set_version_and_alias(beyondcorp_protos)
target_link_libraries(google_cloud_cpp_beyondcorp_protos PUBLIC ${proto_deps})

file(
GLOB source_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"*.h" "*.cc" "internal/*.h" "internal/*.cc")
list(SORT source_files)
add_library(google_cloud_cpp_beyondcorp ${source_files})
target_include_directories(
google_cloud_cpp_beyondcorp
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>)
target_link_libraries(
google_cloud_cpp_beyondcorp
PUBLIC google-cloud-cpp::grpc_utils google-cloud-cpp::common
google-cloud-cpp::beyondcorp_protos)
google_cloud_cpp_add_common_options(google_cloud_cpp_beyondcorp)
set_target_properties(
google_cloud_cpp_beyondcorp
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-beyondcorp
VERSION "${PROJECT_VERSION}"
SOVERSION "${PROJECT_VERSION_MAJOR}")
target_compile_options(google_cloud_cpp_beyondcorp
PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})

add_library(google-cloud-cpp::experimental-beyondcorp ALIAS
google_cloud_cpp_beyondcorp)

# Create a header-only library for the mocks. We use a CMake `INTERFACE` library
# for these, a regular library would not work on macOS (where the library needs
# at least one .o file). Unfortunately INTERFACE libraries are a bit weird in
# that they need absolute paths for their sources.
file(
GLOB relative_mock_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
"mocks/*.h")
list(SORT relative_mock_files)
set(mock_files)
foreach (file IN LISTS relative_mock_files)
list(APPEND mock_files "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
endforeach ()
add_library(google_cloud_cpp_beyondcorp_mocks INTERFACE)
target_sources(google_cloud_cpp_beyondcorp_mocks INTERFACE ${mock_files})
target_link_libraries(
google_cloud_cpp_beyondcorp_mocks
INTERFACE google-cloud-cpp::experimental-beyondcorp GTest::gmock_main
GTest::gmock GTest::gtest)
set_target_properties(
google_cloud_cpp_beyondcorp_mocks
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-beyondcorp_mocks)
target_include_directories(
google_cloud_cpp_beyondcorp_mocks
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
$<INSTALL_INTERFACE:include>)
target_compile_options(google_cloud_cpp_beyondcorp_mocks
INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})

include(CTest)
if (BUILD_TESTING)
add_executable(beyondcorp_quickstart "quickstart/quickstart.cc")
target_link_libraries(beyondcorp_quickstart
PRIVATE google-cloud-cpp::experimental-beyondcorp)
google_cloud_cpp_add_common_options(beyondcorp_quickstart)
add_test(
NAME beyondcorp_quickstart
COMMAND
cmake -P "${PROJECT_SOURCE_DIR}/cmake/quickstart-runner.cmake"
$<TARGET_FILE:beyondcorp_quickstart> GOOGLE_CLOUD_PROJECT
GOOGLE_CLOUD_CPP_TEST_REGION)
set_tests_properties(beyondcorp_quickstart
PROPERTIES LABELS "integration-test;quickstart")
endif ()

# Get the destination directories based on the GNU recommendations.
include(GNUInstallDirs)

# Export the CMake targets to make it easy to create configuration files.
install(
EXPORT google_cloud_cpp_beyondcorp-targets
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_beyondcorp"
COMPONENT google_cloud_cpp_development)

# Install the libraries and headers in the locations determined by
# GNUInstallDirs
install(
TARGETS google_cloud_cpp_beyondcorp google_cloud_cpp_beyondcorp_protos
EXPORT google_cloud_cpp_beyondcorp-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT google_cloud_cpp_runtime
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT google_cloud_cpp_runtime
NAMELINK_SKIP
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT google_cloud_cpp_development)
# With CMake-3.12 and higher we could avoid this separate command (and the
# duplication).
install(
TARGETS google_cloud_cpp_beyondcorp google_cloud_cpp_beyondcorp_protos
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT google_cloud_cpp_development
NAMELINK_ONLY
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT google_cloud_cpp_development)

google_cloud_cpp_install_proto_library_protos(
"google_cloud_cpp_beyondcorp_protos" "${EXTERNAL_GOOGLEAPIS_SOURCE}")
google_cloud_cpp_install_proto_library_headers(
"google_cloud_cpp_beyondcorp_protos")
google_cloud_cpp_install_headers("google_cloud_cpp_beyondcorp"
"include/google/cloud/beyondcorp")
google_cloud_cpp_install_headers("google_cloud_cpp_beyondcorp_mocks"
"include/google/cloud/beyondcorp")

google_cloud_cpp_add_pkgconfig(
beyondcorp
"The BeyondCorp API C++ Client Library"
"Provides C++ APIs to use the BeyondCorp API."
"google_cloud_cpp_grpc_utils"
" google_cloud_cpp_common"
" google_cloud_cpp_beyondcorp_protos")

# Create and install the CMake configuration files.
include(CMakePackageConfigHelpers)
configure_file("config.cmake.in" "google_cloud_cpp_beyondcorp-config.cmake"
@ONLY)
write_basic_package_version_file(
"google_cloud_cpp_beyondcorp-config-version.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_beyondcorp-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_beyondcorp-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_beyondcorp"
COMPONENT google_cloud_cpp_development)

external_googleapis_install_pc("google_cloud_cpp_beyondcorp_protos")
Loading