Makefile.fetch | 1 RepositoryExternal.mk | 7 ++ config_host.mk.in | 1 configure.ac | 72 ++++++++++++++++++-------- download.lst | 5 + external/Module_external.mk | 1 external/harfbuzz/ExternalProject_harfbuzz.mk | 5 + external/meson/Makefile | 14 +++++ external/meson/Module_meson.mk | 16 +++++ external/meson/README.md | 8 ++ external/meson/UnpackedTarball_meson.mk | 14 +++++ solenv/gbuild/platform/unxgcc.mk | 3 - 12 files changed, 121 insertions(+), 26 deletions(-)
New commits: commit 9430b6549a6bf4b6717530c578796e93c5a43f9a Author: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> AuthorDate: Wed May 7 19:46:13 2025 +0200 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Fri May 9 19:54:07 2025 +0200 use meson as an external when building with fully-internal python people didn't read configure's warnings and systemwide installed copy of meson just causes too many conflicts or even if people read the message they'd still break the idea behind fully-internal python. If the user specifies MESON in autogen.input it will be called as specified, if configure autodetects it, it will be prefixed with the python command used for building. meson requires python 3.7, so if harfbuzz is enabled configure now also now checks for that (can by bypassed by setting PYTHON in autogen.input Change-Id: I6535c9f421fe865b389a87252163ab99d617b7b0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185032 Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> Tested-by: Jenkins diff --git a/Makefile.fetch b/Makefile.fetch index 7c8d45f07a01..332a73fb5d2c 100644 --- a/Makefile.fetch +++ b/Makefile.fetch @@ -209,6 +209,7 @@ $(WORKDIR)/download: $(BUILDDIR)/config_$(gb_Side).mk $(SRCDIR)/download.lst $(S $(call fetch_Optional,MORE_FONTS,FONT_LUGRASIMO_TARBALL) \ $(call fetch_Optional,MORE_FONTS,FONT_LUMANOSIMO_TARBALL) \ $(call fetch_Optional,MORE_FONTS,FONT_LUNASIMA_TARBALL) \ + $(call fetch_Optional,MESON,MESON_TARBALL) \ $(call fetch_Optional,MSPUB,MSPUB_TARBALL) \ $(call fetch_Optional,MWAW,MWAW_TARBALL) \ $(call fetch_Optional,MYTHES,MYTHES_TARBALL) \ diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index ed7e47804b3d..44430a0a2aa3 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -4478,4 +4478,11 @@ gb_LinkTarget__use_yrs := endif +gb_ExternalProject__use_meson := +ifneq (,$(filter MESON,$(BUILD_TYPE))) +define gb_ExternalProject__use_meson +$(call gb_ExternalProject_use_unpacked,$(1),meson) +endef +endif + # vim: set noet sw=4 ts=4: diff --git a/config_host.mk.in b/config_host.mk.in index 70775a16782e..d09ecc519ce3 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -504,7 +504,6 @@ export MDDS_LIBS=$(gb_SPACE)@MDDS_LIBS@ export MERGELIBS=@MERGELIBS@ export MERGELIBS_MORE=@MERGELIBS_MORE@ MESON=@MESON@ -MESON_NO_PYTHON=@MESON_NO_PYTHON@ export ML_EXE=@ML_EXE@ export MOC5=@MOC5@ export MOC6=@MOC6@ diff --git a/configure.ac b/configure.ac index d52460df2b7a..ba731eb6e47d 100644 --- a/configure.ac +++ b/configure.ac @@ -6180,6 +6180,9 @@ if test "$cross_compiling" = "yes"; then # windows uses full-internal python and that in turn relies on openssl, so also enable openssl # when cross-compiling for aarch64, overriding the defaults below test "${PLATFORMID}" = "windows_aarch64" && sub_conf_opts="$sub_conf_opts --enable-openssl --with-tls=openssl" + # cross-compilations don't necessarily enable python support in the product/the sub-configure needs to know + # that the minimum supported python version is 3.7 or later... + test "$with_system_harfbuzz" != "yes" && sub_conf_opts="$sub_conf_opts NEED_MESON=TRUE" # Don't bother having configure look for stuff not needed for the build platform anyway # WARNING: any option with an argument containing spaces must be handled separately (see --with-theme) @@ -10387,7 +10390,7 @@ AC_SUBST(LIBXML_LIBS) AC_SUBST(XMLLINT) # ===================================================================== -# Checking for a Python interpreter with version >= 3.3. +# Checking for a Python interpreter with version >= 3.3 (or 3.7 if the build needs meson) # Optionally user can pass an option to configure, i. e. # ./configure PYTHON=/usr/bin/python # ===================================================================== @@ -10401,7 +10404,12 @@ if test "$build_os" != "cygwin" -a "$enable_python" != fully-internal; then PYTHON_FOR_BUILD=$PYTHON else # This allows a lack of system python with no error, we use internal one in that case. - AM_PATH_PYTHON([3.3],, [:]) + if test "$with_system_harfbuzz" = "yes"; then + AM_PATH_PYTHON([3.3],, [:]) + else + # harfbuzz is built using meson, and current meson requires at least python 3.7 + AM_PATH_PYTHON([3.7],, [:]) + fi # Clean PYTHON_VERSION checked below if cross-compiling PYTHON_VERSION="" if test "$PYTHON" != ":"; then @@ -10443,7 +10451,11 @@ no|disable) # we actually do check anew. AC_MSG_RESULT([]) unset PYTHON am_cv_pathless_PYTHON ac_cv_path_PYTHON am_cv_python_version am_cv_python_platform am_cv_python_pythondir am_cv_python_pyexecdir - AM_PATH_PYTHON([3.3],, [:]) + if test -z "$NEED_MESON"; then + AM_PATH_PYTHON([3.3],, [:]) + else + AM_PATH_PYTHON([3.7],, [:]) + fi AC_MSG_CHECKING([which Python to use for Pyuno]) if test "$PYTHON" = ":"; then if test -z "$PYTHON_FOR_BUILD"; then @@ -10490,7 +10502,13 @@ if test $enable_python = system; then # we actually do check anew. unset PYTHON am_cv_pathless_PYTHON ac_cv_path_PYTHON am_cv_python_version am_cv_python_platform am_cv_python_pythondir am_cv_python_pyexecdir # This causes an error if no python command is found - AM_PATH_PYTHON([3.3]) + # the version found here also sets PYTHON_FOR_BUILD below, so the python picked here + # needs to be suitable for meson/the harfbuzz build + if test -z "$PYTHON_FOR_BUILD" -a "$with_system_harfbuzz" = "yes"; then + AM_PATH_PYTHON([3.7]) + else + AM_PATH_PYTHON([3.3]) + fi python_include=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('INCLUDEPY'));"` python_version=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('VERSION'));"` python_libs=`$PYTHON -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('LIBS'));"` @@ -11537,7 +11555,6 @@ esac libo_CHECK_SYSTEM_MODULE([graphite],[GRAPHITE],[graphite2 >= 0.9.3]) libo_CHECK_SYSTEM_MODULE([harfbuzz],[HARFBUZZ],[harfbuzz-icu >= $harfbuzz_required_version]) -MESON_NO_PYTHON= if test "$with_system_harfbuzz" = "yes"; then if test "$with_system_graphite" = "no"; then AC_MSG_ERROR([--with-system-graphite must be used when --with-system-harfbuzz is used]) @@ -11555,28 +11572,39 @@ else 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_ARG_VAR(MESON, [point to a specific meson to use instead of autodetecting]) + if test -z "$MESON"; then + if test -z "$PYTHON_FOR_BUILD"; then + # we also want to call meson with internal python and use internal meson + BUILD_TYPE="$BUILD_TYPE MESON" + MESON='$(gb_UnpackedTarball_workdir)/meson/meson.py' + else + # autodetect, prefer meson.py / standalone version that can more likely be run + # by different python runtimes + AC_PATH_PROGS(MESON,[meson.py meson],,[$LODE_HOME/packages/meson-1.7.2:$PATH]) + if test -z "$MESON"; then + AC_MSG_WARN([meson not found, using internal copy]) + BUILD_TYPE="$BUILD_TYPE MESON" + MESON='$(gb_UnpackedTarball_workdir)/meson/meson.py' + else + PathFormat "$MESON" + MESON="$formatted_path" + AC_MSG_CHECKING([whether meson can be run with "$PYTHON_FOR_BUILD $MESON"]) + if ($PYTHON_FOR_BUILD $MESON runpython --version >/dev/null) ; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([meson incompatible with the specified python. Try using a different python runtime or a plain release of meson by adding PYTHON=/other/python.version and/or MESON=/path/to/meson.py to autogen.input]) + fi + fi + fi + MESON='$(call gb_ExternalExecutable_get_command,python) '"$MESON" + fi 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 - if test -z "$PYTHON_FOR_BUILD"; then - if test "$(basename $MESON)" = "$(basename -s .py $MESON)"; then - MESON_NO_PYTHON=TRUE - fi - else - AC_MSG_CHECKING([whether meson can be run with "$PYTHON_FOR_BUILD $MESON"]) - if ($PYTHON_FOR_BUILD $MESON --version >/dev/null) ; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - AC_MSG_ERROR([meson incompatible with the specified python. Try using a different python runtime or a plain release of meson by adding PYTHON=/other/python.version and/or MESON=/path/to/meson.py to autogen.input]) - fi - fi fi -AC_SUBST(MESON_NO_PYTHON) if test -z "$NINJA" || test "$NINJA" = 'assumed to be available from Visual Studio'; then x_NINJA=[\#] else diff --git a/download.lst b/download.lst index 1e8434a7eca2..4a6dfdff48e3 100644 --- a/download.lst +++ b/download.lst @@ -496,6 +496,11 @@ MDNSRESPONDER_TARBALL := mDNSResponder-878.200.35.tar.gz # three static lines # so that git cherry-pick # will not run into conflicts +MESON_SHA256SUM := 0a9b23311271519bd03dca12d7d8b0eab582c3a2c5da433d465b6e519dc88e2f +MESON_TARBALL := meson-1.8.0.tar.gz +# three static lines +# so that git cherry-pick +# will not run into conflicts MSPUB_SHA256SUM := ef36c1a1aabb2ba3b0bedaaafe717bf4480be2ba8de6f3894be5fd3702b013ba MSPUB_TARBALL := libmspub-0.1.4.tar.xz # three static lines diff --git a/external/Module_external.mk b/external/Module_external.mk index 6390a3a7d95b..b84568d7e536 100644 --- a/external/Module_external.mk +++ b/external/Module_external.mk @@ -71,6 +71,7 @@ $(eval $(call gb_Module_add_moduledirs,external,\ $(call gb_Helper_optional,MARIADB_CONNECTOR_C,mariadb-connector-c) \ $(call gb_Helper_optional,MDDS,mdds) \ $(call gb_Helper_optional,MDNSRESPONDER,mdnsresponder) \ + $(call gb_Helper_optional,MESON,meson) \ $(call gb_Helper_optional,MORE_FONTS,more_fonts) \ $(call gb_Helper_optional,MSPUB,libmspub) \ $(call gb_Helper_optional,MWAW,libmwaw) \ diff --git a/external/harfbuzz/ExternalProject_harfbuzz.mk b/external/harfbuzz/ExternalProject_harfbuzz.mk index aae898a82fe8..462a807ee5d6 100644 --- a/external/harfbuzz/ExternalProject_harfbuzz.mk +++ b/external/harfbuzz/ExternalProject_harfbuzz.mk @@ -16,6 +16,7 @@ $(eval $(call gb_ExternalProject_register_targets,harfbuzz,\ $(eval $(call gb_ExternalProject_use_externals,harfbuzz,\ icu \ graphite \ + meson \ )) # We cannot use environment vars inside the meson cross-build file, @@ -50,7 +51,7 @@ $(call gb_ExternalProject_get_state_target,harfbuzz,build) : | $(call gb_Externa $(call gb_ExternalProject_run,build,\ PKG_CONFIG_PATH="${PKG_CONFIG_PATH}$(LIBO_PATH_SEPARATOR)$(gb_UnpackedTarball_workdir)/graphite$(if $(SYSTEM_ICU),,$(LIBO_PATH_SEPARATOR)$(gb_UnpackedTarball_workdir)/icu)" \ PYTHONWARNINGS= \ - $(if $(MESON_NO_PYTHON),,$(call gb_ExternalExecutable_get_command,python)) $(MESON) setup builddir \ + $(MESON) setup builddir \ -Ddefault_library=static -Dbuildtype=$(if $(ENABLE_DBGUTIL),debug,$(if $(ENABLE_DEBUG),debugoptimized,release \ $(if $(call gb_Module__symbols_enabled,harfbuzz),$(addsuffix "$(strip $(gb_DEBUGINFO_FLAGS))",-Dc_args= -Dcpp_args=)))) \ -Dauto_features=disabled \ @@ -61,7 +62,7 @@ $(call gb_ExternalProject_get_state_target,harfbuzz,build) : | $(call gb_Externa -Dicu_builtin=true \ -Dgraphite2=enabled \ $(if $(filter-out $(BUILD_PLATFORM),$(HOST_PLATFORM))$(WSL),--cross-file cross-file.txt) && \ - $(if $(MESON_NO_PYTHON),,$(call gb_ExternalExecutable_get_command,python)) $(MESON) compile -C builddir lib \ + $(MESON) compile -C builddir lib \ $(if $(verbose),--verbose) \ ) $(call gb_Trace_EndRange,harfbuzz,EXTERNAL) diff --git a/external/meson/Makefile b/external/meson/Makefile new file mode 100644 index 000000000000..6427d44e3790 --- /dev/null +++ b/external/meson/Makefile @@ -0,0 +1,14 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST)))) + +include $(module_directory)/../../solenv/gbuild/partial_build.mk + +# vim: set noet sw=4 ts=4: diff --git a/external/meson/Module_meson.mk b/external/meson/Module_meson.mk new file mode 100644 index 000000000000..98bbec043764 --- /dev/null +++ b/external/meson/Module_meson.mk @@ -0,0 +1,16 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_Module_Module,meson)) + +$(eval $(call gb_Module_add_targets,meson,\ + UnpackedTarball_meson \ +)) + +# vim: set noet sw=4 ts=4: diff --git a/external/meson/README.md b/external/meson/README.md new file mode 100644 index 000000000000..fd1522eb9148 --- /dev/null +++ b/external/meson/README.md @@ -0,0 +1,8 @@ +Meson build tool + +https://github.com/mesonbuild/meson/ + +using internal copy to ensure it can be called with fully-internal python. +Some distro installed versions of meson cannot be called with different python +runtimes and when not using fully-internal python the whole point of +fully-internal python is invalidated… diff --git a/external/meson/UnpackedTarball_meson.mk b/external/meson/UnpackedTarball_meson.mk new file mode 100644 index 000000000000..30be47b5eeba --- /dev/null +++ b/external/meson/UnpackedTarball_meson.mk @@ -0,0 +1,14 @@ +# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t; fill-column: 100 -*- +# +# This file is part of the LibreOffice project. +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# + +$(eval $(call gb_UnpackedTarball_UnpackedTarball,meson)) + +$(eval $(call gb_UnpackedTarball_set_tarball,meson,$(MESON_TARBALL))) + +# vim: set noet sw=4 ts=4: commit 37af47835ef334e91be37929ee3c519933d9c1bc Author: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> AuthorDate: Fri May 9 15:28:57 2025 +0200 Commit: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> CommitDate: Fri May 9 19:53:56 2025 +0200 fix fully-internal python on linux when cross-compiling the build needs to use the python created for the build side, so follow the windows example Change-Id: I167df5d342529a20da0a94651f4c9c7ec864efc2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185096 Tested-by: Jenkins Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk index f89ddfa584c4..ef6750ed5f38 100644 --- a/solenv/gbuild/platform/unxgcc.mk +++ b/solenv/gbuild/platform/unxgcc.mk @@ -433,7 +433,8 @@ endef gb_UIMenubarTarget_UIMenubarTarget_platform := # Python -gb_Python_PRECOMMAND := PYTHONHOME="$(INSTDIR)/program/python-core-$(PYTHON_VERSION)" PYTHONPATH="$${PYPATH:+$$PYPATH:}$(INSTDIR)/program/python-core-$(PYTHON_VERSION)/lib:$(INSTDIR)/program/python-core-$(PYTHON_VERSION)/lib/lib-dynload" +gb_Python_HOME := $(INSTDIR_FOR_BUILD)/program/python-core-$(PYTHON_VERSION) +gb_Python_PRECOMMAND := PYTHONHOME="$(gb_Python_HOME)" PYTHONPATH="$${PYPATH:+$$PYPATH:}$(gb_Python_HOME)/lib:$(gb_Python_HOME)/lib/lib-dynload" gb_Python_INSTALLED_EXECUTABLE := /bin/sh $(INSTROOT)/program/python # this is passed to gdb as executable when running tests gb_Python_INSTALLED_EXECUTABLE_GDB := $(INSTROOT)/program/python.bin