8250894: Provide a configure option to build and run against the platform libharfbuzz

Reviewed-by: erikj
This commit is contained in:
Phil Race 2020-08-04 12:20:37 -07:00
parent 42f4170b2a
commit 84e397b4de
5 changed files with 122 additions and 58 deletions

View File

@ -101,6 +101,8 @@ apt_help() {
PKGHANDLER_COMMAND="sudo apt-get install libfontconfig1-dev" ;;
freetype)
PKGHANDLER_COMMAND="sudo apt-get install libfreetype6-dev" ;;
harfbuzz)
PKGHANDLER_COMMAND="sudo apt-get install libharfbuzz-dev" ;;
ffi)
PKGHANDLER_COMMAND="sudo apt-get install libffi-dev" ;;
x11)
@ -124,6 +126,8 @@ zypper_help() {
PKGHANDLER_COMMAND="sudo zypper install fontconfig-devel" ;;
freetype)
PKGHANDLER_COMMAND="sudo zypper install freetype-devel" ;;
harfbuzz)
PKGHANDLER_COMMAND="sudo zypper install harfbuzz-devel" ;;
x11)
PKGHANDLER_COMMAND="sudo zypper install libX11-devel libXext-devel libXrender-devel libXrandr-devel libXtst-devel libXt-devel libXi-devel" ;;
ccache)
@ -143,6 +147,8 @@ yum_help() {
PKGHANDLER_COMMAND="sudo yum install fontconfig-devel" ;;
freetype)
PKGHANDLER_COMMAND="sudo yum install freetype-devel" ;;
harfbuzz)
PKGHANDLER_COMMAND="sudo yum install harfbuzz-devel" ;;
x11)
PKGHANDLER_COMMAND="sudo yum install libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel" ;;
ccache)

View File

