This is an automated email from the ASF dual-hosted git repository.

jvanderzee 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 1036e47eda Add auto options for all experimental plugins (#10967)
1036e47eda is described below

commit 1036e47eda5e4a395d51c3e54a290263a3fa2e81
Author: JosiahWI <[email protected]>
AuthorDate: Fri May 31 15:18:51 2024 -0500

    Add auto options for all experimental plugins (#10967)
    
    * Add auto options for all experimental plugins
    
    Auto options were added for the experimental plugins with special
    dependencies in #10741. This adds options for the remaining experimental
    plugins.
    
    It was pointed out that WITH_SUBDIRECTORY is giving auto_options
    too many responsibilities and it will be removed.
    
    * Remove WITH_SUBDIRECTORY from auto_option
---
 CMakeLists.txt                             |  21 ++---
 cmake/AutoOptionHelpers.cmake              |  12 +--
 cmake/ExperimentalPlugins.cmake            |  72 +++++++++++------
 plugins/CMakeLists.txt                     |  29 +++++--
 plugins/experimental/CMakeLists.txt        | 126 +++++++++++++++++++++--------
 plugins/experimental/magick/CMakeLists.txt |   3 +
 6 files changed, 176 insertions(+), 87 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 49b6933ff6..9d9c7a1539 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,21 +109,8 @@ auto_option(
   "sys/prctl.h"
 )
 auto_option(LUAJIT PACKAGE_DEPENDS luajit)
-auto_option(
-  MAGICK
-  PACKAGE_DEPENDS
-  ImageMagick
-  COMPONENTS
-  Magick++
-  MagickWand
-  MagickCore
-)
-
 auto_option(UNWIND FEATURE_VAR TS_USE_REMOTE_UNWINDING PACKAGE_DEPENDS unwind)
 
-# This creates the magic import target if necessary (older cmake)
-include(magick_target)
-
 option(ENABLE_ASAN "Use address sanitizer (default OFF)")
 option(ENABLE_FUZZING "Enable fuzzing (default OFF)")
 option(ENABLE_FIPS "Enable fips compliance (default OFF)")
@@ -656,10 +643,16 @@ endif()
 if(ENABLE_FUZZING)
   add_subdirectory(tests/fuzzing)
 endif()
-add_subdirectory(plugins)
 
 # set up auto options for experimental plugins
+# This must be done before setting up the stable plugins
+# because they check whether the experimental plugins
+# already found ImageMagick, but not the other way around.
+# Doing these in the other order may add ImageMagick::Magick++
+# twice which is an error.
 include(ExperimentalPlugins)
+# This also adds any experimental plugins that have been enabled.
+add_subdirectory(plugins)
 
 add_subdirectory(configs)
 if(ENABLE_EXAMPLE)
diff --git a/cmake/AutoOptionHelpers.cmake b/cmake/AutoOptionHelpers.cmake
index 8af3e6d7ed..0bd52720a2 100644
--- a/cmake/AutoOptionHelpers.cmake
+++ b/cmake/AutoOptionHelpers.cmake
@@ -87,7 +87,6 @@ endmacro()
 #   [DESCRIPTION <description>]
 #   [DEFAULT <default>]
 #   [FEATURE_VAR <feature_var>]
-#   [WITH_SUBDIRECTORY <name>]
 #   [COMPONENT <component>]
 #   [PACKAGE_DEPENDS <package_one> <package_two> ...]
 #   [HEADER_DEPENDS <header_one> <header_two> ...]
@@ -120,9 +119,6 @@ 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.
-#
 # COMPONENT check for a component of the package. Currently this only works if
 # specifying a single package in PACKAGE_DEPENDS
 #
@@ -131,9 +127,7 @@ endmacro()
 # 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;WITH_SUBDIRECTORY" 
"PACKAGE_DEPENDS;HEADER_DEPENDS;COMPONENTS" ${ARGN}
-  )
+  cmake_parse_arguments(ARG "" "DESCRIPTION;DEFAULT;FEATURE_VAR" 
"PACKAGE_DEPENDS;HEADER_DEPENDS;COMPONENTS" ${ARGN})
 
   set(OPTION_VAR "ENABLE_${_FEATURE_NAME}")
   if(ARG_FEATURE_VAR)
@@ -165,10 +159,6 @@ 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
index c96c69fb22..c555f34385 100644
--- a/cmake/ExperimentalPlugins.cmake
+++ b/cmake/ExperimentalPlugins.cmake
@@ -27,61 +27,87 @@ else()
   set(_DEFAULT OFF)
 endif()
 
-include(add_atsplugin)
-
+auto_option(ACCESS_CONTROL FEATURE_VAR BUILD_ACCESS_CONTROL DEFAULT 
${_DEFAULT})
+auto_option(BLOCK_ERRORS FEATURE_VAR BUILD_BLOCK_ERRORS DEFAULT ${_DEFAULT})
+auto_option(CACHE_FILL FEATURE_VAR BUILD_CACHE_FILL DEFAULT ${_DEFAULT})
+auto_option(CERT_REPORTING_TOOL FEATURE_VAR BUILD_CERT_REPORTING_TOOL DEFAULT 
${_DEFAULT})
+auto_option(COOKIE_REMAP FEATURE_VAR BUILD_COOKIE_REMAP DEFAULT ${_DEFAULT})
+auto_option(CUSTOM_REDIRECT FEATURE_VAR BUILD_CUSTOM_REDIRECT DEFAULT 
${_DEFAULT})
+auto_option(FQ_PACING FEATURE_VAR BUILD_FQ_PACING DEFAULT ${_DEFAULT})
+auto_option(GEOIP_ACL FEATURE_VAR BUILD_GEOIP_ACL DEFAULT ${_DEFAULT})
+auto_option(HEADER_FREQ FEATURE_VAR BUILD_HEADER_FREQ DEFAULT ${_DEFAULT})
+auto_option(HOOK_TRACE FEATURE_VAR BUILD_HOOK_TRACE DEFAULT ${_DEFAULT})
+auto_option(HTTP_STATS FEATURE_VAR BUILD_HTTP_STATS DEFAULT ${_DEFAULT})
+auto_option(ICAP FEATURE_VAR BUILD_ICAP DEFAULT ${_DEFAULT})
+auto_option(INLINER FEATURE_VAR BUILD_INLINER DEFAULT ${_DEFAULT})
+auto_option(
+  MAGICK
+  FEATURE_VAR
+  BUILD_MAGICK
+  PACKAGE_DEPENDS
+  ImageMagick
+  COMPONENTS
+  Magick++
+  MagickWand
+  MagickCore
+  DEFAULT
+  ${_DEFAULT}
+)
 auto_option(
   MAXMIND_ACL
   FEATURE_VAR
   BUILD_MAXMIND_ACL
-  WITH_SUBDIRECTORY
-  plugins/experimental/maxmind_acl
   PACKAGE_DEPENDS
   maxminddb
   DEFAULT
   ${_DEFAULT}
 )
+auto_option(MEMCACHE FEATURE_VAR BUILD_MEMCACHE DEFAULT ${_DEFAULT})
+auto_option(MEMORY_PROFILE FEATURE_VAR BUILD_MEMORY_PROFILE DEFAULT 
${_DEFAULT})
+auto_option(MONEY_TRACE FEATURE_VAR BUILD_MONEY_TRACE DEFAULT ${_DEFAULT})
+auto_option(MP4 FEATURE_VAR BUILD_MP4 DEFAULT ${_DEFAULT})
+auto_option(
+  OTEL_TRACER
+  FEATURE_VAR
+  BUILD_OTEL_TRACER
+  PACKAGE_DEPENDS
+  opentelemetry
+  Protobuf
+  CURL
+  DEFAULT
+  ${_DEFAULT}
+)
+auto_option(RATE_LIMIT FEATURE_VAR BUILD_RATE_LIMIT DEFAULT ${_DEFAULT})
+auto_option(REDO_CACHE_LOOKUP FEATURE_VAR BUILD_REDO_CACHE_LOOKUP DEFAULT 
${_DEFAULT})
+auto_option(SSLHEADERS FEATURE_VAR BUILD_SSLHEADERS DEFAULT ${_DEFAULT})
 auto_option(
   STEK_SHARE
   FEATURE_VAR
   BUILD_STEK_SHARE
-  WITH_SUBDIRECTORY
-  plugins/experimental/stek_share
   PACKAGE_DEPENDS
   nuraft
   DEFAULT
   ${_DEFAULT}
 )
+auto_option(STREAM_EDITOR FEATURE_VAR BUILD_STREAM_EDITOR DEFAULT ${_DEFAULT})
+auto_option(SYSTEM_STATS FEATURE_VAR BUILD_SYSTEM_STATS DEFAULT ${_DEFAULT})
+auto_option(TLS_BRIDGE FEATURE_VAR BUILD_TLS_BRIDGE DEFAULT ${_DEFAULT})
+auto_option(TXN_BOX FEATURE_VAR BUILD_TXN_BOX DEFAULT ${_DEFAULT})
 auto_option(
   URI_SIGNING
   FEATURE_VAR
   BUILD_URI_SIGNING
-  WITH_SUBDIRECTORY
-  plugins/experimental/uri_signing
   PACKAGE_DEPENDS
   cjose
   jansson
   DEFAULT
   ${_DEFAULT}
 )
-auto_option(
-  OTEL_TRACER
-  FEATURE_VAR
-  BUILD_OTEL_TRACER
-  WITH_SUBDIRECTORY
-  plugins/experimental/otel_tracer
-  PACKAGE_DEPENDS
-  opentelemetry
-  Protobuf
-  CURL
-  DEFAULT
-  ${_DEFAULT}
-)
+auto_option(URL_SIG FEATURE_VAR BUILD_URL_SIG DEFAULT ${_DEFAULT})
 auto_option(
   WASM
   FEATURE_VAR
   BUILD_WASM
-  WITH_SUBDIRECTORY
-  plugins/experimental/wasm
   PACKAGE_DEPENDS
   wamr
   DEFAULT
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index 4d0e24419b..499b18fc08 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -17,6 +17,8 @@
 
 include(add_atsplugin)
 
+# The experimental plugins are handled in cmake/ExperimentalPlugins.cmake.
+
 add_subdirectory(authproxy)
 add_subdirectory(background_fetch)
 add_subdirectory(cache_promote)
@@ -53,14 +55,31 @@ if(USE_LUAJIT)
   add_subdirectory(lua)
 endif()
 
-if(BUILD_EXPERIMENTAL_PLUGINS)
-  add_subdirectory(experimental)
-endif()
-
 if(HOST_OS STREQUAL "linux")
   add_subdirectory(healthchecks)
 endif()
 
-if(USE_MAGICK)
+# FindImageMagick.cmake fails to check whether the target
+# exists before creating it, and we also find this for
+# the experimental/magick plugin. We have to guard the
+# find_package() call to ensure the module doesn't try
+# to create the same target twice.
+if(NOT TARGET ImageMagick::Magick++)
+  auto_option(
+    WEBP_TRANSFORM
+    FEATURE_VAR
+    BUILD_WEBP_TRANSFORM
+    PACKAGE_DEPENDS
+    ImageMagick
+    COMPONENTS
+    Magick++
+  )
+
+  include(magick_target)
+endif()
+
+if(BUILD_WEBP_TRANSFORM)
   add_subdirectory(webp_transform)
 endif()
+
+add_subdirectory(experimental)
diff --git a/plugins/experimental/CMakeLists.txt 
b/plugins/experimental/CMakeLists.txt
index a02d891d1c..0dcdcbb73b 100644
--- a/plugins/experimental/CMakeLists.txt
+++ b/plugins/experimental/CMakeLists.txt
@@ -15,40 +15,98 @@
 #
 #######################
 
-add_subdirectory(access_control)
-add_subdirectory(block_errors)
-add_subdirectory(cache_fill)
-add_subdirectory(cert_reporting_tool)
-add_subdirectory(cookie_remap)
-add_subdirectory(custom_redirect)
-add_subdirectory(fq_pacing)
-add_subdirectory(geoip_acl)
-add_subdirectory(header_freq)
-add_subdirectory(hook-trace)
-add_subdirectory(http_stats)
-add_subdirectory(icap)
-add_subdirectory(inliner)
-add_subdirectory(memcache)
-add_subdirectory(memory_profile)
-add_subdirectory(money_trace)
-add_subdirectory(mp4)
-add_subdirectory(rate_limit)
-add_subdirectory(redo_cache_lookup)
-add_subdirectory(sslheaders)
-add_subdirectory(stale_response)
-add_subdirectory(stream_editor)
-add_subdirectory(system_stats)
-add_subdirectory(tls_bridge)
-add_subdirectory(url_sig)
-add_subdirectory(txn_box)
+# See cmake/ExperimentalPlugins.cmake for the auto_options.
 
-if(USE_MAGICK)
+if(BUILD_ACCESS_CONTROL)
+  add_subdirectory(access_control)
+endif()
+if(BUILD_BLOCK_ERRORS)
+  add_subdirectory(block_errors)
+endif()
+if(BUILD_CACHE_FILL)
+  add_subdirectory(cache_fill)
+endif()
+if(BUILD_CERT_REPORTING_TOOL)
+  add_subdirectory(cert_reporting_tool)
+endif()
+if(BUILD_COOKIE_REMAP)
+  add_subdirectory(cookie_remap)
+endif()
+if(BUILD_CUSTOM_REDIRECT)
+  add_subdirectory(custom_redirect)
+endif()
+if(BUILD_FQ_PACING)
+  add_subdirectory(fq_pacing)
+endif()
+if(BUILD_GEOIP_ACL)
+  add_subdirectory(geoip_acl)
+endif()
+if(BUILD_HEADER_FREQ)
+  add_subdirectory(header_freq)
+endif()
+if(BUILD_HOOK_TRACE)
+  add_subdirectory(hook-trace)
+endif()
+if(BUILD_HOOK_STATS)
+  add_subdirectory(hook_stats)
+endif()
+if(BUILD_ICAP)
+  add_subdirectory(icap)
+endif()
+if(BUILD_INLINER)
+  add_subdirectory(inliner)
+endif()
+if(BUILD_MAGICK)
   add_subdirectory(magick)
 endif()
-#add_subdirectory(wasm)
-
-# These are included via cmake/ExperimentalPlugins.cmake
-#add_subdirectory(maxmind_acl)
-#add_subdirectory(stek_share)
-#add_subdirectory(uri_signing)
-#add_subdirectory(otel_tracer)
+if(BUILD_MAXMIND_ACL)
+  add_subdirectory(maxmind_acl)
+endif()
+if(BUILD_MEMCACHE)
+  add_subdirectory(memcache)
+endif()
+if(BUILD_MEMORY_PROFILE)
+  add_subdirectory(memory_profile)
+endif()
+if(BUILD_MONEY_TRACE)
+  add_subdirectory(money_trace)
+endif()
+if(BUILD_MP4)
+  add_subdirectory(mp4)
+endif()
+if(BUILD_OTEL_TRACER)
+  add_subdirectory(otel_tracer)
+endif()
+if(BUILD_RATE_LIMIT)
+  add_subdirectory(rate_limit)
+endif()
+if(BUILD_REDO_CACHE_LOOKUP)
+  add_subdirectory(redo_cache_lookup)
+endif()
+if(BUILD_SSLHEADERS)
+  add_subdirectory(sslheaders)
+endif()
+if(BUILD_STEK_SHARE)
+  add_subdirectory(stek_share)
+endif()
+if(BUILD_STREAM_EDITOR)
+  add_subdirectory(stream_editor)
+endif()
+if(BUILD_SYSTEM_STATS)
+  add_subdirectory(system_stats)
+endif()
+if(BUILD_TLS_BRIDGE)
+  add_subdirectory(tls_bridge)
+endif()
+if(BUILD_TXN_BOX)
+  add_subdirectory(txn_box)
+endif()
+if(BUILD_URI_SIGNING)
+  add_subdirectory(uri_signing)
+endif()
+if(BUILD_URL_SIG)
+  add_subdirectory(url_sig)
+endif()
+if(BUILD_WASM)
+  add_subdirectory(wasm)
+endif()
diff --git a/plugins/experimental/magick/CMakeLists.txt 
b/plugins/experimental/magick/CMakeLists.txt
index 1fd0dc3dcb..d534a9de55 100644
--- a/plugins/experimental/magick/CMakeLists.txt
+++ b/plugins/experimental/magick/CMakeLists.txt
@@ -17,6 +17,9 @@
 
 add_atsplugin(magick magick.cc)
 
+# This creates the magic import target if necessary (older cmake)
+include(magick_target)
+
 target_link_libraries(magick PRIVATE ImageMagick::MagickWand 
ImageMagick::MagickCore ts::tscppapi OpenSSL::Crypto)
 
 verify_global_plugin(magick 
${CMAKE_CURRENT_SOURCE_DIR}/image_magic_dlopen_leak_suppression.txt)

Reply via email to