diff --git a/cmake/GoogleCloudCppFeatures.cmake b/cmake/GoogleCloudCppFeatures.cmake index 19d0ff5cd2e02..2360cdbf67f33 100644 --- a/cmake/GoogleCloudCppFeatures.cmake +++ b/cmake/GoogleCloudCppFeatures.cmake @@ -428,6 +428,13 @@ function (google_cloud_cpp_enable_features) ) continue() endif () + if (IS_DIRECTORY + "${PROJECT_SOURCE_DIR}/protos/google/cloud/${feature}" + AND EXISTS + "${PROJECT_SOURCE_DIR}/protos/google/cloud/${feature}/CMakeLists.txt" + ) + add_subdirectory(protos/google/cloud/${feature}) + endif () add_subdirectory(google/cloud/${feature}) if (GOOGLE_CLOUD_CPP_ENABLE_EXAMPLES AND IS_DIRECTORY diff --git a/google/cloud/storage/tests/BUILD.bazel b/google/cloud/storage/tests/BUILD.bazel index 6ce3f7f5dc568..bba8539a4a130 100644 --- a/google/cloud/storage/tests/BUILD.bazel +++ b/google/cloud/storage/tests/BUILD.bazel @@ -21,19 +21,6 @@ package(default_visibility = ["//visibility:private"]) licenses(["notice"]) # Apache 2.0 -proto_library( - name = "storage_conformance_tests_proto", - srcs = [ - "conformance_tests.proto", - ], - deps = ["@com_google_protobuf//:timestamp_proto"], -) - -cc_proto_library( - name = "storage_conformance_tests_cc_proto", - deps = [":storage_conformance_tests_proto"], -) - VARIATIONS = { "default": {"GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG": "none"}, "grpc-metadata": {"GOOGLE_CLOUD_CPP_STORAGE_GRPC_CONFIG": "metadata"}, @@ -56,12 +43,13 @@ VARIATIONS = { "integration-test-" + v_label, ] + (["integration-test-gha"] if test.startswith("smoke_test") else []), deps = [ - ":storage_conformance_tests_cc_proto", "//:common", "//:storage", "//google/cloud/storage:storage_client_testing", "//google/cloud/testing_util:google_cloud_cpp_testing_grpc_private", "//google/cloud/testing_util:google_cloud_cpp_testing_private", + "//protos:system_includes", + "//protos/google/cloud/storage/tests:storage_conformance_tests_cc_proto", "@com_google_absl//absl/strings", "@com_google_googletest//:gtest_main", ], diff --git a/google/cloud/storage/tests/CMakeLists.txt b/google/cloud/storage/tests/CMakeLists.txt index e6cbab3a9ae2d..538795b60a168 100644 --- a/google/cloud/storage/tests/CMakeLists.txt +++ b/google/cloud/storage/tests/CMakeLists.txt @@ -84,16 +84,6 @@ export_list_to_bazel( "storage_client_integration_tests.bzl" "storage_client_integration_tests" "storage_client_integration_tests_production" YEAR "2018") -# Signed URL conformance tests are parsed using protos. In order to simplify the -# build files, only build these conformance tests if gRPC in GCS is compiled. -if (GOOGLE_CLOUD_CPP_STORAGE_ENABLE_GRPC) - # We need to disable clang tidy for the generated CC files. - google_cloud_cpp_proto_library( - google_cloud_cpp_storage_tests_conformance_protos - conformance_tests.proto PROTO_PATH_DIRECTORIES - ${CMAKE_CURRENT_SOURCE_DIR}) -endif () - foreach (fname IN LISTS storage_client_integration_tests) google_cloud_cpp_add_executable(target "storage" "${fname}") target_link_libraries( diff --git a/google/cloud/storage/tests/signed_url_conformance_test.cc b/google/cloud/storage/tests/signed_url_conformance_test.cc index 429a8da4ffdae..7f14085984059 100644 --- a/google/cloud/storage/tests/signed_url_conformance_test.cc +++ b/google/cloud/storage/tests/signed_url_conformance_test.cc @@ -18,13 +18,13 @@ #include "google/cloud/storage/internal/base64.h" #include "google/cloud/storage/internal/signed_url_requests.h" #include "google/cloud/storage/list_objects_reader.h" -#include "google/cloud/storage/tests/conformance_tests.pb.h" #include "google/cloud/internal/format_time_point.h" #include "google/cloud/internal/getenv.h" #include "google/cloud/internal/time_utils.h" #include "google/cloud/terminate_handler.h" #include "google/cloud/testing_util/scoped_environment.h" #include "google/cloud/testing_util/status_matchers.h" +#include #include #include #include diff --git a/protos/BUILD.bazel b/protos/BUILD.bazel index b55abb27530ee..49a23f30a4ce3 100644 --- a/protos/BUILD.bazel +++ b/protos/BUILD.bazel @@ -19,5 +19,8 @@ licenses(["notice"]) # Apache 2.0 cc_library( name = "system_includes", includes = ["."], - visibility = ["//google/cloud/compute:__pkg__"], + visibility = [ + "//google/cloud/compute:__pkg__", + "//google/cloud/storage/tests:__pkg__", + ], ) diff --git a/protos/google/cloud/storage/CMakeLists.txt b/protos/google/cloud/storage/CMakeLists.txt new file mode 100644 index 0000000000000..9b320e6d52840 --- /dev/null +++ b/protos/google/cloud/storage/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright 2024 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. + +add_subdirectory(tests) diff --git a/protos/google/cloud/storage/tests/BUILD.bazel b/protos/google/cloud/storage/tests/BUILD.bazel new file mode 100644 index 0000000000000..f3f70add7cbf2 --- /dev/null +++ b/protos/google/cloud/storage/tests/BUILD.bazel @@ -0,0 +1,33 @@ +# Copyright 2024 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 + +proto_library( + name = "storage_conformance_tests_proto", + srcs = [ + "conformance_tests.proto", + ], + deps = ["@com_google_protobuf//:timestamp_proto"], +) + +cc_proto_library( + name = "storage_conformance_tests_cc_proto", + visibility = [ + "//google/cloud/storage/tests:__pkg__", + ], + deps = [":storage_conformance_tests_proto"], +) diff --git a/protos/google/cloud/storage/tests/CMakeLists.txt b/protos/google/cloud/storage/tests/CMakeLists.txt new file mode 100644 index 0000000000000..d09e64c33919c --- /dev/null +++ b/protos/google/cloud/storage/tests/CMakeLists.txt @@ -0,0 +1,49 @@ +# Copyright 2024 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. + +# Signed URL conformance tests are parsed using protos. In order to simplify the +# build files, only build these conformance tests if gRPC in GCS is compiled. +if ((NOT GOOGLE_CLOUD_CPP_STORAGE_ENABLE_GRPC) OR (NOT BUILD_TESTING)) + return() +endif () + +include(GoogleCloudCppCommon) +find_package(Protobuf CONFIG QUIET) +if (NOT Protobuf_FOUND) + find_package(Protobuf REQUIRED) +endif () + +# Generate protobuf code and library +if (COMMAND protobuf_generate) + set(protobuf_PROTOC_EXE ${Protobuf_PROTOC_EXECUTABLE}) + add_library(google_cloud_cpp_storage_tests_conformance_protos) + protobuf_generate( + LANGUAGE cpp TARGET google_cloud_cpp_storage_tests_conformance_protos + PROTOS conformance_tests.proto) +elseif (COMMAND protobuf_generate_cpp) + protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS conformance_tests.proto) + add_library(google_cloud_cpp_storage_tests_conformance_protos ${PROTO_HDRS} + ${PROTO_SRCS}) +else () + message(FATAL_ERROR "Missing protobuf_generate_cpp and protobuf_generate") +endif () + +target_link_libraries(google_cloud_cpp_storage_tests_conformance_protos + PUBLIC protobuf::libprotobuf) +target_include_directories(google_cloud_cpp_storage_tests_conformance_protos + SYSTEM PUBLIC "${PROJECT_BINARY_DIR}/protos") +google_cloud_cpp_add_common_options( + google_cloud_cpp_storage_tests_conformance_protos NO_WARNINGS) +set_target_properties(google_cloud_cpp_storage_tests_conformance_protos + PROPERTIES CXX_CLANG_TIDY "") diff --git a/google/cloud/storage/tests/conformance_tests.proto b/protos/google/cloud/storage/tests/conformance_tests.proto similarity index 100% rename from google/cloud/storage/tests/conformance_tests.proto rename to protos/google/cloud/storage/tests/conformance_tests.proto