diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2020-12-29 11:42:30 +0100 |
---|---|---|
committer | Thorsten Behrens <thorsten.behrens@allotropia.de> | 2021-04-16 15:31:50 +0200 |
commit | cfe493051ce09291fcab222876b33211c76a3e53 (patch) | |
tree | 20084c418fadf8d225134058b657d9eb6888d9bf | |
parent | 79f0e289175e449405c98cb51151e2fa7a7750f6 (diff) |
gbuild: introduce plugin (loader) concept
This introduces two concepts: a plugin and its loader (library)
LO currrently has dependency cycles for some libraries. There is
scui, which depends on sc, while sc dlopen's scui. There are the
various vclplug_* and the filters/gie libraries, which depends on
vcl and vcl dlopen's them. While the dependcies of the plugins on
their loader works fine, for static builds you must add a
dependency from the loader to the plugins, which introduces a
dependency cycle.
I codeified a few rules into the build system along with it:
* just plugins are allowed to depend / link other plugins
* plugins aren't allowed to be linked into the merge lib
* plugin loaders are "limited" to libraries
At the high level, this is implemented via two new gbuild calls:
* gb_Library_set_plugin_for,lib,loader: declare a library to be a
plugin of a loader library
* gb_Helper_register_plugins_for_install: "plugin" replacement for
gb_Helper_register_libraries_for_install to implement some
additional checks in the build system
For the shared build, nothing changes. gb_Library_set_plugin_for is
just forwarded to gb_LinkTarget__use_libraries.
P.S. Android and iOS don't build their "executables" using gbuild,
but call bin/lo-all-static-libs to "let the linker figure it out".
P.P.S. the static handling isn't implemented in this commit, as it
turned out to be (very) much more complex.
Change-Id: I7b01d9c384cbc5838bd2cc93aff18e4868939d6e
-rw-r--r-- | Repository.mk | 47 | ||||
-rw-r--r-- | sc/Library_scui.mk | 3 | ||||
-rw-r--r-- | sd/Library_sdui.mk | 3 | ||||
-rw-r--r-- | solenv/gbuild/Helper.mk | 7 | ||||
-rw-r--r-- | solenv/gbuild/Library.mk | 12 | ||||
-rw-r--r-- | solenv/gbuild/LinkTarget.mk | 36 | ||||
-rw-r--r-- | sw/Library_swui.mk | 3 | ||||
-rw-r--r-- | vcl/Library_vclplug_gen.mk | 3 | ||||
-rw-r--r-- | vcl/Library_vclplug_gtk3.mk | 3 | ||||
-rw-r--r-- | vcl/Library_vclplug_gtk3_kde5.mk | 3 | ||||
-rw-r--r-- | vcl/Library_vclplug_kf5.mk | 3 | ||||
-rw-r--r-- | vcl/Library_vclplug_osx.mk | 3 | ||||
-rw-r--r-- | vcl/Library_vclplug_qt5.mk | 3 | ||||
-rw-r--r-- | vcl/Library_vclplug_win.mk | 3 |
14 files changed, 105 insertions, 27 deletions
diff --git a/Repository.mk b/Repository.mk index 74b3967ca05b..7607fb1a5d12 100644 --- a/Repository.mk +++ b/Repository.mk @@ -252,12 +252,15 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,calc, \ sc \ scd \ scfilt \ - scui \ wpftcalc \ solver \ $(call gb_Helper_optional,SCRIPTING,vbaobj) \ )) +$(eval $(call gb_Helper_register_plugins_for_install,OOOLIBS,calc, \ + scui \ +)) + $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,graphicfilter, \ svgfilter \ wpftdraw \ @@ -280,19 +283,26 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,onlineupdate, \ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,gnome, \ $(if $(ENABLE_EVOAB2),evoab) \ - $(if $(ENABLE_GTK3),vclplug_gtk3) \ $(if $(ENABLE_GIO),losessioninstall) \ $(if $(ENABLE_GIO),ucpgio1) \ )) +$(eval $(call gb_Helper_register_plugins_for_install,OOOLIBS,gnome, \ + $(if $(ENABLE_GTK3),vclplug_gtk3) \ +)) + $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,kde, \ $(if $(ENABLE_KF5),kf5be1) \ - $(if $(USING_X11), \ - $(if $(ENABLE_KF5),vclplug_kf5) \ - $(if $(ENABLE_QT5),vclplug_qt5) \ - $(if $(ENABLE_GTK3_KDE5),vclplug_gtk3_kde5) \ - ) \ )) + +ifneq (,$(USING_X11)) +$(eval $(call gb_Helper_register_plugins_for_install,OOOLIBS,kde, \ + $(if $(ENABLE_KF5),vclplug_kf5) \ + $(if $(ENABLE_QT5),vclplug_qt5) \ + $(if $(ENABLE_GTK3_KDE5),vclplug_gtk3_kde5) \ +)) +endif + ifneq ($(ENABLE_GTK3_KDE5),) $(eval $(call gb_Helper_register_executables_for_install,OOO,kde, \ lo_kde5filepicker \ @@ -300,7 +310,7 @@ $(eval $(call gb_Helper_register_executables_for_install,OOO,kde, \ endif ifeq ($(OS),HAIKU) -$(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,haiku, \ +$(eval $(call gb_Helper_register_plugins_for_install,OOOLIBS,haiku, \ $(if $(ENABLE_QT5),vclplug_qt5) \ $(if $(ENABLE_KF5),vclplug_kf5) \ )) @@ -406,7 +416,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ sd \ sdd \ sdfilt \ - sdui \ sfx \ simplecanvas \ slideshow \ @@ -451,14 +460,10 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ xof \ xsltdlg \ xsltfilter \ - $(if $(USING_X11), \ - vclplug_gen \ - ) \ $(if $(filter $(OS),WNT), \ ado \ oleautobridge \ smplmail \ - vclplug_win \ wininetbe1 \ ) \ $(if $(filter $(OS),MACOSX), \ @@ -466,12 +471,19 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \ AppleRemote \ ) \ fps_aqua \ - vclplug_osx \ ) \ $(if $(filter iOS MACOSX,$(OS)), \ MacOSXSpell \ ) \ - $(if $(filter EMSCRIPTEN,$(OS)),vclplug_qt5) \ +)) + +$(eval $(call gb_Helper_register_plugins_for_install,OOOLIBS,ooo, \ + gie \ + sdui \ + $(if $(USING_X11),vclplug_gen) \ + $(if $(filter $(OS),WNT),vclplug_win) \ + $(if $(filter $(OS),MACOSX),vclplug_osx) \ + $(if $(filter EMSCRIPTEN,$(OS)),vclplug_qt5) \ )) $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,postgresqlsdbc, \ @@ -510,7 +522,6 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,writer, \ $(if $(ENABLE_LWP),lwpft) \ msword \ swd \ - swui \ t602filter \ $(call gb_Helper_optional,SCRIPTING,vbaswobj) \ wpftwriter \ @@ -518,6 +529,10 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,writer, \ $(call gb_Helper_optional,DBCONNECTIVITY,writer) \ )) +$(eval $(call gb_Helper_register_plugins_for_install,OOOLIBS,writer, \ + swui \ +)) + # cli_cppuhelper is NONE even though it is actually in URE because it is CliNativeLibrary $(eval $(call gb_Helper_register_libraries,PLAINLIBS_NONE, \ smoketest \ diff --git a/sc/Library_scui.mk b/sc/Library_scui.mk index 86605ab63a0d..4d4cffa12bd4 100644 --- a/sc/Library_scui.mk +++ b/sc/Library_scui.mk @@ -9,6 +9,8 @@ $(eval $(call gb_Library_Library,scui)) +$(eval $(call gb_Library_set_plugin_for,scui,sc)) + $(eval $(call gb_Library_set_include,scui,\ -I$(SRCDIR)/sc/source/core/inc \ -I$(SRCDIR)/sc/source/filter/inc \ @@ -55,7 +57,6 @@ $(eval $(call gb_Library_use_libraries,scui,\ $(call gb_Helper_optional,OPENCL, \ opencl) \ sal \ - sc \ sfx \ sot \ svl \ diff --git a/sd/Library_sdui.mk b/sd/Library_sdui.mk index c776e2eed532..a774d0610cb4 100644 --- a/sd/Library_sdui.mk +++ b/sd/Library_sdui.mk @@ -9,6 +9,8 @@ $(eval $(call gb_Library_Library,sdui)) +$(eval $(call gb_Library_set_plugin_for,sdui,sd)) + $(eval $(call gb_Library_set_include,sdui,\ $$(INCLUDE) \ -I$(SRCDIR)/sd/inc \ @@ -49,7 +51,6 @@ $(eval $(call gb_Library_use_libraries,sdui,\ fwk \ sal \ salhelper \ - sd \ sfx \ sot \ svl \ diff --git a/solenv/gbuild/Helper.mk b/solenv/gbuild/Helper.mk index 2aa0fc8d65b2..2367a8ba9a91 100644 --- a/solenv/gbuild/Helper.mk +++ b/solenv/gbuild/Helper.mk @@ -199,6 +199,13 @@ $(if $(filter UNOVERLIBS RTVERLIBS,$(1)),\ endef +# a plugin is a library, why can't be dynamically linked and must be dlopen'd, but must be linked static +define gb_Helper_register_plugins_for_install +$(call gb_Helper_register_libraries_for_install,$(1),$(2),$(3)) +gb_Library_KNOWNPLUGINS += $(3) + +endef + define gb_Helper__register_jars $(foreach group,$(gb_Jar_VALIDGROUPS),\ $(foreach target,$(2),\ diff --git a/solenv/gbuild/Library.mk b/solenv/gbuild/Library.mk index 8c3c2207480d..8883262025af 100644 --- a/solenv/gbuild/Library.mk +++ b/solenv/gbuild/Library.mk @@ -162,6 +162,18 @@ gb_Library__COMPONENTPREFIXES := \ gb_Library_get_runtime_filename = $(call gb_Library_get_filename,$(1)) +# call gb_Library_set_plugin_for,library,loader +define gb_Library_set_plugin_for +ifneq (,$$(filter-out $(gb_Library_KNOWNPLUGINS),$(1))) +$$(eval $$(call gb_Output_info,currently known plugins are: $(sort $(gb_Library_KNOWNPLUGINS)),ALL)) +$$(eval $$(call gb_Output_error,Unknown plugin(s) '$$(filter-out $(gb_Library_KNOWNPLUGINS),$(1)))'. Plugins must be registered in Repository.mk or RepositoryExternal.mk)) +endif + +$(call gb_LinkTarget_get_target,$(call gb_Library_get_linktarget,$(2))) : PLUGINS += $(1) +$(eval $(call gb_LinkTarget__add_plugin,$(call gb_Library_get_linktarget,$(2)),$(1))) +$(call gb_Library__forward_to_Linktarget,$(0),$(1),$(2),$(3)) +endef + # forward the call to the gb_LinkTarget implementation # (note: because the function name is in $(1), the other args are shifted by 1) define gb_Library__forward_to_Linktarget diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk index 6cd8719f91b7..fdd74c4887b8 100644 --- a/solenv/gbuild/LinkTarget.mk +++ b/solenv/gbuild/LinkTarget.mk @@ -1041,6 +1041,7 @@ ifeq ($(DISABLE_DYNLOADING),) $(call gb_LinkTarget_get_target,$(1)) : \ $(foreach lib,$(3),$(call gb_Library_get_exports_target,$(lib))) endif + $(call gb_LinkTarget_get_headers_target,$(1)) : \ $(foreach lib,$(2),$(call gb_Library_get_headers_target,$(lib))) $(foreach lib,$(2),$(call gb_LinkTarget__lib_dummy_depend,$(lib))) @@ -1089,7 +1090,12 @@ endef define gb_LinkTarget_use_libraries ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2))) $$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL)) -$$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk or RepositoryExternal.mk)) +$$(eval $$(call gb_Output_error,Cannot link against library/libraries '$$(filter-out $(gb_Library_KNOWNLIBS),$(2))'. Libraries must be registered in Repository.mk or RepositoryExternal.mk)) +endif +ifneq (,$$(filter $(2),$(gb_Library_KNOWNPLUGINS))) +ifneq (,$$(filter $(1),$$(foreach plugin,$(gb_Library_KNOWNPLUGINS),$(call gb_Library__get_workdir_linktargetname,$(plugin))))) +$$(eval $$(call gb_Output_error,Cannot link against plugin library/libraries '$$(filter $(2),$(gb_Library_KNOWNPLUGINS))'. Only plugins are allowed to do that.)) +endif endif ifeq ($(call gb_LinkTarget__is_build_tool,$(1)),$(true)) @@ -1789,5 +1795,33 @@ $(call gb_LinkTarget_get_target,$(1)) : T_USE_LD := $(or $(CLANG_USE_LD),$(USE_L endef +gb_LinkTarget__get_plugins_var = $(call gb_LinkTarget__get_workdir_linktargetname,$(1))<>PLUGINS +gb_LinkTarget__get_plugins = $($(call gb_LinkTarget__get_plugins_var,$(1))) +gb_Library__get_plugins = $($(call gb_LinkTarget__get_plugins_var,$(call gb_Library_get_linktarget,$(1)))) + +define gb_LinkTarget__add_plugin +$(call gb_LinkTarget__get_plugins_var,$(1)) += $(2) + +endef + +# call gb_LinkTarget__set_plugin_for,linktarget,loader +define gb_LinkTarget__set_plugin_for +ifneq (,$$(filter-out $(gb_Library_KNOWNLIBS),$(2))) +$$(eval $$(call gb_Output_info,currently known libraries are: $(sort $(gb_Library_KNOWNLIBS)),ALL)) +$$(eval $$(call gb_Output_error,Cannot link against library/libraries $$(filter-out $(gb_Library_KNOWNLIBS),$(2)). Libraries must be registered in Repository.mk or RepositoryExternal.mk)) +endif +ifeq (,$(filter $(1),$(foreach plugin,$(gb_Library_KNOWNPLUGINS),$(call gb_Library_get_linktarget,$(plugin))))) +$$(eval $$(call gb_Output_error,Unknown plugin(s) '$(filter $(1),$(foreach plugin,$(gb_Library_KNOWNPLUGINS),$(call gb_Library_get_linktarget,$(plugin))))'. Plugins must be registered in Repository.mk or RepositoryExternal.mk)) +endif +ifeq (,$(filter $(1),$(foreach lib,$(gb_MERGEDLIBS),$(call gb_Library_get_linktarget,$(lib))))) +$$(eval $$(call gb_Output_error,Plugins can't be in mergelibs)) +endif +ifeq ($(call gb_LinkTarget__is_build_tool,$(1)),$(true)) +$$(eval $$(call gb_Output_error,Plugin support for build tools not implemented)) +endif + +$(call gb_LinkTarget__use_libraries,$(1),$(2),$(2)) + +endef # vim: set noet sw=4: diff --git a/sw/Library_swui.mk b/sw/Library_swui.mk index 99f1dd20ae3d..e643179d355f 100644 --- a/sw/Library_swui.mk +++ b/sw/Library_swui.mk @@ -19,6 +19,8 @@ $(eval $(call gb_Library_Library,swui)) +$(eval $(call gb_Library_set_plugin_for,swui,sw)) + $(eval $(call gb_Library_set_include,swui,\ -I$(SRCDIR)/sw/inc \ -I$(SRCDIR)/sw/source/uibase/inc \ @@ -69,7 +71,6 @@ $(eval $(call gb_Library_use_libraries,swui,\ svx \ svx \ svxcore \ - sw \ tk \ tl \ ucbhelper \ diff --git a/vcl/Library_vclplug_gen.mk b/vcl/Library_vclplug_gen.mk index 3ebf80034c91..73f5464d7362 100644 --- a/vcl/Library_vclplug_gen.mk +++ b/vcl/Library_vclplug_gen.mk @@ -19,6 +19,8 @@ $(eval $(call gb_Library_Library,vclplug_gen)) +$(eval $(call gb_Library_set_plugin_for,vclplug_gen,vcl)) + $(eval $(call gb_Library_set_include,vclplug_gen,\ $$(INCLUDE) \ -I$(SRCDIR)/vcl/inc \ @@ -33,7 +35,6 @@ $(eval $(call gb_Library_use_sdk_api,vclplug_gen)) $(eval $(call gb_Library_use_common_precompiled_header,vclplug_gen)) $(eval $(call gb_Library_use_libraries,vclplug_gen,\ - vcl \ tl \ utl \ sot \ diff --git a/vcl/Library_vclplug_gtk3.mk b/vcl/Library_vclplug_gtk3.mk index 44d742e01c77..27eb13821bb3 100644 --- a/vcl/Library_vclplug_gtk3.mk +++ b/vcl/Library_vclplug_gtk3.mk @@ -19,6 +19,8 @@ $(eval $(call gb_Library_Library,vclplug_gtk3)) +$(eval $(call gb_Library_set_plugin_for,vclplug_gtk3,vcl)) + # Silence deprecation warnings wholesale as long as vcl/unx/gtk3/*.cxx just # forward to vcl/unx/gtk/*.cxx: $(eval $(call gb_Library_add_cxxflags,vclplug_gtk3, \ @@ -54,7 +56,6 @@ $(eval $(call gb_Library_add_libs,vclplug_gtk3,\ )) $(eval $(call gb_Library_use_libraries,vclplug_gtk3,\ - vcl \ svl \ tl \ utl \ diff --git a/vcl/Library_vclplug_gtk3_kde5.mk b/vcl/Library_vclplug_gtk3_kde5.mk index ab804e76a697..68a3ca8809c7 100644 --- a/vcl/Library_vclplug_gtk3_kde5.mk +++ b/vcl/Library_vclplug_gtk3_kde5.mk @@ -19,6 +19,8 @@ $(eval $(call gb_Library_Library,vclplug_gtk3_kde5)) +$(eval $(call gb_Library_set_plugin_for,vclplug_gtk3_kde5,vcl)) + # Silence deprecation warnings wholesale as long as vcl/unx/gtk3/*.cxx just # forward to vcl/unx/gtk/*.cxx: $(eval $(call gb_Library_add_cxxflags,vclplug_gtk3_kde5, \ @@ -60,7 +62,6 @@ $(eval $(call gb_Library_add_libs,vclplug_gtk3_kde5,\ $(eval $(call gb_Library_use_libraries,vclplug_gtk3_kde5,\ svl \ - vcl \ tl \ utl \ sot \ diff --git a/vcl/Library_vclplug_kf5.mk b/vcl/Library_vclplug_kf5.mk index d10cecd167d5..1e7765a6d6ce 100644 --- a/vcl/Library_vclplug_kf5.mk +++ b/vcl/Library_vclplug_kf5.mk @@ -19,6 +19,8 @@ $(eval $(call gb_Library_Library,vclplug_kf5)) +$(eval $(call gb_Library_set_plugin_for,vclplug_kf5,vcl)) + $(eval $(call gb_Library_use_custom_headers,vclplug_kf5,vcl/unx/kf5)) $(eval $(call gb_Library_set_include,vclplug_kf5,\ @@ -35,7 +37,6 @@ $(eval $(call gb_Library_use_sdk_api,vclplug_kf5)) $(eval $(call gb_Library_use_libraries,vclplug_kf5,\ vclplug_qt5 \ - vcl \ tl \ utl \ sot \ diff --git a/vcl/Library_vclplug_osx.mk b/vcl/Library_vclplug_osx.mk index c80d3bc8d7f3..5cb854343df6 100644 --- a/vcl/Library_vclplug_osx.mk +++ b/vcl/Library_vclplug_osx.mk @@ -19,6 +19,8 @@ $(eval $(call gb_Library_Library,vclplug_osx)) +$(eval $(call gb_Library_set_plugin_for,vclplug_osx,vcl)) + $(eval $(call gb_Library_set_include,vclplug_osx,\ $$(INCLUDE) \ -I$(SRCDIR)/vcl/inc \ @@ -51,7 +53,6 @@ $(eval $(call gb_Library_use_libraries,vclplug_osx,\ sal \ salhelper \ tl \ - vcl \ )) $(eval $(call gb_Library_use_externals,vclplug_osx,\ diff --git a/vcl/Library_vclplug_qt5.mk b/vcl/Library_vclplug_qt5.mk index b7ea9acdb08e..a91841ec32e4 100644 --- a/vcl/Library_vclplug_qt5.mk +++ b/vcl/Library_vclplug_qt5.mk @@ -19,6 +19,8 @@ $(eval $(call gb_Library_Library,vclplug_qt5)) +$(eval $(call gb_Library_set_plugin_for,vclplug_qt5,vcl)) + $(eval $(call gb_Library_use_custom_headers,vclplug_qt5,vcl/qt5)) $(eval $(call gb_Library_set_include,vclplug_qt5,\ @@ -36,7 +38,6 @@ $(eval $(call gb_Library_add_defs,vclplug_qt5,\ $(eval $(call gb_Library_use_sdk_api,vclplug_qt5)) $(eval $(call gb_Library_use_libraries,vclplug_qt5,\ - vcl \ tl \ utl \ sot \ diff --git a/vcl/Library_vclplug_win.mk b/vcl/Library_vclplug_win.mk index ca75300670b3..2fd00d7bd03b 100644 --- a/vcl/Library_vclplug_win.mk +++ b/vcl/Library_vclplug_win.mk @@ -19,6 +19,8 @@ $(eval $(call gb_Library_Library,vclplug_win)) +$(eval $(call gb_Library_set_plugin_for,vclplug_win,vcl)) + $(eval $(call gb_Library_set_componentfile,vclplug_win,vcl/vclplug_win)) $(eval $(call gb_Library_set_include,vclplug_win,\ @@ -53,7 +55,6 @@ $(eval $(call gb_Library_use_libraries,vclplug_win,\ salhelper \ tl \ utl \ - vcl \ )) $(eval $(call gb_Library_use_externals,vclplug_win,\ |