[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8042 - in Extractor: . contrib/macosx src src/common src/i
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8042 - in Extractor: . contrib/macosx src src/common src/include src/intlemu src/main src/plugins |
Date: |
Sun, 28 Dec 2008 08:48:29 -0700 (MST) |
Author: holindho
Date: 2008-12-28 08:48:29 -0700 (Sun, 28 Dec 2008)
New Revision: 8042
Added:
Extractor/src/intlemu/
Extractor/src/intlemu/Makefile.am
Extractor/src/intlemu/intlemu.c
Extractor/src/intlemu/libintlemu.h
Modified:
Extractor/configure.ac
Extractor/contrib/macosx/build-osx-framework.sh
Extractor/src/Makefile.am
Extractor/src/common/Makefile.am
Extractor/src/include/platform.h
Extractor/src/main/Makefile.am
Extractor/src/plugins/Makefile-plugins.am
Log:
OS X native i18n for the framework build
Modified: Extractor/configure.ac
===================================================================
--- Extractor/configure.ac 2008-12-28 15:47:25 UTC (rev 8041)
+++ Extractor/configure.ac 2008-12-28 15:48:29 UTC (rev 8042)
@@ -516,8 +516,23 @@
[ffmpegarch=$withval])
+LE_INTLINCL=""
+LE_LIBINTL="$LTLIBINTL"
+AC_ARG_ENABLE(framework, [ --enable-framework enable Mac OS X framework
build helpers],enable_framework_build=$enableval)
+AM_CONDITIONAL(WANT_FRAMEWORK, test x$enable_framework_build = xyes)
+if test x$enable_framework_build = xyes
+then
+ AC_DEFINE([FRAMEWORK_BUILD], 1, [Build a Mac OS X Framework])
+ LE_INTLINCL='-I$(top_srcdir)/src/intlemu'
+ LE_LIBINTL='$(top_builddir)/src/intlemu/libintlemu.la -framework
CoreFoundation'
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$LE_INTLINCL])
+fi
+
+
LE_LIB_LDFLAGS="-export-dynamic -no-undefined"
LE_PLUGIN_LDFLAGS="-export-dynamic -avoid-version -module -no-undefined"
+
+
dnl TODO insert a proper check here
AC_CACHE_CHECK([whether -export-symbols-regex works],
gn_cv_export_symbols_regex_works,
@@ -534,6 +549,8 @@
fi
AC_SUBST(LE_LIB_LDFLAGS)
AC_SUBST(LE_PLUGIN_LDFLAGS)
+AC_SUBST(LE_INTLINCL)
+AC_SUBST(LE_LIBINTL)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
@@ -547,6 +564,7 @@
doc/Makefile
src/Makefile
src/include/Makefile
+src/intlemu/Makefile
src/common/Makefile
src/main/Makefile
src/plugins/Makefile
Modified: Extractor/contrib/macosx/build-osx-framework.sh
===================================================================
--- Extractor/contrib/macosx/build-osx-framework.sh 2008-12-28 15:47:25 UTC
(rev 8041)
+++ Extractor/contrib/macosx/build-osx-framework.sh 2008-12-28 15:48:29 UTC
(rev 8042)
@@ -313,17 +313,17 @@
#
build_dependencies()
{
- prepare_package "${GETTEXT_NAME}"
- build_package "${GETTEXT_NAME}" \
- "${ARCH_HOSTSETTING} \
- --prefix="${FW_DIR}" \
- --with-pic \
- --disable-shared \
- --enable-static \
- --disable-java \
- --disable-native-java \
- --without-emacs \
- --with-libiconv-prefix=${SDK_PATH}/usr"
+# prepare_package "${GETTEXT_NAME}"
+# build_package "${GETTEXT_NAME}" \
+# "${ARCH_HOSTSETTING} \
+# --prefix="${FW_DIR}" \
+# --with-pic \
+# --disable-shared \
+# --enable-static \
+# --disable-java \
+# --disable-native-java \
+# --without-emacs \
+# --with-libiconv-prefix=${SDK_PATH}/usr"
prepare_package "${LIBOGG_NAME}"
build_package "${LIBOGG_NAME}" \
@@ -388,13 +388,14 @@
CFLAGS="${CFLAGS}" \
CXXFLAGS="${CXXFLAGS}" \
LDFLAGS="${LDFLAGS}" \
- gt_cv_func_gnugettext1_libintl=yes \
+ xxgt_cv_func_gnugettext1_libintl=yes \
ac_cv_func_memcmp_working=yes \
ac_cv_func_mmap_fixed_mapped=yes \
ac_cv_func_stat_empty_string_bug=no \
./configure "${ARCH_HOSTSETTING}" \
--prefix="${FW_DIR}" \
--enable-shared \
+ --enable-framework \
--disable-gsf \
--disable-gnome \
--enable-ffmpeg \
@@ -559,6 +560,52 @@
done
}
+install_message_catalog_to_framework()
+{
+ local src_file="$1"
+ local lang_name=$( basename -s .po $src_file )
+ local
dst_file="${FINAL_FW_DIR}/Resources/${lang_name}.lproj/Localizable.strings"
+ if [ ! -e "$dst_file" ]
+ then
+ echo "MSGCAT $src_file $dst_file"
+ create_directory_for "$dst_file"
+ if ! ( msgcat -t UTF-8 --stringtable-output -o "$dst_file"
"$src_file" )
+ then
+ echo "error creating message catalog: $lang"
+ exit 1
+ fi
+ if ! ( chmod 0755 "${dst_file}" )
+ then
+ echo "error setting permissions"
+ exit 1
+ fi
+ plutil -lint "$dst_file"
+ fi
+}
+
+install_en_message_catalog_to_framework()
+{
+ local src_file="$1"
+ local lang_name="en"
+ local
dst_file="${FINAL_FW_DIR}/Resources/${lang_name}.lproj/Localizable.strings"
+ if [ ! -e "$dst_file" ]
+ then
+ echo "MSGCAT $src_file $dst_file"
+ create_directory_for "$dst_file"
+ if ! ( msgcat -t UTF-8 "$src_file" | msgen --stringtable-output
-o "$dst_file" - )
+ then
+ echo "error creating English message catalog"
+ exit 1
+ fi
+ if ! ( chmod 0755 "${dst_file}" )
+ then
+ echo "error setting permissions"
+ exit 1
+ fi
+ plutil -lint "$dst_file"
+ fi
+}
+
copy_file_to_framework()
{
local src_file="$1"
@@ -691,7 +738,12 @@
cd "${ORIG_DIR}"
copy_file_to_framework "./contrib/macosx/Info.plist" "Resources/Info.plist"
fill_framework_revision "Resources/Info.plist"
-copy_file_to_framework "./contrib/macosx/English.lproj/InfoPlist.strings"
"Resources/English.lproj/InfoPlist.strings"
+for tfn in ./po/*.po
+do
+ install_message_catalog_to_framework "$tfn"
+done
+install_en_message_catalog_to_framework "./po/libextractor.pot"
+#copy_file_to_framework "./contrib/macosx/English.lproj/InfoPlist.strings"
"Resources/English.lproj/InfoPlist.strings"
make_framework_link "lib/libextractor.dylib" "Extractor"
make_framework_link "lib" "Libraries"
make_framework_link "lib/libextractor" "PlugIns"
Modified: Extractor/src/Makefile.am
===================================================================
--- Extractor/src/Makefile.am 2008-12-28 15:47:25 UTC (rev 8041)
+++ Extractor/src/Makefile.am 2008-12-28 15:48:29 UTC (rev 8042)
@@ -1,3 +1,7 @@
+if WANT_FRAMEWORK
+ INTLEMU_SUBDIRS = intlemu
+endif
+
INCLUDES = -I$(top_srcdir)/src/include
-SUBDIRS = include main common plugins test .
+SUBDIRS = include $(INTLEMU_SUBDIRS) main common plugins test .
Modified: Extractor/src/common/Makefile.am
===================================================================
--- Extractor/src/common/Makefile.am 2008-12-28 15:47:25 UTC (rev 8041)
+++ Extractor/src/common/Makefile.am 2008-12-28 15:48:29 UTC (rev 8042)
@@ -1,7 +1,7 @@
INCLUDES = -I$(top_srcdir)/src/include $(LTDLINCL)
LIBS = \
- @LTLIBINTL@ @LIBS@
+ @LE_LIBINTL@ @LIBS@
lib_LTLIBRARIES = \
libextractor_common.la
Modified: Extractor/src/include/platform.h
===================================================================
--- Extractor/src/include/platform.h 2008-12-28 15:47:25 UTC (rev 8041)
+++ Extractor/src/include/platform.h 2008-12-28 15:48:29 UTC (rev 8042)
@@ -29,8 +29,13 @@
#define PLATFORM_H
#include "config.h"
+#ifndef FRAMEWORK_BUILD
#include "gettext.h"
#define _(a) dgettext(PACKAGE, a)
+#else
+#include "libintlemu.h"
+#define _(a) dgettext("org.gnunet.libextractor", a)
+#endif
#include "plibc.h"
Added: Extractor/src/intlemu/Makefile.am
===================================================================
--- Extractor/src/intlemu/Makefile.am (rev 0)
+++ Extractor/src/intlemu/Makefile.am 2008-12-28 15:48:29 UTC (rev 8042)
@@ -0,0 +1,8 @@
+noinst_LTLIBRARIES = \
+ libintlemu.la
+
+libintlemu_la_SOURCES = \
+ libintlemu.h \
+ intlemu.c
+libintlemu_la_LDFLAGS = \
+ -framework CoreFoundation
Added: Extractor/src/intlemu/intlemu.c
===================================================================
--- Extractor/src/intlemu/intlemu.c (rev 0)
+++ Extractor/src/intlemu/intlemu.c 2008-12-28 15:48:29 UTC (rev 8042)
@@ -0,0 +1,136 @@
+#include <CoreFoundation/CoreFoundation.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+static pthread_mutex_t intlemu_lock;
+static CFMutableDictionaryRef intlemu_dict;
+
+static void intlemu_cstring_release(CFAllocatorRef allocator, const void
*value)
+{
+ //printf("intlemu_cstring_release: %p\n", value);
+ free((void *)value);
+}
+
+void __attribute__ ((constructor)) intlemu_init_() {
+ //printf("intlemu: init\n");
+ CFDictionaryValueCallBacks cstring_value_callbacks =
+ {
+ 0, /* version */
+ NULL, /* retain callback */
+ &intlemu_cstring_release, /* release callback */
+ NULL, /* copy description */
+ NULL /* equal */
+ };
+ pthread_mutex_init(&intlemu_lock, NULL);
+
+ intlemu_dict = CFDictionaryCreateMutable(
+ kCFAllocatorDefault,
+ 0,
+ &kCFCopyStringDictionaryKeyCallBacks,
+ &cstring_value_callbacks);
+ if (intlemu_dict == NULL) {
+ //printf("Error creating dictionary\n");
+ return;
+ }
+}
+
+void __attribute__ ((destructor)) intlemu_fini_() {
+ //printf("intlemu: fini\n");
+ CFRelease(intlemu_dict);
+
+ pthread_mutex_destroy(&intlemu_lock);
+}
+
+char * intlemu_bgettext (CFBundleRef bundle, const char *msgid)
+{
+ CFStringRef key;
+ const char *value;
+ CFStringRef s;
+ CFRange r;
+ CFIndex len;
+ CFIndex clen;
+ char *buf;
+
+ if (msgid == NULL)
+ return NULL;
+
+ key = CFStringCreateWithBytes(
+ kCFAllocatorDefault,
+ (const UInt8 *)msgid,
+ (CFIndex)strlen(msgid),
+ kCFStringEncodingUTF8,
+ false);
+
+ pthread_mutex_lock(&intlemu_lock);
+ value = (char *)CFDictionaryGetValue(intlemu_dict, key);
+ pthread_mutex_unlock(&intlemu_lock);
+ //printf("CFDictionaryGetValue: [%s]\n", value);
+ if (value != NULL) {
+ CFRelease(key);
+ return (char *)value;
+ }
+
+ /* no cached translaation, so, find one from the bundle */
+ s = CFBundleCopyLocalizedString(
+ bundle,
+ key,
+ NULL,
+ NULL);
+ if (s == key) {
+ //printf("no translation found\n");
+ CFRelease(key);
+ return (char *)msgid;
+ }
+ /* get the length in bytes */
+ r.location = 0;
+ r.length = CFStringGetLength(s);
+ len = 0;
+ clen = CFStringGetBytes(
+ s,
+ r,
+ kCFStringEncodingUTF8,
+ 0,
+ false,
+ NULL,
+ 0,
+ &len);
+ buf = NULL;
+ if (clen == r.length) {
+ //printf("allocate dictionary value: %d\n", len+1);
+ buf = malloc(len + 1);
+ }
+
+ if (buf == NULL) {
+ CFRelease(s);
+ CFRelease(key);
+ return (char *)msgid;
+ }
+
+ clen = CFStringGetBytes(
+ s,
+ r,
+ kCFStringEncodingUTF8,
+ 0,
+ false,
+ (UInt8 *)buf,
+ len,
+ &len);
+ buf[len] = '\0';
+ if (clen == r.length) {
+ pthread_mutex_lock(&intlemu_lock);
+ CFDictionaryAddValue(intlemu_dict, key, buf);
+ pthread_mutex_unlock(&intlemu_lock);
+ value = buf;
+ }
+ else {
+ free(buf);
+ value = msgid;
+ }
+
+ CFRelease(s);
+
+ CFRelease(key);
+
+ return (char *)value;
+}
+
Added: Extractor/src/intlemu/libintlemu.h
===================================================================
--- Extractor/src/intlemu/libintlemu.h (rev 0)
+++ Extractor/src/intlemu/libintlemu.h 2008-12-28 15:48:29 UTC (rev 8042)
@@ -0,0 +1,18 @@
+/* Mac OS X CoreFoundation libintl emulator */
+
+#ifndef LIBINTLEMU_H
+#define LIBINTLEMU_H
+
+#include <CoreFoundation/CoreFoundation.h>
+
+#define gettext(msgid) \
+ intlemu_bgettext(CFBundleGetMainBundle(), msgid)
+
+#define dgettext(domainname, msgid) \
+ intlemu_bgettext(CFBundleGetBundleWithIdentifier(CFSTR(domainname)),
msgid)
+
+#define gettext_noop(s) s
+
+extern char * intlemu_bgettext (CFBundleRef bundle, const char *msgid);
+
+#endif
Modified: Extractor/src/main/Makefile.am
===================================================================
--- Extractor/src/main/Makefile.am 2008-12-28 15:47:25 UTC (rev 8041)
+++ Extractor/src/main/Makefile.am 2008-12-28 15:48:29 UTC (rev 8042)
@@ -6,7 +6,7 @@
plugindir = $(libdir)/@RPLUGINDIR@
LIBS = \
- @LTLIBINTL@ @LIBS@
+ @LE_LIBINTL@ @LIBS@
lib_LTLIBRARIES = \
libextractor.la
Modified: Extractor/src/plugins/Makefile-plugins.am
===================================================================
--- Extractor/src/plugins/Makefile-plugins.am 2008-12-28 15:47:25 UTC (rev
8041)
+++ Extractor/src/plugins/Makefile-plugins.am 2008-12-28 15:48:29 UTC (rev
8042)
@@ -4,7 +4,7 @@
plugindir = $(libdir)/@RPLUGINDIR@
LIBS = \
- @LTLIBINTL@ @LIBS@
+ @LE_LIBINTL@ @LIBS@
if HAVE_GNU_LD
makesymbolic=-Wl,-Bsymbolic
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8042 - in Extractor: . contrib/macosx src src/common src/include src/intlemu src/main src/plugins,
gnunet <=