Skip to content

Commit

Permalink
Update PCRE2 to version 10.43
Browse files Browse the repository at this point in the history
  • Loading branch information
danyeaw authored and pbor committed Feb 17, 2024
1 parent e41a72b commit ccd75d9
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 94 deletions.
300 changes: 209 additions & 91 deletions gvsbuild/patches/pcre2/meson.build
Original file line number Diff line number Diff line change
@@ -1,28 +1,77 @@
project('pcre2', 'c',
project(
'pcre2',
'c',
license: 'BSD-3',
meson_version: '>=0.49.0',
version: '10.40',
version: '10.43',
)

pcre2_8_lib_version = '0.11.0'
pcre2_16_lib_version = '0.11.0'
pcre2_32_lib_version = '0.11.0'
pcre2_posix_lib_version = '3.0.2'

c_compiler = meson.get_compiler('c')

pcre2_h = configure_file(input : 'src/pcre2.h.generic',
output : 'pcre2.h',
copy: true)
platform_is_unixlike = host_machine.system() in [
'dragonfly',
'freebsd',
'netbsd',
'openbsd',
'haiku',
'linux',
'android',
'darwin',
'cygwin'
]

chartables = configure_file(input : 'src/pcre2_chartables.c.dist',
output : 'pcre2_chartables.c',
copy: true)
platform_supports_sljit = host_machine.system() in [
'linux',
'android',
'netbsd'
]

# pcre2.h
pcredata = configuration_data()
varr = meson.project_version().split('.')
pcredata.set('PCRE2_MAJOR', varr[0])
pcredata.set('PCRE2_MINOR', varr[1])
pcredata.set('PCRE2_PRERELEASE', '')
pcredata.set('PCRE2_DATE', '2022-12-11')

# config.h
cdata = configuration_data()
cdata.set('LINK_SIZE', '2')
cdata.set('HEAP_LIMIT', '20000000')
cdata.set('MATCH_LIMIT', '10000000')
cdata.set('MATCH_LIMIT_DEPTH', 'MATCH_LIMIT')
cdata.set('NEWLINE_DEFAULT', '2') # default in config.h.generic
cdata.set('PARENS_NEST_LIMIT', '250')
cdata.set('PCRE2GREP_BUFSIZE', '20480')
cdata.set('PCRE2GREP_MAX_BUFSIZE', '1048576')
cdata.set('MAX_NAME_SIZE', '32')
cdata.set('MAX_NAME_COUNT', '10000')
cdata.set('MAX_VARLOOKBEHIND', '255')

jit_deps = []
if not get_option('jit').disabled() and platform_is_unixlike
jit_deps += dependency('threads')
cdata.set10('SUPPORT_JIT', true)
endif

config_h = configure_file(input : 'src/config.h.generic',
output : 'config.h',
copy: true)
if not get_option('jit_sealloc').disabled()
if c_compiler.has_function('mkostemp', prefix: '#include <stdlib.h>', args: ['-D_GNU_SOURCE'])
if platform_supports_sljit
cdata.set10('SLJIT_PROT_EXECUTABLE_ALLOCATOR', true)
elif get_option('jit_sealloc').enabled()
error('Your configuration is not supported')
endif
endif
endif

sources = [
sources = files(
'src/pcre2_auto_possess.c',
chartables,
config_h, pcre2_h,
'src/pcre2_chkdint.c',
'src/pcre2_compile.c',
'src/pcre2_config.c',
'src/pcre2_context.c',
Expand All @@ -47,133 +96,194 @@ sources = [
'src/pcre2_tables.c',
'src/pcre2_ucd.c',
'src/pcre2_valid_utf.c',
'src/pcre2_xclass.c'
]
'src/pcre2_xclass.c',
)

includes = [include_directories('.'), include_directories('src')]
includes = include_directories('.', 'src')

check_headers = [
'inttypes.h',
'bzlib.h',
'sys/stat.h',
'sys/types.h',
'sys/wait.h',
'inttypes.h',
'dirent.h',
'dlfcn.h',
'limits.h',
'stdint.h',
'stdlib.h',
'string.h',
'windows.h',
'unistd.h'
'unistd.h',
]

config_h_defs = []
foreach h : check_headers
if c_compiler.has_header(h)
config_h_defs += ['-DHAVE_' + h.underscorify().to_upper()]
cdata.set10('HAVE_' + h.underscorify().to_upper(), true)
endif
endforeach


check_funs = [
['HAVE_STRERROR', 'strerror'],
'bcopy',
'memfd_create',
'memmove',
'realpath',
'secure_getenv',
'strerror',
]

foreach f : check_funs
if c_compiler.has_function(f.get(1))
config_h_defs += ['-D' + f.get(0)]
if c_compiler.has_function(f)
cdata.set10('HAVE_@0@'.format(f.to_upper()), true)
endif
endforeach


config_h_defs += ['-DHAVE_MEMMOVE', '-DSTDC_HEADERS', '-DSUPPORT_PCRE2_8', '-DSUPPORT_UNICODE']
cdata.set10('SUPPORT_PCRE2_8', true)
cdata.set10('SUPPORT_UNICODE', true)

if get_option('default_library') == 'static'
static_defs = ['-DPCRE2_STATIC']
config_h_defs += static_defs
else
static_defs = []
endif

pcre2_8_lib = library('pcre2-8', sources,
include_directories: includes,
c_args: config_h_defs + ['-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=8'],
install: true)
pcre2_h = configure_file(
input: 'src/pcre2.h.in',
output: 'pcre2.h',
configuration: pcredata,
)

pcre2_posix_lib = library('pcre2-posix', ['src/pcre2posix.c', 'src/pcre2posix.h'],
chartables = configure_file(
input: 'src/pcre2_chartables.c.dist',
output: 'pcre2_chartables.c',
copy: true,
)
sources += chartables

config_h = configure_file(
output: 'config.h',
configuration: cdata,
)

general_c_args = [static_defs, '-DHAVE_CONFIG_H', '-D_GNU_SOURCE']
pcre2_8_lib = library(
'pcre2-8',
sources,
dependencies: jit_deps,
include_directories: includes,
link_with: pcre2_8_lib,
c_args: config_h_defs + ['-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=8'],
install: true)
c_args: [general_c_args, '-DPCRE2_CODE_UNIT_WIDTH=8'],
version: pcre2_8_lib_version,
install: true,
)

pcre2_16_lib = library('pcre2-16', sources,
libpcre2_8 = declare_dependency(
link_with: pcre2_8_lib,
include_directories: includes,
c_args: config_h_defs + ['-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=16'],
install: true)
compile_args: static_defs,
)

pcre2_posix_lib = library(
'pcre2-posix',
'src/pcre2posix.c',
dependencies: libpcre2_8,
c_args: [general_c_args, '-DPCRE2_CODE_UNIT_WIDTH=8'],
version: pcre2_posix_lib_version,
install: true,
)

pcre2_32_lib = library('pcre2-32', sources,
libpcre2_posix = declare_dependency(
link_with: pcre2_posix_lib,
include_directories: includes,
c_args: config_h_defs + ['-DHAVE_CONFIG_H', '-DPCRE2_CODE_UNIT_WIDTH=32'],
install: true)
compile_args: static_defs,
)

libpcre2_8 = declare_dependency(link_with: pcre2_8_lib,
pcre2_16_lib = library(
'pcre2-16',
sources,
dependencies: jit_deps,
include_directories: includes,
compile_args: static_defs)
libpcre2_posix = declare_dependency(link_with: pcre2_posix_lib,
c_args: [general_c_args, '-DPCRE2_CODE_UNIT_WIDTH=16'],
version: pcre2_16_lib_version,
install: true,
)

libpcre2_16 = declare_dependency(
link_with: pcre2_16_lib,
include_directories: includes,
compile_args: static_defs)
libpcre2_16 = declare_dependency(link_with: pcre2_16_lib,
compile_args: static_defs,
)

pcre2_32_lib = library(
'pcre2-32',
sources,
dependencies: jit_deps,
include_directories: includes,
compile_args: static_defs)
libpcre2_32 = declare_dependency(link_with: pcre2_32_lib,
c_args: [general_c_args, '-DPCRE2_CODE_UNIT_WIDTH=32'],
version: pcre2_32_lib_version,
install: true,
)

libpcre2_32 = declare_dependency(
link_with: pcre2_32_lib,
include_directories: includes,
compile_args: static_defs)
compile_args: static_defs,
)

if get_option('grep')
pcre2grep = executable('pcre2grep', ['src/pcre2grep.c'],
include_directories: includes,
link_with: [pcre2_8_lib],
c_args: config_h_defs + ['-DHAVE_CONFIG_H'],
install: true)
pcre2grep = executable(
'pcre2grep',
'src/pcre2grep.c',
dependencies: libpcre2_8,
c_args: general_c_args,
install: true,
)
endif

install_headers([pcre2_h, 'src/pcre2posix.h'])
install_headers(pcre2_h, 'src/pcre2posix.h')

########### pkg-config #############

pkg = import('pkgconfig')

pkg.generate(pcre2_8_lib,
name : 'libpcre2-8',
description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support',
version: meson.project_version())

pkg.generate(pcre2_16_lib,
name : 'libpcre2-16',
description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support',
version: meson.project_version())
pkg.generate(
pcre2_8_lib,
name: 'libpcre2-8',
description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support',
version: meson.project_version(),
)

pkg.generate(pcre2_32_lib,
name : 'libpcre2-32',
description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support',
version: meson.project_version())
pkg.generate(
pcre2_16_lib,
name: 'libpcre2-16',
description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support',
version: meson.project_version(),
)

pkg.generate(
pcre2_32_lib,
name: 'libpcre2-32',
description: 'PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support',
version: meson.project_version(),
)

#### tests

if get_option('test') and not meson.is_cross_build() # wine wrappers are not bat-friendly, this would need better testing
if (
get_option('test')
and not meson.is_cross_build() # wine wrappers are not bat-friendly, this would need better testing
)
link_args = []
if c_compiler.get_argument_syntax() == 'msvc'
link_args += '/STACK:2500000'
endif

pcre2test = executable('pcre2test', ['src/pcre2test.c'],
include_directories: includes,
link_with: [pcre2_8_lib, pcre2_posix_lib, pcre2_16_lib, pcre2_32_lib],
c_args: config_h_defs + ['-DHAVE_CONFIG_H'],
link_args: link_args)
pcre2test = executable(
'pcre2test',
'src/pcre2test.c',
dependencies: [libpcre2_8, libpcre2_posix, libpcre2_16, libpcre2_32],
c_args: general_c_args,
link_args: link_args,
)

pcre2posix_test = executable(
'pcre2posix_test',
'src/pcre2posix_test.c',
dependencies: [libpcre2_8, libpcre2_posix],
link_args: link_args,
)
test('pcre2posix_test', pcre2posix_test)

if c_compiler.get_argument_syntax() == 'msvc'
runtest = find_program('RunTest.bat')
Expand All @@ -183,13 +293,21 @@ if get_option('test') and not meson.is_cross_build() # wine wrappers are not bat
rungreptest = find_program('RunGrepTest')
endif

test('RunTest', runtest,
test(
'RunTest',
runtest,
should_fail: host_machine.system() == 'windows' and c_compiler.get_argument_syntax() != 'msvc',
env : ['srcdir=@0@'.format(meson.current_source_dir())],
workdir: meson.current_build_dir())

test('RunGrepTest', rungreptest,
should_fail: host_machine.system() == 'windows',
env : ['srcdir=@0@'.format(meson.current_source_dir())],
workdir: meson.current_build_dir())
env: 'srcdir=@0@'.format(meson.current_source_dir()),
workdir: meson.current_build_dir(),
)

if get_option('grep')
test(
'RunGrepTest',
rungreptest,
should_fail: host_machine.system() == 'windows',
env: 'srcdir=@0@'.format(meson.current_source_dir()),
workdir: meson.current_build_dir(),
)
endif
endif
Loading

0 comments on commit ccd75d9

Please sign in to comment.