@ -40,6 +40,7 @@ AC_DEFUN_ONCE([LIB_SETUP_BUNDLED_LIBS],
LIB_SETUP_LIBPNG
LIB_SETUP_ZLIB
LIB_SETUP_LCMS
LIB_SETUP_HARFBUZZ
])
################################################################################
@ -263,3 +264,43 @@ AC_DEFUN_ONCE([LIB_SETUP_LCMS],
AC_SUBST(LCMS_CFLAGS)
AC_SUBST(LCMS_LIBS)
])
################################################################################
# Setup harfbuzz
################################################################################
AC_DEFUN_ONCE([LIB_SETUP_HARFBUZZ],
[
AC_ARG_WITH(harfbuzz, [AS_HELP_STRING([--with-harfbuzz],
[use harfbuzz from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
AC_MSG_CHECKING([for which harfbuzz to use])
DEFAULT_HARFBUZZ=bundled
# If user didn't specify, use DEFAULT_HARFBUZZ
if test "x${with_harfbuzz}" = "x"; then
with_harfbuzz=${DEFAULT_HARFBUZZ}
fi
if test "x${with_harfbuzz}" = "xbundled"; then
USE_EXTERNAL_HARFBUZZ=false
HARFBUZZ_CFLAGS=""
HARFBUZZ_LIBS=""
AC_MSG_RESULT([bundled])
elif test "x${with_harfbuzz}" = "xsystem"; then
AC_MSG_RESULT([system])
PKG_CHECK_MODULES([HARFBUZZ], [harfbuzz], [HARFBUZZ_FOUND=yes], [HARFBUZZ_FOUND=no])
if test "x${HARFBUZZ_FOUND}" = "xyes"; then
# PKG_CHECK_MODULES will set HARFBUZZ_CFLAGS and HARFBUZZ_LIBS
USE_EXTERNAL_HARFBUZZ=true
else
HELP_MSG_MISSING_DEPENDENCY([harfbuzz])
AC_MSG_ERROR([--with-harfbuzz=system specified, but no harfbuzz found! $HELP_MSG])
fi
else
AC_MSG_ERROR([Invalid value for --with-harfbuzz: ${with_harfbuzz}, use 'system' or 'bundled'])
fi
AC_SUBST(USE_EXTERNAL_HARFBUZZ)
AC_SUBST(HARFBUZZ_CFLAGS)
AC_SUBST(HARFBUZZ_LIBS)
])

View File

@ -824,6 +824,10 @@ USE_EXTERNAL_LCMS:=@USE_EXTERNAL_LCMS@
LCMS_CFLAGS:=@LCMS_CFLAGS@
LCMS_LIBS:=@LCMS_LIBS@
USE_EXTERNAL_HARFBUZZ:=@USE_EXTERNAL_HARFBUZZ@
HARFBUZZ_CFLAGS:=@HARFBUZZ_CFLAGS@
HARFBUZZ_LIBS:=@HARFBUZZ_LIBS@
USE_EXTERNAL_LIBPNG:=@USE_EXTERNAL_LIBPNG@
PNG_LIBS:=@PNG_LIBS@
PNG_CFLAGS:=@PNG_CFLAGS@

View File

@ -71,6 +71,10 @@ ifeq ($(FREETYPE_TO_USE), system)
LEGAL_EXCLUDES += freetype.md
endif
ifeq ($(USE_EXTERNAL_HARFBUZZ), true)
LEGAL_EXCLUDES += harfbuzz.md
endif
$(eval $(call SetupCopyLegalFiles, COPY_LEGAL, \
EXCLUDES := $(LEGAL_EXCLUDES), \
))

View File

@ -432,82 +432,87 @@ endif
###########################################################################
HARFBUZZ_CFLAGS := -DHAVE_OT -DHAVE_FALLBACK -DHAVE_UCDN -DHAVE_ROUND
ifeq ($(USE_EXTERNAL_HARFBUZZ), true)
LIBHARFBUZZ_LIBS := $(HARFBUZZ_LIBS)
else
HARFBUZZ_CFLAGS := -DHAVE_OT -DHAVE_FALLBACK -DHAVE_UCDN -DHAVE_ROUND
# This is better than adding EXPORT_ALL_SYMBOLS
ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
HARFBUZZ_CFLAGS += -DHB_EXTERN=__attribute__\(\(visibility\(\"default\"\)\)\)
else ifeq ($(TOOLCHAIN_TYPE), microsoft)
HARFBUZZ_CFLAGS += -DHB_EXTERN=__declspec\(dllexport\)
endif
# This is better than adding EXPORT_ALL_SYMBOLS
ifneq ($(filter $(TOOLCHAIN_TYPE), gcc clang), )
HARFBUZZ_CFLAGS += -DHB_EXTERN=__attribute__\(\(visibility\(\"default\"\)\)\)
else ifeq ($(TOOLCHAIN_TYPE), microsoft)
HARFBUZZ_CFLAGS += -DHB_EXTERN=__declspec\(dllexport\)
endif
ifeq ($(call isTargetOs, windows), false)
HARFBUZZ_CFLAGS += -DGETPAGESIZE -DHAVE_MPROTECT -DHAVE_PTHREAD \
ifeq ($(call isTargetOs, windows), false)
HARFBUZZ_CFLAGS += -DGETPAGESIZE -DHAVE_MPROTECT -DHAVE_PTHREAD \
-DHAVE_SYSCONF -DHAVE_SYS_MMAN_H -DHAVE_UNISTD_H \
-DHB_NO_PRAGMA_GCC_DIAGNOSTIC
endif
ifeq ($(call isTargetOs, linux macosx), true)
HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES
endif
ifeq ($(call isTargetOs, macosx), true)
HARFBUZZ_CFLAGS += -DHAVE_CORETEXT
endif
ifeq ($(call isTargetOs, macosx), false)
LIBHARFBUZZ_EXCLUDE_FILES += harfbuzz/hb-coretext.cc
endif
# hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later.
LIBHARFBUZZ_EXCLUDE_FILES += harfbuzz/hb-ft.cc
endif
ifeq ($(call isTargetOs, linux macosx), true)
HARFBUZZ_CFLAGS += -DHAVE_INTEL_ATOMIC_PRIMITIVES
endif
ifeq ($(call isTargetOs, macosx), true)
HARFBUZZ_CFLAGS += -DHAVE_CORETEXT
endif
ifeq ($(call isTargetOs, macosx), false)
LIBHARFBUZZ_EXCLUDE_FILES += harfbuzz/hb-coretext.cc
endif
# hb-ft.cc is not presently needed, and requires freetype 2.4.2 or later.
LIBHARFBUZZ_EXCLUDE_FILES += harfbuzz/hb-ft.cc
LIBHARFBUZZ_CFLAGS += $(HARFBUZZ_CFLAGS)
LIBHARFBUZZ_CFLAGS += $(HARFBUZZ_CFLAGS)
# For use by libfontmanager:
ifeq ($(call isTargetOs, windows), true)
LIBHARFBUZZ_LIBS := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libharfbuzz/harfbuzz.lib
else
LIBHARFBUZZ_LIBS := -lharfbuzz
endif
# For use by libfontmanager:
ifeq ($(call isTargetOs, windows), true)
LIBHARFBUZZ_LIBS := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libharfbuzz/harfbuzz.lib
else
LIBHARFBUZZ_LIBS := -lharfbuzz
endif
LIBHARFBUZZ_EXTRA_HEADER_DIRS := \
LIBHARFBUZZ_EXTRA_HEADER_DIRS := \
libharfbuzz/hb-ucdn \
#
LIBHARFBUZZ_OPTIMIZATION := HIGH
LIBHARFBUZZ_OPTIMIZATION := HIGH
LIBHARFBUZZ_CFLAGS += $(X_CFLAGS) -DLE_STANDALONE -DHEADLESS
LIBHARFBUZZ_CFLAGS += $(X_CFLAGS) -DLE_STANDALONE -DHEADLESS
$(eval $(call SetupJdkLibrary, BUILD_LIBHARFBUZZ, \
NAME := harfbuzz, \
EXCLUDE_FILES := $(LIBHARFBUZZ_EXCLUDE_FILES), \
TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBHARFBUZZ_CFLAGS), \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBHARFBUZZ_CFLAGS), \
OPTIMIZATION := $(LIBHARFBUZZ_OPTIMIZATION), \
CFLAGS_windows = -DCC_NOEX, \
EXTRA_HEADER_DIRS := $(LIBHARFBUZZ_EXTRA_HEADER_DIRS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := type-limits missing-field-initializers strict-aliasing, \
DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \
$(eval $(call SetupJdkLibrary, BUILD_LIBHARFBUZZ, \
NAME := harfbuzz, \
EXCLUDE_FILES := $(LIBHARFBUZZ_EXCLUDE_FILES), \
TOOLCHAIN := TOOLCHAIN_LINK_CXX, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBHARFBUZZ_CFLAGS), \
CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBHARFBUZZ_CFLAGS), \
OPTIMIZATION := $(LIBHARFBUZZ_OPTIMIZATION), \
CFLAGS_windows = -DCC_NOEX, \
EXTRA_HEADER_DIRS := $(LIBHARFBUZZ_EXTRA_HEADER_DIRS), \
WARNINGS_AS_ERRORS_xlc := false, \
DISABLED_WARNINGS_gcc := type-limits missing-field-initializers strict-aliasing, \
DISABLED_WARNINGS_CXX_gcc := reorder delete-non-virtual-dtor strict-overflow \
maybe-uninitialized class-memaccess, \
DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \
DISABLED_WARNINGS_clang := unused-value incompatible-pointer-types \
tautological-constant-out-of-range-compare int-to-pointer-cast \
undef missing-field-initializers, \
DISABLED_WARNINGS_microsoft := 4267 4244 4090 4146 4334 4819 4101 4068 4805 4138, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
DISABLED_WARNINGS_microsoft := 4267 4244 4090 4146 4334 4819 4101 4068 4805 4138, \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
LDFLAGS_aix := -Wl$(COMMA)-berok, \
LIBS := $(BUILD_LIBHARFBUZZ), \
LIBS_unix := $(LIBM) $(LIBCXX), \
LIBS_macosx := -framework CoreText -framework CoreFoundation -framework CoreGraphics, \
LIBS_windows := user32.lib, \
))
LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \
LDFLAGS_aix := -Wl$(COMMA)-berok, \
LIBS := $(BUILD_LIBHARFBUZZ), \
LIBS_unix := $(LIBM) $(LIBCXX), \
LIBS_macosx := -framework CoreText -framework CoreFoundation -framework CoreGraphics, \
LIBS_windows := user32.lib, \
))
ifeq ($(FREETYPE_TO_USE), bundled)
$(BUILD_LIBHARFBUZZ): $(BUILD_LIBFREETYPE)
endif
TARGETS += $(BUILD_LIBHARFBUZZ)
ifeq ($(FREETYPE_TO_USE), bundled)
$(BUILD_LIBHARFBUZZ): $(BUILD_LIBFREETYPE)
endif
TARGETS += $(BUILD_LIBHARFBUZZ)
###########################################################################
LIBFONTMANAGER_EXTRA_HEADER_DIRS := \
@ -576,7 +581,11 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \
$(WIN_AWT_LIB), \
))
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT) $(BUILD_LIBHARFBUZZ)
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT)
ifeq ($(USE_EXTERNAL_HARFBUZZ), false)
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBHARFBUZZ)
endif
ifeq ($(call isTargetOs, macosx), true)
$(BUILD_LIBFONTMANAGER): $(call FindLib, $(MODULE), awt_lwawt)