Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to pcre2 #249

Merged
merged 11 commits into from
Feb 16, 2022
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ set(external_deps
Zlib
OpenSSL
MariaDBConnector
PCRE
pcre2
Sqlite3
APR
Apache
Expand Down
2 changes: 1 addition & 1 deletion Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ARG USER_UID=1000
ARG USER_GID=$USER_UID

ARG LINK_TYPE_DEFAULT=static # static or dynamic
ARG LINK_DYNAMIC_PACKAGES="libgc-dev libpcre3-dev zlib1g-dev apache2-dev libmysqlclient-dev libsqlite3-dev libmbedtls-dev"
ARG LINK_DYNAMIC_PACKAGES="libgc-dev libpcre2-dev zlib1g-dev apache2-dev libmysqlclient-dev libsqlite3-dev libmbedtls-dev"

vscode-dev-containers-scripts:
FROM curlimages/curl:7.80.0
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Neko needs to link with various third-party libraries, which are summarized as f
|-----------------------------------------|-------------|-----------------------------------------------------------|
| Boehm GC | all | libgc-dev |
| OpenSSL | all | libssl-dev |
| PCRE | all | libpcre3-dev |
| pcre2 | all | libpcre2-dev |
| zlib | all | zlib1g-dev |
| Apache 2.2 / 2.4, with apr and apr-util | all | apache2-dev |
| MariaDB / MySQL (Connector/C) | all | libmariadb-client-lgpl-dev-compat (or libmysqlclient-dev) |
Expand Down Expand Up @@ -115,7 +115,7 @@ Settings that allow to exclude libraries and their dependencies from the build;

Default value: `all` for Windows, `none` otherwise

It defines the dependencies that should be linked statically. Can be `all`, `none`, or a list of library names (e.g. `BoehmGC;Zlib;OpenSSL;MariaDBConnector;PCRE;Sqlite3;APR;APRutil;Apache;MbedTLS`). NOTE: On MacOS, APRutil cannot be added here as it has become part of the APR version used on MacOS builds.
It defines the dependencies that should be linked statically. Can be `all`, `none`, or a list of library names (e.g. `BoehmGC;Zlib;OpenSSL;MariaDBConnector;pcre2;Sqlite3;APR;APRutil;Apache;MbedTLS`). NOTE: On MacOS, APRutil cannot be added here as it has become part of the APR version used on MacOS builds.

CMake will automatically download and build the specified dependencies into the build folder. If a library is not present in this list, it should be installed manually, and it will be linked dynamically.

Expand Down
55 changes: 0 additions & 55 deletions cmake/FindPCRE.cmake

This file was deleted.

19 changes: 19 additions & 0 deletions cmake/FindPCRE2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# https://github.com/refu-lang/rfbase/blob/master/cmake/FindPCRE2.cmake

# This CMake file tries to find the Perl regular expression libraries
# The following variables are set:
# PCRE2_FOUND - System has the PCRE library
# PCRE2_LIBRARIES - The PCRE library file
# PCRE2_INCLUDE_DIRS - The folder with the PCRE headers

find_library(PCRE2_LIBRARIES NAMES pcre2 pcre2-8)
find_path(PCRE2_INCLUDE_DIRS pcre2.h)
if(PCRE2_LIBRARIES AND PCRE2_INCLUDE_DIRS)
message(STATUS "PCRE2 libs: ${PCRE2_LIBRARIES}")
message(STATUS "PCRE2 include directory: ${PCRE2_INCLUDE_DIRS}")
set(PCRE2_FOUND TRUE CACHE BOOL "Found PCRE2 libraries" FORCE)
add_custom_target(pcre2)
else()
set(PCRE2_FOUND FALSE CACHE BOOL "Found PCRE2 libraries" FORCE)
message(STATUS "PCRE2 library not found.")
endif()
2 changes: 1 addition & 1 deletion extra/azure-pipelines/Brewfile-STATIC_DEPS_NONE
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ brew "pkg-config"
brew "bdw-gc"
brew "mariadb-connector-c"
brew "mbedtls@2", link: true
brew "pcre"
brew "pcre2"
73 changes: 68 additions & 5 deletions libs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ if (WITH_APACHE)
set(APRUTIL_CONF "")
set(APRUTIL_DEP "")
endif()
if (STATIC_PCRE)
# APACHE still uses old pcre currently
# if (STATIC_PCRE2)
set(PCRE_CONF --with-pcre=${CMAKE_BINARY_DIR}/libs/src/install-prefix)
set(PCRE_DEP PCRE)
elseif()
set(PCRE_CONF "")
set(PCRE_DEP "")
endif()
# elseif()
# set(PCRE_CONF "")
# set(PCRE_DEP "")
# endif()
if (STATIC_ZLIB)
set(ZLIB_CONF --with-z=${CMAKE_BINARY_DIR}/libs/src/install-prefix)
set(ZLIB_DEP Zlib)
Expand Down Expand Up @@ -84,6 +85,68 @@ if (WITH_APACHE)
)
endif()

