RepositoryExternal.mk | 22 +++++++++++++++++++ config_host.mk.in | 3 ++ config_host/config_cpdb.h.in | 14 ++++++++++++ configure.ac | 28 +++++++++++++++++++++++++ vcl/Library_vcl.mk | 5 +++- vcl/unx/generic/printer/ppdparser.cxx | 3 +- vcl/unx/generic/printer/printerinfomanager.cxx | 4 +++ 7 files changed, 77 insertions(+), 2 deletions(-)
New commits: commit e702e27795bc32de9c68ed05fd4f3476b8d1ebc2 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Tue Jun 11 07:31:07 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Jun 13 09:23:38 2024 +0200 Handle CPDB lib in configure/build system In preparation of Biswadeep's upcoming GSoC changes (see [1]) to update the CPDB (Common Print Dialog Backends) support to the latest version and use the CPDB C API, add a corresponding `--enable-cpdb` autogen option (disabled by default). When CPDB is enabled, check for the cpdb-frontend library, define `ENABLE_CPDB` and set the compiler and linker flags for building the `CPDManager` (in vcl/unx/generic/printer/cpdmgr.cxx). Add checks for existing code using `CPDBManager`, so it only gets used when when CPDB is actually enabled. While the cpdb-frontend library is currently not actually used in `CPDManager` yet (as the previous approach tried to use some DBUs API directly), it will be in Biswadeep's upcoming changes. With this commit in place, an `--enable-cpdb` build works with this additional local test change in place to actually make use of the library: diff --git a/vcl/unx/generic/printer/cpdmgr.cxx b/vcl/unx/generic/printer/cpdmgr.cxx index 7dc17cede353..0c3b71d519db 100644 --- a/vcl/unx/generic/printer/cpdmgr.cxx +++ b/vcl/unx/generic/printer/cpdmgr.cxx @@ -22,6 +22,8 @@ #include <cstddef> #include <unistd.h> +#include <cpdb/cpdb-frontend.h> + #include <unx/cpdmgr.hxx> #include <osl/file.h> @@ -259,6 +261,7 @@ CPDManager* CPDManager::tryLoadCPD() } } #endif + cpdbPrintFile(nullptr, nullptr); return pManager; } [1] https://lists.freedesktop.org/archives/libreoffice/2024-May/091911.html Change-Id: Ifc50d2cd6496346bea55c73cb703e3c2d3eb44b8 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168656 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Reviewed-by: Biswadeep Purkayastha <bpdp...@hotmail.com> diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk index c72b814b8a07..1b2f147df595 100644 --- a/RepositoryExternal.mk +++ b/RepositoryExternal.mk @@ -2569,6 +2569,28 @@ gb_LinkTarget__use_avahi := endif # ENABLE_AVAHI +ifeq ($(ENABLE_CPDB),TRUE) + +define gb_LinkTarget__use_cpdb +$(call gb_LinkTarget_set_include,$(1),\ + $$(INCLUDE) \ + $(CPDB_CFLAGS) \ +) + +$(call gb_LinkTarget_add_libs,$(1),\ + $(CPDB_LIBS) \ +) + +endef + +else # ENABLE_CPDB + +define gb_LinkTarget__use_cpdb + +endef + +endif # ENABLE_CPDB + ifeq ($(ENABLE_CUPS),TRUE) define gb_LinkTarget__use_cups diff --git a/config_host.mk.in b/config_host.mk.in index 787a1e629c43..b9a7cbfb4cae 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -93,6 +93,8 @@ export COMPILER_PLUGINS_TOOLING_ARGS=@COMPILER_PLUGINS_TOOLING_ARGS@ export COMPRESSIONTOOL=@COMPRESSIONTOOL@ export COM_IS_CLANG=@COM_IS_CLANG@ export COREDUMPCTL=@COREDUMPCTL@ +export CPDB_CFLAGS=@CPDB_CFLAGS@ +export CPDB_LIBS=@CPDB_LIBS@ export CPPU_ENV=@CPPU_ENV@ export CPPU_ENV_FOR_BUILD=@CPPU_ENV_FOR_BUILD@ export CPPUNIT_CFLAGS=$(gb_SPACE)@CPPUNIT_CFLAGS@ @@ -159,6 +161,7 @@ SYSTEM_COINMP=@SYSTEM_COINMP@ export COINMP_CFLAGS=@COINMP_CFLAGS@ export COINMP_LIBS=@COINMP_LIBS@ export ENABLE_ATSPI_TESTS=@ENABLE_ATSPI_TESTS@ +export ENABLE_CPDB=@ENABLE_CPDB@ export ENABLE_CUPS=@ENABLE_CUPS@ export ENABLE_CURL=@ENABLE_CURL@ export ENABLE_DBGUTIL=@ENABLE_DBGUTIL@ diff --git a/config_host/config_cpdb.h.in b/config_host/config_cpdb.h.in new file mode 100644 index 000000000000..9a3aca17452b --- /dev/null +++ b/config_host/config_cpdb.h.in @@ -0,0 +1,14 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * 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/. + */ + +#pragma once + +#define ENABLE_CPDB 0 + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/configure.ac b/configure.ac index 55416d77adf7..f59128e84d61 100644 --- a/configure.ac +++ b/configure.ac @@ -1215,6 +1215,7 @@ if test -z "$using_x11" -o -z "$using_freetype_fontconfig"; then fi # Set defaults, if not set by platform +test "${test_cpdb+set}" = set || test_cpdb="$using_x11" test "${test_cups+set}" = set || test_cups="$using_x11" test "${test_dbus+set}" = set || test_dbus="$using_x11" test "${test_gen+set}" = set || test_gen="$using_x11" @@ -1246,6 +1247,7 @@ test "$using_freetype_fontconfig" = yes && test_cairo=yes # Keep in sync with the above $using_x11 depending test default list disable_x11_tests() { + test_cpdb=no test_cups=no test_dbus=no test_gen=no @@ -1900,6 +1902,11 @@ AC_ARG_ENABLE(ld, needed for Clang 12).]), ,) +AC_ARG_ENABLE(cpdb, + AS_HELP_STRING([--enable-cpdb], + [Build CPDB (Common Print Dialog Backends) support.]), +,) + libo_FUZZ_ARG_ENABLE(cups, AS_HELP_STRING([--disable-cups], [Do not build cups support.]) @@ -6290,6 +6297,26 @@ else fi AC_SUBST(ENABLE_PAGEIN) + +AC_MSG_CHECKING([whether to enable CPDB support]) +ENABLE_CPDB="" +CPDB_CFLAGS="" +CPDB_LIBS="" +if test "$test_cpdb" = yes -a "x$enable_cpdb" = "xyes"; then + ENABLE_CPDB="TRUE" + AC_MSG_RESULT([yes]) + PKG_CHECK_MODULES(CPDB, cpdb-frontend) + CPDB_CFLAGS=$(printf '%s' "$CPDB_CFLAGS" | sed -e "s/-I/${ISYSTEM?}/g") + FilterLibs "${CPDB_LIBS}" + CPDB_LIBS="${filteredlibs}" + AC_DEFINE([ENABLE_CPDB],[1]) +else + AC_MSG_RESULT([no]) +fi +AC_SUBST(ENABLE_CPDB) +AC_SUBST(CPDB_LIBS) +AC_SUBST(CPDB_CFLAGS) + dnl =================================================================== dnl check for cups support dnl =================================================================== @@ -15560,6 +15587,7 @@ AC_CONFIG_HEADERS([config_host/config_buildconfig.h]) AC_CONFIG_HEADERS([config_host/config_buildid.h]) AC_CONFIG_HEADERS([config_host/config_box2d.h]) AC_CONFIG_HEADERS([config_host/config_clang.h]) +AC_CONFIG_HEADERS([config_host/config_cpdb.h]) AC_CONFIG_HEADERS([config_host/config_crypto.h]) AC_CONFIG_HEADERS([config_host/config_dconf.h]) AC_CONFIG_HEADERS([config_host/config_eot.h]) diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk index a92d6281e0b0..361d55a0ae2c 100644 --- a/vcl/Library_vcl.mk +++ b/vcl/Library_vcl.mk @@ -578,7 +578,9 @@ ifeq ($(USING_X11),TRUE) $(eval $(call gb_Library_add_exception_objects,vcl,\ vcl/unx/generic/desktopdetect/desktopdetector \ vcl/unx/generic/window/sessioninhibitor \ - vcl/unx/generic/printer/cpdmgr \ + $(if $(ENABLE_CPDB), \ + vcl/unx/generic/printer/cpdmgr \ + ) \ )) $(eval $(call gb_Library_use_externals,vcl,\ @@ -644,6 +646,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\ $(eval $(call gb_Library_use_externals,vcl,\ $(if $(USE_HEADLESS_CODE), \ cairo \ + $(if $(ENABLE_CPDB),cpdb) \ $(if $(ENABLE_CUPS),cups) \ fontconfig \ freetype \ diff --git a/vcl/unx/generic/printer/ppdparser.cxx b/vcl/unx/generic/printer/ppdparser.cxx index c869765c8767..12be50e7a685 100644 --- a/vcl/unx/generic/printer/ppdparser.cxx +++ b/vcl/unx/generic/printer/ppdparser.cxx @@ -18,6 +18,7 @@ */ #include <sal/config.h> +#include <config_cpdb.h> #include <stdlib.h> @@ -569,7 +570,7 @@ const PPDParser* PPDParser::getParser( const OUString& rFile ) #endif } else if ( rMgr.getType() == PrinterInfoManager::Type::CPD ) { -#if ENABLE_DBUS && ENABLE_GIO +#if ENABLE_CPDB pNewParser = const_cast<PPDParser*>(static_cast<CPDManager&>(rMgr).createCPDParser( aFile )); #endif } diff --git a/vcl/unx/generic/printer/printerinfomanager.cxx b/vcl/unx/generic/printer/printerinfomanager.cxx index da4818195a8e..2b9eb6aef70a 100644 --- a/vcl/unx/generic/printer/printerinfomanager.cxx +++ b/vcl/unx/generic/printer/printerinfomanager.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <config_cpdb.h> + #include <unx/cpdmgr.hxx> #include <unx/cupsmgr.hxx> #include <unx/gendata.hxx> @@ -81,7 +83,9 @@ PrinterInfoManager& PrinterInfoManager::get() if (pPIM) return *pPIM; +#if ENABLE_CPDB pPIM = CPDManager::tryLoadCPD(); +#endif if (!pPIM) pPIM = CUPSManager::tryLoadCUPS(); if (!pPIM)