Skip to content

Commit eaedae4

Browse files
authored
cleanup(bigquery): rename feature; bazel clean up (#10832)
1 parent e1cbcea commit eaedae4

9 files changed

Lines changed: 192 additions & 74 deletions

File tree

ci/cloudbuild/builds/clang-tidy.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ read -r ENABLED_FEATURES < <(features::always_build_cmake)
3030
ENABLED_FEATURES="${ENABLED_FEATURES},experimental-storage-grpc"
3131
ENABLED_FEATURES="${ENABLED_FEATURES},generator"
3232
ENABLED_FEATURES="${ENABLED_FEATURES},internal-docfx"
33+
# TODO(#10830) - pick up experimental-bigquery_rest from `always_build_cmake`
34+
ENABLED_FEATURES="${ENABLED_FEATURES},experimental-bigquery_rest"
3335
readonly ENABLED_FEATURES
3436

3537
mapfile -t cmake_args < <(cmake::common_args)

ci/cloudbuild/builds/lib/features.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ function features::always_build() {
3838
logging
3939
# By default, build the library with OpenTelemetry in our CI.
4040
experimental-opentelemetry
41-
# Handcrafted bigquery v2 library.
42-
bigquery_v2_minimal
41+
# TODO(#10830) - add experimental-bigquery_rest
4342
)
4443
printf "%s\n" "${list[@]}" | sort -u
4544
}

cmake/GoogleCloudCppFeatures.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function (google_cloud_cpp_enable_cleanup)
200200

201201
set(GOOGLE_CLOUD_CPP_ENABLE_REST OFF)
202202
if ((storage IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
203-
OR (bigquery_v2_minimal IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
203+
OR (experimental-bigquery_rest IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
204204
OR (generator IN_LIST GOOGLE_CLOUD_CPP_ENABLE))
205205
set(GOOGLE_CLOUD_CPP_ENABLE_REST ON)
206206
endif ()
@@ -229,7 +229,7 @@ function (google_cloud_cpp_enable_features)
229229
if (NOT ("storage" IN_LIST GOOGLE_CLOUD_CPP_ENABLE))
230230
add_subdirectory(google/cloud/storage)
231231
endif ()
232-
elseif ("${feature}" STREQUAL "bigquery_v2_minimal")
232+
elseif ("${feature}" STREQUAL "experimental-bigquery_rest")
233233
if (NOT ("bigquery" IN_LIST GOOGLE_CLOUD_CPP_ENABLE))
234234
add_subdirectory(google/cloud/bigquery)
235235
endif ()

google/cloud/bigquery/BUILD.bazel

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,11 @@ filegroup(
3232
]),
3333
)
3434

35-
filegroup(
36-
name = "v2_srcs",
37-
srcs = [
38-
"v2/minimal/internal/bigquery_http_response.cc",
39-
],
40-
)
41-
42-
filegroup(
43-
name = "v2_hdrs",
44-
srcs = [
45-
"v2/minimal/internal/bigquery_http_response.h",
46-
],
47-
)
48-
4935
filegroup(
5036
name = "mocks",
5137
srcs = glob(["mocks/*.h"]),
5238
)
5339

54-
cc_library(
55-
name = "bigquery_v2_minimal_internal",
56-
srcs = [":v2_srcs"],
57-
hdrs = [":v2_hdrs"],
58-
visibility = ["//:__pkg__"],
59-
deps = [
60-
"//:common",
61-
"//google/cloud:google_cloud_cpp_rest_internal",
62-
],
63-
)
64-
6540
cc_library(
6641
name = "google_cloud_cpp_bigquery",
6742
srcs = [":srcs"],
@@ -117,14 +92,27 @@ mock_samples_glob = ["samples/mock_*.cc"]
11792
],
11893
) for sample in glob(mock_samples_glob)]
11994

