Merge branch 'autodetect-iconv-impl' into 'master'

meson: Add autodetection to the iconv combo option

Closes #1557

See merge request GNOME/glib!759
This commit is contained in:
Nirbheek Chauhan 2019-04-12 06:02:45 +00:00
commit 61c4531b45
4 changed files with 24 additions and 41 deletions

View File

@ -95,7 +95,9 @@ cross-android_api21_arm64:
<<: *cross-template <<: *cross-template
script: script:
# FIXME: add --werror # FIXME: add --werror
- meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_21.txt -Diconv=gnu -Dinternal_pcre=true _build # We use -Diconv=auto to test that we successfully detect that iconv is not
# provided by android api 21, and detect the external iconv instead.
- meson ${MESON_COMMON_OPTIONS} --cross-file=/opt/cross_file_android_arm64_21.txt -Diconv=auto -Dinternal_pcre=true _build
- ninja -C _build - ninja -C _build
cross-android_api28_arm64: cross-android_api28_arm64:
@ -173,10 +175,10 @@ freebsd-11-x86_64:
LANG: en_US.UTF-8 LANG: en_US.UTF-8
script: script:
# We cannot use -Wl,--no-undefined because GLib uses 'environ' variable. # We cannot use -Wl,--no-undefined because GLib uses 'environ' variable.
# FreeBSD iconv doesn't handle transliteration, so we use GNU libiconv here. # FreeBSD iconv doesn't handle transliteration, so we use (external) GNU libiconv here.
# FreeBSD supports xattr, but its API is different from Linux xattr. # FreeBSD supports xattr, but its API is different from Linux xattr.
# FIXME: extattr(2) support: https://gitlab.gnome.org/GNOME/glib/issues/1404 # FIXME: extattr(2) support: https://gitlab.gnome.org/GNOME/glib/issues/1404
- meson ${MESON_COMMON_OPTIONS} -Db_lundef=false -Diconv=gnu -Dxattr=false _build - meson ${MESON_COMMON_OPTIONS} -Db_lundef=false -Diconv=external -Dxattr=false _build
- ninja -C _build - ninja -C _build
- bash -x ./.gitlab-ci/run-tests.sh - bash -x ./.gitlab-ci/run-tests.sh
except: except:

View File

@ -52,14 +52,6 @@
#include "glibintl.h" #include "glibintl.h"
#if defined(USE_LIBICONV_GNU) && !defined (_LIBICONV_H)
#error GNU libiconv in use but included iconv.h not from libiconv
#endif
#if !defined(USE_LIBICONV_GNU) && defined (_LIBICONV_H) \
&& !defined (__APPLE_CC__) && !defined (__LP_64__)
#error GNU libiconv not in use but included iconv.h is from libiconv
#endif
/** /**
* SECTION:conversions * SECTION:conversions

View File

@ -1690,42 +1690,31 @@ glibconfig_conf.set10('G_HAVE_GROWING_STACK', growing_stack)
# Tests for iconv # Tests for iconv
# #
# USE_LIBICONV_GNU: Using GNU libiconv # We should never use the MinGW C library's iconv because it may not be
# USE_LIBICONV_NATIVE: Using a native impl of iconv in a separate library # available in the actual runtime environment. On Windows, we always use
# # the built-in implementation
# We should never use the MinGW C library's iconv. On Windows we use the iconv_opt = get_option('iconv')
# GNU implementation that ships with MinGW.
# On Windows, just always use the built-in implementation
if host_system == 'windows' if host_system == 'windows'
libiconv = [] libiconv = []
glib_conf.set('USE_LIBICONV_NATIVE', true) # We have a #include "win_iconv.c" in gconvert.c on Windows, so we don't need
# any external library for it
if iconv_opt != 'auto'
warning('-Diconv was set to @0@, which was ignored')
endif
else else
found_iconv = false found_iconv = false
iconv_opt = get_option('iconv') if ['auto', 'libc'].contains(iconv_opt) and cc.has_function('iconv_open')
if iconv_opt == 'libc' libiconv = []
if cc.has_function('iconv_open') found_iconv = true
libiconv = [] endif
found_iconv = true if not found_iconv and ['auto', 'external'].contains(iconv_opt) and cc.has_header_symbol('iconv.h', 'iconv_open')
endif libiconv = [cc.find_library('iconv')]
elif iconv_opt == 'gnu' found_iconv = true
if cc.has_header_symbol('iconv.h', 'libiconv_open')
glib_conf.set('USE_LIBICONV_GNU', true)
libiconv = [cc.find_library('iconv')]
found_iconv = true
endif
elif iconv_opt == 'native'
if cc.has_header_symbol('iconv.h', 'iconv_open')
glib_conf.set('USE_LIBICONV_NATIVE', true)
libiconv = [cc.find_library('iconv')]
found_iconv = true
endif
endif endif
if not found_iconv if not found_iconv
error('iconv implementation "@0@" not found'.format(iconv_opt)) error('iconv implementation "@0@" not found'.format(iconv_opt))
endif endif
endif endif
if get_option('internal_pcre') if get_option('internal_pcre')

View File

@ -5,9 +5,9 @@ option('runtime_libdir',
option('iconv', option('iconv',
type : 'combo', type : 'combo',
choices : ['libc', 'gnu', 'native'], choices : ['auto', 'libc', 'external'],
value : 'libc', value : 'auto',
description : 'iconv implementation to use (\'libc\' = \'Part of the C stdlib\'; \'gnu\' = \'GNU\'s iconv\'; \'native\' = \'A separate iconv\')') description : 'iconv implementation to use (\'libc\' = \'Part of the C library\'; \'external\' = \'External libiconv\'; \'auto\' = \'Auto-detect which iconv is available\')')
option('charsetalias_dir', option('charsetalias_dir',
type : 'string', type : 'string',