Skip to content

Commit f450216

Browse files
authored
cleanup: remove ci/etc/full_feature_list (#12761)
We had two sources of truth for the "list of all the libraries". This is clearly undesirable, and it was time to fix it. I had to change some of the CMake scripts, and took an opportunity to (in my opinion) simplify them. This makes `oauth2` a regular library, but then its `main.dox` must follow the pattern for hand-crafted libraries so it is skipped by the script to automatically update it.
1 parent e3c2d59 commit f450216

14 files changed

Lines changed: 68 additions & 198 deletions

ci/cloudbuild/builds/check-api.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if [ "${GOOGLE_CLOUD_CPP_CHECK_API:-}" ]; then
3232
IFS=',' read -ra library_list <<<"${GOOGLE_CLOUD_CPP_CHECK_API}"
3333
else
3434
readonly ENABLED_FEATURES="__ga_libraries__,opentelemetry"
35-
mapfile -t library_list < <(cmake -DCMAKE_MODULE_PATH="${PWD}/cmake" -P cmake/print-ga-libraries.cmake 2>&1)
35+
mapfile -t library_list < <(cmake -P cmake/print-ga-libraries.cmake 2>&1)
3636
# These libraries are not "features", but they are part of the public API
3737
library_list+=("common" "grpc_utils")
3838
# This is a GA library, not included in __ga_libraries__

ci/cloudbuild/builds/checkers.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ time {
203203
done
204204

205205
mapfile -t libraries < <(features::libraries)
206-
for library in "${libraries[@]}" opentelemetry oauth2; do
206+
for library in "${libraries[@]}" opentelemetry; do
207207
ci/generate-markdown/update-library-readme.sh "${library}"
208208
done
209209
}

ci/cloudbuild/builds/cmake-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ env -C "${out_dir}" ctest "${ctest_args[@]}"
202202
# shellcheck disable=SC2046
203203
feature_list="$(printf "%s;" $(features::libraries))"
204204
# GCS+gRPC, OAuth2, and OpenTelemetry also have quickstarts.
205-
feature_list="${feature_list}experimental-storage_grpc;oauth2;opentelemetry"
205+
feature_list="${feature_list}experimental-storage_grpc;opentelemetry"
206206
cmake -G Ninja \
207207
-S "${PROJECT_ROOT}/ci/verify_quickstart" \
208208
-B "${PROJECT_ROOT}/cmake-out/quickstart" \

ci/cloudbuild/builds/cmake-split-install.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ io::run cmake --install cmake-out/features --prefix "${INSTALL_PREFIX}"
7878

7979
# Tests the installed artifacts by building all the quickstarts.
8080
# shellcheck disable=SC2046
81-
mapfile -t feature_list < <(cmake -DCMAKE_MODULE_PATH="${PWD}/cmake" -P cmake/print-ga-features.cmake 2>&1)
81+
mapfile -t feature_list < <(cmake -P cmake/print-ga-features.cmake 2>&1)
8282
FEATURES=$(printf ";%s" "${feature_list[@]}")
8383
FEATURES="${FEATURES:1}"
8484
io::run cmake -G Ninja \

ci/cloudbuild/builds/lib/features.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ function features::always_build_cmake() {
5555

5656
function features::libraries() {
5757
local feature_list
58-
mapfile -t feature_list <ci/etc/full_feature_list
58+
mapfile -t feature_list < <(cmake -P cmake/print-all-features.cmake 2>&1)
5959
printf "%s\n" "${feature_list[@]}" | sort -u
6060
}
6161

6262
function features::_internal_extra() {
6363
local list=(
6464
experimental-bigquery_rest
6565
experimental-storage_grpc
66-
oauth2
6766
opentelemetry
6867
)
6968
printf "%s\n" "${list[@]}"

ci/etc/full_feature_list

Lines changed: 0 additions & 122 deletions
This file was deleted.

ci/generate-markdown/generate-readme.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ file="README.md"
3434
) | sponge "${file}"
3535

3636
(
37-
mapfile -t features < <(cmake -DCMAKE_MODULE_PATH="${PWD}/cmake" -P cmake/print-ga-features.cmake 2>&1 | LC_ALL=C sort)
37+
mapfile -t features < <(cmake -P cmake/print-ga-features.cmake 2>&1 | LC_ALL=C sort)
3838
sed '/<!-- inject-GA-features-start -->/q' "${file}"
3939
for feature in "${features[@]}"; do
4040
if [[ "${feature}" == "oauth2" ]]; then

cmake/GoogleCloudCppFeatures.cmake

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -241,34 +241,24 @@ set(GOOGLE_CLOUD_CPP_COMPUTE_LIBRARIES
241241
"compute_region_operations"
242242
"compute_zone_operations")
243243

244-
list(FIND GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES "compute"
245-
compute_experimental)
246-
if (NOT compute_experimental EQUAL -1)
247-
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES "compute")
248-
list(APPEND GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES
249-
${GOOGLE_CLOUD_CPP_COMPUTE_LIBRARIES})
250-
list(SORT GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES)
251-
endif ()
252-
253-
list(FIND GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES "compute" compute_transition)
254-
if (NOT compute_transition EQUAL -1)
255-
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES "compute")
256-
list(APPEND GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES
257-
${GOOGLE_CLOUD_CPP_COMPUTE_LIBRARIES})
258-
list(SORT GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES)
259-
endif ()
260-
261-
list(FIND GOOGLE_CLOUD_CPP_GA_LIBRARIES "compute" compute_ga)
262-
if (NOT compute_ga EQUAL -1)
263-
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_GA_LIBRARIES "compute")
264-
list(APPEND GOOGLE_CLOUD_CPP_GA_LIBRARIES
265-
${GOOGLE_CLOUD_CPP_COMPUTE_LIBRARIES})
266-
list(SORT GOOGLE_CLOUD_CPP_GA_LIBRARIES)
267-
endif ()
244+
# Use a function to get a new scope, so the GOOGLE_CLOUD_CPP_*_LIBRARIES remain
245+
# unchanged.
246+
function (export_libraries_bzl)
247+
foreach (stage IN ITEMS EXPERIMENTAL TRANSITION GA)
248+
set(var "GOOGLE_CLOUD_CPP_${stage}_LIBRARIES")
249+
if (NOT "compute" IN_LIST ${var})
250+
continue()
251+
endif ()
252+
list(REMOVE_ITEM ${var} "compute")
253+
list(APPEND ${var} ${GOOGLE_CLOUD_CPP_COMPUTE_LIBRARIES})
254+
list(SORT ${var})
255+
endforeach ()
268256

