diff --git a/ports/chimera/CONTROL b/ports/chimera/CONTROL new file mode 100644 index 00000000000000..3fe852c7d91255 --- /dev/null +++ b/ports/chimera/CONTROL @@ -0,0 +1,5 @@ +Source: chimera +Version: 5.2.1 +Homepage: https://github.com/intel/hyperscan +Description: Chimera is a software regular expression matching engine that is a hybrid of Hyperscan and PCRE. The design goals of Chimera are to fully support PCRE syntax as well as to take advantage of the high performance nature of Hyperscan. +Build-Depends: python3, ragel, hyperscan diff --git a/ports/chimera/fix-cmakelists.patch b/ports/chimera/fix-cmakelists.patch new file mode 100644 index 00000000000000..4fb4f28c3d8c19 --- /dev/null +++ b/ports/chimera/fix-cmakelists.patch @@ -0,0 +1,57 @@ +diff --git a/chimera/CMakeLists.txt b/chimera/CMakeLists.txt +index 1cd66a3..82b6468 100644 +--- a/chimera/CMakeLists.txt ++++ b/chimera/CMakeLists.txt +@@ -1,7 +1,26 @@ + # Chimera lib ++cmake_minimum_required (VERSION 2.8.11) ++project (chimera C CXX) + +-include_directories(${PCRE_INCLUDE_DIRS}) ++set (HS_MAJOR_VERSION 5) ++set (HS_MINOR_VERSION 3) ++set (HS_PATCH_VERSION 0) ++set (HS_VERSION ${HS_MAJOR_VERSION}.${HS_MINOR_VERSION}.${HS_PATCH_VERSION}) ++ ++set(CMAKE_CXX_STANDARD 11) + ++set(HS_INTERNAL_INCLUDE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../src) ++ ++configure_file(${CMAKE_CURRENT_LIST_DIR}/../cmake/config.h.in ${CMAKE_BINARY_DIR}/config.h) ++configure_file(${CMAKE_CURRENT_LIST_DIR}/../src/hs_version.h.in ${CMAKE_BINARY_DIR}/hs_version.h) ++ ++find_path(HS_INCLUDE_DIRS hs_common.h PATH_SUFFIXES hs) ++find_library(hs hs REQUIRED) ++find_library(hs_rt hs_runtime REQUIRED) ++ ++find_path(PCRE_INCLUDE_DIRS pcre.h) ++find_library(pcre pcre REQUIRED) ++include_directories(${PCRE_INCLUDE_DIRS} ${HS_INCLUDE_DIRS} ${HS_INTERNAL_INCLUDE_DIRS} ${CMAKE_BINARY_DIR}) + # only set these after all tests are done + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}") +@@ -28,11 +45,14 @@ SET(chimera_SRCS + ) + + add_library(chimera STATIC ${chimera_SRCS}) +-add_dependencies(chimera hs pcre) +-target_link_libraries(chimera hs pcre) ++target_link_libraries(chimera hs pcre hs_rt) ++target_compile_definitions(chimera PUBLIC -DUSE_INTRIN_H) + + install(TARGETS chimera DESTINATION ${CMAKE_INSTALL_LIBDIR}) + ++file(GLOB CHIMERA_HEADERS ${CMAKE_CURRENT_LIST_DIR}/*.h) ++install(FILES ${CHIMERA_HEADERS} DESTINATION include) ++ + if (NOT WIN32) + # expand out library names for pkgconfig static link info + foreach (LIB ${CMAKE_CXX_IMPLICIT_LINK_LIBRARIES}) +@@ -44,6 +64,6 @@ if (NOT WIN32) + set(PRIVATE_LIBS "${PRIVATE_LIBS} -L${LIBDIR} -lpcre") + + configure_file(libch.pc.in libch.pc @ONLY) # only replace @ quoted vars +- install(FILES ${CMAKE_BINARY_DIR}/chimera/libch.pc ++ install(FILES ${CMAKE_BINARY_DIR}/libch.pc + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + endif() diff --git a/ports/chimera/fix-include-path.patch b/ports/chimera/fix-include-path.patch new file mode 100644 index 00000000000000..a237786947b12b --- /dev/null +++ b/ports/chimera/fix-include-path.patch @@ -0,0 +1,26 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 59c6e6e..51e8498 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -559,7 +559,7 @@ SET(hs_HEADERS + src/hs_compile.h + src/hs_runtime.h + ) +-install(FILES ${hs_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hs") ++install(FILES ${hs_HEADERS} DESTINATION include/hs) + + set (hs_exec_common_SRCS + src/alloc.c +diff --git a/chimera/CMakeLists.txt b/chimera/CMakeLists.txt +index 1503dbe..b1a22c5 100644 +--- a/chimera/CMakeLists.txt ++++ b/chimera/CMakeLists.txt +@@ -29,7 +29,7 @@ SET(chimera_HEADERS + ch_compile.h + ch_runtime.h + ) +-install(FILES ${chimera_HEADERS} DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/hs") ++install(FILES ${chimera_HEADERS} DESTINATION include/hs) + + SET(chimera_SRCS + ${chimera_HEADERS} diff --git a/ports/chimera/fix-unix-build.patch b/ports/chimera/fix-unix-build.patch new file mode 100644 index 00000000000000..923c2f94c49921 --- /dev/null +++ b/ports/chimera/fix-unix-build.patch @@ -0,0 +1,25 @@ +diff --git a/src/util/intrinsics.h b/src/util/intrinsics.h +index edc4f6e..075b777 100644 +--- a/src/util/intrinsics.h ++++ b/src/util/intrinsics.h +@@ -55,6 +55,7 @@ + # endif + #endif + ++#ifdef _WIN32 + #if defined(USE_X86INTRIN_H) + #include + #elif defined(USE_INTRIN_H) +@@ -62,5 +63,12 @@ + #else + #error no intrinsics file + #endif ++#else ++#if defined(USE_X86INTRIN_H) || defined(USE_INTRIN_H) ++#include ++#else ++#error no intrinsics file ++#endif ++#endif + + #endif // INTRINSICS_H diff --git a/ports/chimera/portfile.cmake b/ports/chimera/portfile.cmake new file mode 100644 index 00000000000000..8cd43de515a2c2 --- /dev/null +++ b/ports/chimera/portfile.cmake @@ -0,0 +1,34 @@ +vcpkg_check_linkage(ONLY_STATIC_LIBRARY) + +# checkout hyperscan source code which is required by and also contains chimera +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO intel/hyperscan + REF c00683d73916e39f01b0d418f686c8b5c379159c + SHA512 3c4d52706901acc9ef4c3d12b0e5b2956f4e6bce13f6828a4ba3b736c05ffacb1d733ef9c226988ca80220584525f9cb6dcfe4914ced6cc34ae6a0a45975afb5 + HEAD_REF master + PATCHES + fix-cmakelists.patch + fix-unix-build.patch + fix-include-path.patch +) + +vcpkg_find_acquire_program(PYTHON3) +get_filename_component(PYTHON3_DIR ${PYTHON3} DIRECTORY) +vcpkg_add_to_path(${PYTHON3_DIR}) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH}/chimera + PREFER_NINJA + OPTIONS + -DPYTHON_EXECUTABLE=${PYTHON3} +) + +vcpkg_install_cmake() + +# remove debug dir +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share") + +# Handle copyright +file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright) diff --git a/ports/chimera/usage b/ports/chimera/usage new file mode 100644 index 00000000000000..74b7dd725ebb1d --- /dev/null +++ b/ports/chimera/usage @@ -0,0 +1,10 @@ + +The package @PORT@:@TARGET_TRIPLET@ provides CMake targets: + + find_library(CHIMERA_LIBRARY NAMES chimera) + find_library(HS_LIBRARY NAMES hs) + find_path(CHIMERA_INCLUDE_DIR hs) + find_library(PCRE_LIBRARY NAMES pcre) + + target_include_directories(main PUBLIC ${CHIMERA_INCLUDE_DIR}) + target_link_libraries(main ${CHIMERA_LIBRARY} ${HS_LIBRARY} ${PCRE_LIBRARY}) diff --git a/ports/hyperscan/portfile.cmake b/ports/hyperscan/portfile.cmake index 19144cca4f450b..a7442e7202f560 100644 --- a/ports/hyperscan/portfile.cmake +++ b/ports/hyperscan/portfile.cmake @@ -8,6 +8,8 @@ vcpkg_from_github( REF v${HYPERSCAN_VERSION} SHA512 e6ac2aef1f3efa1535c00d73fa590ea62fff4686c4ad3ee023d2e72c51896ca4616ec1b85d7c6f88ac7b42d92c3557b9c4bb3b51cfb796e20a79d53b28e53b6c HEAD_REF master + PATCHES + remove-werror.patch ) vcpkg_find_acquire_program(PYTHON3) diff --git a/ports/hyperscan/remove-werror.patch b/ports/hyperscan/remove-werror.patch new file mode 100644 index 00000000000000..6965b953a617ed --- /dev/null +++ b/ports/hyperscan/remove-werror.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 83197af..34c0b84 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -232,7 +232,7 @@ else() + set(EXTRA_C_FLAGS "${OPT_C_FLAG} -std=c99 -Wall -Wextra -Wshadow -Wcast-qual -fno-strict-aliasing") + set(EXTRA_CXX_FLAGS "${OPT_CXX_FLAG} -std=c++11 -Wall -Wextra -Wshadow -Wswitch -Wreturn-type -Wcast-qual -Wno-deprecated -Wnon-virtual-dtor -fno-strict-aliasing") + +- if (NOT RELEASE_BUILD) ++ if (NOT RELEASE_BUILD AND OFF) + # -Werror is most useful during development, don't potentially break + # release builds + set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Werror")