From 50294d8ca57da086e1e420cc495d8503c95319ba Mon Sep 17 00:00:00 2001 From: Norbert Lindenberg Date: Sat, 13 Apr 2013 12:26:06 -0400 Subject: [PATCH] Bug 724533 - Integrate ICU into the Mozilla build. r=glandium --- js/src/Makefile.in | 49 +++++++++++++++++++++++-- js/src/configure.in | 89 ++++++++++++++++++++++++++++++++++++++++++++- js/src/jsversion.h | 3 -- 3 files changed, 133 insertions(+), 8 deletions(-) diff --git a/js/src/Makefile.in b/js/src/Makefile.in index 564c076d56f..3f3bc4e7d7b 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -599,13 +599,53 @@ distclean clean:: endif endif + +############################################# +# BEGIN ECMAScript Internationalization API +# + # ICU headers need to be available whether we build with the complete # Internationalization API or not - ICU stubs rely on them. LOCAL_INCLUDES += \ - -I$(topsrcdir)/../../intl/icu/source/common \ - -I$(topsrcdir)/../../intl/icu/source/i18n \ - $(NULL) + -I$(topsrcdir)/../../intl/icu/source/common \ + -I$(topsrcdir)/../../intl/icu/source/i18n \ + $(NULL) + +ifdef ENABLE_INTL_API + +ifeq ($(OS_ARCH),WINNT) + # Parallel gmake is buggy on Windows + ICU_GMAKE_OPTIONS="-j1" + # Library names: On Windows, ICU uses modified library names for static + # and debug libraries. + ifdef MOZ_DEBUG + ICU_LIB_SUFFIX=d + endif + ICU_LIB_RENAME = $(foreach libname,$(ICU_LIB_NAMES),\ + cp -p intl/icu/lib/s$(libname)$(ICU_LIB_SUFFIX).lib intl/icu/lib/$(libname).lib;) +endif + +# - Build ICU as part of the "export" target, so things get built +# in the right order. +# - ICU requires GNU make according to its readme.html. pymake can't be used +# because it doesn't support order only dependencies. +# - Force ICU to use the standard suffix for object files because expandlibs +# will discard all files with a non-standard suffix (bug 857450). +# - Options for genrb: -k strict parsing; -R omit collation tailoring rules. +export:: + $(GMAKE) $(ICU_GMAKE_OPTIONS) -C intl/icu STATIC_O=$(OBJ_SUFFIX) GENRBOPTS='-k -R' + $(ICU_LIB_RENAME) + +distclean clean:: + $(call SUBMAKE,$@,intl/icu) + +endif + +# +# END ECMAScript Internationalization API +############################################# + # The "find any vanilla new/new[] calls" script is tailored to Linux, so # only run it there. That should be enough to catch any such calls that @@ -734,6 +774,8 @@ ifneq (,$(MOZ_ZLIB_LIBS)$(MOZ_GLUE_LDFLAGS)) DEFINES += -DUSE_ZLIB endif +SHARED_LIBRARY_LIBS += $(ICU_LIBS) + # Prevent floating point errors caused by VC++ optimizations ifdef _MSC_VER # XXX We should add this to CXXFLAGS, too? @@ -1038,4 +1080,3 @@ endif # # END kludges for the Nitro assembler ############################################### - diff --git a/js/src/configure.in b/js/src/configure.in index b16f2576d57..cb0d5a1628f 100644 --- a/js/src/configure.in +++ b/js/src/configure.in @@ -4370,14 +4370,102 @@ if test "$ACCESSIBILITY" -a "$MOZ_ENABLE_GTK2" ; then AC_DEFINE_UNQUOTED(ATK_REV_VERSION, $ATK_REV_VERSION) fi + +dnl ======================================================== dnl ECMAScript Internationalization API Support (uses ICU) dnl ======================================================== +MOZ_ARG_ENABLE_BOOL(intl-api, +[ --enable-intl-api Enable ECMAScript Internationalization API], + ENABLE_INTL_API=1 ) + +dnl Settings for the implementation of the ECMAScript Internationalization API +if test -n "$ENABLE_INTL_API"; then + AC_DEFINE(ENABLE_INTL_API) + # We build ICU as a static library. + AC_DEFINE(U_STATIC_IMPLEMENTATION) + + case "$OS_TARGET" in + WINNT) + ICU_LIB_NAMES="icuin icuuc icudt" + ;; + Darwin|Linux) + ICU_LIB_NAMES="icui18n icuuc icudata" + ;; + *) + AC_MSG_ERROR([ECMAScript Internationalization API is not yet supported on this platform]) + esac + + ICU_LIBS='$(call EXPAND_LIBNAME_PATH,$(ICU_LIB_NAMES),$(DEPTH)/intl/icu/lib)' +else + ICU_LIB_NAMES= + ICU_LIBS= +fi + +AC_SUBST(ENABLE_INTL_API) +AC_SUBST(ICU_LIB_NAMES) +AC_SUBST(ICU_LIBS) + dnl Source files that use ICU should have control over which parts of the ICU dnl namespace they want to use. AC_DEFINE(U_USING_ICU_NAMESPACE,0) +dnl Settings for ICU +if test -n "$ENABLE_INTL_API" ; then + # Set ICU compile options + ICU_CPPFLAGS="" + # don't use icu namespace automatically in client code + ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_USING_ICU_NAMESPACE=0" + # don't include obsolete header files + ICU_CPPFLAGS="$ICU_CPPFLAGS -DU_NO_DEFAULT_INCLUDE_UTF_HEADERS=1" + # remove chunks of the library that we don't need (yet) + ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_LEGACY_CONVERSION" + ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_TRANSLITERATION" + ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_REGULAR_EXPRESSIONS" + ICU_CPPFLAGS="$ICU_CPPFLAGS -DUCONFIG_NO_BREAK_ITERATION" + + # Set OS dependent options for ICU + case "$OS_TARGET" in + Darwin) + ICU_TARGET=MacOSX + ;; + Linux) + ICU_TARGET=Linux + ;; + WINNT) + ICU_TARGET=MSYS/MSVC + ;; + esac + + # To reduce library size, use static linking + ICU_LINK_OPTS="--enable-static --disable-shared" + # Force the ICU static libraries to be position independent code + ICU_CFLAGS="$DSO_PIC_CFLAGS" + ICU_CXXFLAGS="$DSO_PIC_CFLAGS" + + ICU_BUILD_OPTS="" + if test -n "$MOZ_DEBUG"; then + ICU_BUILD_OPTS="$ICU_BUILD_OPTS --enable-debug" + fi + if test -z "$MOZ_OPTIMIZE"; then + ICU_BUILD_OPTS="$ICU_BUILD_OPTS --disable-release" + fi + + abs_srcdir=`(cd $srcdir; pwd)` + mkdir -p $_objdir/intl/icu + (cd $_objdir/intl/icu; \ + CFLAGS="$ICU_CFLAGS" CPPFLAGS="$ICU_CPPFLAGS" CXXFLAGS="$ICU_CXXFLAGS" \ + $(SHELL) $abs_srcdir/../../intl/icu/source/runConfigureICU \ + $ICU_BUILD_OPTS \ + $ICU_TARGET \ + $ICU_LINK_OPTS \ + --enable-extras=no --enable-icuio=no --enable-layout=no \ + --enable-tests=no --enable-samples=no || exit 1 + ) || exit 1 +fi + + dnl ======================================================== dnl JavaScript shell dnl ======================================================== @@ -4469,4 +4557,3 @@ if test "$JS_HAS_CTYPES" -a -z "$MOZ_NATIVE_FFI"; then ac_configure_args="$_SUBDIR_CONFIG_ARGS" CONFIG_FILES=$old_config_files fi - diff --git a/js/src/jsversion.h b/js/src/jsversion.h index 50e2fa6beb0..9b1224ec6ea 100644 --- a/js/src/jsversion.h +++ b/js/src/jsversion.h @@ -175,7 +175,4 @@ MOZ_NOT_REACHED("don't call this! to be used in the new object representation") #endif -/* ECMAScript Internationalization API isn't fully implemented yet. */ -#define ENABLE_INTL_API 0 - #endif /* jsversion_h___ */