269-
export_list_to_bazel(
270-
"libraries.bzl" YEAR 2023 GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES
271-
GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES GOOGLE_CLOUD_CPP_GA_LIBRARIES)
257+
export_list_to_bazel(
258+
"libraries.bzl" YEAR 2023 GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES
259+
GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES GOOGLE_CLOUD_CPP_GA_LIBRARIES)
260+
endfunction ()
261+
export_libraries_bzl()
272262

273263
# ~~~
274264
# Handle the dependencies between features. That is, if feature "X" is enabled
@@ -294,11 +284,17 @@ macro (google_cloud_cpp_enable_deps)
294284
set(GOOGLE_CLOUD_CPP_ENABLE_GRPC ON)
295285
set(GOOGLE_CLOUD_CPP_ENABLE_REST ON)
296286
endif ()
287+
if (compute IN_LIST GOOGLE_CLOUD_CPP_ENABLE)
288+
list(APPEND GOOGLE_CLOUD_CPP_ENABLE
289+
${GOOGLE_CLOUD_CPP_COMPUTE_LIBRARIES})
290+
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "compute")
291+
endif ()
297292
set(disabled_features ${GOOGLE_CLOUD_CPP_ENABLE})
298293
list(FILTER disabled_features INCLUDE REGEX "^-")
299294
foreach (disabled IN LISTS disabled_features)
300295
if (disabled STREQUAL "-compute")
301296
list(FILTER GOOGLE_CLOUD_CPP_ENABLE EXCLUDE REGEX "^compute_.*")
297+
list(REMOVE_ITEM GOOGLE_CLOUD_CPP_ENABLE "compute")
302298
continue()
303299
endif ()
304300
string(SUBSTRING "${disabled}" 1 -1 feature)

cmake/print-all-features.cmake

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
# A CMake script to print all the features.
18+
cmake_minimum_required(VERSION 3.13...3.24)
19+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
20+
include(GoogleCloudCppFeatures)
21+
22+
foreach (
23+
feature IN
24+
LISTS GOOGLE_CLOUD_CPP_GA_LIBRARIES GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES
25+
GOOGLE_CLOUD_CPP_EXPERIMENTAL_LIBRARIES)
26+
message(${feature})
27+
endforeach ()

cmake/print-ga-features.cmake

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,11 @@
1515
# ~~~
1616

1717
# A CMake script to print the GA features.
18-
18+
cmake_minimum_required(VERSION 3.13...3.24)
19+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
1920
include(GoogleCloudCppFeatures)
2021

21-
set(emitted_compute_feature FALSE)
2222
foreach (feature IN LISTS GOOGLE_CLOUD_CPP_GA_LIBRARIES
2323
GOOGLE_CLOUD_CPP_TRANSITION_LIBRARIES)
24-
string(REGEX MATCH "^compute_.*" compute_regex_match ${feature})
25-
if (compute_regex_match)
26-
if (NOT emitted_compute_feature)
27-
message("compute")
28-
set(emitted_compute_feature TRUE)
29-
endif ()
30-
else ()
31-
message(${feature})
32-
endif ()
24+
message(${feature})
3325
endforeach ()

0 commit comments

Comments
 (0)