harfbuzz: migrate to meson

Change-Id: I33aa7ca814409b39b9adb7da1d168c5ebb11b14d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183345
Reviewed-by: Khaled Hosny <khaled@libreoffice.org>
Tested-by: Jenkins
This commit is contained in:
Christian Lohmaier 2025-04-08 12:19:31 +02:00 committed by Khaled Hosny
parent 233539764f
commit ae24fc8c63
17 changed files with 94 additions and 129 deletions

View File

@ -503,6 +503,7 @@ export MDDS_CFLAGS=$(gb_SPACE)@MDDS_CFLAGS@
export MDDS_LIBS=$(gb_SPACE)@MDDS_LIBS@
export MERGELIBS=@MERGELIBS@
export MERGELIBS_MORE=@MERGELIBS_MORE@
MESON=@MESON@
export ML_EXE=@ML_EXE@
export MOC5=@MOC5@
export MOC6=@MOC6@

View File

@ -999,6 +999,8 @@ cygwin*|wsl*)
DLLPOST=".dll"
LINKFLAGSNOUNDEFS=
# bypass check for ninja, it is not in default path, but it can be used nevertheless by default
NINJA="assumed to be available from Visual Studio"
if test "$host_cpu" = "aarch64"; then
build_skia=yes
@ -4102,7 +4104,7 @@ cygwin*|wsl*)
COM=MSC
OS=WNT
RTL_OS=Windows
if test "$GNUMAKE_WIN_NATIVE" = "TRUE" ; then
if test "$GNUMAKE_WIN_NATIVE" = "TRUE" -o -n "$WSL_ONLY_AS_HELPER" ; then
P_SEP=";"
else
P_SEP=:
@ -6935,9 +6937,10 @@ fi
dnl ===================================================================
dnl Check for pkg-config
dnl ===================================================================
if test "$_os" != "WINNT"; then
PKG_PROG_PKG_CONFIG
fi
# pkgconf/pkg-config detection is already triggered by the configure switches way above
# (more specifically PKG_CHECK_MODULES), so only do some cleanup of the vars here
PathFormat "$(command -v $PKG_CONFIG)"
PKG_CONFIG="$formatted_path"
AC_SUBST(PKG_CONFIG)
AC_SUBST(PKG_CONFIG_PATH)
AC_SUBST(PKG_CONFIG_LIBDIR)
@ -6979,7 +6982,11 @@ if test $_os = Darwin; then
if test "$enable_bogus_pkg_config" = "yes"; then
AC_MSG_RESULT([yes, user-approved from unknown origin.])
else
AC_MSG_ERROR([yes, from unknown origin. This *will* break the build. Please modify your PATH variable so that $PKG_CONFIG is no longer found by configure scripts.])
if test -z "$($PKG_CONFIG --list-all |grep -v '^libpkgconf')" ; then
AC_MSG_RESULT([yes, accepted since no packages available in default searchpath])
else
AC_MSG_ERROR([yes, from unknown origin. This *will* break the build. Please modify your PATH variable so that $PKG_CONFIG is no longer found by configure scripts.])
fi
fi
fi
else
@ -11417,11 +11424,11 @@ HARFBUZZ_CFLAGS_internal="-I${WORKDIR}/UnpackedTarball/harfbuzz/src"
case "$_os" in
Linux)
GRAPHITE_LIBS_internal='$(gb_StaticLibrary_WORKDIR)/libgraphite.a'
HARFBUZZ_LIBS_internal="${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs/libharfbuzz.a"
HARFBUZZ_LIBS_internal="${WORKDIR}/UnpackedTarball/harfbuzz/builddir/src/libharfbuzz.a"
;;
*)
GRAPHITE_LIBS_internal='-L$(gb_StaticLibrary_WORKDIR) -lgraphite'
HARFBUZZ_LIBS_internal="-L${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs -lharfbuzz"
HARFBUZZ_LIBS_internal="-L${WORKDIR}/UnpackedTarball/harfbuzz/builddir/src/ -lharfbuzz"
;;
esac
libo_CHECK_SYSTEM_MODULE([graphite],[GRAPHITE],[graphite2 >= 0.9.3])
@ -11429,7 +11436,7 @@ libo_CHECK_SYSTEM_MODULE([harfbuzz],[HARFBUZZ],[harfbuzz-icu >= $harfbuzz_requir
if test "$COM" = "MSC"; then # override the above
GRAPHITE_LIBS='$(gb_StaticLibrary_WORKDIR)/graphite.lib'
HARFBUZZ_LIBS="${WORKDIR}/UnpackedTarball/harfbuzz/src/.libs/libharfbuzz.lib"
HARFBUZZ_LIBS='$(gb_UnpackedTarball_workdir)/harfbuzz/builddir/src/libharfbuzz.a $(GRAPHITE_LIBS)'
fi
if test "$with_system_harfbuzz" = "yes"; then
@ -11448,6 +11455,14 @@ else
if test "$with_system_graphite" = "yes"; then
AC_MSG_ERROR([--without-system-graphite must be used when --without-system-harfbuzz is used])
fi
# harfbuzz is now built using meson
AC_PATH_PROGS(MESON,[meson.py meson],,[$LODE_HOME/packages/meson-1.7.2:$PATH])
PathFormat "$MESON"
MESON="$formatted_path"
AC_CHECK_PROG(NINJA,ninja,ninja)
if test -z "$MESON" -o -z "$NINJA"; then
AC_MSG_ERROR([you need to have meson and ninja in order to build harfbuzz])
fi
fi
if test "$USING_X11" = TRUE; then

View File

@ -4,3 +4,4 @@
--enable-optimized
--enable-odk
--disable-online-update
PKG_CONFIG=pkgconf

View File

@ -3,3 +3,4 @@
--disable-dependency-tracking
--enable-odk
--disable-online-update
PKG_CONFIG=pkgconf-2.4.3.exe

View File

@ -10,3 +10,4 @@
--with-package-format=dmg
--enable-odk
--enable-mergelibs=more
PKG_CONFIG=pkgconf

View File

@ -14,3 +14,4 @@
--enable-mergelibs
--enable-lto
--enable-odk
PKG_CONFIG=pkgconf-2.4.3.exe

View File

@ -15,3 +15,4 @@
--enable-mergelibs=more
--enable-lto
--enable-odk
PKG_CONFIG=pkgconf-2.4.3.exe

View File

@ -13,3 +13,4 @@
--enable-mergelibs
--enable-lto
--enable-odk
PKG_CONFIG=pkgconf-2.4.3.exe

View File

@ -76,4 +76,6 @@ $(eval $(call gb_StaticLibrary_add_generated_exception_objects,graphite,\
UnpackedTarball/graphite/src/UtfCodec \
))
$(call gb_StaticLibrary_get_target,graphite): $(gb_UnpackedTarball_workdir)/graphite/graphite2-uninstalled.pc
# vim: set noet sw=4 ts=4:

View File

@ -18,4 +18,9 @@ $(eval $(call gb_UnpackedTarball_add_patches,graphite, \
external/graphite/enumarith.patch \
))
# cannot use post_action since $(file ..) would be run when the recipe is parsed, i.e. would always
# happen before the tarball is unpacked
$(gb_UnpackedTarball_workdir)/graphite/graphite2-uninstalled.pc: $(call gb_UnpackedTarball_get_target,graphite)
$(file >$@,$(call gb_pkgconfig_file,graphite2,1.3.14,$(GRAPHITE_CFLAGS),$(GRAPHITE_LIBS)))
# vim: set noet sw=4 ts=4:

View File

@ -9,8 +9,6 @@
$(eval $(call gb_ExternalProject_ExternalProject,harfbuzz))
$(eval $(call gb_ExternalProject_use_autoconf,harfbuzz,build))
$(eval $(call gb_ExternalProject_register_targets,harfbuzz,\
build \
))
@ -20,37 +18,47 @@ $(eval $(call gb_ExternalProject_use_externals,harfbuzz,\
graphite \
))
$(call gb_ExternalProject_get_state_target,harfbuzz,build) :
# We cannot use environment vars inside the meson cross-build file,
# so we're going to have to generate one on-the-fly.
# mungle variables into python list format
cross_c = '$(subst $(WHITESPACE),'$(COMMA)',$(strip $(gb_CC)))'
cross_cxx = '$(subst $(WHITESPACE),'$(COMMA)',$(strip $(gb_CXX)))'
define gb_harfbuzz_cross_compile
[binaries]
c = [$(cross_c)]
cpp = [$(cross_cxx)]
c_ld = [$(subst cl.exe,link.exe,$(cross_c))]
cpp_ld = [$(subst cl.exe,link.exe,$(cross_c))]
ar = '$(AR)'
strip = '$(STRIP)'
# TODO: this is pretty ugly...
[host_machine]
system = '$(if $(filter WNT,$(OS)),windows,$(if $(filter MACOSX,$(OS)),darwin,$(if $(filter ANDROID,$(OS)),android,linux)))'
cpu_family = '$(RTL_ARCH)'
cpu = '$(if $(filter x86,$(RTL_ARCH)),i686,$(if $(filter X86_64,$(RTL_ARCH)),x86_64,$(if $(filter AARCH64,$(RTL_ARCH)),aarch64,armv7)))'
endian = '$(ENDIANNESS)'
endef
# cannot use CROSS_COMPILING as condition since we have cross-compilation "light" for cases where
# the builder can run the host binaries, like for example when compiling for win 32bit on win 64bit
$(call gb_ExternalProject_get_state_target,harfbuzz,build) : | $(call gb_ExternalExecutable_get_dependencies,python)
$(call gb_Trace_StartRange,harfbuzz,EXTERNAL)
$(file >$(gb_UnpackedTarball_workdir)/harfbuzz/cross-file.txt,$(gb_harfbuzz_cross_compile))
$(call gb_ExternalProject_run,build,\
$(if $(CROSS_COMPILING),ICU_CONFIG=$(SRCDIR)/external/icu/cross-bin/icu-config) \
$(if $(SYSTEM_ICU),,ICU_CONFIG=$(SRCDIR)/external/icu/cross-bin/icu-config) \
GRAPHITE2_CFLAGS="$(GRAPHITE_CFLAGS)" \
GRAPHITE2_LIBS="$(GRAPHITE_LIBS)" \
$(gb_RUN_CONFIGURE) ./configure \
--enable-static \
--disable-shared \
--disable-gtk-doc \
--with-pic \
--with-icu=builtin \
--with-freetype=no \
--with-fontconfig=no \
--with-cairo=no \
--with-glib=no \
--with-graphite2=yes \
$(if $(verbose),--disable-silent-rules,--enable-silent-rules) \
$(if $(gb_FULLDEPS),,--disable-dependency-tracking) \
--libdir=$(gb_UnpackedTarball_workdir)/harfbuzz/src/.libs \
$(gb_CONFIGURE_PLATFORMS) \
CXXFLAGS=' \
$(if $(filter ANDROID,$(OS)),-DHB_NO_MMAP=1,) \
$(call gb_ExternalProject_get_build_flags,harfbuzz) \
$(if $(ENABLE_RUNTIME_OPTIMIZATIONS),,-frtti) \
$(CXXFLAGS) $(CXXFLAGS_CXX11) \
$(if $(filter LINUX,$(OS)),-fvisibility=hidden)' \
LDFLAGS="$(call gb_ExternalProject_get_link_flags,harfbuzz)" \
MAKE=$(MAKE) \
&& (cd $(EXTERNAL_WORKDIR)/src && $(MAKE) lib) \
PKG_CONFIG_PATH="${PKG_CONFIG_PATH}$(LIBO_PATH_SEPARATOR)$(gb_UnpackedTarball_workdir)/graphite$(if $(SYSTEM_ICU),,$(LIBO_PATH_SEPARATOR)$(gb_UnpackedTarball_workdir)/icu)" \
PYTHONWARNINGS= \
$(call gb_ExternalExecutable_get_command,python) $(MESON) setup builddir \
-Ddefault_library=static -Dbuildtype=$(if $(ENABLE_DEBUG),debug,release) \
-Dauto_features=disabled \
-Dcpp_std=$(subst -std:,,$(subst -std=,,$(filter -std%,$(CXXFLAGS_CXX11)))) \
-Dtests=disabled \
-Dutilities=disabled \
-Dicu=enabled \
-Dicu_builtin=true \
-Dgraphite2=enabled \
$(if $(filter-out $(BUILD_PLATFORM),$(HOST_PLATFORM))$(WSL),--cross-file cross-file.txt) && \
$(call gb_ExternalExecutable_get_command,python) $(MESON) compile -C builddir lib \
$(if $(verbose),--verbose) \
)
$(call gb_Trace_EndRange,harfbuzz,EXTERNAL)

View File

@ -17,7 +17,6 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,harfbuzz,0))
$(eval $(call gb_UnpackedTarball_add_patches,harfbuzz, \
external/harfbuzz/tdf159529.patch.0 \
external/harfbuzz/icu_75.patch.0 \
))
# vim: set noet sw=4 ts=4:

View File

@ -1,88 +0,0 @@
--- configure 2024-06-12 16:35:18.736933604 +0200
+++ configure 2024-06-12 16:57:39.544214075 +0200
@@ -22533,7 +22362,83 @@
fi
if $have_icu; then
- CXXFLAGS="$CXXFLAGS `$PKG_CONFIG --variable=CXXFLAGS icu-uc`"
+ is_icu75=false
+
+pkg_failed=no
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for icu-uc >= 75.1" >&5
+printf %s "checking for icu-uc >= 75.1... " >&6; }
+
+if test -n "$ICU_CFLAGS"; then
+ pkg_cv_ICU_CFLAGS="$ICU_CFLAGS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"icu-uc >= 75.1\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "icu-uc >= 75.1") 2>&5
+ ac_status=$?
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_ICU_CFLAGS=`$PKG_CONFIG --cflags "icu-uc >= 75.1" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+if test -n "$ICU_LIBS"; then
+ pkg_cv_ICU_LIBS="$ICU_LIBS"
+ elif test -n "$PKG_CONFIG"; then
+ if test -n "$PKG_CONFIG" && \
+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"icu-uc >= 75.1\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "icu-uc >= 75.1") 2>&5
+ ac_status=$?
+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ pkg_cv_ICU_LIBS=`$PKG_CONFIG --libs "icu-uc >= 75.1" 2>/dev/null`
+ test "x$?" != "x0" && pkg_failed=yes
+else
+ pkg_failed=yes
+fi
+ else
+ pkg_failed=untried
+fi
+
+
+
+if test $pkg_failed = yes; then
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+ _pkg_short_errors_supported=yes
+else
+ _pkg_short_errors_supported=no
+fi
+ if test $_pkg_short_errors_supported = yes; then
+ ICU_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "icu-uc >= 75.1" 2>&1`
+ else
+ ICU_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "icu-uc >= 75.1" 2>&1`
+ fi
+ # Put the nasty error message in config.log where it belongs
+ echo "$ICU_PKG_ERRORS" >&5
+
+ :
+elif test $pkg_failed = untried; then
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+ :
+else
+ ICU_CFLAGS=$pkg_cv_ICU_CFLAGS
+ ICU_LIBS=$pkg_cv_ICU_LIBS
+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+ is_icu75=true
+fi
+ if $is_icu75; then
+ CXXFLAGS="$CXXFLAGS `$PKG_CONFIG --variable=CXXFLAGS -std=c++17 icu-uc`"
+ else
+ CXXFLAGS="$CXXFLAGS `$PKG_CONFIG --variable=CXXFLAGS icu-uc`"
+ fi
printf "%s\n" "#define HAVE_ICU 1" >>confdefs.h

View File

@ -15,6 +15,8 @@ $(eval $(call gb_ExternalProject_register_targets,icu,\
icu_CPPFLAGS:="-DHAVE_GCC_ATOMICS=$(if $(filter TRUE,$(GCC_HAVE_BUILTIN_ATOMIC)),1,0)"
$(call gb_ExternalProject_get_state_target,icu,build) : $(gb_UnpackedTarball_workdir)/icu/icu-uc-uninstalled.pc
ifeq ($(OS),WNT)
$(call gb_ExternalProject_get_state_target,icu,build) :

View File

@ -44,4 +44,9 @@ $(eval $(call gb_UnpackedTarball_add_patches,icu,\
$(eval $(call gb_UnpackedTarball_add_file,icu,source/data/brkitr/khmerdict.dict,external/icu/khmerdict.dict))
# cannot use post_action since $(file ..) would be run when the recipe is parsed, i.e. would always
# happen before the tarball is unpacked
$(gb_UnpackedTarball_workdir)/icu/icu-uc-uninstalled.pc: $(call gb_UnpackedTarball_get_target,icu)
$(file >$@,$(call gb_pkgconfig_file,icu-uc,$(ICU_MAJOR).$(ICU_MINOR),$(ICU_CFLAGS),$(ICU_LIBS)))
# vim: set noet sw=4 ts=4:

View File

@ -387,4 +387,14 @@ $(if $(gb_QUIET_EXTERNAL), \
( $(1) ))
endef
# call gb_pkgconfig_file,name,version,cflags,libs[,additional-lines]
define gb_pkgconfig_file
Name: $(1)
Description: dummy pkg-config file for $(1)
Version: $(2)
Cflags: $(3)
Libs: $(4)
$(5)
endef
# vim: set noet sw=4 ts=4:

View File

@ -739,7 +739,7 @@ gb_UIMenubarTarget_UIMenubarTarget_platform :=
# Python
gb_Python_HOME := $(INSTDIR_FOR_BUILD)/program/python-core-$(PYTHON_VERSION)
gb_Python_PRECOMMAND := PATH="$(shell cygpath -w $(INSTDIR_FOR_BUILD)/program)" PYTHONHOME="$(gb_Python_HOME)" PYTHONPATH="$${PYPATH:+$$PYPATH;}$(gb_Python_HOME)/lib;$(gb_Python_HOME)/lib/lib-dynload:$(INSTDIR_FOR_BUILD)/program"
gb_Python_PRECOMMAND := PATH="$(shell cygpath -u $(INSTDIR_FOR_BUILD)/program):$(shell cygpath.exe -uS)" PYTHONHOME="$(gb_Python_HOME)" PYTHONPATH="$${PYPATH:+$$PYPATH;}$(gb_Python_HOME)/lib;$(gb_Python_HOME)/lib/lib-dynload:$(INSTDIR_FOR_BUILD)/program"
gb_Python_INSTALLED_EXECUTABLE := $(INSTROOT_FOR_BUILD)/$(LIBO_BIN_FOLDER)/python.exe
gb_ICU_PRECOMMAND := PATH="$(shell cygpath -w $(WORKDIR_FOR_BUILD)/UnpackedTarball/icu/source/lib)"