120-
cc_test(
121-
name = "bigquery_v2_minimal_internal_test",
122-
srcs = [
123-
"v2/minimal/internal/bigquery_http_response_test.cc",
95+
load(":google_cloud_cpp_bigquery_rest.bzl", "google_cloud_cpp_bigquery_rest_hdrs", "google_cloud_cpp_bigquery_rest_srcs")
96+
97+
cc_library(
98+
name = "google_cloud_cpp_bigquery_rest",
99+
srcs = google_cloud_cpp_bigquery_rest_srcs,
100+
hdrs = google_cloud_cpp_bigquery_rest_hdrs,
101+
visibility = ["//:__pkg__"],
102+
deps = [
103+
"//:common",
104+
"//google/cloud:google_cloud_cpp_rest_internal",
124105
],
106+
)
107+
108+
load(":bigquery_rest_unit_tests.bzl", "bigquery_rest_unit_tests")
109+
110+
[cc_test(
111+
name = test.replace("/", "_").replace(".cc", ""),
112+
srcs = [test],
125113
deps = [
126-
":bigquery_v2_minimal_internal",
114+
":google_cloud_cpp_bigquery_rest",
127115
"//google/cloud/testing_util:google_cloud_cpp_testing_private",
128116
"@com_google_googletest//:gtest",
129117
],
130-
)
118+
) for test in bigquery_rest_unit_tests]

google/cloud/bigquery/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ if (bigquery IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
3333
include(bigquery_grpc.cmake)
3434
endif ()
3535

36-
# TODO(#10830) - Include bigquery_v2_minimal target for rest transport.
37-
# include("${CMAKE_CURRENT_SOURCE_DIR}/bigquery_v2_minimal_internal.cmake")
36+
if (experimental-bigquery_rest IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
37+
include(bigquery_rest.cmake)
38+
endif ()
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# ~~~
2+
# Copyright 2023 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
# ~~~
16+
17+
add_library(
18+
google_cloud_cpp_bigquery_rest # cmake-format: sort
19+
v2/minimal/internal/bigquery_http_response.cc
20+
v2/minimal/internal/bigquery_http_response.h
21+
v2/minimal/internal/job_idempotency_policy.cc
22+
v2/minimal/internal/job_idempotency_policy.h
23+
v2/minimal/internal/job_logging.cc
24+
v2/minimal/internal/job_logging.h
25+
v2/minimal/internal/job_metadata.cc
26+
v2/minimal/internal/job_metadata.h
27+
v2/minimal/internal/job_options.cc
28+
v2/minimal/internal/job_options.h
29+
v2/minimal/internal/job_rest_connection_impl.cc
30+
v2/minimal/internal/job_rest_connection_impl.h
31+
v2/minimal/internal/job_rest_stub.cc
32+
v2/minimal/internal/job_rest_stub.h
33+
v2/minimal/internal/job_rest_stub_factory.cc
34+
v2/minimal/internal/job_rest_stub_factory.h
35+
v2/minimal/internal/job_retry_policy.h)
36+
target_include_directories(
37+
google_cloud_cpp_bigquery_rest
38+
PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
39+
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
40+
$<INSTALL_INTERFACE:include>)
41+
target_link_libraries(
42+
google_cloud_cpp_bigquery_rest PUBLIC google-cloud-cpp::rest_internal
43+
google-cloud-cpp::common)
44+
google_cloud_cpp_add_common_options(google_cloud_cpp_bigquery_rest)
45+
set_target_properties(
46+
google_cloud_cpp_bigquery_rest
47+
PROPERTIES EXPORT_NAME google-cloud-cpp::experimental-bigquery_rest
48+
VERSION "${PROJECT_VERSION}"
49+
SOVERSION "${PROJECT_VERSION_MAJOR}")
50+
target_compile_options(google_cloud_cpp_bigquery_rest
51+
PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG})
52+
53+
add_library(google-cloud-cpp::experimental-bigquery_rest ALIAS
54+
google_cloud_cpp_bigquery_rest)
55+
56+
# To avoid maintaining the list of files for the library, export them to a .bzl
57+
# file.
58+
include(CreateBazelConfig)
59+
create_bazel_config(google_cloud_cpp_bigquery_rest YEAR "2023")
60+
61+
# Define the tests in a function so we have a new scope for variable names.
62+
function (bigquery_rest_define_tests)
63+
# The tests require googletest to be installed. Force CMake to use the
64+
# config file for googletest (that is, the CMake file installed by
65+
# googletest itself), because the generic `FindGTest` module does not define
66+
# the GTest::gmock target, and the target names are also weird.
67+
find_package(GTest CONFIG REQUIRED)
68+
69+
set(bigquery_rest_unit_tests
70+
# cmake-format: sort
71+
v2/minimal/internal/bigquery_http_response_test.cc)
72+
73+
# Export the list of unit tests to a .bzl file so we do not need to maintain
74+
# the list in two places.
75+
export_list_to_bazel("bigquery_rest_unit_tests.bzl"
76+
"bigquery_rest_unit_tests" YEAR "2023")
77+
78+
# Create a custom target so we can say "build all the tests"
79+
add_custom_target(bigquery_rest-tests)
80+
81+
# Generate a target for each unit test.
82+
foreach (fname ${bigquery_rest_unit_tests})
83+
google_cloud_cpp_add_executable(target "bigquery" "${fname}")
84+
target_link_libraries(
85+
${target}
86+
PRIVATE google_cloud_cpp_testing
87+
google-cloud-cpp::experimental-bigquery_rest
88+
GTest::gmock_main GTest::gmock GTest::gtest)
89+
google_cloud_cpp_add_common_options(${target})
90+
91+
# With googletest it is relatively easy to exceed the default number of
92+
# sections (~65,000) in a single .obj file. Add the /bigobj option to
93+
# all the tests, even if it is not needed.
94+
if (MSVC)
95+
target_compile_options(${target} PRIVATE "/bigobj")
96+
endif ()
97+
add_test(NAME ${target} COMMAND ${target})
98+
add_dependencies(bigquery_rest-tests ${target})
99+
endforeach ()
100+
endfunction ()
101+
102+
if (BUILD_TESTING)
103+
bigquery_rest_define_tests()
104+
endif ()
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# DO NOT EDIT -- GENERATED BY CMake -- Change the CMakeLists.txt file if needed
16+
17+
"""Automatically generated unit tests list - DO NOT EDIT."""
18+
19+
bigquery_rest_unit_tests = [
20+
"v2/minimal/internal/bigquery_http_response_test.cc",
21+
]

google/cloud/bigquery/bigquery_v2_minimal_internal.cmake

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
#
15+
# DO NOT EDIT -- GENERATED BY CMake -- Change the CMakeLists.txt file if needed
16+
17+
"""Automatically generated source lists for google_cloud_cpp_bigquery_rest - DO NOT EDIT."""
18+
19+
google_cloud_cpp_bigquery_rest_hdrs = [
20+
"v2/minimal/internal/bigquery_http_response.h",
21+
"v2/minimal/internal/job_idempotency_policy.h",
22+
"v2/minimal/internal/job_logging.h",
23+
"v2/minimal/internal/job_metadata.h",
24+
"v2/minimal/internal/job_options.h",
25+
"v2/minimal/internal/job_rest_connection_impl.h",
26+
"v2/minimal/internal/job_rest_stub.h",
27+
"v2/minimal/internal/job_rest_stub_factory.h",
28+
"v2/minimal/internal/job_retry_policy.h",
29+
]
30+
31+
google_cloud_cpp_bigquery_rest_srcs = [
32+
"v2/minimal/internal/bigquery_http_response.cc",
33+
"v2/minimal/internal/job_idempotency_policy.cc",
34+
"v2/minimal/internal/job_logging.cc",
35+
"v2/minimal/internal/job_metadata.cc",
36+
"v2/minimal/internal/job_options.cc",
37+
"v2/minimal/internal/job_rest_connection_impl.cc",
38+
"v2/minimal/internal/job_rest_stub.cc",
39+
"v2/minimal/internal/job_rest_stub_factory.cc",
40+
]

0 commit comments

Comments
 (0)