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

cmcfarlen pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

commit 2cba9f2235474df69cf4462562d571179c0a2b93
Author: Brian Neradt <[email protected]>
AuthorDate: Tue Apr 16 12:21:48 2024 -0500

    wasm plugin: Add build support (#11258)
    
    * wasm plugin: Add build support
    
    Initial commits of plugin/experimental/wasm on master had automake build
    support. When we transitioned to cmake we temporarilly dropped the
    automake files, leaving cmake support to a future commit. This is that
    future commit.
    
    * Silence -Werror=missing-field-initializers
    
    This makes it so the lib/src/wamr/wamr.cc builds fine without a warning
    concerning uninitialized members. Presumably the library writer knows
    what they are doing.
    
    (cherry picked from commit 6f014754a1ab476241f948d07583d9791ef95725)
---
 CMakePresets.json                            |  3 ++
 cmake/ExperimentalPlugins.cmake              | 11 ++++++++
 plugins/experimental/wasm/CMakeLists.txt     | 22 +++++++++++++++
 plugins/experimental/wasm/lib/CMakeLists.txt | 41 ++++++++++++++++++++++++++++
 4 files changed, 77 insertions(+)

diff --git a/CMakePresets.json b/CMakePresets.json
index 6fcae37e80..6bf72baa2c 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -164,6 +164,7 @@
         "OPENSSL_ROOT_DIR": "/opt/openssl-quic",
         "opentelemetry_ROOT": "/opt",
         "CURL_ROOT": "/opt",
+        "wamr_ROOT": "/opt",
         "ENABLE_CRIPTS": true
       }
     },
@@ -175,6 +176,7 @@
       "cacheVariables": {
         "opentelemetry_ROOT": "/opt",
         "CURL_ROOT": "/opt",
+        "wamr_ROOT": "/opt",
         "CMAKE_CXX_STANDARD": "20"
       }
     },
@@ -188,6 +190,7 @@
         "quiche_ROOT": "/opt/quiche",
         "opentelemetry_ROOT": "/opt",
         "CURL_ROOT": "/opt",
+        "wamr_ROOT": "/opt",
         "CMAKE_INSTALL_PREFIX": "/tmp/ats-quiche",
         "ENABLE_QUICHE": true
       }
diff --git a/cmake/ExperimentalPlugins.cmake b/cmake/ExperimentalPlugins.cmake
index 673c1f5835..563d268035 100644
--- a/cmake/ExperimentalPlugins.cmake
+++ b/cmake/ExperimentalPlugins.cmake
@@ -74,5 +74,16 @@ auto_option(
   DEFAULT
   ${_DEFAULT}
 )
+auto_option(
+  WASM
+  FEATURE_VAR
+  BUILD_WASM
+  WITH_SUBDIRECTORY
+  plugins/experimental/wasm
+  PACKAGE_DEPENDS
+  wamr
+  DEFAULT
+  ${_DEFAULT}
+)
 
 unset(_DEFAULT)
diff --git a/plugins/experimental/wasm/CMakeLists.txt 
b/plugins/experimental/wasm/CMakeLists.txt
new file mode 100644
index 0000000000..d5ae90cbd6
--- /dev/null
+++ b/plugins/experimental/wasm/CMakeLists.txt
@@ -0,0 +1,22 @@
+#######################
+#
+#  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.
+#
+#######################
+
+add_subdirectory(lib)
+
+add_atsplugin(wasm ats_context.cc ats_wasm.cc wasm_main.cc)
+target_link_libraries(wasm PRIVATE wasmlib wamr::wamr)
+verify_global_plugin(wasm)
diff --git a/plugins/experimental/wasm/lib/CMakeLists.txt 
b/plugins/experimental/wasm/lib/CMakeLists.txt
new file mode 100644
index 0000000000..a8f51447ba
--- /dev/null
+++ b/plugins/experimental/wasm/lib/CMakeLists.txt
@@ -0,0 +1,41 @@
+#######################
+#
+#  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.
+#
+#######################
+
+set(CC_FILES
+    src/bytecode_util.cc
+    src/context.cc
+    src/exports.cc
+    src/shared_data.cc
+    src/shared_queue.cc
+    src/hash.cc
+    src/signature_util.cc
+    src/vm_id_handle.cc
+    src/pairs_util.cc
+    src/wasm.cc
+)
+if(wamr_FOUND)
+  list(APPEND CC_FILES src/wamr/wamr.cc)
+endif()
+
+add_library(wasmlib STATIC ${CC_FILES})
+if(wamr_FOUND)
+  target_compile_options(wasmlib PRIVATE -Wno-missing-field-initializers)
+  target_link_libraries(wasmlib PUBLIC wamr::wamr)
+endif()
+
+target_include_directories(wasmlib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
+set_target_properties(wasmlib PROPERTIES POSITION_INDEPENDENT_CODE ON)

Reply via email to