This is an automated email from the ASF dual-hosted git repository.
bneradt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new e4ff6cab07 Add auto options for maxmind_acl, stek_share, and
uri_signing plugins (#10741)
e4ff6cab07 is described below
commit e4ff6cab0713f25290a62aba74b8e1a595b7bc30
Author: JosiahWI <[email protected]>
AuthorDate: Fri Nov 10 16:21:46 2023 -0600
Add auto options for maxmind_acl, stek_share, and uri_signing plugins
(#10741)
This helps clean up the dependency management and gives fine grained
control over whether these plugins are built. I am planning to add all the
experimental plugins, but I want to get these changes in quickly because we are
still in the middle of fixing the plugins, and other PRs can build on these
changes.
BUILD_EXPERIMENTAL_PLUGINS determines whether these plugins are OFF or AUTO
on the first configuration. Changing the value of BUILD_EXPERIMENTAL_PLUGINS
subsequently will not change whether those plugins are built, because their
enabled/disabled state is cached separately. I have not come up with a good way
to fix this. Suggestions welcome.
---
CMakeLists.txt | 8 +--
cmake/AutoOptionHelpers.cmake | 16 +++++-
cmake/ExperimentalPlugins.cmake | 65 +++++++++++++++++++++++++
cmake/Findnuraft.cmake | 19 ++++----
plugins/experimental/CMakeLists.txt | 7 ---
plugins/experimental/maxmind_acl/CMakeLists.txt | 2 +-
6 files changed, 94 insertions(+), 23 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 10d37354dd..ff6e44e47d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -104,8 +104,6 @@ auto_option(
)
auto_option(LUAJIT PACKAGE_DEPENDS LuaJIT)
auto_option(UNWIND FEATURE_VAR TS_USE_REMOTE_UNWINDING PACKAGE_DEPENDS unwind)
-auto_option(CJOSE PACKAGE_DEPENDS cjose)
-auto_option(JANSSON PACKAGE_DEPENDS jansson)
option(ENABLE_ASAN "Use address sanitizer (default OFF)")
option(ENABLE_FUZZING "Enable fuzzing (default OFF)")
@@ -328,8 +326,6 @@ if(ENABLE_QUICHE)
endif()
endif()
-# for the plugin system
-find_package(nuraft) # experimental stek_share
find_package(maxminddb) # Header_rewrite experimental/maxmind_acl
if(ENABLE_ASAN)
@@ -614,6 +610,10 @@ if(ENABLE_FUZZING)
add_subdirectory(tests/fuzzing)
endif()
add_subdirectory(plugins)
+
+# set up auto options for experimental plugins
+include(ExperimentalPlugins)
+
add_subdirectory(configs)
if(ENABLE_EXAMPLE)
add_subdirectory(example)
diff --git a/cmake/AutoOptionHelpers.cmake b/cmake/AutoOptionHelpers.cmake
index b187db4206..e1b7f93fe2 100644
--- a/cmake/AutoOptionHelpers.cmake
+++ b/cmake/AutoOptionHelpers.cmake
@@ -67,7 +67,9 @@ endmacro()
# [DESCRIPTION <description>]
# [DEFAULT <default>]
# [FEATURE_VAR <feature_var>]
+# [WITH_SUBDIRECTORY <name>]
# [PACKAGE_DEPENDS <package_one> <package_two> ...]
+# [HEADER_DEPENDS <header_one> <header_two> ...]
# )
#
# This macro registers a new auto option and sets its corresponding feature
@@ -97,9 +99,17 @@ endmacro()
# used, given the value of the option and whether the requirements for the
# feature are satisfied. By default, it is USE_<feature_name>.
#
+# WITH_SUBDIRECTORY is an optional subdirectory that should be added if the
+# feature is enabled.
+#
# PACKAGE_DEPENDS is a list of packages that are required for the feature.
+#
+# HEADER_DEPENDS is a list of headers that are required for the feature.
+#
macro(auto_option _FEATURE_NAME)
- cmake_parse_arguments(ARG "" "DESCRIPTION;DEFAULT;FEATURE_VAR"
"PACKAGE_DEPENDS;HEADER_DEPENDS" ${ARGN})
+ cmake_parse_arguments(
+ ARG "" "DESCRIPTION;DEFAULT;FEATURE_VAR;WITH_SUBDIRECTORY"
"PACKAGE_DEPENDS;HEADER_DEPENDS" ${ARGN}
+ )
set(OPTION_VAR "ENABLE_${_FEATURE_NAME}")
if(ARG_FEATURE_VAR)
@@ -127,6 +137,10 @@ macro(auto_option _FEATURE_NAME)
else()
set(${FEATURE_VAR} FALSE)
endif()
+
+ if(ARG_WITH_SUBDIRECTORY AND ${${FEATURE_VAR}})
+ add_subdirectory(${ARG_WITH_SUBDIRECTORY})
+ endif()
endmacro()
# Prints a colorized summary of one auto option.
diff --git a/cmake/ExperimentalPlugins.cmake b/cmake/ExperimentalPlugins.cmake
new file mode 100644
index 0000000000..97f3ab0036
--- /dev/null
+++ b/cmake/ExperimentalPlugins.cmake
@@ -0,0 +1,65 @@
+#######################
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
contributor license
+# agreements. See the NOTICE file distributed with this work for additional
information regarding
+# copyright ownership. The ASF licenses this file to you 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.
+#
+#######################
+
+# These are all the auto options for experimental plugins. They are contained
in a
+# module instead of a subdirectory because auto_options added in a
subdirectory are
+# not visible to their parent directories.
+
+# Note that this default only works on the first run before the options are
cached.
+# Once the options are cached they must be adjusted manually.
+if(BUILD_EXPERIMENTAL_PLUGINS)
+ set(_DEFAULT AUTO)
+else()
+ set(_DEFAULT OFF)
+endif()
+
+auto_option(
+ MAXMIND_ACL
+ FEATURE_VAR
+ BUILD_MAXMIND_ACL
+ WITH_SUBDIRECTORY
+ plugins/experimental/maxmind_acl
+ PACKAGE_DEPENDS
+ maxminddb
+ DEFAULT
+ ${_DEFAULT}
+)
+auto_option(
+ STEK_SHARE
+ FEATURE_VAR
+ BUILD_STEK_SHARE
+ WITH_SUBDIRECTORY
+ plugins/experimental/stek_share
+ PACKAGE_DEPENDS
+ nuraft
+ DEFAULT
+ ${_DEFAULT}
+)
+auto_option(
+ URI_SIGNING
+ FEATURE_VAR
+ BUILD_URI_SIGNING
+ WITH_SUBDIRECTORY
+ plugins/experimental/uri_signing
+ PACKAGE_DEPENDS
+ cjose
+ jansson
+ DEFAULT
+ ${_DEFAULT}
+)
+
+unset(_DEFAULT)
diff --git a/cmake/Findnuraft.cmake b/cmake/Findnuraft.cmake
index 25bb3a5d38..507a5cd3da 100644
--- a/cmake/Findnuraft.cmake
+++ b/cmake/Findnuraft.cmake
@@ -27,20 +27,19 @@
#
find_library(nuraft_LIBRARY nuraft)
-find_path(
- nuraft_INCLUDE_DIR
- NAMES libnuraft/nuraft.hxx
-)
+find_path(nuraft_INCLUDE_DIR NAMES libnuraft/nuraft.hxx)
mark_as_advanced(nuraft_FOUND nuraft_LIBRARY nuraft_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(nuraft REQUIRED_VARS nuraft_LIBRARY
nuraft_INCLUDE_DIR)
-# Add the library but only add libraries if nuraft is found
-add_library(nuraft::nuraft INTERFACE IMPORTED)
-if(nuraft_FOUND)
- set(nuraft_INCLUDE_DIRS ${nuraft_INCLUDE_DIR})
- target_include_directories(nuraft::nuraft INTERFACE ${nuraft_INCLUDE_DIRS})
- target_link_libraries(nuraft::nuraft INTERFACE ${nuraft_LIBRARY})
+if(nuraft_FOUND AND NOT TARGET nuraft::nuraft)
+ # Add the library but only add libraries if nuraft is found
+ add_library(nuraft::nuraft INTERFACE IMPORTED)
+ if(nuraft_FOUND)
+ set(nuraft_INCLUDE_DIRS ${nuraft_INCLUDE_DIR})
+ target_include_directories(nuraft::nuraft INTERFACE ${nuraft_INCLUDE_DIRS})
+ target_link_libraries(nuraft::nuraft INTERFACE ${nuraft_LIBRARY})
+ endif()
endif()
diff --git a/plugins/experimental/CMakeLists.txt
b/plugins/experimental/CMakeLists.txt
index e2e79b2930..a01426dc15 100644
--- a/plugins/experimental/CMakeLists.txt
+++ b/plugins/experimental/CMakeLists.txt
@@ -28,7 +28,6 @@ add_subdirectory(hook-trace)
add_subdirectory(http_stats)
add_subdirectory(icap)
add_subdirectory(inliner)
-add_subdirectory(maxmind_acl)
add_subdirectory(memcache)
add_subdirectory(memory_profile)
add_subdirectory(money_trace)
@@ -36,13 +35,7 @@ add_subdirectory(mp4)
add_subdirectory(rate_limit)
add_subdirectory(redo_cache_lookup)
add_subdirectory(sslheaders)
-add_subdirectory(stek_share)
add_subdirectory(stream_editor)
add_subdirectory(system_stats)
add_subdirectory(tls_bridge)
-if(USE_CJOSE AND USE_JANSSON)
- add_subdirectory(uri_signing)
-else()
- message(STATUS "skipping uri_signing plugin (missing cjose and jansson)")
-endif()
add_subdirectory(url_sig)
diff --git a/plugins/experimental/maxmind_acl/CMakeLists.txt
b/plugins/experimental/maxmind_acl/CMakeLists.txt
index 02c4ca252c..ad5a9c7ede 100644
--- a/plugins/experimental/maxmind_acl/CMakeLists.txt
+++ b/plugins/experimental/maxmind_acl/CMakeLists.txt
@@ -21,7 +21,7 @@ if(maxminddb_FOUND)
target_include_directories(maxmind_acl PRIVATE ${PCRE_INCLUDE_DIR})
- target_link_libraries(maxmind_acl PRIVATE libswoc yaml-cpp::yaml-cpp
maxminddb::maxminddb)
+ target_link_libraries(maxmind_acl PRIVATE libswoc ts::tsapicore
yaml-cpp::yaml-cpp maxminddb::maxminddb)
else()
message(STATUS "skipping maxmind_acl plugin (missing maxminddb)")