Make libintl.h provide inline stubs

Previously libandroid-support contained inline stubs for libintl.h
functions (gettext(), dgettext() and friends).

We now provide inline versions of them in libintl.h directly so
libandroid-support is no longer necessary to get them.
This commit is contained in:
Fredrik Fornwall 2017-08-17 00:34:44 +02:00
parent 48605328dc
commit eaa7b49107
3 changed files with 59 additions and 6 deletions

View File

@ -365,7 +365,7 @@ termux_step_start_build() {
TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_TOPDIR/_lib/${TERMUX_NDK_VERSION}-${TERMUX_ARCH}-${TERMUX_PKG_API_LEVEL}"
# Bump the below version if a change is made in toolchain setup to ensure
# that everyone gets an updated toolchain:
TERMUX_STANDALONE_TOOLCHAIN+="-v11"
TERMUX_STANDALONE_TOOLCHAIN+="-v12"
if [ -n "${TERMUX_PKG_BLACKLISTED_ARCHES:=""}" ] && [ "$TERMUX_PKG_BLACKLISTED_ARCHES" != "${TERMUX_PKG_BLACKLISTED_ARCHES/$TERMUX_ARCH/}" ]; then
echo "Skipping building $TERMUX_PKG_NAME for arch $TERMUX_ARCH"
@ -658,7 +658,7 @@ termux_step_setup_toolchain() {
# elf.h: Taken from glibc since the elf.h in the NDK is lacking.
# sysexits.h: Header-only and used by a few programs.
# ifaddrs.h: Added in android-24 unified headers, use a inline implementation for now.
cp "$TERMUX_SCRIPTDIR"/ndk-patches/{elf.h,sysexits.h,ifaddrs.h} usr/include
cp "$TERMUX_SCRIPTDIR"/ndk-patches/{elf.h,sysexits.h,ifaddrs.h,libintl.h} usr/include
# Remove <sys/shm.h> from the NDK in favour of that from the libandroid-shmem.
# Also remove <sys/sem.h> as it doesn't work for non-root.

53
ndk-patches/libintl.h Normal file
View File

@ -0,0 +1,53 @@
#ifndef _LIBINTL_H
#define _LIBINTL_H
#include <errno.h>
#include <string.h>
static __inline__ char* gettext(const char* msgid)
{ return (char*) msgid; }
static __inline__ char* dgettext(const char* domainname, const char* msgid)
{ return (char*) msgid; }
static __inline__ char* dcgettext(const char* domainname, const char* msgid, int category)
{ return (char*) msgid; }
static __inline__ char* ngettext(const char* msgid1, const char* msgid2, unsigned long int n)
{ return (char *) ((n == 1) ? msgid1 : msgid2); }
static __inline__ char* dngettext(const char* domainname, const char* msgid1, const char* msgid2, unsigned long int n)
{ return (char *) ((n == 1) ? msgid1 : msgid2); }
static __inline__ char* dcngettext(const char* domainname, const char* msgid1, const char* msgid2, unsigned long int n, int category)
{ return (char *) ((n == 1) ? msgid1 : msgid2); }
static __inline__ char* textdomain(const char* domainname)
{
static const char default_str[] = "messages";
if (domainname && *domainname && strcmp(domainname, default_str)) {
errno = EINVAL;
return NULL;
}
return (char*) default_str;
}
static __inline__ char* bindtextdomain(const char* domainname, const char* dirname)
{
static const char dir[] = "/";
if (!domainname || !*domainname || (dirname && ((dirname[0] != '/') || dirname[1]))) {
errno = EINVAL;
return NULL;
}
return (char*) dir;
}
static __inline__ char* bind_textdomain_codeset(const char* domainname, const char* codeset)
{
if (!domainname || !*domainname || (codeset && strcasecmp(codeset, "UTF-8"))) {
errno = EINVAL;
}
return NULL;
}
#endif

View File

@ -1,7 +1,7 @@
TERMUX_PKG_HOMEPAGE=https://github.com/termux/libandroid-support
TERMUX_PKG_DESCRIPTION="Library extending the Android C library (Bionic) for additional multibyte, locale and math support"
TERMUX_PKG_VERSION=21
TERMUX_PKG_SHA256=e355c822d0891ba610275eac4b13e9b0fb4dd57e8e2891b9fd98d11edc6fd40d
TERMUX_PKG_VERSION=22
TERMUX_PKG_SHA256=667f20d0821a6305c50c667363486d546b293e846f31d02f559947d50121f51e
TERMUX_PKG_SRCURL=https://github.com/termux/libandroid-support/archive/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_FOLDERNAME=libandroid-support-$TERMUX_PKG_VERSION
TERMUX_PKG_BUILD_IN_SRC=yes
@ -17,11 +17,11 @@ termux_step_make_install () {
cp libandroid-support.so $TERMUX_PREFIX/lib/
(cd $TERMUX_PREFIX/lib; ln -f -s libandroid-support.so libiconv.so; ln -f -s libandroid-support.so libintl.so)
(cd $TERMUX_PREFIX/lib; ln -f -s libandroid-support.so libiconv.so; )
rm -Rf $TERMUX_PREFIX/include/libandroid-support
mkdir -p $TERMUX_PREFIX/include/libandroid-support
cp -Rf include/* $TERMUX_PREFIX/include/libandroid-support/
(cd $TERMUX_PREFIX/include; ln -f -s libandroid-support/libintl.h libintl.h; ln -f -s libandroid-support/iconv.h iconv.h)
(cd $TERMUX_PREFIX/include; ln -f -s libandroid-support/iconv.h iconv.h)
}