Make builtin option independant from runtime one

Since commit deabd4a, psl2c has been replaced by psl-make-dafsa.
The builtin PSL data is always generated the same way, and the value of the builtin
configure option does not matter anymore.

The built-in data is now embedded by default (instead of the previous "auto"), unless
explicitly disabled by --disable-builtin/-Dbuiltin=false.

When not using an run-time runtime IDNA library (--disable-runtime/-Druntime=no), libpsl can
now include the built-in data without any build-time dependency.
This commit is contained in:
Loïc Yhuel 2022-03-07 14:14:41 +01:00
parent 6a82bcbc2a
commit aa4909766c
11 changed files with 49 additions and 84 deletions

View File

@ -160,22 +160,14 @@ AC_ARG_ENABLE(runtime,
# Check for enable/disable builtin PSL data
AC_ARG_ENABLE(builtin,
[
--enable-builtin[[=IDNA library]]
Specify the IDNA library used for built-in data generation:
libidn2 [[default]]: IDNA2008 library (also needs libunistring)
libicu: IDNA2008 UTS#46 library
libidn: IDNA2003 library (also needs libunistring)
--enable-builtin Generate built-in PSL data
--disable-builtin Do not generate built-in PSL data
], [
if test "$enableval" = "libidn2" -o "$enableval" = "yes"; then
enable_builtin=libidn2
AC_DEFINE([BUILTIN_GENERATOR_LIBIDN2], [1], [generate PSL data using libidn2])
elif test "$enableval" = "libicu"; then
enable_builtin=libicu
AC_DEFINE([BUILTIN_GENERATOR_LIBICU], [1], [generate PSL data using libicu])
elif test "$enableval" = "libidn"; then
enable_builtin=libidn
AC_DEFINE([BUILTIN_GENERATOR_LIBIDN], [1], [generate PSL data using libidn])
if test "$enableval" = "yes"; then
enable_builtin=yes
elif test "$enableval" = "libidn" -o "$enableval" = "libidn2" -o "$enableval" = "libicu"; then
AC_MSG_WARN([--enable-builtin=$enableval is deprecated, use --enable-builtin (enabled by default)])
enable_builtin=yes
elif test "$enableval" = "no"; then
enable_builtin=no
else
@ -183,10 +175,14 @@ AC_ARG_ENABLE(builtin,
fi
], [
# this is the default if neither --enable-builtin nor --disable-builtin were specified
enable_builtin=auto
enable_builtin=yes
])
if test "$enable_runtime" = "libidn2" -o "$enable_builtin" = "libidn2" -o "$enable_runtime" = "auto" -o "$enable_builtin" = "auto"; then
if test "$enable_builtin" = "yes"; then
AC_DEFINE([ENABLE_BUILTIN], [1], [Generate built-in PSL data])
fi
if test "$enable_runtime" = "libidn2" -o "$enable_runtime" = "auto"; then
# Check for libidn2
PKG_CHECK_MODULES([LIBIDN2], [libidn2], [
HAVE_LIBIDN2=yes
@ -197,7 +193,7 @@ if test "$enable_runtime" = "libidn2" -o "$enable_builtin" = "libidn2" -o "$enab
], [
AC_SEARCH_LIBS(idn2_lookup_u8, idn2, HAVE_LIBIDN2=yes,
[
if test "$enable_runtime" = "libidn2" -o "$enable_builtin" = "libidn2"; then
if test "$enable_runtime" = "libidn2"; then
AC_MSG_ERROR(You requested libidn2 but it is not installed.)
fi
], -lunistring)
@ -208,14 +204,10 @@ if test "$enable_runtime" = "libidn2" -o "$enable_builtin" = "libidn2" -o "$enab
enable_runtime=libidn2
AC_DEFINE([WITH_LIBIDN2], [1], [generate PSL data using libidn2])
fi
if test "$enable_builtin" = "auto"; then
enable_builtin=libidn2
AC_DEFINE([BUILTIN_GENERATOR_LIBIDN2], [1], [generate PSL data using libidn2])
fi
fi
fi
if test "$enable_runtime" = "libicu" -o "$enable_builtin" = "libicu" -o "$enable_runtime" = "auto" -o "$enable_builtin" = "auto"; then
if test "$enable_runtime" = "libicu" -o "$enable_runtime" = "auto"; then
# Check for libicu
# using pkg-config won't work on older systems like Ubuntu 12.04 LTS Server Edition 64bit
# using AC_SEARCH_LIBS also don't work since functions have the library version appended
@ -235,7 +227,7 @@ if test "$enable_runtime" = "libicu" -o "$enable_builtin" = "libicu" -o "$enable
[[u_strToUTF8(NULL, 0, NULL, NULL, 0, NULL);]])],
[HAVE_LIBICU=yes; LIBICU_LIBS="-licuuc"; AC_MSG_RESULT([yes])],
[ AC_MSG_RESULT([no]);
if test "$enable_runtime" = "libicu" -o "$enable_builtin" = "libicu"; then
if test "$enable_runtime" = "libicu"; then
AC_MSG_ERROR(You requested libicu but it is not installed.)
fi
LIBS=$OLDLIBS
@ -247,14 +239,10 @@ if test "$enable_runtime" = "libicu" -o "$enable_builtin" = "libicu" -o "$enable
enable_runtime=libicu
AC_DEFINE([WITH_LIBICU], [1], [generate PSL data using libicu])
fi
if test "$enable_builtin" = "auto"; then
enable_builtin=libicu
AC_DEFINE([BUILTIN_GENERATOR_LIBICU], [1], [generate PSL data using libicu])
fi
fi
fi
if test "$enable_runtime" = "libidn" -o "$enable_builtin" = "libidn" -o "$enable_runtime" = "auto" -o "$enable_builtin" = "auto"; then
if test "$enable_runtime" = "libidn" -o "$enable_runtime" = "auto"; then
# Check for libidn
PKG_CHECK_MODULES([LIBIDN], [libidn], [
HAVE_LIBIDN=yes
@ -265,7 +253,7 @@ if test "$enable_runtime" = "libidn" -o "$enable_builtin" = "libidn" -o "$enable
], [
AC_SEARCH_LIBS(idna_to_ascii_8z, idn, HAVE_LIBIDN=yes,
[
if test "$enable_runtime" = "libidn" -o "$enable_builtin" = "libidn"; then
if test "$enable_runtime" = "libidn"; then
AC_MSG_ERROR(You requested libidn but it is not installed.)
fi
])
@ -276,10 +264,6 @@ if test "$enable_runtime" = "libidn" -o "$enable_builtin" = "libidn" -o "$enable
enable_runtime=libidn
AC_DEFINE([WITH_LIBIDN], [1], [generate PSL data using libidn])
fi
if test "$enable_builtin" = "auto"; then
enable_builtin=libidn
AC_DEFINE([BUILTIN_GENERATOR_LIBIDN], [1], [generate PSL data using libidn])
fi
fi
fi
@ -287,9 +271,6 @@ fi
if test "$enable_runtime" = "auto"; then
enable_runtime=no
fi
if test "$enable_builtin" = "auto"; then
enable_builtin=no
fi
if test "x$HAVE_LIBIDN2" = "xyes" -o "x$HAVE_LIBIDN" = "xyes"; then
# Check for libunistring, we need it for psl_str_to_utf8lower()
@ -303,10 +284,7 @@ AM_ICONV
AM_CONDITIONAL([WITH_LIBICU], test "x$enable_runtime" = "xlibicu")
AM_CONDITIONAL([WITH_LIBIDN2], test "x$enable_runtime" = "xlibidn2")
AM_CONDITIONAL([WITH_LIBIDN], test "x$enable_runtime" = "xlibidn")
AM_CONDITIONAL([BUILTIN_GENERATOR_LIBICU], test "x$enable_builtin" = "xlibicu")
AM_CONDITIONAL([BUILTIN_GENERATOR_LIBIDN2], test "x$enable_builtin" = "xlibidn2")
AM_CONDITIONAL([BUILTIN_GENERATOR_LIBIDN], test "x$enable_builtin" = "xlibidn")
AM_CONDITIONAL([WITH_BUILTIN], test $enable_builtin = yes)
AM_CONDITIONAL([ENABLE_BUILTIN], test "x$enable_builtin" = "xyes")
# Solaris has socket in libsocket and inet_ntop in libnsl, but also needs libsocket, so the order is important here
AC_CHECK_LIB([socket], [socket], [NEEDS_SOCKET=yes], [])

View File

@ -37,10 +37,10 @@ for CC in gcc clang; do
rm -f $CACHEFILE
for options in \
"--enable-runtime=libicu --enable-builtin=libicu" \
"--enable-runtime=libidn2 --enable-builtin=libidn2" \
"--enable-runtime=libidn --enable-builtin=libidn" \
"--disable-runtime --enable-builtin=libicu"; do
"--enable-runtime=libicu" \
"--enable-runtime=libidn2" \
"--enable-runtime=libidn" \
"--disable-runtime"; do
export DISTCHECK_CONFIGURE_FLAGS="-q -C --cache-file=$CACHEFILE $options"
if test "$CC" = "clang"; then
echo

View File

@ -51,7 +51,7 @@ cd ..
# build libpsl
export WINEPATH="$INSTALLDIR/bin;$INSTALLDIR/lib;/usr/$PREFIX/bin;/usr/$PREFIX/lib;$PWD/libpsl/.libs;$GCCLIB"
./autogen.sh
./configure --build=x86_64-pc-linux-gnu --host=$PREFIX --enable-shared --disable-gtk-doc --enable-runtime=libidn2 --enable-builtin=libidn2 --prefix=$INSTALLDIR
./configure --build=x86_64-pc-linux-gnu --host=$PREFIX --enable-shared --disable-gtk-doc --enable-runtime=libidn2 --prefix=$INSTALLDIR
make clean
make -j$(nproc)
make check -j$(nproc) LOG_COMPILER=wine

View File

@ -25,7 +25,7 @@ link_language = 'c'
# https://github.com/mesonbuild/meson/issues/4566
# Dependency fallbacks would help too:
# https://github.com/mesonbuild/meson/pull/4595
if ['libidn2', 'auto'].contains(enable_runtime) or ['libidn2', 'auto'].contains(enable_builtin)
if ['libidn2', 'auto'].contains(enable_runtime)
libidn2_dep = dependency('libidn2', required : false)
if not libidn2_dep.found() and cc.has_header('idn2.h')
libidn2_dep = cc.find_library('idn2', required : false)
@ -42,7 +42,7 @@ if ['libidn2', 'auto'].contains(enable_runtime) or ['libidn2', 'auto'].contains(
endif
endif
if ['libicu', 'auto'].contains(enable_runtime) or ['libicu', 'auto'].contains(enable_builtin)
if ['libicu', 'auto'].contains(enable_runtime)
libicu_dep = dependency('icu-uc', required : false)
if not libicu_dep.found() and cc.has_header('unicode/ustring.h')
# MSVC: the debug configuration of ICU generated the libraries with d suffix
@ -71,7 +71,7 @@ if ['libicu', 'auto'].contains(enable_runtime) or ['libicu', 'auto'].contains(en
endif
endif
if ['libidn', 'auto'].contains(enable_runtime) or ['libidn', 'auto'].contains(enable_builtin)
if ['libidn', 'auto'].contains(enable_runtime)
libidn_dep = dependency('libidn', required : false)
if not libidn_dep.found() and cc.has_header('idna.h')
libidn_dep = cc.find_library('idn', required : false)
@ -122,9 +122,7 @@ config.set_quoted('PACKAGE_VERSION', meson.project_version())
config.set('WITH_LIBIDN2', enable_runtime == 'libidn2')
config.set('WITH_LIBICU', enable_runtime == 'libicu')
config.set('WITH_LIBIDN', enable_runtime == 'libidn')
config.set('BUILTIN_GENERATOR_LIBIDN2', enable_builtin == 'libidn2')
config.set('BUILTIN_GENERATOR_LIBICU', enable_builtin == 'libicu')
config.set('BUILTIN_GENERATOR_LIBIDN', enable_builtin == 'libidn')
config.set('ENABLE_BUILTIN', enable_builtin)
config.set('HAVE_UNISTD_H', cc.check_header('unistd.h'))
config.set('HAVE_STDINT_H', cc.check_header('stdint.h'))
config.set('HAVE_ALLOCA_H', cc.check_header('alloca.h'))

View File

@ -2,9 +2,9 @@ option('runtime', type : 'combo',
choices : ['libidn2', 'libicu', 'libidn', 'no', 'auto'], value : 'auto',
description : 'Specify the IDNA library used for libpsl run-time conversions')
option('builtin', type : 'combo',
choices : ['libidn2', 'libicu', 'libidn', 'no', 'auto'], value : 'auto',
description : 'Specify the IDNA library used for built-in data generation')
option('builtin', type : 'boolean',
value : true,
description : 'Specify whether libpsl will include built-in PSL data')
option('psl_distfile', type : 'string', value : '',
description : 'path to distribution-wide PSL file')

View File

@ -91,8 +91,8 @@ build-info:
@echo Configuration/Platform: $(CFG)/$(PLAT)
@echo Library Build Type: $(PSL_LIBTYPE)
@echo Enabled Runtime: $(ENABLED_RUNTIME)
@echo Enabled Builtin: $(ENABLED_BUILTIN)
@if not "$(ENABLED_BUILTIN)" == "none" echo PSL File: $(PSL_FILE)
@echo Enabled Builtin: $(ENABLE_BUILTIN)
@if not "$(ENABLE_BUILTIN)" == "no" echo PSL File: $(PSL_FILE)
clean:
@if exist vs$(VSVER)\$(CFG)\$(PLAT)\psl.dafsa del vs$(VSVER)\$(CFG)\$(PLAT)\psl.dafsa

View File

@ -13,8 +13,8 @@ PSL_TESTFILE=..\list\tests\tests.txt
PSL_FILE_INPUT = $(PSL_FILE:\=/)
PSL_TESTFILE_INPUT = $(PSL_TESTFILE:\=/)
# We only support using the ICU runtime and/or builtin, or no runtime
# and/or builtin for Visual Studio builds
# We only support using the ICU runtime, or no runtime
# for Visual Studio builds
!if "$(CFG)" == "Release" || "$(CFG)" == "release"
ICUUC_LIB = icuuc.lib
!else
@ -79,9 +79,9 @@ PSL_DLL_SUFFIX =
PSL_DLL = vs$(VSVER)\$(CFG)\$(PLAT)\$(PSL_DLL_PREFIX)psl$(PSL_DLL_SUFFIX).dll
# ENABLE_RUNTIME_ICU and ENABLE_BUILTIN_ICU are currently dummy arguments to NMake
# ENABLED_RUNTIME and ENABLE_BUILTIN are currently dummy arguments to NMake
ENABLED_RUNTIME =
ENABLED_BUILTIN =
ENABLE_BUILTIN =
!ifndef DISABLE_RUNTIME
BASE_CFLAGS = $(BASE_CFLAGS) /DWITH_LIBICU=1
@ -92,11 +92,11 @@ ENABLED_RUNTIME = none
!endif
!ifndef DISABLE_BUILTIN
BASE_CFLAGS = $(BASE_CFLAGS) /DBUILTIN_GENERATOR_LIBICU=1
ENABLED_BUILTIN = libicu
BASE_CFLAGS = $(BASE_CFLAGS) /DENABLE_BUILTIN=1
ENABLE_BUILTIN = yes
!else
PSL_MAKE_OPTIONS = $(PSL_MAKE_OPTIONS) DISABLE_BUILTIN^=1
ENABLED_BUILTIN = none
ENABLE_BUILTIN = no
!endif
!ifdef STATIC
@ -107,8 +107,11 @@ PSL_LIBTYPE = static
PSL_LIBTYPE = DLL
!endif
!if "$(DISABLE_RUNTIME)" == "" || "$(DISABLE_BUILTIN)" == ""
!if "$(DISABLE_RUNTIME)" == ""
PSL_ADDITIONAL_LIBS = $(PSL_ADDITIONAL_LIBS) $(ICUUC_LIB)
endif
!if "$(DISABLE_BUILTIN)" == ""
PSL_TESTS = \
$(PSL_TESTS) \
vs$(VSVER)\$(CFG)\$(PLAT)\test-is-public-builtin.exe \

View File

@ -1,14 +1,8 @@
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* generate PSL data using libicu */
/* #undef BUILTIN_GENERATOR_LIBICU */
/* generate PSL data using libidn */
/* #undef BUILTIN_GENERATOR_LIBIDN */
/* generate PSL data using libidn2 */
/* #undef BUILTIN_GENERATOR_LIBIDN2 */
/* Generate built-in PSL data */
/* #undef ENABLE_BUILTIN */
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
systems. This function is required for `alloca.c' support on those systems.

View File

@ -166,7 +166,7 @@ struct psl_ctx_st {
};
/* include the PSL data generated by psl-make-dafsa */
#if defined(BUILTIN_GENERATOR_LIBICU) || defined(BUILTIN_GENERATOR_LIBIDN2) || defined(BUILTIN_GENERATOR_LIBIDN)
#ifdef ENABLE_BUILTIN
#include "suffixes_dafsa.h"
#else
static const unsigned char kDafsa[] = "";
@ -1366,7 +1366,7 @@ void psl_free(psl_ctx_t *psl)
*/
const psl_ctx_t *psl_builtin(void)
{
#if defined(BUILTIN_GENERATOR_LIBICU) || defined(BUILTIN_GENERATOR_LIBIDN2) || defined(BUILTIN_GENERATOR_LIBIDN)
#ifdef ENABLE_BUILTIN
return &builtin_psl;
#else
return NULL;

View File

@ -13,15 +13,7 @@ AM_LDFLAGS = -no-install
# Do not call test-registrable-domain here: it would fail due to missing punycode entries in PSL file.
PSL_TESTS = test-is-public test-is-public-all test-is-cookie-domain-acceptable
if BUILTIN_GENERATOR_LIBICU
PSL_TESTS += test-is-public-builtin test-registrable-domain
endif
if BUILTIN_GENERATOR_LIBIDN2
PSL_TESTS += test-is-public-builtin test-registrable-domain
endif
if BUILTIN_GENERATOR_LIBIDN
if ENABLE_BUILTIN
PSL_TESTS += test-is-public-builtin test-registrable-domain
endif

View File

@ -23,7 +23,7 @@ tests = [
'test-is-cookie-domain-acceptable',
]
if enable_builtin != 'no'
if enable_builtin
tests += ['test-is-public-builtin', 'test-registrable-domain']
endif