# Apache still uses old PCRE. Remove this once they migrate
## Start of PCRE download info
set(PCRE_URL_DATA
URL "https://downloads.sourceforge.net/project/pcre/pcre/8.45/pcre-8.45.tar.gz"
URL_HASH SHA1=a19402ce56d770da1557cf331b109d33adb74062
)
if (WIN32)
ExternalProject_Add(PCRE
${EP_CONFIGS}
${PCRE_URL_DATA}
CMAKE_ARGS
-G ${CMAKE_GENERATOR}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/libs/src/install-prefix
-Wno-dev
-DPCRE_BUILD_PCRECPP=OFF
-DPCRE_BUILD_PCREGREP=OFF
-DPCRE_BUILD_TESTS=OFF
-DPCRE_SUPPORT_JIT=ON
-DPCRE_SUPPORT_UNICODE_PROPERTIES=ON
)
set(PCRE_LIBRARIES
optimized ${CMAKE_BINARY_DIR}/libs/src/install-prefix/lib/pcre.lib
debug ${CMAKE_BINARY_DIR}/libs/src/install-prefix/lib/pcred.lib
)
else()
if (APPLE)
set(PCRE_CFLAGS "-w -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
else()
set(PCRE_CFLAGS "-w")
endif()
set(PCRE_LIBRARIES
${CMAKE_BINARY_DIR}/libs/src/install-prefix/lib/libpcre.a
)
ExternalProject_Add(PCRE
${EP_CONFIGS}
${PCRE_URL_DATA}
CONFIGURE_COMMAND cd ${CMAKE_BINARY_DIR}/libs/src/PCRE &&
./configure
--prefix=${CMAKE_BINARY_DIR}/libs/src/install-prefix
--with-pic
--enable-unicode-properties
--enable-silent-rules
--enable-jit
--disable-cpp
--enable-shared=no
--enable-static=yes
--silent
BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/libs/src/PCRE &&
make "CFLAGS=${PCRE_CFLAGS}"
INSTALL_COMMAND cd ${CMAKE_BINARY_DIR}/libs/src/PCRE &&
make install
BYPRODUCTS ${PCRE_LIBRARIES}
)
endif()

set_target_properties(PCRE PROPERTIES ${EP_PROPS})
# don't want to add PCRE 1 to external_deps,
# but want download_static_deps depends on it
add_dependencies(download_static_deps PCRE-download)

## End of PCRE download info

if (APPLE) # We need to use the most up to date version on MacOS
set(APR_SOURCE
SVN_REPOSITORY https://svn.apache.org/repos/asf/apr/apr/trunk/
Expand Down
72 changes: 36 additions & 36 deletions libs/regexp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,52 @@
# regexp.ndll

add_library(regexp.ndll MODULE regexp.c)
if (STATIC_PCRE)
if (STATIC_PCRE2)
add_compile_definitions(PCRE2_STATIC_LINK)
if (WIN32)
set(PCRE_URL "https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz")
set(PCRE2_URL "https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.37/pcre2-10.37.tar.gz")
if (NOT ${CMAKE_VERSION} VERSION_LESS 3.7)
list(APPEND PCRE_URL
"http://downloads.sourceforge.net/project/pcre/pcre/8.42/pcre-8.42.tar.gz"
list(APPEND PCRE2_URL
"https://sourceforge.net/projects/pcre/files/pcre2/10.37/pcre2-10.37.tar.gz/download"
)
endif()
ExternalProject_Add(PCRE
ExternalProject_Add(pcre2
${EP_CONFIGS}
URL ${PCRE_URL}
URL_MD5 fc18afa0f14a25475cf097ee102a3e4f
URL ${PCRE2_URL}
URL_MD5 a0b59d89828f62d2e1caac04f7c51e0b
CMAKE_ARGS
-G ${CMAKE_GENERATOR}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/libs/src/install-prefix
-Wno-dev
-DPCRE_BUILD_PCRECPP=OFF
-DPCRE_BUILD_PCREGREP=OFF
-DPCRE_BUILD_TESTS=OFF
-DPCRE_SUPPORT_JIT=ON
-DPCRE_SUPPORT_UNICODE_PROPERTIES=ON
-DPCRE2_BUILD_PCRE2GREP=OFF
-DPCRE2_BUILD_TESTS=OFF
-DPCRE2_SUPPORT_JIT=ON
-DPCRE2_SUPPORT_UNICODE=ON
)
set(PCRE_LIBRARIES
optimized ${CMAKE_BINARY_DIR}/libs/src/install-prefix/lib/pcre.lib
debug ${CMAKE_BINARY_DIR}/libs/src/install-prefix/lib/pcred.lib
set(PCRE2_LIBRARIES
optimized ${CMAKE_BINARY_DIR}/libs/src/install-prefix/lib/pcre2-8.lib
debug ${CMAKE_BINARY_DIR}/libs/src/install-prefix/lib/pcre2-8d.lib
)
else()
if (APPLE)
set(PCRE_CFLAGS "-w -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
set(PCRE2_CFLAGS "-w -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
else()
set(PCRE_CFLAGS "-w")
set(PCRE2_CFLAGS "-w")
endif()
set(PCRE_LIBRARIES
${CMAKE_BINARY_DIR}/libs/src/install-prefix/lib/libpcre.a
set(PCRE2_LIBRARIES
${CMAKE_BINARY_DIR}/libs/src/install-prefix/lib/libpcre2-8.a
)
set(PCRE_URL "https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz")
set(PCRE2_URL "https://github.com/PhilipHazel/pcre2/releases/download/pcre2-10.37/pcre2-10.37.tar.gz")
if (NOT ${CMAKE_VERSION} VERSION_LESS 3.7)
list(APPEND PCRE_URL
"http://downloads.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.tar.gz"
list(APPEND PCRE2_URL
"https://sourceforge.net/projects/pcre/files/pcre2/10.37/pcre2-10.37.tar.gz/download"
)
endif()
ExternalProject_Add(PCRE
ExternalProject_Add(pcre2
${EP_CONFIGS}
URL ${PCRE_URL}
URL_MD5 890c808122bd90f398e6bc40ec862102
CONFIGURE_COMMAND cd ${CMAKE_BINARY_DIR}/libs/src/PCRE &&
URL ${PCRE2_URL}
URL_MD5 a0b59d89828f62d2e1caac04f7c51e0b
CONFIGURE_COMMAND cd ${CMAKE_BINARY_DIR}/libs/src/pcre2 &&
./configure
--prefix=${CMAKE_BINARY_DIR}/libs/src/install-prefix
--with-pic
Expand All @@ -59,24 +59,24 @@ if (STATIC_PCRE)
--enable-shared=no
--enable-static=yes
--silent
BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/libs/src/PCRE &&
BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/libs/src/pcre2 &&
make "CFLAGS=${PCRE_CFLAGS}"
INSTALL_COMMAND cd ${CMAKE_BINARY_DIR}/libs/src/PCRE &&
INSTALL_COMMAND cd ${CMAKE_BINARY_DIR}/libs/src/pcre2 &&
make install
BYPRODUCTS ${PCRE_LIBRARIES}
BYPRODUCTS ${PCRE2_LIBRARIES}
)
endif()
set_target_properties(PCRE PROPERTIES ${EP_PROPS})
set(PCRE_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/libs/src/install-prefix/include)
add_dependencies(regexp.ndll PCRE)
set_target_properties(pcre2 PROPERTIES ${EP_PROPS})
set(PCRE2_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/libs/src/install-prefix/include)
add_dependencies(regexp.ndll pcre2)
# Download project for fat source archive
add_dependencies(download_static_deps PCRE-download)
add_dependencies(download_static_deps pcre2-download)
else()
find_package(PCRE REQUIRED)
find_package(PCRE2 REQUIRED)
endif()

target_include_directories(regexp.ndll PRIVATE ${PCRE_INCLUDE_DIRS})
target_link_libraries(regexp.ndll libneko ${PCRE_LIBRARIES})
target_include_directories(regexp.ndll PRIVATE ${PCRE2_INCLUDE_DIRS})
target_link_libraries(regexp.ndll libneko ${PCRE2_LIBRARIES})

set_target_properties(regexp.ndll
PROPERTIES
Expand Down
Loading