summaryrefslogtreecommitdiffstats
path: root/src/fluent-bit/lib/luajit-cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/fluent-bit/lib/luajit-cmake')
-rw-r--r--src/fluent-bit/lib/luajit-cmake/.gitignore2
-rw-r--r--src/fluent-bit/lib/luajit-cmake/Bundle.cmake195
-rw-r--r--src/fluent-bit/lib/luajit-cmake/CMakeLists.txt22
-rw-r--r--src/fluent-bit/lib/luajit-cmake/LICENSE8
-rw-r--r--src/fluent-bit/lib/luajit-cmake/LuaJIT.cmake595
-rw-r--r--src/fluent-bit/lib/luajit-cmake/Makefile48
-rwxr-xr-xsrc/fluent-bit/lib/luajit-cmake/Modules/DetectArchitecture.c29
-rwxr-xr-xsrc/fluent-bit/lib/luajit-cmake/Modules/DetectArchitecture.cmake37
-rwxr-xr-xsrc/fluent-bit/lib/luajit-cmake/Modules/DetectFPUApi.cmake68
-rwxr-xr-xsrc/fluent-bit/lib/luajit-cmake/Modules/DetectFpuAbi.c34
-rw-r--r--src/fluent-bit/lib/luajit-cmake/Modules/FindUnwind.cmake60
-rw-r--r--src/fluent-bit/lib/luajit-cmake/Utils/Darwin.wine.cmake3
-rw-r--r--src/fluent-bit/lib/luajit-cmake/Utils/host.toolchain.cmake3
-rw-r--r--src/fluent-bit/lib/luajit-cmake/Utils/ios.toolchain.cmake672
-rw-r--r--src/fluent-bit/lib/luajit-cmake/Utils/windows.toolchain.cmake38
-rw-r--r--src/fluent-bit/lib/luajit-cmake/Utils/zig.toolchain.cmake114
-rwxr-xr-xsrc/fluent-bit/lib/luajit-cmake/host/buildvm/CMakeLists.txt52
-rwxr-xr-xsrc/fluent-bit/lib/luajit-cmake/host/minilua/CMakeLists.txt15
-rw-r--r--src/fluent-bit/lib/luajit-cmake/lua.cmake175
-rw-r--r--src/fluent-bit/lib/luajit-cmake/lua2c.lua99
-rw-r--r--src/fluent-bit/lib/luajit-cmake/luauser.h26
-rw-r--r--src/fluent-bit/lib/luajit-cmake/readme.md48
22 files changed, 2343 insertions, 0 deletions
diff --git a/src/fluent-bit/lib/luajit-cmake/.gitignore b/src/fluent-bit/lib/luajit-cmake/.gitignore
new file mode 100644
index 000000000..9ef96044f
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/.gitignore
@@ -0,0 +1,2 @@
+build
+
diff --git a/src/fluent-bit/lib/luajit-cmake/Bundle.cmake b/src/fluent-bit/lib/luajit-cmake/Bundle.cmake
new file mode 100644
index 000000000..7823785ea
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Bundle.cmake
@@ -0,0 +1,195 @@
+# Modfied from luajit.cmake Added LUA_ADD_EXECUTABLE Ryan Phillips <ryan at
+# trolocsis.com> This CMakeLists.txt has been first taken from LuaDist Copyright
+# (C) 2007-2011 LuaDist. Created by Peter Drahoš Redistribution and use of this
+# file is allowed according to the terms of the MIT license. Debugged and (now
+# seriously) modIFied by Ronan Collobert, for Torch7
+
+if(NOT DEFINED BUNDLE_CMD)
+ set(BUNDLE_CMD luajit CACHE STRING "Use lua to do lua file bundle")
+endif()
+if(NOT DEFINED BUNDLE_CMD_ARGS)
+ set(BUNDLE_CMD_ARGS "" CACHE STRING "Bundle args for cross compile")
+endif()
+if(NOT DEFINED BUNDLE_USE_LUA2C)
+ set(BUNDLE_USE_LUA2C OFF CACHE BOOL "Use bin2c.lua do lua file bundle")
+endif()
+
+include (TestBigEndian)
+TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
+if(IS_BIG_ENDIAN)
+ message(STATUS "BIG_ENDIAN")
+else()
+ message(STATUS "LITTLE_ENDIAN")
+endif()
+
+if(BUNDLE_USE_LUA2C)
+ file(COPY ${CMAKE_CURRENT_LIST_DIR}/lua2c.lua DESTINATION ${LUA_TARGET_PATH})
+endif()
+
+macro(LUA_add_custom_commands luajit_target)
+ set(target_srcs "")
+ foreach(file ${ARGN})
+ if(${file} MATCHES ".*\\.lua$")
+ if(NOT IS_ABSOLUTE ${file})
+ set(file "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
+ endif()
+ set(source_file ${file})
+ string(LENGTH ${CMAKE_SOURCE_DIR} _luajit_source_dir_length)
+ string(LENGTH ${file} _luajit_file_length)
+ math(EXPR _begin "${_luajit_source_dir_length} + 1")
+ math(EXPR _stripped_file_length
+ "${_luajit_file_length} - ${_luajit_source_dir_length} - 1")
+ string(SUBSTRING ${file}
+ ${_begin}
+ ${_stripped_file_length}
+ stripped_file)
+
+ set(
+ generated_file
+ "${CMAKE_BINARY_DIR}/luacode_tmp/${stripped_file}_${luajit_target}_generated.c"
+ )
+
+ add_custom_command(
+ OUTPUT ${generated_file}
+ MAIN_DEPENDENCY ${source_file}
+ DEPENDS ${LUA_TARGET}
+ COMMAND ${BUNDLE_CMD} ARGS
+ ${BUNDLE_CMD_ARGS} lua2c.lua ${source_file} ${generated_file}
+ COMMENT "${BUNDLE_CMD} ${BUNDLE_CMD_ARGS} lua2c.lua ${source_file} ${generated_file}"
+ WORKING_DIRECTORY ${LUA_TARGET_PATH})
+
+ get_filename_component(basedir ${generated_file} PATH)
+ file(MAKE_DIRECTORY ${basedir})
+
+ set(target_srcs ${target_srcs} ${generated_file})
+ set_source_files_properties(${generated_file}
+ properties
+ generated
+ true # to say that "it is OK that the obj-
+ # files do not exist before build time"
+ )
+ else()
+ set(target_srcs ${target_srcs} ${file})
+ endif()
+ endforeach()
+endmacro()
+
+if(NOT LJ_TARGET_ARCH)
+include(${CMAKE_CURRENT_LIST_DIR}/Modules/DetectArchitecture.cmake)
+detect_architecture(LJ_DETECTED_ARCH)
+if("${LJ_DETECTED_ARCH}" STREQUAL "x86")
+ set(LJ_TARGET_ARCH "x86")
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "x86_64")
+ set(LJ_TARGET_ARCH "x64")
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "AArch64")
+ set(LJ_TARGET_ARCH "arm64")
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "ARM")
+ set(LJ_TARGET_ARCH "arm")
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "Mips64")
+ if(IS_BIG_ENDIAN)
+ set(LJ_TARGET_ARCH "mips64")
+ else()
+ set(LJ_TARGET_ARCH "mips64el")
+ endif()
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "Mips")
+ if(IS_BIG_ENDIAN)
+ set(LJ_TARGET_ARCH "mips")
+ else()
+ set(LJ_TARGET_ARCH "mipsel")
+ endif()
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "PowerPC")
+ if(LJ_64)
+ set(LJ_TARGET_ARCH "ppc64")
+ else()
+ set(LJ_TARGET_ARCH "ppc")
+ endif()
+else()
+ message(FATAL_ERROR "Unsupported target architecture: '${LJ_DETECTED_ARCH}'")
+endif()
+endif()
+
+macro(LUAJIT_add_custom_commands luajit_target)
+ set(target_srcs "")
+
+ if(WIN32)
+ set(LJDUMP_OPT -b -g -a ${LJ_TARGET_ARCH} -o windows)
+ elseif(APPLE)
+ set(LJDUMP_OPT -b -g -a ${LJ_TARGET_ARCH} -o osx)
+ elseif(ANDROID OR ${CMAKE_SYSTEM_NAME} STREQUAL Linux)
+ set(LJDUMP_OPT -b -g -a ${LJ_TARGET_ARCH} -o linux)
+ else()
+ set(LJDUMP_OPT -b -g -a ${LJ_TARGET_ARCH})
+ endif()
+
+ foreach(file ${ARGN})
+ if(${file} MATCHES ".*\\.lua$")
+ if(NOT IS_ABSOLUTE ${file})
+ set(file "${CMAKE_CURRENT_SOURCE_DIR}/${file}")
+ endif()
+ set(source_file ${file})
+ string(LENGTH ${CMAKE_SOURCE_DIR} _luajit_source_dir_length)
+ string(LENGTH ${file} _luajit_file_length)
+ math(EXPR _begin "${_luajit_source_dir_length} + 1")
+ math(EXPR _stripped_file_length
+ "${_luajit_file_length} - ${_luajit_source_dir_length} - 1")
+ string(SUBSTRING ${file}
+ ${_begin}
+ ${_stripped_file_length}
+ stripped_file)
+
+ set(
+ generated_file
+ "${CMAKE_CURRENT_BINARY_DIR}/jitted_tmp/${stripped_file}_${luajit_target}_generated${CMAKE_C_OUTPUT_EXTENSION}"
+ )
+ string(REPLACE ";" " " LJDUMP_OPT_STR "${LJDUMP_OPT}")
+
+ add_custom_command(
+ OUTPUT ${generated_file}
+ MAIN_DEPENDENCY ${source_file}
+ DEPENDS ${LUA_TARGET}
+ COMMAND ${BUNDLE_CMD} ARGS
+ ${BUNDLE_CMD_ARGS}
+ ${LJDUMP_OPT} ${source_file} ${generated_file}
+ COMMENT "${BUNDLE_CMD} ${BUNDLE_CMD_ARGS} ${LJDUMP_OPT_STR} ${source_file} ${generated_file}"
+ WORKING_DIRECTORY ${LUA_TARGET_PATH})
+ get_filename_component(basedir ${generated_file} PATH)
+ file(MAKE_DIRECTORY ${basedir})
+
+ set(target_srcs ${target_srcs} ${generated_file})
+ set_source_files_properties(${generated_file}
+ properties
+ external_object
+ true # this is an object file
+ generated
+ true # to say that "it is OK that the obj-
+ # files do not exist before build time"
+ )
+ else()
+ set(target_srcs ${target_srcs} ${file})
+ endif()
+ endforeach()
+endmacro()
+
+if(BUNDLE_USE_LUA2C)
+
+ macro(LUA_ADD_CUSTOM luajit_target)
+ lua_add_custom_commands(${luajit_target} ${ARGN})
+ endmacro()
+
+ macro(LUA_ADD_EXECUTABLE luajit_target)
+ lua_add_custom_commands(${luajit_target} ${ARGN})
+ add_executable(${luajit_target} ${target_srcs})
+ endmacro()
+
+else()
+
+ macro(LUA_ADD_CUSTOM luajit_target)
+ luajit_add_custom_commands(${luajit_target} ${ARGN})
+ endmacro()
+
+ macro(LUA_ADD_EXECUTABLE luajit_target)
+ luajit_add_custom_commands(${luajit_target} ${ARGN})
+ add_executable(${luajit_target} ${target_srcs})
+ endmacro()
+
+endif()
diff --git a/src/fluent-bit/lib/luajit-cmake/CMakeLists.txt b/src/fluent-bit/lib/luajit-cmake/CMakeLists.txt
new file mode 100644
index 000000000..343df2df4
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/CMakeLists.txt
@@ -0,0 +1,22 @@
+cmake_minimum_required(VERSION 3.0)
+
+option(LUA_DIR "Path of Lua 5.4 source dir" OFF)
+option(LUAJIT_DIR "Path of LuaJIT 2.1 source dir" OFF)
+
+if(LUAJIT_DIR)
+ project(luajit)
+ include(LuaJIT.cmake)
+ if (PARENT_DIRECTORY)
+ set(LUA_TARGET luajit PARENT_SCOPE)
+ set(LUA_LIBRARIES libluajit PARENT_SCOPE)
+ endif()
+elseif(LUA_DIR)
+ project(lua)
+ include(lua.cmake)
+ if (PARENT_DIRECTORY)
+ set(LUA_TARGET lua PARENT_SCOPE)
+ set(LUA_LIBRARIES liblua PARENT_SCOPE)
+ endif()
+else()
+ message(FATAL_ERROR "Must set LUAJIT_DIR or LUA_DIR to build with CMake")
+endif()
diff --git a/src/fluent-bit/lib/luajit-cmake/LICENSE b/src/fluent-bit/lib/luajit-cmake/LICENSE
new file mode 100644
index 000000000..e870eda06
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/LICENSE
@@ -0,0 +1,8 @@
+The MIT License (MIT)
+Copyright © 2021 <zhaozg@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/src/fluent-bit/lib/luajit-cmake/LuaJIT.cmake b/src/fluent-bit/lib/luajit-cmake/LuaJIT.cmake
new file mode 100644
index 000000000..4ce66d1db
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/LuaJIT.cmake
@@ -0,0 +1,595 @@
+cmake_minimum_required(VERSION 3.0)
+
+project(luajit C)
+set(can_use_assembler TRUE)
+enable_language(ASM)
+
+if(NOT LUAJIT_DIR)
+ message(FATAL_ERROR "Must set LUAJIT_DIR to build luajit with CMake")
+endif()
+
+set(LJ_DIR ${LUAJIT_DIR}/src)
+
+list(APPEND CMAKE_MODULE_PATH
+ "${CMAKE_CURRENT_LIST_DIR}/Modules"
+)
+
+if (NOT WIN32)
+ include(GNUInstallDirs)
+endif ()
+
+set(CMAKE_OSX_DEPLOYMENT_TARGET "10.10" CACHE STRING "Minimum version of macOS/iOS)")
+set(LUAJIT_BUILD_EXE ON CACHE BOOL "Enable luajit exe build")
+set(LUAJIT_BUILD_ALAMG OFF CACHE BOOL "Enable alamg build mode")
+set(LUAJIT_DISABLE_GC64 OFF CACHE BOOL "Disable GC64 mode for x64")
+set(LUA_MULTILIB "lib" CACHE PATH "The name of lib directory.")
+set(LUAJIT_DISABLE_FFI OFF CACHE BOOL "Permanently disable the FFI extension")
+set(LUAJIT_DISABLE_JIT OFF CACHE BOOL "Disable the JIT compiler")
+set(LUAJIT_NO_UNWIND OFF CACHE BOOL "Disable the UNWIND")
+set(LUAJIT_NUMMODE 0 CACHE STRING
+"Specify the number mode to use. Possible values:
+ 0 - Default mode
+ 1 - Single number mode
+ 2 - Dual number mode
+")
+
+message(STATUS "${CMAKE_CROSSCOMPILING} ${CMAKE_HOST_SYSTEM_NAME}")
+message(STATUS "${CMAKE_SIZEOF_VOID_P} ${CMAKE_SYSTEM_NAME}")
+if(CMAKE_CROSSCOMPILING)
+ if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES 64)
+ set(HOST_64 TRUE)
+ else()
+ set(HOST_64 FALSE)
+ endif()
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(TARGET_64 TRUE)
+ else()
+ set(TARGET_64 FALSE)
+ endif()
+ message(STATUS "HOST_64 is ${HOST_64}")
+ message(STATUS "TARGET_64 is ${TARGET_64}")
+
+ if(HOST_64 AND NOT TARGET_64)
+ if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL Darwin)
+ if(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
+ set(HOST_WINE wine)
+ set(TOOLCHAIN "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
+ if(TARGET_SYS)
+ set(TARGET_SYS "-DTARGET_SYS=${TARGET_SYS}")
+ endif()
+ include(${CMAKE_CURRENT_LIST_DIR}/Utils/Darwin.wine.cmake)
+ else()
+ include(${CMAKE_CURRENT_LIST_DIR}/Utils/Darwin.wine.cmake)
+ endif()
+ else()
+ message(FATAL_ERROR
+ "NYI build ${CMAKE_SYSTEM_NAME} for on ${CMAKE_HOST_SYSTEM_NAME}")
+ endif()
+ else()
+ set(TOOLCHAIN "-UCMAKE_TOOLCHAIN_FILE")
+ if(DEFINED ENV{CMAKE_TOOLCHAIN_FILE})
+ message(STATUS "Check CMAKE_TOOLCHAIN_FILE in environment variable, found")
+ unset(ENV{CMAKE_TOOLCHAIN_FILE})
+ message(WARNING "unset Environment Variables CMAKE_TOOLCHAIN_FILE")
+ else()
+ message(STATUS "Check CMAKE_TOOLCHAIN_FILE in environment variable, not found")
+ endif()
+ endif()
+endif()
+
+set(MINILUA_EXE minilua)
+if(HOST_WINE)
+ set(MINILUA_EXE minilua.exe)
+endif()
+set(MINILUA_PATH ${CMAKE_CURRENT_BINARY_DIR}/minilua/${MINILUA_EXE})
+
+include(CheckTypeSize)
+include(TestBigEndian)
+test_big_endian(LJ_BIG_ENDIAN)
+
+include(${CMAKE_CURRENT_LIST_DIR}/Modules/DetectArchitecture.cmake)
+detect_architecture(LJ_DETECTED_ARCH)
+
+include(${CMAKE_CURRENT_LIST_DIR}/Modules/DetectFPUApi.cmake)
+detect_fpu_mode(LJ_DETECTED_FPU_MODE)
+detect_fpu_abi(LJ_DETECTED_FPU_ABI)
+
+find_library(LIBM_LIBRARIES NAMES m)
+find_library(LIBDL_LIBRARIES NAMES dl)
+
+if($ENV{LUA_TARGET_SHARED})
+ add_definitions(-fPIC)
+endif()
+
+set(TARGET_ARCH "")
+set(DASM_FLAGS "")
+
+set(LJ_TARGET_ARCH "")
+if("${LJ_DETECTED_ARCH}" STREQUAL "x86")
+ set(LJ_TARGET_ARCH "x86")
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "x86_64")
+ set(LJ_TARGET_ARCH "x64")
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "AArch64")
+ set(LJ_TARGET_ARCH "arm64")
+ if(LJ_BIG_ENDIAN)
+ set(TARGET_ARCH -D__AARCH64EB__=1)
+ endif()
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "ARM")
+ set(LJ_TARGET_ARCH "arm")
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "Mips64")
+ set(LJ_TARGET_ARCH "mips64")
+ if(NOT LJ_BIG_ENDIAN)
+ set(TARGET_ARCH -D__MIPSEL__=1)
+ endif()
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "Mips")
+ set(LJ_TARGET_ARCH "mips")
+ if(NOT LJ_BIG_ENDIAN)
+ set(TARGET_ARCH -D__MIPSEL__=1)
+ endif()
+elseif("${LJ_DETECTED_ARCH}" STREQUAL "PowerPC")
+ if(LJ_64)
+ set(LJ_TARGET_ARCH "ppc64")
+ else()
+ set(LJ_TARGET_ARCH "ppc")
+ endif()
+ if(LJ_BIG_ENDIAN)
+ set(TARGET_ARCH -DLJ_ARCH_ENDIAN=LUAJIT_BE)
+ else()
+ set(TARGET_ARCH -DLJ_ARCH_ENDIAN=LUAJIT_LE)
+ endif()
+else()
+ message(FATAL_ERROR "Unsupported target architecture: '${LJ_DETECTED_ARCH}'")
+endif()
+
+if("${LJ_DETECTED_FPU_MODE}" STREQUAL "Hard")
+ set(LJ_HAS_FPU 1)
+ set(DASM_FLAGS ${DASM_FLAGS} -D FPU)
+ set(TARGET_ARCH ${TARGET_ARCH} -DLJ_ARCH_HASFPU=1)
+else()
+ set(LJ_HAS_FPU 0)
+ set(TARGET_ARCH ${TARGET_ARCH} -DLJ_ARCH_HASFPU=0)
+endif()
+
+if("${LJ_DETECTED_FPU_ABI}" STREQUAL "Hard")
+ set(LJ_ABI_SOFTFP 0)
+ set(DASM_FLAGS ${DASM_FLAGS} -D HFABI)
+ set(TARGET_ARCH ${TARGET_ARCH} -DLJ_ABI_SOFTFP=0)
+else()
+ set(LJ_ABI_SOFTFP 1)
+ set(TARGET_ARCH ${TARGET_ARCH} -DLJ_ABI_SOFTFP=1)
+endif()
+
+set(TARGET_ARCH ${TARGET_ARCH} -DLUAJIT_TARGET=LUAJIT_ARCH_${LJ_TARGET_ARCH})
+
+if(WIN32 OR MINGW)
+ set(DASM_FLAGS ${DASM_FLAGS} -D WIN)
+endif()
+
+include(${CMAKE_CURRENT_LIST_DIR}/Modules/FindUnwind.cmake)
+if (NOT unwind_FOUND)
+ set(LUAJIT_NO_UNWIND ON)
+ if(CMAKE_SYSTEM_PROCESSOR STREQUAL mips64 OR
+ CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64 OR
+ CMAKE_SYSTEM_NAME STREQUAL Windows)
+ if(NOT IOS)
+ set(LUAJIT_NO_UNWIND IGNORE)
+ endif()
+ endif()
+endif()
+
+message(STATUS "#### CMAKE_SYSTEM_NAME is ${CMAKE_SYSTEM_NAME}")
+message(STATUS "#### CMAKE_SYSTEM_PROCESSOR is ${CMAKE_SYSTEM_PROCESSOR}")
+message(STATUS "#### ARCH is ${ARCH}")
+message(STATUS "#### unwind_FOUND is ${unwind_FOUND}")
+message(STATUS "#### HAVE_UNWIND_H is ${HAVE_UNWIND_H}")
+message(STATUS "#### HAVE_UNWIND_LIB is ${HAVE_UNWIND_LIB}")
+message(STATUS "#### UNWIND_LIBRARY is ${UNWIND_LIBRARY}")
+
+message(STATUS "#### LUAJIT_NO_UNWIND is ${LUAJIT_NO_UNWIND}")
+
+set(LJ_DEFINITIONS "")
+if(LUAJIT_NO_UNWIND STREQUAL ON)
+ # LUAJIT_NO_UNWIND is ON
+ set(DASM_FLAGS ${DASM_FLAGS} -D NO_UNWIND)
+ set(TARGET_ARCH ${TARGET_ARCH} -DLUAJIT_NO_UNWIND)
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS} -DLUAJIT_NO_UNWIND)
+elseif(${LUAJIT_NO_UNWIND} STREQUAL OFF)
+ # LUAJIT_NO_UNWIND is OFF
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS} -DLUAJIT_UNWIND_EXTERNAL)
+ set(TARGET_ARCH ${TARGET_ARCH} -DLUAJIT_UNWIND_EXTERNAL)
+endif()
+
+if(ANDROID)
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS} -DLJ_NO_SYSTEM=1)
+endif()
+
+if(IOS)
+ set(LUAJIT_DISABLE_JIT ON)
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS} -DLJ_NO_SYSTEM=1)
+endif()
+
+set(LJ_ENABLE_LARGEFILE 1)
+if(ANDROID AND (CMAKE_SYSTEM_VERSION LESS 21))
+ set(LJ_ENABLE_LARGEFILE 0)
+elseif(WIN32 OR MINGW)
+ set(LJ_ENABLE_LARGEFILE 0)
+endif()
+
+if(LJ_ENABLE_LARGEFILE)
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS}
+ -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
+endif()
+
+set(LJ_FFI 1)
+if(LUAJIT_DISABLE_FFI)
+ set(LJ_FFI 0)
+endif()
+
+set(LJ_JIT 1)
+if(LUAJIT_DISABLE_JIT)
+ set(LJ_JIT 0)
+endif()
+
+if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(LJ_64 1)
+endif()
+
+set(LJ_GC64 ${LJ_64})
+
+if(LJ_64 AND LUAJIT_DISABLE_GC64 AND ("${LJ_TARGET_ARCH}" STREQUAL "x64"))
+ set(LJ_GC64 0)
+endif()
+
+set(LJ_FR2 ${LJ_GC64})
+
+set(LJ_NUMMODE_SINGLE 0) # Single-number mode only.
+set(LJ_NUMMODE_SINGLE_DUAL 1) # Default to single-number mode.
+set(LJ_NUMMODE_DUAL 2) # Dual-number mode only.
+set(LJ_NUMMODE_DUAL_SINGLE 3) # Default to dual-number mode.
+
+set(LJ_ARCH_NUMMODE ${LJ_NUMMODE_DUAL})
+if(LJ_HAS_FPU)
+ set(LJ_ARCH_NUMMODE ${LJ_NUMMODE_DUAL_SINGLE})
+endif()
+
+if(("${LJ_TARGET_ARCH}" STREQUAL "x86") OR
+ ("${LJ_TARGET_ARCH}" STREQUAL "x64"))
+ set(LJ_ARCH_NUMMODE ${LJ_NUMMODE_SINGLE_DUAL})
+endif()
+
+if(("${LJ_TARGET_ARCH}" STREQUAL "arm") OR
+ ("${LJ_TARGET_ARCH}" STREQUAL "arm64") OR
+ ("${LJ_TARGET_ARCH}" STREQUAL "mips") OR
+ ("${LJ_TARGET_ARCH}" STREQUAL "mips64"))
+ set(LJ_ARCH_NUMMODE ${LJ_NUMMODE_DUAL})
+endif()
+
+# Enable or disable the dual-number mode for the VM.
+if(((LJ_ARCH_NUMMODE EQUAL LJ_NUMMODE_SINGLE) AND (LUAJIT_NUMMODE EQUAL 2)) OR
+ ((LJ_ARCH_NUMMODE EQUAL LJ_NUMMODE_DUAL) AND (LUAJIT_NUMMODE EQUAL 1)))
+ message(FATAL_ERROR "No support for this number mode on this architecture")
+endif()
+if(
+ (LJ_ARCH_NUMMODE EQUAL LJ_NUMMODE_DUAL) OR
+ ( (LJ_ARCH_NUMMODE EQUAL LJ_NUMMODE_DUAL_SINGLE) AND NOT
+ (LUAJIT_NUMMODE EQUAL 1) ) OR
+ ( (LJ_ARCH_NUMMODE EQUAL LJ_NUMMODE_SINGLE_DUAL) AND
+ (LUAJIT_NUMMODE EQUAL 2) )
+ )
+ set(LJ_DUALNUM 1)
+else()
+ set(LJ_DUALNUM 0)
+endif()
+
+set(BUILDVM_ARCH_H ${CMAKE_CURRENT_BINARY_DIR}/buildvm_arch.h)
+set(DASM_PATH ${LUAJIT_DIR}/dynasm/dynasm.lua)
+
+if(NOT LJ_BIG_ENDIAN)
+ set(DASM_FLAGS ${DASM_FLAGS} -D ENDIAN_LE)
+else()
+ set(DASM_FLAGS ${DASM_FLAGS} -D ENDIAN_BE)
+endif()
+
+if(LJ_64)
+ set(DASM_FLAGS ${DASM_FLAGS} -D P64)
+endif()
+
+if(LJ_FFI)
+ set(DASM_FLAGS ${DASM_FLAGS} -D FFI)
+endif()
+
+if(LJ_JIT)
+ set(DASM_FLAGS ${DASM_FLAGS} -D JIT)
+endif()
+
+if(LJ_DUALNUM)
+ set(DASM_FLAGS ${DASM_FLAGS} -D DUALNUM)
+endif()
+
+set(DASM_ARCH ${LJ_TARGET_ARCH})
+
+if("${LJ_TARGET_ARCH}" STREQUAL "x64")
+ if(NOT LJ_FR2)
+ set(DASM_ARCH "x86")
+ endif()
+endif()
+
+set(DASM_FLAGS ${DASM_FLAGS} -D VER=)
+
+set(TARGET_OS_FLAGS "")
+if(${CMAKE_SYSTEM_NAME} STREQUAL Android)
+ set(TARGET_OS_FLAGS ${TARGET_OS_FLAGS} -DLUAJIT_OS=LUAJIT_OS_LINUX)
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL Windows)
+ set(TARGET_OS_FLAGS ${TARGET_OS_FLAGS} -DLUAJIT_OS=LUAJIT_OS_WINDOWS)
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
+ set(TARGET_OS_FLAGS ${TARGET_OS_FLAGS} -DLUAJIT_OS=LUAJIT_OS_OSX)
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
+ set(TARGET_OS_FLAGS ${TARGET_OS_FLAGS} -DLUAJIT_OS=LUAJIT_OS_LINUX)
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL Haiku)
+ set(TARGET_OS_FLAGS ${TARGET_OS_FLAGS} -DLUAJIT_OS=LUAJIT_OS_POSIX)
+elseif(${CMAKE_SYSTEM_NAME} MATCHES "(Open|Free|Net)BSD")
+ set(TARGET_OS_FLAGS ${TARGET_OS_FLAGS} -DLUAJIT_OS=LUAJIT_OS_BSD)
+elseif(${CMAKE_SYSTEM_NAME} STREQUAL iOS)
+ set(TARGET_OS_FLAGS ${TARGET_OS_FLAGS} -DLUAJIT_OS=LUAJIT_OS_OSX -DTARGET_OS_IPHONE=1)
+else()
+ set(TARGET_OS_FLAGS ${TARGET_OS_FLAGS} -DLUAJIT_OS=LUAJIT_OS_OTHER)
+endif()
+
+if(LUAJIT_DISABLE_GC64)
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS} -DLUAJIT_DISABLE_GC64)
+ set(TARGET_ARCH ${TARGET_ARCH} -DLUAJIT_DISABLE_GC64)
+endif()
+
+set(TARGET_ARCH ${TARGET_ARCH} ${TARGET_OS_FLAGS})
+set(LJ_DEFINITIONS ${LJ_DEFINITIONS} ${TARGET_OS_FLAGS})
+
+if(LUAJIT_DISABLE_FFI)
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS} -DLUAJIT_DISABLE_FFI)
+ set(TARGET_ARCH ${TARGET_ARCH} -DLUAJIT_DISABLE_FFI)
+endif()
+if(LUAJIT_DISABLE_JIT)
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS} -DLUAJIT_DISABLE_JIT)
+ set(TARGET_ARCH ${TARGET_ARCH} -DLUAJIT_DISABLE_JIT)
+endif()
+
+if(("${LUAJIT_NUMMODE}" STREQUAL "1") OR
+ ("${LUAJIT_NUMMODE}" STREQUAL "2"))
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS} -DLUAJIT_NUMMODE=${LUAJIT_NUMMODE})
+ set(TARGET_ARCH ${TARGET_ARCH} -DLUAJIT_NUMMODE=${LUAJIT_NUMMODE})
+endif()
+
+if(LUAJIT_ENABLE_GDBJIT)
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS} -DLUAJIT_ENABLE_GDBJIT)
+ set(TARGET_ARCH ${TARGET_ARCH} -DLUAJIT_ENABLE_GDBJIT)
+endif()
+
+set(VM_DASC_PATH ${LJ_DIR}/vm_${DASM_ARCH}.dasc)
+
+# Build the minilua for host platform
+if(NOT CMAKE_CROSSCOMPILING)
+ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/host/minilua)
+ set(MINILUA_PATH $<TARGET_FILE:minilua>)
+else()
+ make_directory(${CMAKE_CURRENT_BINARY_DIR}/minilua)
+
+ add_custom_command(OUTPUT ${MINILUA_PATH}
+ COMMAND ${CMAKE_COMMAND} ${TOOLCHAIN} ${TARGET_SYS} -DLUAJIT_DIR=${LUAJIT_DIR}
+ -DCMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}
+ ${CMAKE_CURRENT_LIST_DIR}/host/minilua
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/minilua
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/minilua)
+
+ add_custom_target(minilua ALL
+ DEPENDS ${MINILUA_PATH}
+ )
+endif()
+
+# Generate buildvm_arch.h
+add_custom_command(OUTPUT ${BUILDVM_ARCH_H}
+ COMMAND ${HOST_WINE} ${MINILUA_PATH} ${DASM_PATH} ${DASM_FLAGS}
+ -o ${BUILDVM_ARCH_H} ${VM_DASC_PATH}
+ DEPENDS minilua)
+add_custom_target(buildvm_arch_h ALL
+ DEPENDS ${BUILDVM_ARCH_H}
+)
+
+# Build the buildvm for host platform
+set(BUILDVM_COMPILER_FLAGS "${TARGET_ARCH}")
+
+set(BUILDVM_COMPILER_FLAGS_PATH
+ "${CMAKE_CURRENT_BINARY_DIR}/buildvm_flags.config")
+file(WRITE ${BUILDVM_COMPILER_FLAGS_PATH} "${BUILDVM_COMPILER_FLAGS}")
+
+set(BUILDVM_EXE buildvm)
+if(HOST_WINE)
+ set(BUILDVM_EXE buildvm.exe)
+endif()
+
+if(NOT CMAKE_CROSSCOMPILING)
+ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/host/buildvm)
+ set(BUILDVM_PATH $<TARGET_FILE:buildvm>)
+ add_dependencies(buildvm buildvm_arch_h)
+else()
+ set(BUILDVM_PATH ${CMAKE_CURRENT_BINARY_DIR}/buildvm/${BUILDVM_EXE})
+
+ make_directory(${CMAKE_CURRENT_BINARY_DIR}/buildvm)
+
+ add_custom_command(OUTPUT ${BUILDVM_PATH}
+ COMMAND ${CMAKE_COMMAND} ${TOOLCHAIN} ${TARGET_SYS}
+ ${CMAKE_CURRENT_LIST_DIR}/host/buildvm
+ -DCMAKE_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}
+ -DLUAJIT_DIR=${LUAJIT_DIR}
+ -DEXTRA_COMPILER_FLAGS_FILE=${BUILDVM_COMPILER_FLAGS_PATH}
+ COMMAND ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/buildvm
+ DEPENDS ${CMAKE_CURRENT_LIST_DIR}/host/buildvm/CMakeLists.txt
+ DEPENDS buildvm_arch_h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/buildvm)
+
+ add_custom_target(buildvm ALL
+ DEPENDS ${BUILDVM_PATH}
+ )
+endif()
+
+set(LJVM_MODE elfasm)
+if(APPLE)
+ set(LJVM_MODE machasm)
+elseif(WIN32 OR MINGW)
+ set(LJVM_MODE peobj)
+endif()
+
+set(LJ_VM_NAME lj_vm.S)
+if("${LJVM_MODE}" STREQUAL "peobj")
+ set(LJ_VM_NAME lj_vm.obj)
+endif()
+if(IOS)
+ set_source_files_properties(${LJ_VM_NAME} PROPERTIES
+ COMPILE_FLAGS "-arch ${ARCHS} -isysroot ${CMAKE_OSX_SYSROOT} ${BITCODE}")
+endif()
+
+
+set(LJ_VM_S_PATH ${CMAKE_CURRENT_BINARY_DIR}/${LJ_VM_NAME})
+add_custom_command(OUTPUT ${LJ_VM_S_PATH}
+ COMMAND ${HOST_WINE} ${BUILDVM_PATH} -m ${LJVM_MODE} -o ${LJ_VM_S_PATH}
+ DEPENDS buildvm
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/)
+
+if(APPLE AND CMAKE_OSX_DEPLOYMENT_TARGET AND NOT(CMAKE_CROSSCOMPILING))
+ set_source_files_properties(${LJ_VM_NAME} PROPERTIES
+ COMPILE_FLAGS -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET})
+endif()
+
+make_directory(${CMAKE_CURRENT_BINARY_DIR}/jit)
+set(LJ_LIBDEF_PATH ${CMAKE_CURRENT_BINARY_DIR}/lj_libdef.h)
+set(LJ_RECDEF_PATH ${CMAKE_CURRENT_BINARY_DIR}/lj_recdef.h)
+set(LJ_FFDEF_PATH ${CMAKE_CURRENT_BINARY_DIR}/lj_ffdef.h)
+set(LJ_BCDEF_PATH ${CMAKE_CURRENT_BINARY_DIR}/lj_bcdef.h)
+set(LJ_VMDEF_PATH ${CMAKE_CURRENT_BINARY_DIR}/jit/vmdef.lua)
+
+set(LJ_LIB_SOURCES
+ ${LJ_DIR}/lib_base.c ${LJ_DIR}/lib_math.c ${LJ_DIR}/lib_bit.c
+ ${LJ_DIR}/lib_string.c ${LJ_DIR}/lib_table.c ${LJ_DIR}/lib_io.c
+ ${LJ_DIR}/lib_os.c ${LJ_DIR}/lib_package.c ${LJ_DIR}/lib_debug.c
+ ${LJ_DIR}/lib_jit.c ${LJ_DIR}/lib_ffi.c ${LJ_DIR}/lib_buffer.c)
+add_custom_command(
+ OUTPUT ${LJ_LIBDEF_PATH} ${LJ_VMDEF_PATH} ${LJ_RECDEF_PATH} ${LJ_FFDEF_PATH}
+ OUTPUT ${LJ_BCDEF_PATH}
+ COMMAND ${HOST_WINE}
+ ${BUILDVM_PATH} -m libdef -o ${LJ_LIBDEF_PATH} ${LJ_LIB_SOURCES}
+ COMMAND ${HOST_WINE}
+ ${BUILDVM_PATH} -m recdef -o ${LJ_RECDEF_PATH} ${LJ_LIB_SOURCES}
+ COMMAND ${HOST_WINE}
+ ${BUILDVM_PATH} -m ffdef -o ${LJ_FFDEF_PATH} ${LJ_LIB_SOURCES}
+ COMMAND ${HOST_WINE}
+ ${BUILDVM_PATH} -m bcdef -o ${LJ_BCDEF_PATH} ${LJ_LIB_SOURCES}
+ COMMAND ${HOST_WINE}
+ ${BUILDVM_PATH} -m vmdef -o ${LJ_VMDEF_PATH} ${LJ_LIB_SOURCES}
+ DEPENDS buildvm ${LJ_LIB_SOURCE}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/)
+
+add_custom_target(lj_gen_headers ALL
+ DEPENDS ${LJ_LIBDEF_PATH} ${LJ_RECDEF_PATH} ${LJ_VMDEF_PATH}
+ DEPENDS ${LJ_FFDEF_PATH} ${LJ_BCDEF_PATH}
+)
+
+set(LJ_FOLDDEF_PATH ${CMAKE_CURRENT_BINARY_DIR}/lj_folddef.h)
+
+set(LJ_FOLDDEF_SOURCE ${LJ_DIR}/lj_opt_fold.c)
+add_custom_command(
+ OUTPUT ${LJ_FOLDDEF_PATH}
+ COMMAND ${HOST_WINE}
+ ${BUILDVM_PATH} -m folddef -o ${LJ_FOLDDEF_PATH} ${LJ_FOLDDEF_SOURCE}
+ DEPENDS ${BUILDVM_PATH}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/)
+
+add_custom_target(lj_gen_folddef ALL
+ DEPENDS ${LJ_FOLDDEF_PATH}
+)
+
+file(GLOB_RECURSE SRC_LJCORE "${LJ_DIR}/lj_*.c")
+file(GLOB_RECURSE SRC_LIBCORE "${LJ_DIR}/lib_*.c")
+
+if(LUAJIT_BUILD_ALAMG)
+ set(luajit_sources ${LJ_DIR}/ljamalg.c ${LJ_VM_NAME})
+else()
+ set(luajit_sources ${SRC_LIBCORE} ${SRC_LJCORE} ${LJ_VM_NAME})
+endif()
+
+# Build the luajit static library
+add_library(libluajit ${luajit_sources})
+set_target_properties(libluajit PROPERTIES OUTPUT_NAME luajit)
+add_dependencies(libluajit
+ buildvm_arch_h
+ buildvm
+ lj_gen_headers
+ lj_gen_folddef)
+target_include_directories(libluajit PRIVATE
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_SOURCE_DIR})
+if(BUILD_SHARED_LIBS)
+ if(WIN32 OR MINGW)
+ set(LJ_DEFINITIONS ${LJ_DEFINITIONS}
+ -DLUA_BUILD_AS_DLL -DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
+ endif()
+endif()
+
+if(LIBM_LIBRARIES)
+ target_link_libraries(libluajit ${LIBM_LIBRARIES})
+endif()
+
+if(LIBDL_LIBRARIES)
+ target_link_libraries(libluajit ${LIBDL_LIBRARIES})
+endif()
+
+set(LJ_DEFINITIONS ${LJ_DEFINITIONS} -DLUA_MULTILIB="${LUA_MULTILIB}")
+target_compile_definitions(libluajit PRIVATE ${LJ_DEFINITIONS})
+if(IOS)
+ set_xcode_property(libluajit IPHONEOS_DEPLOYMENT_TARGET "9.0" "all")
+endif()
+
+if("${LJ_TARGET_ARCH}" STREQUAL "x86")
+ if(CMAKE_COMPILER_IS_CLANGXX OR CMAKE_COMPILER_IS_GNUCXX)
+ target_compile_options(libluajit PRIVATE
+ -march=i686 -msse -msse2 -mfpmath=sse)
+ endif()
+endif()
+
+set(LJ_COMPILE_OPTIONS -U_FORTIFY_SOURCE)
+if(NO_STACK_PROTECTOR_FLAG)
+ set(LJ_COMPILE_OPTIONS ${LJ_COMPILE_OPTIONS} -fno-stack-protector)
+endif()
+if(IOS AND ("${LJ_TARGET_ARCH}" STREQUAL "arm64"))
+ set(LJ_COMPILE_OPTIONS ${LJ_COMPILE_OPTIONS} -fno-omit-frame-pointer)
+endif()
+
+target_compile_options(libluajit PRIVATE ${LJ_COMPILE_OPTIONS})
+
+set(luajit_headers
+ ${LJ_DIR}/lauxlib.h
+ ${LJ_DIR}/lua.h
+ ${LJ_DIR}/luaconf.h
+ ${LJ_DIR}/luajit.h
+ ${LJ_DIR}/lualib.h)
+install(FILES ${luajit_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/luajit)
+install(TARGETS libluajit
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
+# Build the luajit binary
+if (LUAJIT_BUILD_EXE)
+ add_executable(luajit ${LJ_DIR}/luajit.c)
+ target_link_libraries(luajit libluajit)
+ if(APPLE AND ${CMAKE_C_COMPILER_ID} STREQUAL "zig")
+ target_link_libraries(luajit c pthread)
+ set_target_properties(minilua PROPERTIES
+ LINK_FLAGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
+ endif()
+ if(HAVE_UNWIND_LIB AND (NOT LUAJIT_NO_UNWIND STREQUAL ON))
+ target_link_libraries(luajit ${UNWIND_LIBRARY})
+ endif()
+
+ target_compile_definitions(luajit PRIVATE ${LJ_DEFINITIONS})
+ file(COPY ${LJ_DIR}/jit DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
+
+ install(TARGETS luajit DESTINATION "${CMAKE_INSTALL_BINDIR}")
+endif()
+
diff --git a/src/fluent-bit/lib/luajit-cmake/Makefile b/src/fluent-bit/lib/luajit-cmake/Makefile
new file mode 100644
index 000000000..93cf3d9fb
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Makefile
@@ -0,0 +1,48 @@
+ifeq ($(MAKE),mingw32-make)
+CMAKE_OPTIONS += -G"MinGW Makefiles"
+endif
+
+ifeq (${LUAJIT_DIR}, )
+LUAJIT_DIR = $(shell pwd)/../LuaJIT
+endif
+CMAKE_OPTIONS += -DLUAJIT_DIR=${LUAJIT_DIR}
+
+IOS_ARCH ?= armv7
+
+.PHONY : all build install clean
+
+# Basic
+all: build
+ cmake --build build --config Release
+
+install: all
+ cmake --install build
+
+build:
+ cmake -H. -Bbuild ${CMAKE_OPTIONS}
+
+clean:
+ @cmake -E remove_directory build
+
+lua:
+ cmake -H. -Bbuild -DLUA_DIR=$(shell pwd)/../lua
+ cmake --build build --config Release
+
+# Advance
+iOS:
+ cmake -H. -Bbuild ${CMAKE_OPTIONS} \
+ -DCMAKE_TOOLCHAIN_FILE=$(shell pwd)/Utils/ios.toolchain.cmake \
+ -DIOS_PLATFORM=OS -DIOS_ARCH=$(IOS_ARCH) -DLUAJIT_DISABLE_JIT=1 \
+ -DASM_FLAGS="-arch ${IOS_ARCH} -isysroot ${shell xcrun --sdk iphoneos --show-sdk-path}"
+ cmake --build build --config Release
+
+Android:
+ cmake -H. -Bbuild ${CMAKE_OPTIONS} \
+ -DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake
+ cmake --build build --config Release
+
+Windows:
+ cmake -H. -Bbuild ${CMAKE_OPTIONS} \
+ -DCMAKE_TOOLCHAIN_FILE=${shell pwd}/Utils/windows.toolchain.cmake
+ cmake --build build --config Release
+
diff --git a/src/fluent-bit/lib/luajit-cmake/Modules/DetectArchitecture.c b/src/fluent-bit/lib/luajit-cmake/Modules/DetectArchitecture.c
new file mode 100755
index 000000000..8d7eba6f0
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Modules/DetectArchitecture.c
@@ -0,0 +1,29 @@
+#if defined(__aarch64__) || defined(__arm64__) || defined(_M_ARM64)
+const char *str = "ARCHITECTURE IS AArch64";
+#elif defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM)
+const char *str = "ARCHITECTURE IS ARM";
+#elif defined(__alpha__)
+const char *str = "ARCHITECTURE IS Alpha";
+#elif defined(__mips64__) || defined(__mips64) || defined(__MIPS64__) || defined(__MIPS64)
+const char *str = "ARCHITECTURE IS Mips64";
+#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(__MIPS)
+const char *str = "ARCHITECTURE IS Mips";
+#elif defined(__ppc__) || defined(__ppc) || defined(__PPC__) || defined(__PPC) || defined(__powerpc__) || defined(__powerpc) || defined(__POWERPC__) || defined(__POWERPC) || defined(_M_PPC)
+const char *str = "ARCHITECTURE IS PowerPC";
+#elif defined(__s390__)
+const char *str = "ARCHITECTURE IS SystemZ";
+#elif defined(__sparc__)
+const char *str = "ARCHITECTURE IS Sparc";
+#elif defined(__xcore__)
+const char *str = "ARCHITECTURE IS XCore";
+#elif defined(__i386__) || defined(__i686__) || defined(_M_IX86)
+const char *str = "ARCHITECTURE IS x86";
+#elif defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)
+const char *str = "ARCHITECTURE IS x86_64";
+#endif
+
+int main(int argc, char **argv) {
+ int require = str[argc];
+ (void)argv;
+ return require;
+}
diff --git a/src/fluent-bit/lib/luajit-cmake/Modules/DetectArchitecture.cmake b/src/fluent-bit/lib/luajit-cmake/Modules/DetectArchitecture.cmake
new file mode 100755
index 000000000..a35c52387
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Modules/DetectArchitecture.cmake
@@ -0,0 +1,37 @@
+
+##===- DetectArchitecture.cmake -------------------------------------------===##
+#
+# Performs a try_compile to determine the architecture of the target.
+#
+##===----------------------------------------------------------------------===##
+get_filename_component(__check_architecture_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+macro(detect_architecture variable)
+ try_compile(HAVE_${variable}
+ ${CMAKE_BINARY_DIR}
+ ${__check_architecture_size_dir}/DetectArchitecture.c
+ OUTPUT_VARIABLE OUTPUT
+ COPY_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectArchitecture.bin)
+
+ if(HAVE_${variable})
+ file(STRINGS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectArchitecture.bin
+ DETECT_ARCH_STRING LIMIT_COUNT 1 REGEX "ARCHITECTURE IS")
+ if(DETECT_ARCH_STRING)
+ string(REGEX MATCH "[^ ]*$" DETECT_ARCH_MATCH ${DETECT_ARCH_STRING})
+ if(DETECT_ARCH_MATCH)
+ message(STATUS "Check target system architecture: ${DETECT_ARCH_MATCH}")
+ set(${variable} ${DETECT_ARCH_MATCH})
+ else()
+ message(SEND_ERROR "Could not detect target system architecture!")
+ endif()
+ else()
+ message(SEND_ERROR "Could not detect target system architecture!")
+ endif()
+ else()
+ message(STATUS "Determine the system architecture - failed")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining the system architecture failed with the following output:\n${OUTPUT}")
+ set(${variable})
+ endif()
+
+endmacro(detect_architecture)
diff --git a/src/fluent-bit/lib/luajit-cmake/Modules/DetectFPUApi.cmake b/src/fluent-bit/lib/luajit-cmake/Modules/DetectFPUApi.cmake
new file mode 100755
index 000000000..0aa2528bf
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Modules/DetectFPUApi.cmake
@@ -0,0 +1,68 @@
+
+##===- DetectArchitecture.cmake -------------------------------------------===##
+#
+# Performs a try_compile to determine the architecture of the target.
+#
+##===----------------------------------------------------------------------===##
+
+get_filename_component(__check_fpu_mode_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
+
+macro(detect_fpu_mode variable)
+ try_compile(HAVE_${variable}
+ ${CMAKE_BINARY_DIR}
+ ${__check_fpu_mode_dir}/DetectFpuAbi.c
+ OUTPUT_VARIABLE OUTPUT
+ COPY_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectFpuAbi.bin)
+
+ if(HAVE_${variable})
+ file(STRINGS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectFpuAbi.bin
+ DETECT_FPU_STRING LIMIT_COUNT 1 REGEX "FPU IS")
+ if(DETECT_FPU_STRING)
+ string(REGEX MATCH "[^ ]*$" DETECT_FPU_MATCH ${DETECT_FPU_STRING})
+ if(DETECT_FPU_MATCH)
+ message(STATUS "Check target fpu: ${DETECT_FPU_STRING}")
+ set(${variable} ${DETECT_FPU_MATCH})
+ else()
+ message(SEND_ERROR "Could not detect target fpu mode!")
+ endif()
+ else()
+ message(SEND_ERROR "Could not detect fpu mode!")
+ endif()
+ else()
+ message(STATUS "Determine the fpu mode - failed")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining the fpu mode failed with the following output:\n${OUTPUT}")
+ set(${variable})
+ endif()
+
+endmacro(detect_fpu_mode)
+
+macro(detect_fpu_abi variable)
+ try_compile(HAVE_${variable}
+ ${CMAKE_BINARY_DIR}
+ ${__check_fpu_mode_dir}/DetectFpuAbi.c
+ OUTPUT_VARIABLE OUTPUT
+ COPY_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectFpuAbi.bin)
+
+ if(HAVE_${variable})
+ file(STRINGS ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/DetectFpuAbi.bin
+ DETECT_FPU_ABI_STRING LIMIT_COUNT 1 REGEX "FPU ABI IS")
+ if(DETECT_FPU_ABI_STRING)
+ string(REGEX MATCH "[^ ]*$" DETECT_FPU_ABI_MATCH ${DETECT_FPU_ABI_STRING})
+ if(DETECT_FPU_ABI_MATCH)
+ message(STATUS "Check target fpu abi: ${DETECT_FPU_ABI_STRING}")
+ set(${variable} ${DETECT_FPU_ABI_MATCH})
+ else()
+ message(SEND_ERROR "Could not detect target fpu abi!")
+ endif()
+ else()
+ message(SEND_ERROR "Could not detect fpu abi!")
+ endif()
+ else()
+ message(STATUS "Determine the fpu abi - failed")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Determining the fpu abi failed with the following output:\n${OUTPUT}")
+ set(${variable})
+ endif()
+
+endmacro(detect_fpu_abi)
diff --git a/src/fluent-bit/lib/luajit-cmake/Modules/DetectFpuAbi.c b/src/fluent-bit/lib/luajit-cmake/Modules/DetectFpuAbi.c
new file mode 100755
index 000000000..ebc6baa84
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Modules/DetectFpuAbi.c
@@ -0,0 +1,34 @@
+#if defined(__SOFTFP__) || defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) || defined(__mips_soft_float)
+#define HAS_FPU 0
+#else
+#define HAS_FPU 1
+#endif
+
+#if !HAS_FPU
+const char *str = "\0FPU IS Soft";
+#else
+const char *str = "\0FPU IS Hard";
+#endif
+
+#if defined(__SOFTFP__) || defined(_SOFT_FLOAT) || defined(_SOFT_DOUBLE) || defined(__mips_soft_float)
+#define SOFT_FPU_ABI 1
+#else
+#if (defined(__arm__) || defined(__arm) || defined(__ARM__) || defined(__ARM)) && !defined(__ARM_PCS_VFP)
+#define SOFT_FPU_ABI 1
+#else
+#define SOFT_FPU_ABI 0
+#endif
+#endif
+
+#if SOFT_FPU_ABI
+const char *fpu_abi_str = "\0FPU ABI IS Soft";
+#else
+const char *fpu_abi_str = "\0FPU ABI IS Hard";
+#endif
+
+int main(int argc, char **argv) {
+ int require = str[argc];
+ (void)argv;
+ require += fpu_abi_str[argc];
+ return require;
+}
diff --git a/src/fluent-bit/lib/luajit-cmake/Modules/FindUnwind.cmake b/src/fluent-bit/lib/luajit-cmake/Modules/FindUnwind.cmake
new file mode 100644
index 000000000..a3649a5e8
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Modules/FindUnwind.cmake
@@ -0,0 +1,60 @@
+# - Try to find libunwind
+# Once done this will define
+#
+# unwind_FOUND - system has libunwind
+# unwind - cmake target for libunwind
+
+find_library (UNWIND_LIBRARY NAMES unwind DOC "unwind library")
+include (CheckIncludeFile)
+
+check_include_file (unwind.h HAVE_UNWIND_H)
+if (NOT HAVE_UNWIND_H)
+ check_include_file (libunwind.h HAVE_UNWIND_H)
+endif ()
+
+if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
+ set(LIBUNWIND_ARCH "arm")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
+ set(LIBUNWIND_ARCH "aarch64")
+elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR
+ CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64" OR
+ CMAKE_SYSTEM_PROCESSOR STREQUAL "corei7-64")
+ set(LIBUNWIND_ARCH "x86_64")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
+ set(LIBUNWIND_ARCH "x86")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64")
+ set(LIBUNWIND_ARCH "ppc64")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc")
+ set(LIBUNWIND_ARCH "ppc32")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
+ set(LIBUNWIND_ARCH "mips")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^hppa")
+ set(LIBUNWIND_ARCH "hppa")
+elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^ia64")
+ set(LIBUNWIND_ARCH "ia64")
+endif()
+
+if (UNWIND_LIBRARY MATCHES "_FOUND")
+ set(UNWIND_LIBRARY unwind)
+ set(HAVE_UNWIND_LIB ON)
+else()
+ find_library (UNWIND_LIBRARY NAMES "unwind-${LIBUNWIND_ARCH}" DOC "unwind library platform")
+ if (UNWIND_LIBRARY MATCHES "_FOUND")
+ set(HAVE_UNWIND_LIB ON)
+ set(UNWIND_LIBRARY unwind-${LIBUNWIND_ARCH})
+ endif ()
+endif()
+
+if (HAVE_UNWIND_LIB AND HAVE_UNWIND_H)
+ set(unwind_FOUND ON)
+elseif(HAVE_UNWIND_H)
+ if (CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64
+ AND CMAKE_C_COMPILER_ID STREQUAL zig
+ AND NOT ANDROID
+ AND NOT IOS)
+ set(UNWIND_LIBRARY unwind)
+ set(HAVE_UNWIND_LIB ON)
+ endif()
+else ()
+ unset(UNWIND_LIBRARY)
+endif ()
diff --git a/src/fluent-bit/lib/luajit-cmake/Utils/Darwin.wine.cmake b/src/fluent-bit/lib/luajit-cmake/Utils/Darwin.wine.cmake
new file mode 100644
index 000000000..7cbb02229
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Utils/Darwin.wine.cmake
@@ -0,0 +1,3 @@
+set(WINE true)
+set(HOST_WINE wine)
+set(TOOLCHAIN "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_CURRENT_LIST_DIR}/windows.toolchain.cmake")
diff --git a/src/fluent-bit/lib/luajit-cmake/Utils/host.toolchain.cmake b/src/fluent-bit/lib/luajit-cmake/Utils/host.toolchain.cmake
new file mode 100644
index 000000000..5ceda275e
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Utils/host.toolchain.cmake
@@ -0,0 +1,3 @@
+set(WINE true)
+set(HOST_WINE wine)
+set(TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/zig.toolchain.cmake")
diff --git a/src/fluent-bit/lib/luajit-cmake/Utils/ios.toolchain.cmake b/src/fluent-bit/lib/luajit-cmake/Utils/ios.toolchain.cmake
new file mode 100644
index 000000000..2da39c4a8
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Utils/ios.toolchain.cmake
@@ -0,0 +1,672 @@
+# This file is part of the ios-cmake project. It was retrieved from
+# https://github.com/cristeab/ios-cmake.git, which is a fork of
+# https://code.google.com/p/ios-cmake/. Which in turn is based off of
+# the Platform/Darwin.cmake and Platform/UnixPaths.cmake files which
+# are included with CMake 2.8.4
+#
+# The ios-cmake project is licensed under the new BSD license.
+#
+# Copyright (c) 2014, Bogdan Cristea and LTE Engineering Software,
+# Kitware, Inc., Insight Software Consortium. All rights reserved.
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# 3. Neither the name of the copyright holder nor the names of its
+# contributors may be used to endorse or promote products derived from
+# this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+# This file is based off of the Platform/Darwin.cmake and
+# Platform/UnixPaths.cmake files which are included with CMake 2.8.4
+# It has been altered for iOS development.
+#
+# Updated by Alex Stewart (alexs.mac@gmail.com)
+#
+# *****************************************************************************
+# Now maintained by Alexander Widerberg (widerbergaren [at] gmail.com)
+# under the BSD-3-Clause license
+# https://github.com/leetal/ios-cmake
+# *****************************************************************************
+#
+# INFORMATION / HELP
+#
+# The following arguments control the behaviour of this toolchain:
+#
+# PLATFORM: (default "OS")
+# OS = Build for iPhoneOS.
+# OS64 = Build for arm64 iphoneOS.
+# OS64COMBINED = Build for arm64 x86_64 iphoneOS. Combined into FAT STATIC lib (supported on 3.14+ of CMakewith "-G Xcode" argument ONLY)
+# SIMULATOR = Build for x86 i386 iphoneOS Simulator.
+# SIMULATOR64 = Build for x86_64 iphoneOS Simulator.
+# TVOS = Build for arm64 tvOS.
+# TVOSCOMBINED = Build for arm64 x86_64 tvOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY)
+# SIMULATOR_TVOS = Build for x86_64 tvOS Simulator.
+# WATCHOS = Build for armv7k arm64_32 for watchOS.
+# WATCHOSCOMBINED = Build for armv7k arm64_32 x86_64 watchOS. Combined into FAT STATIC lib (supported on 3.14+ of CMake with "-G Xcode" argument ONLY)
+# SIMULATOR_WATCHOS = Build for x86_64 for watchOS Simulator.
+#
+# CMAKE_OSX_SYSROOT: Path to the SDK to use. By default this is
+# automatically determined from PLATFORM and xcodebuild, but
+# can also be manually specified (although this should not be required).
+#
+# CMAKE_DEVELOPER_ROOT: Path to the Developer directory for the platform
+# being compiled for. By default this is automatically determined from
+# CMAKE_OSX_SYSROOT, but can also be manually specified (although this should
+# not be required).
+#
+# DEPLOYMENT_TARGET: Minimum SDK version to target. Default 2.0 on watchOS and 9.0 on tvOS+iOS
+#
+# ENABLE_BITCODE: (1|0) Enables or disables bitcode support. Default 1 (true)
+#
+# ENABLE_ARC: (1|0) Enables or disables ARC support. Default 1 (true, ARC enabled by default)
+#
+# ENABLE_VISIBILITY: (1|0) Enables or disables symbol visibility support. Default 0 (false, visibility hidden by default)
+#
+# ENABLE_STRICT_TRY_COMPILE: (1|0) Enables or disables strict try_compile() on all Check* directives (will run linker
+# to actually check if linking is possible). Default 0 (false, will set CMAKE_TRY_COMPILE_TARGET_TYPE to STATIC_LIBRARY)
+#
+# ARCHS: (armv7 armv7s armv7k arm64 arm64_32 i386 x86_64) If specified, will override the default architectures for the given PLATFORM
+# OS = armv7 armv7s arm64 (if applicable)
+# OS64 = arm64 (if applicable)
+# SIMULATOR = i386
+# SIMULATOR64 = x86_64
+# TVOS = arm64
+# SIMULATOR_TVOS = x86_64 (i386 has since long been deprecated)
+# WATCHOS = armv7k arm64_32 (if applicable)
+# SIMULATOR_WATCHOS = x86_64 (i386 has since long been deprecated)
+#
+# This toolchain defines the following variables for use externally:
+#
+# XCODE_VERSION: Version number (not including Build version) of Xcode detected.
+# SDK_VERSION: Version of SDK being used.
+# CMAKE_OSX_ARCHITECTURES: Architectures being compiled for (generated from PLATFORM).
+#
+# This toolchain defines the following macros for use externally:
+#
+# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE XCODE_VARIANT)
+# A convenience macro for setting xcode specific properties on targets.
+# Available variants are: All, Release, RelWithDebInfo, Debug, MinSizeRel
+# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1" "all").
+#
+# find_host_package (PROGRAM ARGS)
+# A macro used to find executable programs on the host system, not within the
+# environment. Thanks to the android-cmake project for providing the
+# command.
+#
+# ******************************** DEPRECATIONS *******************************
+#
+# IOS_DEPLOYMENT_TARGET: (Deprecated) Alias to DEPLOYMENT_TARGET
+# CMAKE_IOS_DEVELOPER_ROOT: (Deprecated) Alias to CMAKE_DEVELOPER_ROOT
+# IOS_PLATFORM: (Deprecated) Alias to PLATFORM
+# IOS_ARCH: (Deprecated) Alias to ARCHS
+#
+# *****************************************************************************
+#
+
+# Fix for PThread library not in path
+set(CMAKE_THREAD_LIBS_INIT "-lpthread")
+set(CMAKE_HAVE_THREADS_LIBRARY 1)
+set(CMAKE_USE_WIN32_THREADS_INIT 0)
+set(CMAKE_USE_PTHREADS_INIT 1)
+
+# Cache what generator is used
+set(USED_CMAKE_GENERATOR "${CMAKE_GENERATOR}" CACHE STRING "Expose CMAKE_GENERATOR" FORCE)
+
+if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14")
+ set(MODERN_CMAKE YES)
+ message(STATUS "Merging integrated CMake 3.14+ iOS,tvOS,watchOS,macOS toolchain(s) with this toolchain!")
+endif()
+
+# Get the Xcode version being used.
+execute_process(COMMAND xcodebuild -version
+ OUTPUT_VARIABLE XCODE_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+string(REGEX MATCH "Xcode [0-9\\.]+" XCODE_VERSION "${XCODE_VERSION}")
+string(REGEX REPLACE "Xcode ([0-9\\.]+)" "\\1" XCODE_VERSION "${XCODE_VERSION}")
+message(STATUS "Building with Xcode version: ${XCODE_VERSION}")
+
+######## ALIASES (DEPRECATION WARNINGS)
+
+if(DEFINED IOS_PLATFORM)
+ set(PLATFORM ${IOS_PLATFORM})
+ message(DEPRECATION "IOS_PLATFORM argument is DEPRECATED. Consider using the new PLATFORM argument instead.")
+endif()
+
+if(DEFINED IOS_DEPLOYMENT_TARGET)
+ set(DEPLOYMENT_TARGET ${IOS_DEPLOYMENT_TARGET})
+ message(DEPRECATION "IOS_DEPLOYMENT_TARGET argument is DEPRECATED. Consider using the new DEPLOYMENT_TARGET argument instead.")
+endif()
+
+if(DEFINED CMAKE_IOS_DEVELOPER_ROOT)
+ set(CMAKE_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT})
+ message(DEPRECATION "CMAKE_IOS_DEVELOPER_ROOT argument is DEPRECATED. Consider using the new CMAKE_DEVELOPER_ROOT argument instead.")
+endif()
+
+if(DEFINED IOS_ARCH)
+ set(ARCHS ${IOS_ARCH})
+ message(DEPRECATION "IOS_ARCH argument is DEPRECATED. Consider using the new ARCHS argument instead.")
+endif()
+
+######## END ALIASES
+
+# Unset the FORCE on cache variables if in try_compile()
+set(FORCE_CACHE FORCE)
+get_property(_CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE)
+if(_CMAKE_IN_TRY_COMPILE)
+ unset(FORCE_CACHE)
+endif()
+
+# Default to building for iPhoneOS if not specified otherwise, and we cannot
+# determine the platform from the CMAKE_OSX_ARCHITECTURES variable. The use
+# of CMAKE_OSX_ARCHITECTURES is such that try_compile() projects can correctly
+# determine the value of PLATFORM from the root project, as
+# CMAKE_OSX_ARCHITECTURES is propagated to them by CMake.
+if(NOT DEFINED PLATFORM)
+ if (CMAKE_OSX_ARCHITECTURES)
+ if(CMAKE_OSX_ARCHITECTURES MATCHES ".*arm.*" AND CMAKE_OSX_SYSROOT MATCHES ".*iphoneos.*")
+ set(PLATFORM "OS")
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_SYSROOT MATCHES ".*iphonesimulator.*")
+ set(PLATFORM "SIMULATOR")
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" AND CMAKE_OSX_SYSROOT MATCHES ".*iphonesimulator.*")
+ set(PLATFORM "SIMULATOR64")
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "arm64" AND CMAKE_OSX_SYSROOT MATCHES ".*appletvos.*")
+ set(PLATFORM "TVOS")
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" AND CMAKE_OSX_SYSROOT MATCHES ".*appletvsimulator.*")
+ set(PLATFORM "SIMULATOR_TVOS")
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES ".*armv7k.*" AND CMAKE_OSX_SYSROOT MATCHES ".*watchos.*")
+ set(PLATFORM "WATCHOS")
+ elseif(CMAKE_OSX_ARCHITECTURES MATCHES "i386" AND CMAKE_OSX_SYSROOT MATCHES ".*watchsimulator.*")
+ set(PLATFORM "SIMULATOR_WATCHOS")
+ endif()
+ endif()
+ if (NOT PLATFORM)
+ set(PLATFORM "OS")
+ endif()
+endif()
+
+set(PLATFORM_INT "${PLATFORM}" CACHE STRING "Type of platform for which the build targets.")
+
+# Handle the case where we are targeting iOS and a version above 10.3.4 (32-bit support dropped officially)
+if(PLATFORM_INT STREQUAL "OS" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4)
+ set(PLATFORM_INT "OS64")
+ message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.")
+elseif(PLATFORM_INT STREQUAL "SIMULATOR" AND DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 10.3.4)
+ set(PLATFORM_INT "SIMULATOR64")
+ message(STATUS "Targeting minimum SDK version ${DEPLOYMENT_TARGET}. Dropping 32-bit support.")
+endif()
+
+# Determine the platform name and architectures for use in xcodebuild commands
+# from the specified PLATFORM name.
+if(PLATFORM_INT STREQUAL "OS")
+ set(SDK_NAME iphoneos)
+ if(NOT ARCHS)
+ set(ARCHS armv7 armv7s arm64)
+ endif()
+elseif(PLATFORM_INT STREQUAL "OS64")
+ set(SDK_NAME iphoneos)
+ if(NOT ARCHS)
+ if (XCODE_VERSION VERSION_GREATER 10.0)
+ set(ARCHS arm64) # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example
+ else()
+ set(ARCHS arm64)
+ endif()
+ endif()
+elseif(PLATFORM_INT STREQUAL "OS64COMBINED")
+ set(SDK_NAME iphoneos)
+ if(MODERN_CMAKE)
+ if(NOT ARCHS)
+ if (XCODE_VERSION VERSION_GREATER 10.0)
+ set(ARCHS arm64 x86_64) # Add arm64e when Apple have fixed the integration issues with it, libarclite_iphoneos.a is currently missung bitcode markers for example
+ else()
+ set(ARCHS arm64 x86_64)
+ endif()
+ endif()
+ else()
+ message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the OS64COMBINED setting work")
+ endif()
+elseif(PLATFORM_INT STREQUAL "SIMULATOR")
+ set(SDK_NAME iphonesimulator)
+ if(NOT ARCHS)
+ set(ARCHS i386)
+ endif()
+ message(DEPRECATION "SIMULATOR IS DEPRECATED. Consider using SIMULATOR64 instead.")
+elseif(PLATFORM_INT STREQUAL "SIMULATOR64")
+ set(SDK_NAME iphonesimulator)
+ if(NOT ARCHS)
+ set(ARCHS x86_64)
+ endif()
+elseif(PLATFORM_INT STREQUAL "TVOS")
+ set(SDK_NAME appletvos)
+ if(NOT ARCHS)
+ set(ARCHS arm64)
+ endif()
+elseif (PLATFORM_INT STREQUAL "TVOSCOMBINED")
+ set(SDK_NAME appletvos)
+ if(MODERN_CMAKE)
+ if(NOT ARCHS)
+ set(ARCHS arm64 x86_64)
+ endif()
+ else()
+ message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the TVOSCOMBINED setting work")
+ endif()
+elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS")
+ set(SDK_NAME appletvsimulator)
+ if(NOT ARCHS)
+ set(ARCHS x86_64)
+ endif()
+elseif(PLATFORM_INT STREQUAL "WATCHOS")
+ set(SDK_NAME watchos)
+ if(NOT ARCHS)
+ if (XCODE_VERSION VERSION_GREATER 10.0)
+ set(ARCHS armv7k arm64_32)
+ else()
+ set(ARCHS armv7k)
+ endif()
+ endif()
+elseif(PLATFORM_INT STREQUAL "WATCHOSCOMBINED")
+ set(SDK_NAME watchos)
+ if(MODERN_CMAKE)
+ if(NOT ARCHS)
+ if (XCODE_VERSION VERSION_GREATER 10.0)
+ set(ARCHS armv7k arm64_32 i386)
+ else()
+ set(ARCHS armv7k i386)
+ endif()
+ endif()
+ else()
+ message(FATAL_ERROR "Please make sure that you are running CMake 3.14+ to make the WATCHOSCOMBINED setting work")
+ endif()
+elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
+ set(SDK_NAME watchsimulator)
+ if(NOT ARCHS)
+ set(ARCHS i386)
+ endif()
+else()
+ message(FATAL_ERROR "Invalid PLATFORM: ${PLATFORM_INT}")
+endif()
+message(STATUS "Configuring ${SDK_NAME} build for platform: ${PLATFORM_INT}, architecture(s): ${ARCHS}")
+
+if(MODERN_CMAKE AND PLATFORM_INT MATCHES ".*COMBINED" AND NOT USED_CMAKE_GENERATOR MATCHES "Xcode")
+ message(FATAL_ERROR "The COMBINED options only work with Xcode generator, -G Xcode")
+endif()
+
+# If user did not specify the SDK root to use, then query xcodebuild for it.
+execute_process(COMMAND xcodebuild -version -sdk ${SDK_NAME} Path
+ OUTPUT_VARIABLE CMAKE_OSX_SYSROOT_INT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+if (NOT DEFINED CMAKE_OSX_SYSROOT_INT AND NOT DEFINED CMAKE_OSX_SYSROOT)
+ message(SEND_ERROR "Please make sure that Xcode is installed and that the toolchain"
+ "is pointing to the correct path. Please run:"
+ "sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
+ "and see if that fixes the problem for you.")
+ message(FATAL_ERROR "Invalid CMAKE_OSX_SYSROOT: ${CMAKE_OSX_SYSROOT} "
+ "does not exist.")
+elseif(DEFINED CMAKE_OSX_SYSROOT)
+ message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT} for platform: ${PLATFORM_INT} when checking compatibility")
+elseif(DEFINED CMAKE_OSX_SYSROOT_INT)
+ message(STATUS "Using SDK: ${CMAKE_OSX_SYSROOT_INT} for platform: ${PLATFORM_INT}")
+ set(CMAKE_OSX_SYSROOT "${CMAKE_OSX_SYSROOT_INT}" CACHE INTERNAL "")
+endif()
+
+# Set Xcode property for SDKROOT as well if Xcode generator is used
+if(USED_CMAKE_GENERATOR MATCHES "Xcode")
+ set(CMAKE_OSX_SYSROOT "${SDK_NAME}" CACHE INTERNAL "")
+ if(NOT DEFINED CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)
+ set(CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM 123456789A CACHE INTERNAL "")
+ endif()
+endif()
+
+# Specify minimum version of deployment target.
+if(NOT DEFINED DEPLOYMENT_TARGET)
+ if (PLATFORM_INT STREQUAL "WATCHOS" OR PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
+ # Unless specified, SDK version 2.0 is used by default as minimum target version (watchOS).
+ set(DEPLOYMENT_TARGET "2.0"
+ CACHE STRING "Minimum SDK version to build for." )
+ else()
+ # Unless specified, SDK version 9.0 is used by default as minimum target version (iOS, tvOS).
+ set(DEPLOYMENT_TARGET "9.0"
+ CACHE STRING "Minimum SDK version to build for." )
+ endif()
+ message(STATUS "Using the default min-version since DEPLOYMENT_TARGET not provided!")
+endif()
+# Use bitcode or not
+if(NOT DEFINED ENABLE_BITCODE AND NOT ARCHS MATCHES "((^|;|, )(i386|x86_64))+")
+ # Unless specified, enable bitcode support by default
+ message(STATUS "Enabling bitcode support by default. ENABLE_BITCODE not provided!")
+ set(ENABLE_BITCODE TRUE)
+elseif(NOT DEFINED ENABLE_BITCODE)
+ message(STATUS "Disabling bitcode support by default on simulators. ENABLE_BITCODE not provided for override!")
+ set(ENABLE_BITCODE FALSE)
+endif()
+set(ENABLE_BITCODE_INT ${ENABLE_BITCODE} CACHE BOOL "Whether or not to enable bitcode" ${FORCE_CACHE})
+# Use ARC or not
+if(NOT DEFINED ENABLE_ARC)
+ # Unless specified, enable ARC support by default
+ set(ENABLE_ARC TRUE)
+ message(STATUS "Enabling ARC support by default. ENABLE_ARC not provided!")
+endif()
+set(ENABLE_ARC_INT ${ENABLE_ARC} CACHE BOOL "Whether or not to enable ARC" ${FORCE_CACHE})
+# Use hidden visibility or not
+if(NOT DEFINED ENABLE_VISIBILITY)
+ # Unless specified, disable symbols visibility by default
+ set(ENABLE_VISIBILITY FALSE)
+ message(STATUS "Hiding symbols visibility by default. ENABLE_VISIBILITY not provided!")
+endif()
+set(ENABLE_VISIBILITY_INT ${ENABLE_VISIBILITY} CACHE BOOL "Whether or not to hide symbols (-fvisibility=hidden)" ${FORCE_CACHE})
+# Set strict compiler checks or not
+if(NOT DEFINED ENABLE_STRICT_TRY_COMPILE)
+ # Unless specified, disable strict try_compile()
+ set(ENABLE_STRICT_TRY_COMPILE FALSE)
+ message(STATUS "Using NON-strict compiler checks by default. ENABLE_STRICT_TRY_COMPILE not provided!")
+endif()
+set(ENABLE_STRICT_TRY_COMPILE_INT ${ENABLE_STRICT_TRY_COMPILE} CACHE BOOL "Whether or not to use strict compiler checks" ${FORCE_CACHE})
+# Get the SDK version information.
+execute_process(COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version SDKVersion
+ OUTPUT_VARIABLE SDK_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+
+# Find the Developer root for the specific iOS platform being compiled for
+# from CMAKE_OSX_SYSROOT. Should be ../../ from SDK specified in
+# CMAKE_OSX_SYSROOT. There does not appear to be a direct way to obtain
+# this information from xcrun or xcodebuild.
+if (NOT DEFINED CMAKE_DEVELOPER_ROOT AND NOT USED_CMAKE_GENERATOR MATCHES "Xcode")
+ get_filename_component(PLATFORM_SDK_DIR ${CMAKE_OSX_SYSROOT} PATH)
+ get_filename_component(CMAKE_DEVELOPER_ROOT ${PLATFORM_SDK_DIR} PATH)
+
+ if (NOT DEFINED CMAKE_DEVELOPER_ROOT)
+ message(FATAL_ERROR "Invalid CMAKE_DEVELOPER_ROOT: "
+ "${CMAKE_DEVELOPER_ROOT} does not exist.")
+ endif()
+endif()
+# Find the C & C++ compilers for the specified SDK.
+if(NOT CMAKE_C_COMPILER)
+ execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang
+ OUTPUT_VARIABLE CMAKE_C_COMPILER
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message(STATUS "Using C compiler: ${CMAKE_C_COMPILER}")
+endif()
+if(NOT CMAKE_CXX_COMPILER)
+ execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find clang++
+ OUTPUT_VARIABLE CMAKE_CXX_COMPILER
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ message(STATUS "Using CXX compiler: ${CMAKE_CXX_COMPILER}")
+endif()
+# Find (Apple's) libtool.
+execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find libtool
+ OUTPUT_VARIABLE BUILD_LIBTOOL
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+message(STATUS "Using libtool: ${BUILD_LIBTOOL}")
+# Configure libtool to be used instead of ar + ranlib to build static libraries.
+# This is required on Xcode 7+, but should also work on previous versions of
+# Xcode.
+set(CMAKE_C_CREATE_STATIC_LIBRARY
+ "${BUILD_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
+set(CMAKE_CXX_CREATE_STATIC_LIBRARY
+ "${BUILD_LIBTOOL} -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
+# Find the toolchain's provided install_name_tool if none is found on the host
+if(NOT CMAKE_INSTALL_NAME_TOOL)
+ execute_process(COMMAND xcrun -sdk ${CMAKE_OSX_SYSROOT} -find install_name_tool
+ OUTPUT_VARIABLE CMAKE_INSTALL_NAME_TOOL_INT
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ set(CMAKE_INSTALL_NAME_TOOL ${CMAKE_INSTALL_NAME_TOOL_INT} CACHE STRING "" ${FORCE_CACHE})
+ message(STATUS "Using install_name_tool: ${CMAKE_INSTALL_NAME_TOOL}")
+endif()
+# Get the version of Darwin (OS X) of the host.
+execute_process(COMMAND uname -r
+ OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION
+ ERROR_QUIET
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+# CMake 3.14+ support building for iOS, watchOS and tvOS out of the box.
+if(MODERN_CMAKE)
+ if(SDK_NAME MATCHES "iphone")
+ set(CMAKE_SYSTEM_NAME iOS CACHE INTERNAL "" ${FORCE_CACHE})
+ elseif(SDK_NAME MATCHES "appletv")
+ set(CMAKE_SYSTEM_NAME tvOS CACHE INTERNAL "" ${FORCE_CACHE})
+ elseif(SDK_NAME MATCHES "watch")
+ set(CMAKE_SYSTEM_NAME watchOS CACHE INTERNAL "" ${FORCE_CACHE})
+ endif()
+
+ # Provide flags for a combined FAT library build on newer CMake versions
+ if(PLATFORM_INT MATCHES ".*COMBINED")
+ set(CMAKE_XCODE_ATTRIBUTE_ONLY_ACTIVE_ARCH NO CACHE INTERNAL "" ${FORCE_CACHE})
+ set(CMAKE_IOS_INSTALL_COMBINED YES CACHE INTERNAL "" ${FORCE_CACHE})
+ message(STATUS "Will combine built (static) artifacts into FAT lib...")
+ endif()
+else()
+ # Legacy code path prior to CMake 3.14
+ set(CMAKE_SYSTEM_NAME Darwin CACHE INTERNAL "" ${FORCE_CACHE})
+endif()
+# Standard settings.
+set(CMAKE_SYSTEM_VERSION ${SDK_VERSION} CACHE INTERNAL "")
+set(UNIX TRUE CACHE BOOL "")
+set(APPLE TRUE CACHE BOOL "")
+set(IOS TRUE CACHE BOOL "")
+set(CMAKE_AR ar CACHE FILEPATH "" FORCE)
+set(CMAKE_RANLIB ranlib CACHE FILEPATH "" FORCE)
+set(CMAKE_STRIP strip CACHE FILEPATH "" FORCE)
+# Set the architectures for which to build.
+set(CMAKE_OSX_ARCHITECTURES ${ARCHS} CACHE STRING "Build architecture for iOS")
+# Change the type of target generated for try_compile() so it'll work when cross-compiling, weak compiler checks
+if(ENABLE_STRICT_TRY_COMPILE_INT)
+ message(STATUS "Using strict compiler checks (default in CMake).")
+else()
+ set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+endif()
+# All iOS/Darwin specific settings - some may be redundant.
+set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
+set(CMAKE_SHARED_LIBRARY_SUFFIX ".dylib")
+set(CMAKE_SHARED_MODULE_PREFIX "lib")
+set(CMAKE_SHARED_MODULE_SUFFIX ".so")
+set(CMAKE_C_COMPILER_ABI ELF)
+set(CMAKE_CXX_COMPILER_ABI ELF)
+set(CMAKE_C_HAS_ISYSROOT 1)
+set(CMAKE_CXX_HAS_ISYSROOT 1)
+set(CMAKE_MODULE_EXISTS 1)
+set(CMAKE_DL_LIBS "")
+set(CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG "-compatibility_version ")
+set(CMAKE_C_OSX_CURRENT_VERSION_FLAG "-current_version ")
+set(CMAKE_CXX_OSX_COMPATIBILITY_VERSION_FLAG "${CMAKE_C_OSX_COMPATIBILITY_VERSION_FLAG}")
+set(CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
+
+if(ARCHS MATCHES "((^|;|, )(arm64|arm64e|x86_64))+")
+ set(CMAKE_C_SIZEOF_DATA_PTR 8)
+ set(CMAKE_CXX_SIZEOF_DATA_PTR 8)
+ if(ARCHS MATCHES "((^|;|, )(arm64|arm64e))+")
+ set(CMAKE_SYSTEM_PROCESSOR "aarch64")
+ else()
+ set(CMAKE_SYSTEM_PROCESSOR "x86_64")
+ endif()
+ message(STATUS "Using a data_ptr size of 8")
+else()
+ set(CMAKE_C_SIZEOF_DATA_PTR 4)
+ set(CMAKE_CXX_SIZEOF_DATA_PTR 4)
+ set(CMAKE_SYSTEM_PROCESSOR "arm")
+ message(STATUS "Using a data_ptr size of 4")
+endif()
+
+message(STATUS "Building for minimum ${SDK_NAME} version: ${DEPLOYMENT_TARGET}"
+ " (SDK version: ${SDK_VERSION})")
+# Note that only Xcode 7+ supports the newer more specific:
+# -m${SDK_NAME}-version-min flags, older versions of Xcode use:
+# -m(ios/ios-simulator)-version-min instead.
+if(PLATFORM_INT STREQUAL "OS" OR PLATFORM_INT STREQUAL "OS64")
+ if(XCODE_VERSION VERSION_LESS 7.0)
+ set(SDK_NAME_VERSION_FLAGS
+ "-mios-version-min=${DEPLOYMENT_TARGET}")
+ else()
+ # Xcode 7.0+ uses flags we can build directly from SDK_NAME.
+ set(SDK_NAME_VERSION_FLAGS
+ "-m${SDK_NAME}-version-min=${DEPLOYMENT_TARGET}")
+ endif()
+elseif(PLATFORM_INT STREQUAL "TVOS")
+ set(SDK_NAME_VERSION_FLAGS
+ "-mtvos-version-min=${DEPLOYMENT_TARGET}")
+elseif(PLATFORM_INT STREQUAL "SIMULATOR_TVOS")
+ set(SDK_NAME_VERSION_FLAGS
+ "-mtvos-simulator-version-min=${DEPLOYMENT_TARGET}")
+elseif(PLATFORM_INT STREQUAL "WATCHOS")
+ set(SDK_NAME_VERSION_FLAGS
+ "-mwatchos-version-min=${DEPLOYMENT_TARGET}")
+elseif(PLATFORM_INT STREQUAL "SIMULATOR_WATCHOS")
+ set(SDK_NAME_VERSION_FLAGS
+ "-mwatchos-simulator-version-min=${DEPLOYMENT_TARGET}")
+else()
+ # SIMULATOR or SIMULATOR64 both use -mios-simulator-version-min.
+ set(SDK_NAME_VERSION_FLAGS
+ "-mios-simulator-version-min=${DEPLOYMENT_TARGET}")
+endif()
+message(STATUS "Version flags set to: ${SDK_NAME_VERSION_FLAGS}")
+set(CMAKE_OSX_DEPLOYMENT_TARGET ${DEPLOYMENT_TARGET} CACHE STRING
+ "Set CMake deployment target" ${FORCE_CACHE})
+
+if(ENABLE_BITCODE_INT)
+ set(BITCODE "-fembed-bitcode")
+ set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE bitcode CACHE INTERNAL "")
+ message(STATUS "Enabling bitcode support.")
+else()
+ set(BITCODE "")
+ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE NO CACHE INTERNAL "")
+ message(STATUS "Disabling bitcode support.")
+endif()
+
+if(ENABLE_ARC_INT)
+ set(FOBJC_ARC "-fobjc-arc")
+ set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES CACHE INTERNAL "")
+ message(STATUS "Enabling ARC support.")
+else()
+ set(FOBJC_ARC "-fno-objc-arc")
+ set(CMAKE_XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC NO CACHE INTERNAL "")
+ message(STATUS "Disabling ARC support.")
+endif()
+
+if(NOT ENABLE_VISIBILITY_INT)
+ set(VISIBILITY "-fvisibility=hidden")
+ set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN YES CACHE INTERNAL "")
+ message(STATUS "Hiding symbols (-fvisibility=hidden).")
+else()
+ set(VISIBILITY "")
+ set(CMAKE_XCODE_ATTRIBUTE_GCC_SYMBOLS_PRIVATE_EXTERN NO CACHE INTERNAL "")
+endif()
+
+#Check if Xcode generator is used, since that will handle these flags automagically
+if(USED_CMAKE_GENERATOR MATCHES "Xcode")
+ message(STATUS "Not setting any manual command-line buildflags, since Xcode is selected as generator.")
+else()
+ set(CMAKE_C_FLAGS
+ "${SDK_NAME_VERSION_FLAGS} ${BITCODE} -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_C_FLAGS}")
+ # Hidden visibilty is required for C++ on iOS.
+ set(CMAKE_CXX_FLAGS
+ "${SDK_NAME_VERSION_FLAGS} ${BITCODE} ${VISIBILITY} -fvisibility-inlines-hidden -fobjc-abi-version=2 ${FOBJC_ARC} ${CMAKE_CXX_FLAGS}")
+ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -O0 -g ${CMAKE_CXX_FLAGS_DEBUG}")
+ set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS} -DNDEBUG -Os -ffast-math ${CMAKE_CXX_FLAGS_MINSIZEREL}")
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -DNDEBUG -O2 -g -ffast-math ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
+ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -DNDEBUG -O3 -ffast-math ${CMAKE_CXX_FLAGS_RELEASE}")
+ set(CMAKE_C_LINK_FLAGS "${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
+ set(CMAKE_CXX_LINK_FLAGS "${SDK_NAME_VERSION_FLAGS} -Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
+
+ # In order to ensure that the updated compiler flags are used in try_compile()
+ # tests, we have to forcibly set them in the CMake cache, not merely set them
+ # in the local scope.
+ list(APPEND VARS_TO_FORCE_IN_CACHE
+ CMAKE_C_FLAGS
+ CMAKE_CXX_FLAGS
+ CMAKE_CXX_FLAGS_DEBUG
+ CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ CMAKE_CXX_FLAGS_MINSIZEREL
+ CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_C_LINK_FLAGS
+ CMAKE_CXX_LINK_FLAGS)
+ foreach(VAR_TO_FORCE ${VARS_TO_FORCE_IN_CACHE})
+ set(${VAR_TO_FORCE} "${${VAR_TO_FORCE}}" CACHE STRING "")
+ endforeach()
+endif()
+
+set(CMAKE_PLATFORM_HAS_INSTALLNAME 1)
+set(CMAKE_SHARED_LINKER_FLAGS "-rpath @executable_path/Frameworks -rpath @loader_path/Frameworks")
+set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
+set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names")
+set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,")
+set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,")
+set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a")
+set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-install_name")
+
+# Set the find root to the iOS developer roots and to user defined paths.
+set(CMAKE_FIND_ROOT_PATH ${CMAKE_OSX_SYSROOT_INT} ${CMAKE_PREFIX_PATH} CACHE STRING "Root path that will be prepended
+ to all search paths")
+# Default to searching for frameworks first.
+set(CMAKE_FIND_FRAMEWORK FIRST)
+# Set up the default search directories for frameworks.
+set(CMAKE_FRAMEWORK_PATH
+ ${CMAKE_DEVELOPER_ROOT}/Library/PrivateFrameworks
+ ${CMAKE_OSX_SYSROOT_INT}/System/Library/Frameworks
+ ${CMAKE_FRAMEWORK_PATH} CACHE STRING "Frameworks search paths" ${FORCE_CACHE})
+
+# By default, search both the specified iOS SDK and the remainder of the host filesystem.
+if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH CACHE STRING "" ${FORCE_CACHE})
+endif()
+if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE STRING "" ${FORCE_CACHE})
+endif()
+if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE STRING "" ${FORCE_CACHE})
+endif()
+if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY CACHE STRING "" ${FORCE_CACHE})
+endif()
+
+#
+# Some helper-macros below to simplify and beautify the CMakeFile
+#
+
+# This little macro lets you set any Xcode specific property.
+macro(set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE XCODE_RELVERSION)
+ set(XCODE_RELVERSION_I "${XCODE_RELVERSION}")
+ if(XCODE_RELVERSION_I STREQUAL "All")
+ set_property(TARGET ${TARGET} PROPERTY
+ XCODE_ATTRIBUTE_${XCODE_PROPERTY} "${XCODE_VALUE}")
+ else()
+ set_property(TARGET ${TARGET} PROPERTY
+ XCODE_ATTRIBUTE_${XCODE_PROPERTY}[variant=${XCODE_RELVERSION_I}] "${XCODE_VALUE}")
+ endif()
+endmacro(set_xcode_property)
+# This macro lets you find executable programs on the host system.
+macro(find_host_package)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
+ set(IOS FALSE)
+ find_package(${ARGN})
+ set(IOS TRUE)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH)
+ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
+ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
+ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
+endmacro(find_host_package)
diff --git a/src/fluent-bit/lib/luajit-cmake/Utils/windows.toolchain.cmake b/src/fluent-bit/lib/luajit-cmake/Utils/windows.toolchain.cmake
new file mode 100644
index 000000000..e3b937ba4
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Utils/windows.toolchain.cmake
@@ -0,0 +1,38 @@
+SET(CMAKE_SYSTEM_NAME Windows)
+
+IF(DEFINED ENV{USE_64BITS})
+ SET(USE_64BITS $ENV{USE_64BITS})
+ENDIF()
+
+IF(USE_64BITS OR CMAKE_SIZEOF_VOID_P STREQUAL 8)
+ SET(CROSSCOMPILER x86_64-w64-mingw32-)
+ELSE()
+ SET(CROSSCOMPILER i686-w64-mingw32-)
+ENDIF()
+
+IF($ENV{CROSSCOMPILER})
+ SET(CROSSCOMPILER $ENV{CROSSCOMPILER})
+ENDIF()
+
+
+SET(CMAKE_C_COMPILER ${CROSSCOMPILER}gcc)
+SET(CMAKE_CXX_COMPILER ${CROSSCOMPILER}g++)
+SET(CMAKE_STRIP ${CROSSCOMPILER}strip)
+SET(CMAKE_RC_COMPILER ${CROSSCOMPILER}windres)
+
+
+IF($ENV{CMAKE_FIND_ROOT_PATH})
+ SET(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH})
+ELSE()
+ EXECUTE_PROCESS(COMMAND
+ ${CMAKE_C_COMPILER} --print-sysroot OUTPUT_VARIABLE SYSROOT)
+ IF($ENV{SYSROOT})
+ SET(SYSROOT $ENV{SYSROOT})
+ ENDIF()
+ SET(CMAKE_FIND_ROOT_PATH ${SYSROOT})
+ENDIF()
+
+SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
diff --git a/src/fluent-bit/lib/luajit-cmake/Utils/zig.toolchain.cmake b/src/fluent-bit/lib/luajit-cmake/Utils/zig.toolchain.cmake
new file mode 100644
index 000000000..0a7236e45
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/Utils/zig.toolchain.cmake
@@ -0,0 +1,114 @@
+if(DEFINED ENV{TARGET_SYS})
+ set(TARGET_SYS $ENV{TARGET_SYS})
+endif()
+
+if(TARGET_SYS AND NOT ZIG_INIT)
+ set(ZIG_INIT ON)
+ set(ZIG_HACK)
+ if(DEFINED ENV{ZIG_TOOLCHAIN_PATH})
+ set(ZIG_TOOLCHAIN_PATH $ENV{ZIG_TOOLCHAIN_PATH})
+ endif()
+ if(NOT ZIG_TOOLCHAIN_PATH)
+ set(ZIG_TOOLCHAIN_PATH "/usr/local/bin/zig")
+ endif()
+
+ set(ZBUILDTYPE)
+ #https://github.com/ziglang/zig/wiki/FAQ#why-do-i-get-illegal-instruction-when-using-with-zig-cc-to-build-c-code
+ if(CMAKE_BUILD_TYPE)
+ string(TOLOWER ${CMAKE_BUILD_TYPE} ZBUILDTYPE)
+ if(${ZBUILDTYPE} MATCHES "release")
+ set(BUILDFLAGS "-O3 -pthread")
+ elseif(${ZBUILDTYPE} MATCHES "debug")
+ set(BUILDFLAGS "-Og -g -pthread -fno-sanitize=undefined -fno-sanitize-trap=undefined")
+ endif()
+ endif()
+
+ if(${TARGET_SYS} STREQUAL native)
+ set(CMAKE_SIZEOF_VOID_P 8)
+ set(CMAKE_SIZEOF_UNSIGNED_SHORT 2)
+ else()
+ string(REPLACE "-" ";" TARGETS ${TARGET_SYS})
+
+ list(GET TARGETS 0 ARCH)
+ list(GET TARGETS 1 TARGET)
+ list(GET TARGETS 2 LIBC)
+ if(${ARCH} STREQUAL i386)
+ set(ARCH i686)
+ endif()
+
+ string(SUBSTRING ${TARGET} 0 1 T1)
+ string(TOUPPER ${T1} T1)
+ string(SUBSTRING ${TARGET} 1 10 TARGET)
+ set(TARGET "${T1}${TARGET}")
+
+ if(${TARGET} STREQUAL Macos)
+ set(TARGET Darwin)
+ set(HAVE_FLAG_SEARCH_PATHS_FIRST 0)
+ set(CMAKE_OSX_SYSROOT "") #not use SYSROOT
+ set(APPLE 1)
+ set(UNIX 1)
+ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.09")
+ endif()
+ if(${TARGET} STREQUAL Linux)
+ set(UNIX 1)
+ endif()
+ if(${TARGET} STREQUAL Windows)
+ set(CMAKE_C_LINK_LIBRARY_SUFFIX "")
+ set(WIN32 1)
+ endif()
+
+ string(FIND ${ARCH} "64" BIT64)
+ if(NOT ${BIT64} EQUAL -1)
+ set(CMAKE_SIZEOF_VOID_P 8)
+ else()
+ set(CMAKE_SIZEOF_VOID_P 4)
+ endif()
+ set(CMAKE_SIZEOF_UNSIGNED_SHORT 2)
+ set(CMAKE_CROSSCOMPILING ON)
+ set(CMAKE_SYSTEM_NAME ${TARGET})
+ set(CMAKE_SYSTEM_PROCESSOR ${ARCH})
+ endif()
+
+ include(CMakeForceCompiler)
+
+ set(CMAKE_C_COMPILER_FORCED 1)
+ set(CMAKE_C_COMPILER_ID_RUN TRUE)
+ set(CMAKE_C_COMPILER ${ZIG_TOOLCHAIN_PATH} cc "-target ${TARGET_SYS}")
+ set(CMAKE_C_COMPILER_ID "zig")
+ set(CMAKE_C_COMPILER_VERSION 12.0)
+ set(CMAKE_C_COMPILER_TARGET ${TARGET_SYS})
+ set(CMAKE_C_FLAGS_INIT "${BUILDFLAGS} ${ISYSTEM} ${ZIG_HACK}")
+
+ set(CMAKE_ASM_COMPILER_FORCED 1)
+ set(CMAKE_ASM_COMPILER_ID_RUN TRUE)
+ set(CMAKE_ASM_COMPILER ${ZIG_TOOLCHAIN_PATH} cc "-target ${TARGET_SYS}")
+ set(CMAKE_ASM_COMPILER_ID "zig")
+ set(CMAKE_ASM_COMPILER_VERSION 12.0)
+ set(CMAKE_ASM_COMPILER_TARGET ${TARGET_SYS})
+ set(CMAKE_ASM_FLAGS_INIT "${BUILDFLAGS} ${ISYSTEM} ${ZIG_HACK}")
+
+ set(CMAKE_CXX_COMPILER_FORCED 1)
+ set(CMAKE_CXX_COMPILER_ID_RUN TRUE)
+ set(CMAKE_CXX_COMPILER ${ZIG_TOOLCHAIN_PATH} c++ "-target ${TARGET_SYS}")
+ set(CMAKE_CXX_COMPILER_ID "zig")
+ set(CMAKE_CXX_COMPILER_VERSION 12.0)
+ set(CMAKE_CXX_COMPILER_TARGET ${TARGET_SYS})
+ set(CMAKE_CXX_FLAGS_INIT "${BUILDFLAGS} ${ISYSTEM} ${ZIG_HACK}")
+
+ SET(CMAKE_AR ${ZIG_TOOLCHAIN_PATH})
+ SET(CMAKE_RANLIB ${ZIG_TOOLCHAIN_PATH})
+
+ set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> ar qc <TARGET> <LINK_FLAGS> <OBJECTS>")
+ SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> ranlib <TARGET>")
+ set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> ar q <TARGET> <LINK_FLAGS> <OBJECTS>")
+
+ SET(CMAKE_ASM_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE})
+ SET(CMAKE_ASM_ARCHIVE_FINISH ${CMAKE_C_ARCHIVE_FINISH})
+ SET(CMAKE_ASM_ARCHIVE_APPEND ${CMAKE_C_ARCHIVE_APPEND})
+
+ SET(CMAKE_CXX_ARCHIVE_CREATE ${CMAKE_C_ARCHIVE_CREATE})
+ SET(CMAKE_CXX_ARCHIVE_FINISH ${CMAKE_C_ARCHIVE_FINISH})
+ SET(CMAKE_CXX_ARCHIVE_APPEND ${CMAKE_C_ARCHIVE_APPEND})
+
+ message(STATUS "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
+endif()
diff --git a/src/fluent-bit/lib/luajit-cmake/host/buildvm/CMakeLists.txt b/src/fluent-bit/lib/luajit-cmake/host/buildvm/CMakeLists.txt
new file mode 100755
index 000000000..e824e4820
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/host/buildvm/CMakeLists.txt
@@ -0,0 +1,52 @@
+cmake_minimum_required(VERSION 3.0)
+
+project(buildvm C)
+
+set(EXTRA_COMPILER_FLAGS_FILE ""
+ CACHE PATH "Location of a file to specify extra compiler flags.")
+set(EXTRA_COMPILER_FLAGS "")
+if(EXISTS ${EXTRA_COMPILER_FLAGS_FILE})
+ file(READ ${EXTRA_COMPILER_FLAGS_FILE} EXTRA_COMPILER_FLAGS)
+else()
+ set(EXTRA_COMPILER_FLAGS ${BUILDVM_COMPILER_FLAGS})
+endif()
+
+include(CheckTypeSize)
+if("${EXTRA_COMPILER_FLAGS}" MATCHES "LUAJIT_ARCH_.*64")
+ set(TARGET_SIZE_OF_P 8)
+else()
+ set(TARGET_SIZE_OF_P 4)
+endif()
+
+set(CXX_ARCH_FLAGS "")
+if(NOT (CMAKE_SIZEOF_VOID_P EQUAL ${TARGET_SIZE_OF_P}))
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(CXX_ARCH_FLAGS "-m32")
+ else()
+ set(CXX_ARCH_FLAGS "-m64")
+ endif()
+endif()
+
+find_library(LIBM_LIBRARIES NAMES m)
+
+add_executable(buildvm
+ ${LUAJIT_DIR}/src/host/buildvm.c
+ ${LUAJIT_DIR}/src/host/buildvm_asm.c
+ ${LUAJIT_DIR}/src/host/buildvm_fold.c
+ ${LUAJIT_DIR}/src/host/buildvm_lib.c
+ ${LUAJIT_DIR}/src/host/buildvm_peobj.c)
+
+target_compile_options(buildvm PRIVATE
+ ${EXTRA_COMPILER_FLAGS} ${CXX_ARCH_FLAGS})
+target_link_libraries(buildvm PRIVATE ${CXX_ARCH_FLAGS})
+if(LIBM)
+ target_link_libraries(buildvm PRIVATE ${LIBM_LIBRARIES})
+endif()
+
+target_include_directories(buildvm PRIVATE
+ ${LUAJIT_DIR}/src
+ ${LUAJIT_DIR}/src/host
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/..
+ ${CMAKE_CURRENT_BINARY_DIR}/../../..
+ ${CMAKE_CURRENT_BINARY_DIR})
diff --git a/src/fluent-bit/lib/luajit-cmake/host/minilua/CMakeLists.txt b/src/fluent-bit/lib/luajit-cmake/host/minilua/CMakeLists.txt
new file mode 100755
index 000000000..065031fd4
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/host/minilua/CMakeLists.txt
@@ -0,0 +1,15 @@
+cmake_minimum_required(VERSION 3.0)
+
+project(minilua C)
+
+find_library(LIBM_LIBRARIES NAMES m)
+
+add_executable(minilua ${LUAJIT_DIR}/src/host/minilua.c)
+if(LIBM_LIBRARIES)
+ target_link_libraries(minilua ${LIBM_LIBRARIES})
+endif()
+if(TARGET_ARCH)
+ string (REPLACE ";" " " STARGET_ARCH "${TARGET_ARCH}")
+ set_target_properties(minilua PROPERTIES
+ COMPILE_FLAGS "${STARGET_ARCH}")
+endif()
diff --git a/src/fluent-bit/lib/luajit-cmake/lua.cmake b/src/fluent-bit/lib/luajit-cmake/lua.cmake
new file mode 100644
index 000000000..b5a7f6432
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/lua.cmake
@@ -0,0 +1,175 @@
+# Modfied from luajit.cmake
+# Added LUA_ADD_EXECUTABLE Ryan Phillips <ryan at trolocsis.com>
+# This CMakeLists.txt has been first taken from LuaDist
+# Copyright (C) 2007-2011 LuaDist.
+# Created by Peter Drahoš
+# Redistribution and use of this file is allowed according to the terms of the
+# MIT license.
+# Debugged and (now seriously) modIFied by Ronan Collobert, for Torch7
+
+cmake_minimum_required(VERSION 3.0)
+
+PROJECT(lua C)
+
+IF(NOT LUA_DIR)
+ MESSAGE(FATAL_ERROR "Must set LUA_DIR to build lua with CMake")
+ENDIF()
+
+FILE(COPY ${CMAKE_CURRENT_LIST_DIR}/luauser.h DESTINATION ${CMAKE_BINARY_DIR})
+
+SET(CMAKE_REQUIRED_INCLUDES
+ ${LUA_DIR}
+ ${CMAKE_BINARY_DIR})
+
+# Ugly warnings
+IF(MSVC)
+ ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
+ENDIF()
+
+# Various includes
+INCLUDE(CheckLibraryExists)
+INCLUDE(CheckFunctionExists)
+INCLUDE(CheckCSourceCompiles)
+INCLUDE(CheckTypeSize)
+
+IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ ADD_DEFINITIONS(-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE)
+ENDIF()
+
+IF(NOT WIN32)
+ FIND_LIBRARY(DL_LIBRARY "dl")
+ IF(DL_LIBRARY)
+ SET(CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARY})
+ LIST(APPEND LIBS ${DL_LIBRARY})
+ ENDIF()
+ CHECK_FUNCTION_EXISTS(dlopen LUA_USE_DLOPEN)
+ IF(NOT LUA_USE_DLOPEN)
+ MESSAGE(FATAL_ERROR "Cannot compile a useful lua.
+Function dlopen() seems not to be supported on your platform.
+Apparently you are not on a Windows platform as well.
+So lua has no way to deal with shared libraries!")
+ ENDIF()
+ENDIF()
+
+CHECK_LIBRARY_EXISTS(m sin "" LUA_USE_LIBM)
+IF( LUA_USE_LIBM )
+ LIST( APPEND LIBS m )
+ENDIF()
+
+if($ENV{LUA_TARGET_SHARED})
+ add_definitions(-fPIC)
+endif()
+
+## SOURCES
+SET(SRC_LUALIB
+ ${LUA_DIR}/lbaselib.c
+ ${LUA_DIR}/lcorolib.c
+ ${LUA_DIR}/ldblib.c
+ ${LUA_DIR}/liolib.c
+ ${LUA_DIR}/lmathlib.c
+ ${LUA_DIR}/loadlib.c
+ ${LUA_DIR}/loslib.c
+ ${LUA_DIR}/lstrlib.c
+ ${LUA_DIR}/ltablib.c
+ ${LUA_DIR}/lutf8lib.c
+)
+
+SET(SRC_LUACORE
+ ${LUA_DIR}/lauxlib.c
+ ${LUA_DIR}/lapi.c
+ ${LUA_DIR}/lcode.c
+ ${LUA_DIR}/lctype.c
+ ${LUA_DIR}/ldebug.c
+ ${LUA_DIR}/ldo.c
+ ${LUA_DIR}/ldump.c
+ ${LUA_DIR}/lfunc.c
+ ${LUA_DIR}/lgc.c
+ ${LUA_DIR}/linit.c
+ ${LUA_DIR}/llex.c
+ ${LUA_DIR}/lmem.c
+ ${LUA_DIR}/lobject.c
+ ${LUA_DIR}/lopcodes.c
+ ${LUA_DIR}/lparser.c
+ ${LUA_DIR}/lstate.c
+ ${LUA_DIR}/lstring.c
+ ${LUA_DIR}/ltable.c
+ ${LUA_DIR}/ltm.c
+ ${LUA_DIR}/lundump.c
+ ${LUA_DIR}/lvm.c
+ ${LUA_DIR}/lzio.c
+ ${SRC_LUALIB}
+)
+
+## GENERATE
+IF(WITH_SHARED_LUA)
+ IF(IOS OR ANDROID)
+ SET(LIBTYPE STATIC)
+ ELSE()
+ SET(LIBTYPE SHARED)
+ ENDIF()
+ELSE()
+ SET(LIBTYPE STATIC)
+ENDIF()
+ADD_LIBRARY(lualib ${LIBTYPE} ${SRC_LUACORE})
+SET(LUA_COMPILE_DEFINITIONS)
+IF(ANDROID OR IOS)
+ LIST(APPEND LUA_COMPILE_DEFINITIONS LUA_USER_H="luauser.h")
+ INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
+ENDIF()
+IF(NOT WIN32)
+ LIST(APPEND LUA_COMPILE_DEFINITIONS "LUA_USE_POSIX")
+ENDIF()
+
+SET_TARGET_PROPERTIES(lualib PROPERTIES
+ PREFIX "lib"
+ IMPORT_PREFIX "lib"
+ COMPILE_DEFINITIONS "${LUA_COMPILE_DEFINITIONS}"
+)
+IF(LUA_COMPILE_FLAGS)
+ SET_TARGET_PROPERTIES(lualib PROPERTIES
+ COMPILE_FLAGS ${LUA_COMPILE_FLAGS})
+ENDIF()
+
+TARGET_LINK_LIBRARIES(lualib ${LIBS})
+SET_TARGET_PROPERTIES(lualib PROPERTIES OUTPUT_NAME "lua54")
+if(IOS)
+ set_xcode_property(lualib IPHONEOS_DEPLOYMENT_TARGET "9.0" "all")
+endif()
+LIST(APPEND LIB_LIST lualib)
+
+ADD_EXECUTABLE(lua ${LUA_DIR}/lua.c)
+IF(WIN32)
+ TARGET_LINK_LIBRARIES(lua lualib)
+ELSE()
+ TARGET_LINK_LIBRARIES(lua lualib ${LIBS})
+ENDIF()
+
+SET(lua_headers
+ ${LUA_DIR}/lauxlib.h
+ ${LUA_DIR}/lua.h
+ ${LUA_DIR}/luaconf.h
+ ${LUA_DIR}/lualib.h)
+
+
+## FIXME:
+
+## USE_64BITS= cmake -H. -BLinux -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel
+## CMake Error at /Users/zhaozg/work/lua-forge/cmake/lua.cmake:154 (INSTALL):
+## INSTALL TARGETS given no ARCHIVE DESTINATION for static library target
+## "lualib".
+## Call Stack (most recent call first):
+## /Users/zhaozg/work/lua-forge/CMakeLists.txt:88 (include)
+##
+##
+## CMake Error at /Users/zhaozg/work/lua-forge/cmake/lua.cmake:159 (INSTALL):
+## INSTALL TARGETS given no RUNTIME DESTINATION for executable target "lua".
+## Call Stack (most recent call first):
+## /Users/zhaozg/work/lua-forge/CMakeLists.txt:88 (include)
+
+
+# INSTALL(FILES ${lua_headers} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lua)
+# INSTALL(TARGETS lualib DESTINATION ${CMAKE_INSTALL_LIBDIR})
+#
+# IF(NOT IOS)
+# INSTALL(TARGETS lua DESTINATION ${CMAKE_INSTALL_BINDIR})
+# ENDIF()
diff --git a/src/fluent-bit/lib/luajit-cmake/lua2c.lua b/src/fluent-bit/lib/luajit-cmake/lua2c.lua
new file mode 100644
index 000000000..cc9a90283
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/lua2c.lua
@@ -0,0 +1,99 @@
+--[[
+ Copyright 2014 The Luvit Authors. All Rights Reserved.
+
+ Licensed 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.
+s
+]]
+local src, gen = ...
+local _, jit = pcall(require, "jit") if jit and jit.off then jit.off() end
+
+local chunk = assert(loadfile(src, nil, '@'..src))
+local bytecode = string.dump(chunk)
+
+local function basename(name)
+ local base = name
+ if base:match "[/\\]" then
+ base = name:match("^.*[/\\](.*)$")
+ end
+ base = base:gsub("^%.", "_")
+ if base:match "%." then
+ base = base:match("^(.*)%."):gsub("%.", "_")
+ end
+ return base
+end
+
+local function escapefn(name)
+ return '"'..
+ name:gsub('\\', '\\\\')
+ :gsub('\n', '\\n')
+ :gsub('\r', '\\r')
+ :gsub('"', '\\"')..'"'
+end
+
+local function write_chunk(s)
+ local t = { "{\n " };
+ local cc = 7
+ for i = 1, #s do
+ local c = string.byte(s, i, i)
+ local ss = (" 0x%X"):format(c)
+ if cc + #ss > 77 then
+ t[#t+1] = "\n "
+ t[#t+1] = ss
+ cc = 7 + #ss
+ if i ~= #s then
+ t[#t+1] = ","
+ cc = cc + 1
+ end
+ else
+ t[#t+1] = ss
+ cc = cc + #ss
+ if i ~= #s then
+ t[#t+1] = ","
+ cc = cc + 1
+ end
+ end
+ end
+ t[#t+1] = "\n }"
+ return (table.concat(t))
+end
+
+local function W(...)
+ io.write(...)
+ return W
+end
+
+io.output(gen)
+W [[
+/* generated source for Lua codes */
+
+#ifndef LUA_LIB
+# define LUA_LIB
+#endif
+#include <lua.h>
+#include <lauxlib.h>
+
+LUALIB_API int luaopen_]](basename(src))[[(lua_State *L) {
+ size_t len = ]](#bytecode)[[;
+ const char chunk[] = ]](write_chunk(bytecode))[[;
+
+ if (luaL_loadbuffer(L, chunk, len, ]](escapefn(src))[[) != 0)
+ lua_error(L);
+ lua_insert(L, 1);
+ lua_call(L, lua_gettop(L)-1, LUA_MULTRET);
+ return lua_gettop(L);
+}
+
+]]
+io.close()
+
+
diff --git a/src/fluent-bit/lib/luajit-cmake/luauser.h b/src/fluent-bit/lib/luajit-cmake/luauser.h
new file mode 100644
index 000000000..20ef7629f
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/luauser.h
@@ -0,0 +1,26 @@
+#ifndef LUA_LJDIR
+#if defined(__ANDROID__)
+ #if __ANDROID_API__==19
+ #if defined(lua_getlocaledecpoint)
+ #undef lua_getlocaledecpoint
+ #endif
+
+ #define lua_getlocaledecpoint() ('.')
+ #endif
+ #if __ANDROID_API__ < 25
+ #define fseeko fseek
+ #define ftello ftell
+ #endif
+#endif
+#if defined(__APPLE__) && defined(__MACH__)
+ /* Apple OSX and iOS (Darwin). ------------------------------ */
+ #include <TargetConditionals.h>
+ #if (TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1)
+ /* iOS in Xcode simulator */ /* iOS on iPhone, iPad, etc. */
+ #define system(X) 0
+ #endif
+#endif
+#else
+#pragma clang diagnostic ignored "-Wunused-function"
+#endif
+
diff --git a/src/fluent-bit/lib/luajit-cmake/readme.md b/src/fluent-bit/lib/luajit-cmake/readme.md
new file mode 100644
index 000000000..c64c3ee16
--- /dev/null
+++ b/src/fluent-bit/lib/luajit-cmake/readme.md
@@ -0,0 +1,48 @@
+# luajit-cmake
+
+A flexible cmake builder for LuaJIT. Forked from
+https://github.com/WohlSoft/LuaJIT and update.
+
+## Build
+
+### make
+
+Use a GNU compatible make.
+
+`make -DLUAJIT_DIR=...` or `mingw32-make -DLUAJIT_DIR=...` or `gnumake -DLUAJIT_DIR=...`.
+
+_Note_: When use mingw32-make, please change `\\` to `/` in file path on Windows.
+
+### cmake
+
+Use cmake to compile.
+
+```
+cmake -H. -Bbuild -DLUAJIT_DIR=...
+make --build build --config Release
+```
+
+### CrossCompile
+
+#### iOS
+
+```
+make iOS
+```
+
+#### Android
+
+```
+make Android
+```
+
+#### Windows
+
+```
+make Windows
+```
+
+#### Note
+
+_Note_: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS). So I use mingw-w64 and wine to build and run 32 bits minilua and buildvm.
+