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 e210401770 Build tslua plugin in CMake build (#9990)
e210401770 is described below

commit e21040177034bb90cc51ea2f930629124ced378e
Author: JosiahWI <[email protected]>
AuthorDate: Tue Jul 11 13:25:26 2023 -0500

    Build tslua plugin in CMake build (#9990)
    
    * Build tslua plugin in CMake build
    
    This also adds a Find script for LuaJIT, which uses pkg-config to
    find the LuaJIT library.
    
    * Add option to enable LuaJIT
    
    This adds a new option that defaults to OFF: ENABLE_LUAJIT. When
    the option is enabled, the tslua plugin will be built.
---
 CMakeLists.txt             |  5 +++++
 cmake/FindLuaJIT.cmake     | 48 ++++++++++++++++++++++++++++++++++++++++++
 plugins/CMakeLists.txt     |  4 ++++
 plugins/lua/CMakeLists.txt | 52 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 109 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d17008f78e..1300bccb97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,6 +51,7 @@ option(BUILD_REGRESSION_TESTING "Build regression tests 
(default ON)" ON)
 set(DEFAULT_STACK_SIZE 1048576 CACHE STRING "Default stack size (default 
1048576)")
 option(ENABLE_FAST_SDK "Use fast SDK APIs (default OFF)")
 option(ENABLE_JEMALLOC "Use jemalloc (default OFF)")
+option(ENABLE_LUAJIT   "Use LuaJIT (default OFF)")
 option(ENABLE_MIMALLOC "Use mimalloc (default OFF)")
 option(ENABLE_POSIX_CAP
     "Use POSIX capabilities, turn OFF to use id switching. (default ON)"
@@ -142,6 +143,10 @@ if(brotli_FOUND)
     set(HAVE_BROTLI_ENCODE_H TRUE)
 endif()
 
+if(ENABLE_LUAJIT)
+    find_package(LuaJIT REQUIRED)
+endif()
+
 if(ENABLE_POSIX_CAP)
     find_package(cap REQUIRED)
     set(TS_USE_POSIX_CAP ${cap_FOUND})
diff --git a/cmake/FindLuaJIT.cmake b/cmake/FindLuaJIT.cmake
new file mode 100644
index 0000000000..9a55fab5a7
--- /dev/null
+++ b/cmake/FindLuaJIT.cmake
@@ -0,0 +1,48 @@
+#######################
+#
+#  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.
+#
+#######################
+
+# FindLuaJIT.cmake
+#
+# This will define the following variables
+#
+#     LuaJIT_FOUND
+#
+# and the following imported targets
+#
+#     LuaJIT::LuaJIT
+#
+
+# LuaJIT exports their own config since LuaJIT-1.5.0, but it isn't
+# present in the OpenSUSE libLuaJIT-devel-1.7.1 package and maybe others.
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(LuaJIT luajit)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LuaJIT
+    REQUIRED_VARS LuaJIT_LIBRARIES LuaJIT_INCLUDE_DIRS
+)
+
+if(LuaJIT_FOUND)
+    set(LuaJIT_INCLUDE_DIRS ${LuaJIT_INCLUDE_DIR})
+endif()
+
+if(LuaJIT_FOUND AND NOT TARGET LuaJIT::LuaJIT)
+    add_library(LuaJIT::LuaJIT INTERFACE IMPORTED)
+    target_include_directories(LuaJIT::LuaJIT INTERFACE ${LuaJIT_INCLUDE_DIRS})
+    target_link_libraries(LuaJIT::LuaJIT INTERFACE ${LuaJIT_LIBRARIES})
+endif()
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
index e153a91d9b..d41c66af30 100644
--- a/plugins/CMakeLists.txt
+++ b/plugins/CMakeLists.txt
@@ -54,6 +54,10 @@ add_subdirectory(stats_over_http)
 add_subdirectory(tcpinfo)
 add_subdirectory(xdebug)
 
+if(ENABLE_LUAJIT)
+    add_subdirectory(lua)
+endif()
+
 if(HOST_OS STREQUAL "linux")
     add_subdirectory(healthchecks)
 endif()
diff --git a/plugins/lua/CMakeLists.txt b/plugins/lua/CMakeLists.txt
new file mode 100644
index 0000000000..d0e224f1f4
--- /dev/null
+++ b/plugins/lua/CMakeLists.txt
@@ -0,0 +1,52 @@
+#######################
+#
+#  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_atsplugin(tslua
+    ts_lua.c
+    ts_lua_cached_response.c
+    ts_lua_client_request.c
+    ts_lua_client_response.c
+    ts_lua_client_response.c
+    ts_lua_context.c
+    ts_lua_hook.c
+    ts_lua_http.c
+    ts_lua_http_intercept.c
+    ts_lua_log.c
+    ts_lua_misc.c
+    ts_lua_server_request.c
+    ts_lua_server_response.c
+    ts_lua_transform.c
+    ts_lua_util.c
+    ts_lua_remap.c
+    ts_lua_http_cntl.c
+    ts_lua_http_milestone.c
+    ts_lua_http_txn_info.c
+    ts_lua_http_config.c
+    ts_lua_mgmt.c
+    ts_lua_package.c
+    ts_lua_string.c
+    ts_lua_crypto.c
+    ts_lua_stat.c
+    ts_lua_io.c
+    ts_lua_coroutine.c
+    ts_lua_fetch.c
+    ts_lua_constant.c
+)
+
+target_include_directories(tslua PRIVATE "${PROJECT_SOURCE_DIR}/include")
+
+target_link_libraries(tslua PRIVATE LuaJIT::LuaJIT)

Reply via email to