From 46c58750e9c441821a829862438f44260947fbe5 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Tue, 21 May 2024 13:35:55 +0200 Subject: [PATCH 1/9] libdnf5: API: Do not use inline methods to call private methods Symbols for private methods will be hidden (not exported). --- include/libdnf5/rpm/reldep_list.hpp | 5 ----- include/libdnf5/transaction/comps_environment.hpp | 2 +- include/libdnf5/transaction/comps_group.hpp | 2 +- libdnf5/rpm/reldep_list.cpp | 4 ++++ libdnf5/transaction/comps_environment.cpp | 3 +++ libdnf5/transaction/comps_group.cpp | 4 ++++ 6 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/libdnf5/rpm/reldep_list.hpp b/include/libdnf5/rpm/reldep_list.hpp index 61af5ee62..07fc7bf74 100644 --- a/include/libdnf5/rpm/reldep_list.hpp +++ b/include/libdnf5/rpm/reldep_list.hpp @@ -125,11 +125,6 @@ class ReldepList { std::unique_ptr p_impl; }; - -inline bool ReldepList::add_reldep(const std::string & reldep_str) { - return add_reldep(reldep_str, 1); -} - } // namespace libdnf5::rpm #endif // LIBDNF5_RPM_RELDEP_LIST_HPP diff --git a/include/libdnf5/transaction/comps_environment.hpp b/include/libdnf5/transaction/comps_environment.hpp index d7313f5d5..d37fa549a 100644 --- a/include/libdnf5/transaction/comps_environment.hpp +++ b/include/libdnf5/transaction/comps_environment.hpp @@ -45,7 +45,7 @@ class CompsEnvironment : public TransactionItem { /// Get string representation of the object, which equals to environment_id /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.toStr() - std::string to_string() const { return get_environment_id(); } + std::string to_string() const; CompsEnvironment(const CompsEnvironment & src); CompsEnvironment & operator=(const CompsEnvironment & src); diff --git a/include/libdnf5/transaction/comps_group.hpp b/include/libdnf5/transaction/comps_group.hpp index 5e35a582c..661e3f219 100644 --- a/include/libdnf5/transaction/comps_group.hpp +++ b/include/libdnf5/transaction/comps_group.hpp @@ -45,7 +45,7 @@ class CompsGroup : public TransactionItem { /// Get string representation of the object, which equals to group_id /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupItem.toStr() - std::string to_string() const { return get_group_id(); } + std::string to_string() const; CompsGroup(const CompsGroup & src); CompsGroup & operator=(const CompsGroup & src); diff --git a/libdnf5/rpm/reldep_list.cpp b/libdnf5/rpm/reldep_list.cpp index 1d3cb2930..687baa808 100644 --- a/libdnf5/rpm/reldep_list.cpp +++ b/libdnf5/rpm/reldep_list.cpp @@ -129,6 +129,10 @@ bool ReldepList::add_reldep(const std::string & reldep_str, int create) { } } +bool ReldepList::add_reldep(const std::string & reldep_str) { + return add_reldep(reldep_str, 1); +} + void ReldepList::append(ReldepList & source) { libdnf_assert_same_base(p_impl->base, source.get_base()); p_impl->queue += source.p_impl->queue; diff --git a/libdnf5/transaction/comps_environment.cpp b/libdnf5/transaction/comps_environment.cpp index 556b5ef3d..4aaba0d01 100644 --- a/libdnf5/transaction/comps_environment.cpp +++ b/libdnf5/transaction/comps_environment.cpp @@ -64,6 +64,9 @@ CompsEnvironment & CompsEnvironment::operator=(const CompsEnvironment & src) { CompsEnvironment & CompsEnvironment::operator=(CompsEnvironment && src) noexcept = default; CompsEnvironment::~CompsEnvironment() = default; +std::string CompsEnvironment::to_string() const { + return get_environment_id(); +} const std::string & CompsEnvironment::get_environment_id() const noexcept { return p_impl->environment_id; diff --git a/libdnf5/transaction/comps_group.cpp b/libdnf5/transaction/comps_group.cpp index c6b484322..895b2e90d 100644 --- a/libdnf5/transaction/comps_group.cpp +++ b/libdnf5/transaction/comps_group.cpp @@ -61,6 +61,10 @@ CompsGroup & CompsGroup::operator=(const CompsGroup & src) { CompsGroup & CompsGroup::operator=(CompsGroup && src) noexcept = default; CompsGroup::~CompsGroup() = default; +std::string CompsGroup::to_string() const { + return get_group_id(); +} + const std::string & CompsGroup::get_group_id() const noexcept { return p_impl->group_id; } From 1605f10bc7b8867a3e1d3ddc20bc114d2c281db3 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Tue, 12 Mar 2024 13:00:21 +0100 Subject: [PATCH 2/9] libdnf5: Define macros for assigning symbol visibility The goal is to explicitly set the visibility of symbols using these macros. And switch the default visibility of symbols to "hidden". --- include/libdnf5/defs.h | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 include/libdnf5/defs.h diff --git a/include/libdnf5/defs.h b/include/libdnf5/defs.h new file mode 100644 index 000000000..e88b3ce5a --- /dev/null +++ b/include/libdnf5/defs.h @@ -0,0 +1,59 @@ +/* +Copyright Contributors to the libdnf project. + +This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ + +Libdnf is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +Libdnf is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with libdnf. If not, see . +*/ + +#ifndef LIBDNF5_DEFS_H +#define LIBDNF5_DEFS_H + +// Generic helper definitions for shared library support +#if defined _WIN32 || defined __CYGWIN__ +#define LIBDNF_SYMBOL_IMPORT __declspec(dllimport) +#define LIBDNF_SYMBOL_EXPORT __declspec(dllexport) +#define LIBDNF_SYMBOL_LOCAL +#else +#if __GNUC__ >= 4 +#define LIBDNF_SYMBOL_IMPORT __attribute__((visibility("default"))) +#define LIBDNF_SYMBOL_EXPORT __attribute__((visibility("default"))) +#define LIBDNF_SYMBOL_LOCAL __attribute__((visibility("hidden"))) +#else +#define LIBDNF_SYMBOL_IMPORT +#define LIBDNF_SYMBOL_EXPORT +#define LIBDNF_SYMBOL_LOCAL +#endif +#endif + +// Now define LIBDNF_API, LIBDNF_LOCAL and LIBDNF_PLUGIN_API. +// LIBDNF_API and LIBDNF_PLUGIN_API are used for public API symbols. It either imports or exports the symbol. +// LIBDNF_LOCAL is used for non-api symbols. + +#ifdef LIBDNF_BUILD_LIBRARY // defined if we are building the libdnf library (instead of using it) +#define LIBDNF_API LIBDNF_SYMBOL_EXPORT +#else +#define LIBDNF_API LIBDNF_SYMBOL_IMPORT +#endif + +#define LIBDNF_LOCAL LIBDNF_SYMBOL_LOCAL + +// LIBDNF exports its symbols but imports plugin symbols. +#ifdef LIBDNF_BUILD_LIBRARY // defined if we are building the libdnf library (instead of using it) +#define LIBDNF_PLUGIN_API LIBDNF_SYMBOL_IMPORT +#else +#define LIBDNF_PLUGIN_API LIBDNF_SYMBOL_EXPORT +#endif + +#endif From ca456a0f5076bf0d4c331435de24006e5ba36e34 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Thu, 14 Mar 2024 14:19:17 +0100 Subject: [PATCH 3/9] libdnf5 library, libdnf5 plugins: Do not export private symbols --- bindings/libdnf5/shared.i | 6 +++ include/libdnf5/advisory/advisory.hpp | 5 +- .../libdnf5/advisory/advisory_collection.hpp | 10 ++-- include/libdnf5/advisory/advisory_module.hpp | 7 +-- include/libdnf5/advisory/advisory_package.hpp | 7 +-- include/libdnf5/advisory/advisory_query.hpp | 5 +- .../libdnf5/advisory/advisory_reference.hpp | 8 +-- include/libdnf5/advisory/advisory_set.hpp | 7 +-- .../advisory/advisory_set_iterator.hpp | 8 +-- include/libdnf5/base/base.hpp | 8 +-- include/libdnf5/base/goal.hpp | 7 +-- include/libdnf5/base/goal_elements.hpp | 25 ++++----- include/libdnf5/base/log_event.hpp | 7 +-- include/libdnf5/base/solver_problems.hpp | 5 +- include/libdnf5/base/transaction.hpp | 9 ++-- .../libdnf5/base/transaction_environment.hpp | 8 +-- include/libdnf5/base/transaction_group.hpp | 8 +-- include/libdnf5/base/transaction_module.hpp | 8 +-- include/libdnf5/base/transaction_package.hpp | 11 ++-- include/libdnf5/common/exception.hpp | 15 +++--- include/libdnf5/common/proc.hpp | 6 ++- include/libdnf5/common/sack/match_int64.hpp | 10 ++-- include/libdnf5/common/sack/match_string.hpp | 11 ++-- include/libdnf5/common/sack/query.hpp | 3 +- include/libdnf5/common/xdg.hpp | 14 ++--- .../libdnf5/comps/environment/environment.hpp | 7 +-- include/libdnf5/comps/environment/query.hpp | 5 +- include/libdnf5/comps/group/group.hpp | 7 +-- include/libdnf5/comps/group/package.hpp | 6 ++- include/libdnf5/comps/group/package_type.hpp | 11 ++-- include/libdnf5/comps/group/query.hpp | 5 +- include/libdnf5/conf/config.hpp | 5 +- include/libdnf5/conf/config_main.hpp | 4 +- include/libdnf5/conf/config_parser.hpp | 16 +++--- include/libdnf5/conf/option.hpp | 13 ++--- include/libdnf5/conf/option_binds.hpp | 11 ++-- include/libdnf5/conf/option_bool.hpp | 4 +- include/libdnf5/conf/option_enum.hpp | 4 +- include/libdnf5/conf/option_number.hpp | 4 +- include/libdnf5/conf/option_path.hpp | 4 +- include/libdnf5/conf/option_seconds.hpp | 2 +- include/libdnf5/conf/option_string.hpp | 4 +- include/libdnf5/conf/option_string_list.hpp | 8 +-- include/libdnf5/conf/vars.hpp | 18 +++---- include/libdnf5/logger/factory.hpp | 6 ++- include/libdnf5/logger/global_logger.hpp | 2 +- include/libdnf5/logger/log_router.hpp | 5 +- include/libdnf5/logger/logger.hpp | 5 +- .../libdnf5/logger/memory_buffer_logger.hpp | 6 ++- include/libdnf5/logger/null_logger.hpp | 3 +- .../libdnf5/logger/rotating_file_logger.hpp | 5 +- include/libdnf5/logger/stream_logger.hpp | 9 ++-- include/libdnf5/module/module_dependency.hpp | 6 ++- include/libdnf5/module/module_item.hpp | 47 +++++++++-------- include/libdnf5/module/module_profile.hpp | 8 +-- include/libdnf5/module/module_query.hpp | 5 +- include/libdnf5/module/module_sack.hpp | 13 ++--- include/libdnf5/module/module_status.hpp | 7 +-- include/libdnf5/module/nsvcap.hpp | 6 ++- include/libdnf5/plugin/iplugin.hpp | 15 +++--- include/libdnf5/plugin/plugin_info.hpp | 7 +-- include/libdnf5/repo/config_repo.hpp | 5 +- include/libdnf5/repo/download_callbacks.hpp | 4 +- include/libdnf5/repo/file_downloader.hpp | 5 +- include/libdnf5/repo/package_downloader.hpp | 5 +- include/libdnf5/repo/repo.hpp | 35 +++++++------ include/libdnf5/repo/repo_cache.hpp | 9 ++-- include/libdnf5/repo/repo_callbacks.hpp | 4 +- include/libdnf5/repo/repo_query.hpp | 5 +- include/libdnf5/repo/repo_sack.hpp | 22 ++++---- include/libdnf5/rpm/arch.hpp | 6 ++- include/libdnf5/rpm/checksum.hpp | 7 +-- include/libdnf5/rpm/nevra.hpp | 14 +++-- include/libdnf5/rpm/package.hpp | 13 ++--- include/libdnf5/rpm/package_query.hpp | 8 +-- include/libdnf5/rpm/package_sack.hpp | 5 +- include/libdnf5/rpm/package_set.hpp | 9 ++-- include/libdnf5/rpm/package_set_iterator.hpp | 6 ++- include/libdnf5/rpm/reldep.hpp | 12 +++-- include/libdnf5/rpm/reldep_list.hpp | 7 +-- include/libdnf5/rpm/reldep_list_iterator.hpp | 6 ++- include/libdnf5/rpm/rpm_signature.hpp | 13 ++--- include/libdnf5/rpm/transaction_callbacks.hpp | 3 +- include/libdnf5/rpm/versionlock_config.hpp | 9 ++-- .../libdnf5/transaction/comps_environment.hpp | 47 +++++++++-------- include/libdnf5/transaction/comps_group.hpp | 47 +++++++++-------- include/libdnf5/transaction/offline.hpp | 13 ++--- include/libdnf5/transaction/rpm_package.hpp | 22 ++++---- include/libdnf5/transaction/transaction.hpp | 52 ++++++++++--------- .../transaction/transaction_history.hpp | 7 +-- .../libdnf5/transaction/transaction_item.hpp | 34 ++++++------ .../transaction/transaction_item_action.hpp | 13 ++--- .../transaction/transaction_item_reason.hpp | 17 +++--- .../transaction/transaction_item_state.hpp | 7 +-- .../transaction/transaction_item_type.hpp | 7 +-- include/libdnf5/utils/fs/file.hpp | 4 +- include/libdnf5/utils/fs/temp.hpp | 6 ++- include/libdnf5/utils/locker.hpp | 6 ++- include/libdnf5/version.hpp | 6 ++- libdnf5-plugins/CMakeLists.txt | 3 ++ libdnf5/CMakeLists.txt | 3 ++ libdnf5/utils/bgettext/bgettext.c | 15 +++--- 102 files changed, 585 insertions(+), 447 deletions(-) diff --git a/bindings/libdnf5/shared.i b/bindings/libdnf5/shared.i index 269257b59..e5801462a 100644 --- a/bindings/libdnf5/shared.i +++ b/bindings/libdnf5/shared.i @@ -21,3 +21,9 @@ // be renamed to Perl_get_context #undef get_context %} + + +// Define empty macros. They are used to define the visibility of symbols. +#define LIBDNF_API +#define LIBDNF_LOCAL +#define LIBDNF_PLUGIN_API diff --git a/include/libdnf5/advisory/advisory.hpp b/include/libdnf5/advisory/advisory.hpp index 245415b47..88c2e8f48 100644 --- a/include/libdnf5/advisory/advisory.hpp +++ b/include/libdnf5/advisory/advisory.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define LIBDNF5_ADVISORY_ADVISORY_HPP #include "libdnf5/base/base_weak.hpp" +#include "libdnf5/defs.h" #include #include @@ -43,7 +44,7 @@ struct AdvisoryId { }; /// An advisory, represents advisory used to track security updates -class Advisory { +class LIBDNF_API Advisory { public: Advisory(const Advisory & src); Advisory & operator=(const Advisory & src); @@ -147,7 +148,7 @@ class Advisory { friend class AdvisorySetIterator; friend class AdvisorySet; - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/advisory/advisory_collection.hpp b/include/libdnf5/advisory/advisory_collection.hpp index 203a3eb32..607a91983 100644 --- a/include/libdnf5/advisory/advisory_collection.hpp +++ b/include/libdnf5/advisory/advisory_collection.hpp @@ -25,13 +25,15 @@ along with libdnf. If not, see . #include "advisory_package.hpp" #include "advisory_set.hpp" +#include "libdnf5/defs.h" + #include namespace libdnf5::advisory { //TODO(amatej): add unit tests for AdvisoryCollection -class AdvisoryCollection { +class LIBDNF_API AdvisoryCollection { public: AdvisoryCollection(const AdvisoryCollection & src); AdvisoryCollection & operator=(const AdvisoryCollection & src); @@ -76,7 +78,7 @@ class AdvisoryCollection { friend AdvisorySet; friend class AdvisoryQuery; - AdvisoryCollection(const BaseWeakPtr & base, AdvisoryId advisory, int index); + LIBDNF_LOCAL AdvisoryCollection(const BaseWeakPtr & base, AdvisoryId advisory, int index); /// Get all AdvisoryPackages stored in this AdvisoryCollection /// @@ -85,9 +87,9 @@ class AdvisoryCollection { /// them when collecting AdvisoryPackages from multiple collections. /// @param with_filenames Filenames of AdvisoryPackages are not always useful, this allows skipping them. /// The filename is stored as a c string (not libsolv id) this incurs slowdown. - void get_packages(std::vector & output, bool with_filenames = false); + LIBDNF_LOCAL void get_packages(std::vector & output, bool with_filenames = false); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/advisory/advisory_module.hpp b/include/libdnf5/advisory/advisory_module.hpp index 710f29375..8c245c89e 100644 --- a/include/libdnf5/advisory/advisory_module.hpp +++ b/include/libdnf5/advisory/advisory_module.hpp @@ -23,11 +23,12 @@ along with libdnf. If not, see . #include "advisory.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" namespace libdnf5::advisory { -class AdvisoryModule { +class LIBDNF_API AdvisoryModule { public: AdvisoryModule(const AdvisoryModule & src); AdvisoryModule(AdvisoryModule && src) noexcept; @@ -87,8 +88,8 @@ class AdvisoryModule { private: friend class AdvisoryCollection; - class Impl; - AdvisoryModule(Impl * private_module); + class LIBDNF_LOCAL Impl; + LIBDNF_LOCAL AdvisoryModule(Impl * private_module); ImplPtr p_impl; }; diff --git a/include/libdnf5/advisory/advisory_package.hpp b/include/libdnf5/advisory/advisory_package.hpp index 5d64151ba..53854aa40 100644 --- a/include/libdnf5/advisory/advisory_package.hpp +++ b/include/libdnf5/advisory/advisory_package.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "advisory.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include @@ -41,7 +42,7 @@ class Goal; namespace libdnf5::advisory { -class AdvisoryPackage { +class LIBDNF_API AdvisoryPackage { public: AdvisoryPackage(const AdvisoryPackage & src); AdvisoryPackage(AdvisoryPackage && src) noexcept; @@ -124,8 +125,8 @@ class AdvisoryPackage { friend class libdnf5::rpm::PackageQuery; friend class libdnf5::Goal; - class Impl; - AdvisoryPackage(Impl * private_pkg); + class LIBDNF_LOCAL Impl; + LIBDNF_LOCAL AdvisoryPackage(Impl * private_pkg); ImplPtr p_impl; }; diff --git a/include/libdnf5/advisory/advisory_query.hpp b/include/libdnf5/advisory/advisory_query.hpp index 251b86e68..551d73b88 100644 --- a/include/libdnf5/advisory/advisory_query.hpp +++ b/include/libdnf5/advisory/advisory_query.hpp @@ -28,6 +28,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/common/sack/query_cmp.hpp" +#include "libdnf5/defs.h" #include "libdnf5/rpm/package_set.hpp" @@ -35,7 +36,7 @@ namespace libdnf5::advisory { /// AdvisoryQuery is the only way how to access advisories. /// It is constructed using Base and filled with advisories from enabled repositories in its RepoSack. -class AdvisoryQuery : public AdvisorySet { +class LIBDNF_API AdvisoryQuery : public AdvisorySet { public: /// Create a new AdvisoryQuery instance. /// @@ -112,7 +113,7 @@ class AdvisoryQuery : public AdvisorySet { const libdnf5::rpm::PackageSet & package_set, sack::QueryCmp cmp_type = libdnf5::sack::QueryCmp::EQ) const; private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/advisory/advisory_reference.hpp b/include/libdnf5/advisory/advisory_reference.hpp index ca0d73737..9c73e7857 100644 --- a/include/libdnf5/advisory/advisory_reference.hpp +++ b/include/libdnf5/advisory/advisory_reference.hpp @@ -22,11 +22,13 @@ along with libdnf. If not, see . #include "advisory.hpp" +#include "libdnf5/defs.h" + #include namespace libdnf5::advisory { -class AdvisoryReference { +class LIBDNF_API AdvisoryReference { public: AdvisoryReference(const AdvisoryReference & src); AdvisoryReference & operator=(const AdvisoryReference & src); @@ -72,9 +74,9 @@ class AdvisoryReference { /// @param advisory AdvisoryId into libsolv pool. /// @param index Index of this reference in its advisory. /// @return New AdvisoryReference instance. - AdvisoryReference(const BaseWeakPtr & base, AdvisoryId advisory, int index); + LIBDNF_LOCAL AdvisoryReference(const BaseWeakPtr & base, AdvisoryId advisory, int index); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/advisory/advisory_set.hpp b/include/libdnf5/advisory/advisory_set.hpp index 5bc951b0e..14697eb3f 100644 --- a/include/libdnf5/advisory/advisory_set.hpp +++ b/include/libdnf5/advisory/advisory_set.hpp @@ -25,6 +25,7 @@ along with libdnf. If not, see . #include "advisory_set_iterator.hpp" #include "libdnf5/common/exception.hpp" +#include "libdnf5/defs.h" #include #include @@ -38,7 +39,7 @@ class SolvMap; namespace libdnf5::advisory { -class AdvisorySet { +class LIBDNF_API AdvisorySet { public: using iterator = AdvisorySetIterator; @@ -128,8 +129,8 @@ class AdvisorySet { private: friend AdvisorySetIterator; friend class AdvisoryQuery; - AdvisorySet(const BaseWeakPtr & base, libdnf5::solv::SolvMap & solv_map); - class Impl; + LIBDNF_LOCAL AdvisorySet(const BaseWeakPtr & base, libdnf5::solv::SolvMap & solv_map); + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/advisory/advisory_set_iterator.hpp b/include/libdnf5/advisory/advisory_set_iterator.hpp index b38d56774..1dd671494 100644 --- a/include/libdnf5/advisory/advisory_set_iterator.hpp +++ b/include/libdnf5/advisory/advisory_set_iterator.hpp @@ -23,6 +23,8 @@ along with libdnf. If not, see . #include "advisory.hpp" +#include "libdnf5/defs.h" + #include #include #include @@ -33,7 +35,7 @@ namespace libdnf5::advisory { class AdvisorySet; -class AdvisorySetIterator { +class LIBDNF_API AdvisorySetIterator { public: using iterator_category = std::forward_iterator_tag; using difference_type = std::ptrdiff_t; @@ -61,9 +63,9 @@ class AdvisorySetIterator { void end(); private: - explicit AdvisorySetIterator(const AdvisorySet & advisory_set); + LIBDNF_LOCAL explicit AdvisorySetIterator(const AdvisorySet & advisory_set); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/base/base.hpp b/include/libdnf5/base/base.hpp index c4c8e38a0..435defd0c 100644 --- a/include/libdnf5/base/base.hpp +++ b/include/libdnf5/base/base.hpp @@ -26,6 +26,7 @@ along with libdnf. If not, see . #include "libdnf5/common/weak_ptr.hpp" #include "libdnf5/conf/config_main.hpp" #include "libdnf5/conf/vars.hpp" +#include "libdnf5/defs.h" #include "libdnf5/logger/log_router.hpp" #include "libdnf5/module/module_sack.hpp" #include "libdnf5/plugin/plugin_info.hpp" @@ -55,7 +56,7 @@ class InternalBaseUser; /// Instances of :class:`libdnf5::Base` are the central point of functionality supplied by libdnf5. /// An application will typically create a single instance of this class which it will keep for the run-time needed to accomplish its packaging tasks. /// :class:`.Base` instances are stateful objects owning various data. -class Base { +class LIBDNF_API Base { public: /// Constructs a new Base instance and sets the destination loggers. Base(std::vector> && loggers = {}); @@ -132,8 +133,6 @@ class Base { libdnf5::BaseWeakPtr get_weak_ptr(); - class Impl; - private: friend class libdnf5::InternalBaseUser; friend class libdnf5::base::Transaction; @@ -148,13 +147,14 @@ class Base { friend class libdnf5::repo::SolvRepo; /// Load plugins according to configuration - void load_plugins(); + LIBDNF_LOCAL void load_plugins(); WeakPtrGuard base_guard; // Impl has to be the second data member (right after base_guard which is needed for its construction) because it // contains Pool and that has be destructed last. // See commit: https://github.com/rpm-software-management/dnf5/commit/c8e26cb545aed0d6ca66545d51eda7568efdf232 + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/base/goal.hpp b/include/libdnf5/base/goal.hpp index 1590d0b23..e7e06a9b7 100644 --- a/include/libdnf5/base/goal.hpp +++ b/include/libdnf5/base/goal.hpp @@ -24,6 +24,7 @@ along with libdnf. If not, see . #include "libdnf5/base/goal_elements.hpp" #include "libdnf5/base/transaction.hpp" +#include "libdnf5/defs.h" #include "libdnf5/rpm/package.hpp" @@ -31,7 +32,7 @@ namespace libdnf5 { /// Centralized point to perform operations with RPMs, Comps groups, and Modules -class Goal { +class LIBDNF_API Goal { public: explicit Goal(const libdnf5::BaseWeakPtr & base); explicit Goal(libdnf5::Base & base); @@ -386,8 +387,8 @@ class Goal { libdnf5::BaseWeakPtr get_base() const; private: - rpm::PackageId get_running_kernel_internal(); - class Impl; + LIBDNF_LOCAL rpm::PackageId get_running_kernel_internal(); + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/base/goal_elements.hpp b/include/libdnf5/base/goal_elements.hpp index 4c65d0471..07415a02b 100644 --- a/include/libdnf5/base/goal_elements.hpp +++ b/include/libdnf5/base/goal_elements.hpp @@ -24,6 +24,7 @@ along with libdnf. If not, see . #include "libdnf5/advisory/advisory_query.hpp" #include "libdnf5/comps/group/package.hpp" #include "libdnf5/conf/config_main.hpp" +#include "libdnf5/defs.h" #include "libdnf5/rpm/nevra.hpp" #include @@ -143,7 +144,7 @@ enum class GoalAction { }; /// Convert GoalAction enum to user-readable string -std::string goal_action_to_string(GoalAction action); +LIBDNF_API std::string goal_action_to_string(GoalAction action); /// Settings for GoalJobSettings enum class GoalSetting { AUTO, SET_TRUE, SET_FALSE }; @@ -153,7 +154,7 @@ enum class GoalUsedSetting { UNUSED, USED_TRUE, USED_FALSE }; /// Configure SPEC resolving. /// Important for queries that resolve SPEC. -struct ResolveSpecSettings { +struct LIBDNF_API ResolveSpecSettings { public: ResolveSpecSettings(); ~ResolveSpecSettings(); @@ -235,11 +236,11 @@ struct ResolveSpecSettings { bool get_group_search_environments() const; private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; -struct GoalJobSettings : public ResolveSpecSettings { +struct LIBDNF_API GoalJobSettings : public ResolveSpecSettings { public: GoalJobSettings(); ~GoalJobSettings(); @@ -340,13 +341,13 @@ struct GoalJobSettings : public ResolveSpecSettings { /// @return Resolved value. /// @exception libdnf5::AssertionError When a different value already stored or when invalid value /// @since 1.0 - bool resolve_skip_broken(const libdnf5::ConfigMain & cfg_main); + LIBDNF_LOCAL bool resolve_skip_broken(const libdnf5::ConfigMain & cfg_main); /// Resolve skip_broken value and store the result as the value used. When GoalSetting::auto it returns false /// /// @return Resolved value. /// @exception libdnf5::AssertionError When a different value already stored /// @since 1.0 - bool resolve_skip_broken(); + LIBDNF_LOCAL bool resolve_skip_broken(); /// Resolve skip_unavailable value and store the result as the value used. /// @@ -354,7 +355,7 @@ struct GoalJobSettings : public ResolveSpecSettings { /// @return Resolved value. /// @exception libdnf5::AssertionError When a different value already stored or when invalid value /// @since 1.0 - bool resolve_skip_unavailable(const libdnf5::ConfigMain & cfg_main); + LIBDNF_LOCAL bool resolve_skip_unavailable(const libdnf5::ConfigMain & cfg_main); /// Resolve best value and store the result as the value used. /// @@ -362,27 +363,27 @@ struct GoalJobSettings : public ResolveSpecSettings { /// @return Resolved value. /// @exception libdnf5::AssertionError When a different value already stored or when invalid value /// @since 1.0 - bool resolve_best(const libdnf5::ConfigMain & cfg_main); + LIBDNF_LOCAL bool resolve_best(const libdnf5::ConfigMain & cfg_main); /// Resolve clean_requirements_on_remove value and store the result as the value used. /// /// @param cfg_main Main config used to resolve GoalSetting::auto /// @return Resolved value. /// @exception libdnf5::AssertionError When a different value already stored or when invalid value /// @since 1.0 - bool resolve_clean_requirements_on_remove(const libdnf5::ConfigMain & cfg_main); + LIBDNF_LOCAL bool resolve_clean_requirements_on_remove(const libdnf5::ConfigMain & cfg_main); /// Resolve clean_requirements_on_remove value and store the result as the value used. /// /// @return Resolved value. /// @exception libdnf5::AssertionError When a different value already stored or when invalid value /// @since 1.0 - bool resolve_clean_requirements_on_remove(); + LIBDNF_LOCAL bool resolve_clean_requirements_on_remove(); /// Compute and store effective group_package_types value. Used only for goal jobs operating on groups. /// @return group_package_types value if set, cfg_main.group_package_types value otherwise. /// @exception libdnf5::AssertionError When a different value already stored or when invalid value - libdnf5::comps::PackageType resolve_group_package_types(const libdnf5::ConfigMain & cfg_main); + LIBDNF_LOCAL libdnf5::comps::PackageType resolve_group_package_types(const libdnf5::ConfigMain & cfg_main); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/base/log_event.hpp b/include/libdnf5/base/log_event.hpp index 3386701ec..3f7d7ca3d 100644 --- a/include/libdnf5/base/log_event.hpp +++ b/include/libdnf5/base/log_event.hpp @@ -24,6 +24,7 @@ along with libdnf. If not, see . #include "libdnf5/base/goal_elements.hpp" #include "libdnf5/base/solver_problems.hpp" +#include "libdnf5/defs.h" #include "libdnf5/transaction/transaction_item_type.hpp" #include @@ -33,7 +34,7 @@ along with libdnf. If not, see . namespace libdnf5::base { /// Contain information, hint, or a problem created during libdnf5::Goal::resolve() -class LogEvent { +class LIBDNF_API LogEvent { public: /// Public constructor LogEvent( @@ -70,7 +71,7 @@ class LogEvent { private: /// Convert an element from resolve log to string; - static std::string to_string( + LIBDNF_LOCAL static std::string to_string( libdnf5::GoalAction action, libdnf5::GoalProblem problem, const std::set & additional_data, @@ -79,7 +80,7 @@ class LogEvent { const std::optional & spec, const std::optional & solver_problems); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/base/solver_problems.hpp b/include/libdnf5/base/solver_problems.hpp index 3941cc5d6..c6aa005c9 100644 --- a/include/libdnf5/base/solver_problems.hpp +++ b/include/libdnf5/base/solver_problems.hpp @@ -24,11 +24,12 @@ along with libdnf. If not, see . #include "goal_elements.hpp" +#include "libdnf5/defs.h" namespace libdnf5::base { /// Represent problems detected by a RPM solver (libsolv) -class SolverProblems { +class LIBDNF_API SolverProblems { public: /// Public constructor SolverProblems( @@ -61,7 +62,7 @@ class SolverProblems { private: friend class Transaction; - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/base/transaction.hpp b/include/libdnf5/base/transaction.hpp index 90f24d9d2..d541a8cdf 100644 --- a/include/libdnf5/base/transaction.hpp +++ b/include/libdnf5/base/transaction.hpp @@ -26,6 +26,7 @@ along with libdnf. If not, see . #include "libdnf5/base/log_event.hpp" #include "libdnf5/base/solver_problems.hpp" #include "libdnf5/common/proc.hpp" +#include "libdnf5/defs.h" #include "libdnf5/rpm/transaction_callbacks.hpp" #include @@ -44,7 +45,7 @@ class TransactionModule; class TransactionPackage; /// Error related to processing transaction -class TransactionError : public Error { +class LIBDNF_API TransactionError : public Error { public: using Error::Error; /// @return Error class' domain name" @@ -54,7 +55,7 @@ class TransactionError : public Error { }; -class Transaction { +class LIBDNF_API Transaction { public: /// enum representing Transaction run result enum class TransactionRunResult { @@ -193,9 +194,9 @@ class Transaction { friend class TransactionPackage; friend class libdnf5::Goal; - Transaction(const libdnf5::BaseWeakPtr & base); + LIBDNF_LOCAL Transaction(const libdnf5::BaseWeakPtr & base); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; std::unique_ptr callbacks; diff --git a/include/libdnf5/base/transaction_environment.hpp b/include/libdnf5/base/transaction_environment.hpp index 5336a3fde..569a9c3d1 100644 --- a/include/libdnf5/base/transaction_environment.hpp +++ b/include/libdnf5/base/transaction_environment.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "libdnf5/base/transaction.hpp" #include "libdnf5/comps/environment/environment.hpp" +#include "libdnf5/defs.h" #include "libdnf5/transaction/transaction_item_action.hpp" #include "libdnf5/transaction/transaction_item_reason.hpp" #include "libdnf5/transaction/transaction_item_state.hpp" @@ -30,7 +31,7 @@ along with libdnf. If not, see . namespace libdnf5::base { -class TransactionEnvironment { +class LIBDNF_API TransactionEnvironment { public: using Reason = transaction::TransactionItemReason; using State = transaction::TransactionItemState; @@ -67,9 +68,10 @@ class TransactionEnvironment { private: friend class Transaction::Impl; - TransactionEnvironment(const libdnf5::comps::Environment & grp, Action action, Reason reason, bool with_optional); + LIBDNF_LOCAL TransactionEnvironment( + const libdnf5::comps::Environment & grp, Action action, Reason reason, bool with_optional); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/base/transaction_group.hpp b/include/libdnf5/base/transaction_group.hpp index 55bb5248f..c642f7937 100644 --- a/include/libdnf5/base/transaction_group.hpp +++ b/include/libdnf5/base/transaction_group.hpp @@ -24,6 +24,7 @@ along with libdnf. If not, see . #include "libdnf5/base/transaction.hpp" #include "libdnf5/comps/group/group.hpp" #include "libdnf5/comps/group/package.hpp" +#include "libdnf5/defs.h" #include "libdnf5/rpm/package.hpp" #include "libdnf5/transaction/transaction_item_action.hpp" #include "libdnf5/transaction/transaction_item_reason.hpp" @@ -32,7 +33,7 @@ along with libdnf. If not, see . namespace libdnf5::base { -class TransactionGroup { +class LIBDNF_API TransactionGroup { public: using Reason = transaction::TransactionItemReason; using State = transaction::TransactionItemState; @@ -70,9 +71,10 @@ class TransactionGroup { private: friend class Transaction::Impl; - TransactionGroup(const libdnf5::comps::Group & grp, Action action, Reason reason, const PackageType & types); + LIBDNF_LOCAL TransactionGroup( + const libdnf5::comps::Group & grp, Action action, Reason reason, const PackageType & types); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/base/transaction_module.hpp b/include/libdnf5/base/transaction_module.hpp index f64caf695..8e1a13c36 100644 --- a/include/libdnf5/base/transaction_module.hpp +++ b/include/libdnf5/base/transaction_module.hpp @@ -22,6 +22,7 @@ along with libdnf. If not, see . #define LIBDNF5_BASE_TRANSACTION_MODULE_HPP #include "libdnf5/base/transaction.hpp" +#include "libdnf5/defs.h" #include "libdnf5/transaction/transaction_item_action.hpp" #include "libdnf5/transaction/transaction_item_reason.hpp" #include "libdnf5/transaction/transaction_item_state.hpp" @@ -29,7 +30,7 @@ along with libdnf. If not, see . namespace libdnf5::base { -class TransactionModule { +class LIBDNF_API TransactionModule { public: using Reason = transaction::TransactionItemReason; using State = transaction::TransactionItemState; @@ -73,9 +74,10 @@ class TransactionModule { private: friend class Transaction::Impl; - TransactionModule(const std::string & module_name, const std::string & module_stream, Action action, Reason reason); + LIBDNF_LOCAL TransactionModule( + const std::string & module_name, const std::string & module_stream, Action action, Reason reason); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/base/transaction_package.hpp b/include/libdnf5/base/transaction_package.hpp index 14ae52402..549b6cb0b 100644 --- a/include/libdnf5/base/transaction_package.hpp +++ b/include/libdnf5/base/transaction_package.hpp @@ -22,6 +22,7 @@ along with libdnf. If not, see . #define LIBDNF5_BASE_TRANSACTION_PACKAGE_HPP #include "libdnf5/base/transaction.hpp" +#include "libdnf5/defs.h" #include "libdnf5/rpm/package.hpp" #include "libdnf5/transaction/transaction_item_action.hpp" #include "libdnf5/transaction/transaction_item_reason.hpp" @@ -35,7 +36,7 @@ class RpmTransactionTest; namespace libdnf5::base { /// Describe transaction operation related to rpm Package -class TransactionPackage { +class LIBDNF_API TransactionPackage { public: using Action = transaction::TransactionItemAction; using Reason = transaction::TransactionItemReason; @@ -82,14 +83,14 @@ class TransactionPackage { friend class ::BaseGoalTest; friend class ::RpmTransactionTest; - TransactionPackage(const libdnf5::rpm::Package & pkg, Action action, Reason reason); + LIBDNF_LOCAL TransactionPackage(const libdnf5::rpm::Package & pkg, Action action, Reason reason); - TransactionPackage(const libdnf5::rpm::Package & pkg, Action action, Reason reason, State state); + LIBDNF_LOCAL TransactionPackage(const libdnf5::rpm::Package & pkg, Action action, Reason reason, State state); - TransactionPackage( + LIBDNF_LOCAL TransactionPackage( const libdnf5::rpm::Package & pkg, Action action, Reason reason, const std::optional & group_id); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/common/exception.hpp b/include/libdnf5/common/exception.hpp index 785103bfc..5c25959ec 100644 --- a/include/libdnf5/common/exception.hpp +++ b/include/libdnf5/common/exception.hpp @@ -20,6 +20,7 @@ along with libdnf. If not, see . #ifndef LIBDNF5_COMMON_EXCEPTION_HPP #define LIBDNF5_COMMON_EXCEPTION_HPP +#include "libdnf5/defs.h" #include "libdnf5/utils/bgettext/bgettext-mark-common.h" #include "libdnf5/utils/format.hpp" @@ -81,7 +82,7 @@ struct SourceLocation { /// An AssertionError is a fault in the program logic, it is thrown when an /// incorrect sequence of actions has led to an invalid state in which it is /// impossible to continue running the program. -class AssertionError : public std::logic_error { +class LIBDNF_API AssertionError : public std::logic_error { public: explicit AssertionError(const char * assertion, const SourceLocation & location, const std::string & message); @@ -106,7 +107,7 @@ class AssertionError : public std::logic_error { /// into a standard runtime exception which could be handled, /// whereas with the previous `AssertionError` exception the process /// is terminated and the system state is captured for debugging purposes. -class UserAssertionError : public std::logic_error { +class LIBDNF_API UserAssertionError : public std::logic_error { public: explicit UserAssertionError(const char * assertion, const SourceLocation & location, const std::string & message); @@ -143,7 +144,7 @@ concept AllowedErrorArgTypes = /// `get_domain_name()` should always return the exception's class name and its /// namespace (including enclosing class names in case the exception is nested in /// other classes) respectively. -class Error : public std::runtime_error { +class LIBDNF_API Error : public std::runtime_error { public: /// A constructor that supports formatting the error message. /// @@ -175,7 +176,7 @@ class Error : public std::runtime_error { /// An exception class for system errors represented by the `errno` error code. -class SystemError : public Error { +class LIBDNF_API SystemError : public Error { public: /// Constructs the error from the `errno` error code and generates the /// message from the system error description. @@ -212,7 +213,7 @@ class SystemError : public Error { }; /// An exception class for file system errors represented by the `errno` error code and a path. -class FileSystemError : public Error { +class LIBDNF_API FileSystemError : public Error { public: /// Constructs the error from the `errno` error code, filesystem path and a formatted message. /// The formatted message is prepended to the generated system error message. @@ -243,7 +244,7 @@ class FileSystemError : public Error { // TODO(lukash) This class is used throughout the code where more specific exceptions should be thrown. // Kept as a reminder to replace all those with the correct exception classes. -class RuntimeError : public Error { +class LIBDNF_API RuntimeError : public Error { public: using Error::Error; const char * get_name() const noexcept override { return "RuntimeError"; } @@ -258,7 +259,7 @@ enum FormatDetailLevel { /// Formats the error message of an exception. /// If the exception is nested, recurses to format the message of the exception it holds. -std::string format(const std::exception & e, FormatDetailLevel detail); +LIBDNF_API std::string format(const std::exception & e, FormatDetailLevel detail); } // namespace libdnf5 diff --git a/include/libdnf5/common/proc.hpp b/include/libdnf5/common/proc.hpp index 3fa812167..337dd7a95 100644 --- a/include/libdnf5/common/proc.hpp +++ b/include/libdnf5/common/proc.hpp @@ -20,6 +20,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_COMMON_PROC_HPP #define LIBDNF5_COMMON_PROC_HPP +#include "libdnf5/defs.h" + #include @@ -31,13 +33,13 @@ constexpr uid_t INVALID_UID = static_cast(-1); /// @param pid process id /// @return libdnf5::INVALID_UID if fails, login uid otherwise /// @since 5.0 -uid_t read_login_uid_from_proc(pid_t pid) noexcept; +LIBDNF_API uid_t read_login_uid_from_proc(pid_t pid) noexcept; /// Return the current user login uid, if available. /// The getuid() is returned instead if there was a problem. /// The value is cached. /// @since 5.0 -uid_t get_login_uid() noexcept; +LIBDNF_API uid_t get_login_uid() noexcept; } // namespace libdnf5 diff --git a/include/libdnf5/common/sack/match_int64.hpp b/include/libdnf5/common/sack/match_int64.hpp index 65143af32..bb0ad8d1b 100644 --- a/include/libdnf5/common/sack/match_int64.hpp +++ b/include/libdnf5/common/sack/match_int64.hpp @@ -22,16 +22,18 @@ along with libdnf. If not, see . #include "query_cmp.hpp" +#include "libdnf5/defs.h" + #include #include namespace libdnf5::sack { -bool match_int64(int64_t value, QueryCmp cmp, int64_t pattern); -bool match_int64(int64_t value, QueryCmp cmp, const std::vector & patterns); -bool match_int64(const std::vector & values, QueryCmp cmp, int64_t pattern); -bool match_int64(const std::vector & values, QueryCmp cmp, const std::vector & patterns); +LIBDNF_API bool match_int64(int64_t value, QueryCmp cmp, int64_t pattern); +LIBDNF_API bool match_int64(int64_t value, QueryCmp cmp, const std::vector & patterns); +LIBDNF_API bool match_int64(const std::vector & values, QueryCmp cmp, int64_t pattern); +LIBDNF_API bool match_int64(const std::vector & values, QueryCmp cmp, const std::vector & patterns); } // namespace libdnf5::sack diff --git a/include/libdnf5/common/sack/match_string.hpp b/include/libdnf5/common/sack/match_string.hpp index 1b0bf035c..698cb4a68 100644 --- a/include/libdnf5/common/sack/match_string.hpp +++ b/include/libdnf5/common/sack/match_string.hpp @@ -22,16 +22,19 @@ along with libdnf. If not, see . #include "query_cmp.hpp" +#include "libdnf5/defs.h" + #include #include namespace libdnf5::sack { -bool match_string(const std::string & value, QueryCmp cmp, const std::string & pattern); -bool match_string(const std::string & value, QueryCmp cmp, const std::vector & patterns); -bool match_string(const std::vector & values, QueryCmp cmp, const std::string & pattern); -bool match_string(const std::vector & values, QueryCmp cmp, const std::vector & patterns); +LIBDNF_API bool match_string(const std::string & value, QueryCmp cmp, const std::string & pattern); +LIBDNF_API bool match_string(const std::string & value, QueryCmp cmp, const std::vector & patterns); +LIBDNF_API bool match_string(const std::vector & values, QueryCmp cmp, const std::string & pattern); +LIBDNF_API bool match_string( + const std::vector & values, QueryCmp cmp, const std::vector & patterns); } // namespace libdnf5::sack diff --git a/include/libdnf5/common/sack/query.hpp b/include/libdnf5/common/sack/query.hpp index a460f82a7..200c2ed6f 100644 --- a/include/libdnf5/common/sack/query.hpp +++ b/include/libdnf5/common/sack/query.hpp @@ -26,6 +26,7 @@ along with libdnf. If not, see . #include "libdnf5/common/exception.hpp" #include "libdnf5/common/set.hpp" +#include "libdnf5/defs.h" #include #include @@ -36,7 +37,7 @@ along with libdnf. If not, see . namespace libdnf5::sack { -extern const BgettextMessage msg_err_exact_one_object; +LIBDNF_API extern const BgettextMessage msg_err_exact_one_object; /// Query is a Set with filtering capabilities. template diff --git a/include/libdnf5/common/xdg.hpp b/include/libdnf5/common/xdg.hpp index 7a2fc63a1..c1860498d 100644 --- a/include/libdnf5/common/xdg.hpp +++ b/include/libdnf5/common/xdg.hpp @@ -20,33 +20,35 @@ along with libdnf. If not, see . #ifndef LIBDNF5_COMMON_XDG_HPP #define LIBDNF5_COMMON_XDG_HPP +#include "libdnf5/defs.h" + #include namespace libdnf5::xdg { /// Returns user home directory. -std::filesystem::path get_user_home_dir(); +LIBDNF_API std::filesystem::path get_user_home_dir(); /// Returns user cache directory. /// A base directory relative to which user specific non-essential data files should be stored. -std::filesystem::path get_user_cache_dir(); +LIBDNF_API std::filesystem::path get_user_cache_dir(); /// Returns user configuration directory. /// A base directory relative to which user specific configuration files should be stored. -std::filesystem::path get_user_config_dir(); +LIBDNF_API std::filesystem::path get_user_config_dir(); /// Returns user data directory. /// A base directory relative to which user specific data files should be stored. -std::filesystem::path get_user_data_dir(); +LIBDNF_API std::filesystem::path get_user_data_dir(); /// Returns user state directory. /// A base directory relative to which user specific state data should be stored. -std::filesystem::path get_user_state_dir(); +LIBDNF_API std::filesystem::path get_user_state_dir(); /// Returns user runtime directory. /// A base directory relative to which user-specific non-essential runtime files and other file objects /// (such as sockets, named pipes, ...) should be stored. -std::filesystem::path get_user_runtime_dir(); +LIBDNF_API std::filesystem::path get_user_runtime_dir(); } // namespace libdnf5::xdg diff --git a/include/libdnf5/comps/environment/environment.hpp b/include/libdnf5/comps/environment/environment.hpp index fa324877c..92799df52 100644 --- a/include/libdnf5/comps/environment/environment.hpp +++ b/include/libdnf5/comps/environment/environment.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define LIBDNF5_COMPS_ENVIRONMENT_ENVIRONMENT_HPP #include "libdnf5/base/base_weak.hpp" +#include "libdnf5/defs.h" #include "libdnf5/transaction/transaction_item_reason.hpp" #include @@ -45,7 +46,7 @@ struct EnvironmentId { // @replaces dnf:dnf/comps.py:class:Environment -class Environment { +class LIBDNF_API Environment { public: ~Environment(); @@ -141,9 +142,9 @@ class Environment { private: friend class EnvironmentQuery; - void add_environment_id(const EnvironmentId & environment_id); + LIBDNF_LOCAL void add_environment_id(const EnvironmentId & environment_id); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/comps/environment/query.hpp b/include/libdnf5/comps/environment/query.hpp index c64aedece..9443ade2e 100644 --- a/include/libdnf5/comps/environment/query.hpp +++ b/include/libdnf5/comps/environment/query.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/common/sack/query.hpp" #include "libdnf5/comps/environment/environment.hpp" +#include "libdnf5/defs.h" #include #include @@ -31,7 +32,7 @@ along with libdnf. If not, see . namespace libdnf5::comps { -class EnvironmentQuery : public libdnf5::sack::Query { +class LIBDNF_API EnvironmentQuery : public libdnf5::sack::Query { public: // Create new query with newly composed environments (using only solvables from currently enabled repositories) explicit EnvironmentQuery(const libdnf5::BaseWeakPtr & base, bool empty = false); @@ -57,7 +58,7 @@ class EnvironmentQuery : public libdnf5::sack::Query { private: friend Environment; - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/comps/group/group.hpp b/include/libdnf5/comps/group/group.hpp index 44c7b26e8..033e7005f 100644 --- a/include/libdnf5/comps/group/group.hpp +++ b/include/libdnf5/comps/group/group.hpp @@ -22,6 +22,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/comps/group/package.hpp" +#include "libdnf5/defs.h" #include "libdnf5/transaction/transaction_item_reason.hpp" #include @@ -46,7 +47,7 @@ struct GroupId { // @replaces dnf:dnf/comps.py:class:Group -class Group { +class LIBDNF_API Group { public: ~Group(); @@ -158,9 +159,9 @@ class Group { private: friend class GroupQuery; - void add_group_id(const GroupId & group_id); + LIBDNF_LOCAL void add_group_id(const GroupId & group_id); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/comps/group/package.hpp b/include/libdnf5/comps/group/package.hpp index c9f3e14ee..f941fcf70 100644 --- a/include/libdnf5/comps/group/package.hpp +++ b/include/libdnf5/comps/group/package.hpp @@ -22,6 +22,8 @@ along with libdnf. If not, see . #include "package_type.hpp" +#include "libdnf5/defs.h" + #include namespace libdnf5::comps { @@ -30,7 +32,7 @@ namespace libdnf5::comps { // @replaces dnf:dnf/comps.py:class:Package // @replaces dnf:dnf/comps.py:class:CompsTransPkg -class Package { +class LIBDNF_API Package { public: Package(const std::string & name, PackageType type, const std::string & condition); @@ -68,7 +70,7 @@ class Package { void set_condition(const std::string & value); private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/comps/group/package_type.hpp b/include/libdnf5/comps/group/package_type.hpp index b5ad4fc89..3e874ef76 100644 --- a/include/libdnf5/comps/group/package_type.hpp +++ b/include/libdnf5/comps/group/package_type.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define LIBDNF5_COMPS_GROUP_PACKAGE_TYPE_HPP #include "libdnf5/common/exception.hpp" +#include "libdnf5/defs.h" #include #include @@ -34,7 +35,7 @@ enum class PackageType : int { OPTIONAL = 1 << 3 // not installed by default, but can be checked in the UI }; -class InvalidPackageType : public libdnf5::Error { +class LIBDNF_API InvalidPackageType : public libdnf5::Error { public: InvalidPackageType(const std::string & type); InvalidPackageType(const PackageType type); @@ -66,10 +67,10 @@ inline constexpr bool any(PackageType flags) { return static_cast::type>(flags) != 0; } -PackageType package_type_from_string(const std::string & type); -PackageType package_type_from_string(const std::vector types); -std::string package_type_to_string(const PackageType type); -std::vector package_types_to_strings(const PackageType types); +LIBDNF_API PackageType package_type_from_string(const std::string & type); +LIBDNF_API PackageType package_type_from_string(const std::vector types); +LIBDNF_API std::string package_type_to_string(const PackageType type); +LIBDNF_API std::vector package_types_to_strings(const PackageType types); } // namespace libdnf5::comps diff --git a/include/libdnf5/comps/group/query.hpp b/include/libdnf5/comps/group/query.hpp index d8c798100..fddfabf9f 100644 --- a/include/libdnf5/comps/group/query.hpp +++ b/include/libdnf5/comps/group/query.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/common/sack/query.hpp" #include "libdnf5/comps/group/group.hpp" +#include "libdnf5/defs.h" #include #include @@ -31,7 +32,7 @@ along with libdnf. If not, see . namespace libdnf5::comps { -class GroupQuery : public libdnf5::sack::Query { +class LIBDNF_API GroupQuery : public libdnf5::sack::Query { public: // Create new query with newly composed groups (using only solvables from currently enabled repositories) explicit GroupQuery(const libdnf5::BaseWeakPtr & base, bool empty = false); @@ -67,7 +68,7 @@ class GroupQuery : public libdnf5::sack::Query { private: friend Group; - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/conf/config.hpp b/include/libdnf5/conf/config.hpp index e5faf2746..9ad4e4314 100644 --- a/include/libdnf5/conf/config.hpp +++ b/include/libdnf5/conf/config.hpp @@ -25,13 +25,14 @@ along with libdnf. If not, see . #include "option_binds.hpp" #include "vars.hpp" +#include "libdnf5/defs.h" #include "libdnf5/logger/logger.hpp" namespace libdnf5 { /// Base class for configurations objects -class Config { +class LIBDNF_API Config { public: OptionBinds & opt_binds() noexcept; @@ -46,7 +47,7 @@ class Config { Option::Priority priority); private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/conf/config_main.hpp b/include/libdnf5/conf/config_main.hpp index c4a8d669e..899d5163c 100644 --- a/include/libdnf5/conf/config_main.hpp +++ b/include/libdnf5/conf/config_main.hpp @@ -37,7 +37,7 @@ along with libdnf. If not, see . namespace libdnf5 { /// Holds global configuration -class ConfigMain : public Config { +class LIBDNF_API ConfigMain : public Config { public: ConfigMain(); ~ConfigMain(); @@ -297,7 +297,7 @@ class ConfigMain : public Config { Option::Priority priority = Option::Priority::MAINCONFIG) override; private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/conf/config_parser.hpp b/include/libdnf5/conf/config_parser.hpp index c3479e066..bd1d43bfd 100644 --- a/include/libdnf5/conf/config_parser.hpp +++ b/include/libdnf5/conf/config_parser.hpp @@ -29,7 +29,7 @@ along with libdnf. If not, see . namespace libdnf5 { /// Error accessing config file other than ENOENT; e.g. we don't have read permission -class InaccessibleConfigError : public Error { +class LIBDNF_API InaccessibleConfigError : public Error { public: using Error::Error; const char * get_domain_name() const noexcept override { return "libdnf5"; } @@ -37,7 +37,7 @@ class InaccessibleConfigError : public Error { }; /// Configuration file is missing -class MissingConfigError : public Error { +class LIBDNF_API MissingConfigError : public Error { public: using Error::Error; const char * get_domain_name() const noexcept override { return "libdnf5"; } @@ -45,27 +45,27 @@ class MissingConfigError : public Error { }; /// Configuration file is invalid -class InvalidConfigError : public Error { +class LIBDNF_API InvalidConfigError : public Error { public: using Error::Error; const char * get_domain_name() const noexcept override { return "libdnf5"; } const char * get_name() const noexcept override { return "InvalidConfigError"; } }; -class ConfigParserError : public Error { +class LIBDNF_API ConfigParserError : public Error { public: using Error::Error; const char * get_domain_name() const noexcept override { return "libdnf5"; } const char * get_name() const noexcept override { return "ConfigParserError"; } }; -class ConfigParserSectionNotFoundError : public ConfigParserError { +class LIBDNF_API ConfigParserSectionNotFoundError : public ConfigParserError { public: explicit ConfigParserSectionNotFoundError(const std::string & section); const char * get_name() const noexcept override { return "ConfigParserSectionNotFoundError"; } }; -class ConfigParserOptionNotFoundError : public ConfigParserError { +class LIBDNF_API ConfigParserOptionNotFoundError : public ConfigParserError { public: explicit ConfigParserOptionNotFoundError(const std::string & section, const std::string & option); const char * get_name() const noexcept override { return "ConfigParserOptionNotFoundError"; } @@ -81,7 +81,7 @@ class ConfigParserOptionNotFoundError : public ConfigParserError { * The parsed items are stored into the PreserveOrderMap. * ConfigParser preserve order of items. Comments and empty lines are kept. */ -struct ConfigParser { +struct LIBDNF_API ConfigParser { public: using Container = PreserveOrderMap>; @@ -140,7 +140,7 @@ struct ConfigParser { Container & get_data() noexcept; private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/conf/option.hpp b/include/libdnf5/conf/option.hpp index bd1ee5c01..bc8f4fcac 100644 --- a/include/libdnf5/conf/option.hpp +++ b/include/libdnf5/conf/option.hpp @@ -22,6 +22,7 @@ along with libdnf. If not, see . #include "libdnf5/common/exception.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include @@ -29,7 +30,7 @@ along with libdnf. If not, see . namespace libdnf5 { /// Option exception -class OptionError : public Error { +class LIBDNF_API OptionError : public Error { public: using Error::Error; const char * get_domain_name() const noexcept override { return "libdnf5"; } @@ -37,21 +38,21 @@ class OptionError : public Error { }; /// Exception that is generated when an invalid input value is detected. -class OptionInvalidValueError : public OptionError { +class LIBDNF_API OptionInvalidValueError : public OptionError { public: using OptionError::OptionError; const char * get_name() const noexcept override { return "OptionInvalidValueError"; } }; /// Exception that is generated when not allowed input value is detected. -class OptionValueNotAllowedError : public OptionInvalidValueError { +class LIBDNF_API OptionValueNotAllowedError : public OptionInvalidValueError { public: using OptionInvalidValueError::OptionInvalidValueError; const char * get_name() const noexcept override { return "OptionValueNotAllowedError"; } }; /// Exception that is generated during read an empty Option. -class OptionValueNotSetError : public OptionError { +class LIBDNF_API OptionValueNotSetError : public OptionError { public: using OptionError::OptionError; const char * get_name() const noexcept override { return "OptionValueNotSetError"; } @@ -60,7 +61,7 @@ class OptionValueNotSetError : public OptionError { /// Option class is an abstract class. Parent of all options. Options are used to store a configuration. // @replaces libdnf:conf/Option.hpp:class:Option -class Option { +class LIBDNF_API Option { public: // TODO(jrohel): Prioroties are under discussion and probably will be modified. // @replaces libdnf:conf/Option.hpp:enum class:Option::Priority @@ -128,7 +129,7 @@ class Option { const std::string & get_lock_comment() const noexcept; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/conf/option_binds.hpp b/include/libdnf5/conf/option_binds.hpp index 639af2a4c..dcdaaef2d 100644 --- a/include/libdnf5/conf/option_binds.hpp +++ b/include/libdnf5/conf/option_binds.hpp @@ -48,7 +48,7 @@ class OptionBindsOptionAlreadyExistsError : public OptionBindsError { /// Maps the options names (text names read from config file, command line, ...) to options objects. /// Supports user defined functions for processing new value and converting value to string. -class OptionBinds { +class LIBDNF_API OptionBinds { public: /// Extends the option with user-defined functions for processing a new value and converting value to a string. /// It is used as additional level of processing when the option is accessed by its text name. @@ -66,10 +66,11 @@ class OptionBinds { private: friend class OptionBinds; - Item(Option & option, NewStringFunc new_string_func, GetValueStringFunc get_value_string_func, bool add_value); - explicit Item(Option & option); + LIBDNF_LOCAL Item( + Option & option, NewStringFunc new_string_func, GetValueStringFunc get_value_string_func, bool add_value); + LIBDNF_LOCAL explicit Item(Option & option); - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; @@ -102,7 +103,7 @@ class OptionBinds { const_iterator find(const std::string & id) const; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/conf/option_bool.hpp b/include/libdnf5/conf/option_bool.hpp index d7ffe5aca..906fe5f9f 100644 --- a/include/libdnf5/conf/option_bool.hpp +++ b/include/libdnf5/conf/option_bool.hpp @@ -32,7 +32,7 @@ namespace libdnf5 { /// Conversion from string to bool is done according to vectors which contains strings of true and false values. /// Conversion is case insensitive for input. Values must be lower case in vectors. // @replaces libdnf:conf/OptionBool.hpp:class:OptionBool -class OptionBool : public Option { +class LIBDNF_API OptionBool : public Option { public: using ValueType = bool; @@ -109,7 +109,7 @@ class OptionBool : public Option { std::string to_string(bool value) const; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/conf/option_enum.hpp b/include/libdnf5/conf/option_enum.hpp index 98fef8a72..c7516bab7 100644 --- a/include/libdnf5/conf/option_enum.hpp +++ b/include/libdnf5/conf/option_enum.hpp @@ -32,7 +32,7 @@ namespace libdnf5 { /// It supports default value. /// It supports user defined function for conversion from string. // @replaces libdnf:conf/OptionEnum.hpp:class:OptionEnum -class OptionEnum : public Option { +class LIBDNF_API OptionEnum : public Option { public: using ValueType = std::string; using FromStringFunc = std::function; @@ -75,7 +75,7 @@ class OptionEnum : public Option { std::string from_string(const std::string & value) const; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/conf/option_number.hpp b/include/libdnf5/conf/option_number.hpp index 459f41276..8a3f178fe 100644 --- a/include/libdnf5/conf/option_number.hpp +++ b/include/libdnf5/conf/option_number.hpp @@ -31,7 +31,7 @@ namespace libdnf5 { /// Support default value, minimal and maximal values, user defined function for conversion from string. // @replaces libdnf:conf/OptionNumber.hpp:class:OptionNumber template -class OptionNumber : public Option { +class LIBDNF_API OptionNumber : public Option { public: using ValueType = T; using FromStringFunc = std::function; @@ -109,7 +109,7 @@ class OptionNumber : public Option { std::string to_string(ValueType value) const; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/conf/option_path.hpp b/include/libdnf5/conf/option_path.hpp index 9270629bb..eb917a68d 100644 --- a/include/libdnf5/conf/option_path.hpp +++ b/include/libdnf5/conf/option_path.hpp @@ -36,7 +36,7 @@ class OptionPathNotFoundError : public OptionValueNotAllowedError { /// Option that stores file/directory path. /// Support default value, and path verification (absolute, existence). // @replaces libdnf:conf/OptionPath.hpp:class:OptionPath -class OptionPath : public OptionString { +class LIBDNF_API OptionPath : public OptionString { public: /// Constructor sets default value and conditions. // @replaces libdnf:conf/OptionPath.hpp:ctor:OptionPath.OptionPath(const std::string & defaultValue, bool exists = false, bool absPath = false) @@ -76,7 +76,7 @@ class OptionPath : public OptionString { void test(const std::string & value) const; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/conf/option_seconds.hpp b/include/libdnf5/conf/option_seconds.hpp index 3a649f206..c9c4d2e29 100644 --- a/include/libdnf5/conf/option_seconds.hpp +++ b/include/libdnf5/conf/option_seconds.hpp @@ -28,7 +28,7 @@ namespace libdnf5 { /// Option that stores an integer value of seconds. /// Support default value, minimal and maximal values. // @replaces libdnf:conf/OptionSeconds.hpp:class:OptionSeconds -class OptionSeconds : public OptionNumber { +class LIBDNF_API OptionSeconds : public OptionNumber { public: OptionSeconds(ValueType default_value, ValueType min, ValueType max); OptionSeconds(ValueType default_value, ValueType min); diff --git a/include/libdnf5/conf/option_string.hpp b/include/libdnf5/conf/option_string.hpp index aed29e91c..0d9f08ecb 100644 --- a/include/libdnf5/conf/option_string.hpp +++ b/include/libdnf5/conf/option_string.hpp @@ -28,7 +28,7 @@ namespace libdnf5 { /// Option that stores string value. /// Support default value, and check of an input value using the regular expression // @replaces libdnf:conf/OptionString.hpp:class:OptionString -class OptionString : public Option { +class LIBDNF_API OptionString : public Option { public: using ValueType = std::string; @@ -75,7 +75,7 @@ class OptionString : public Option { private: friend class OptionPath; - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/conf/option_string_list.hpp b/include/libdnf5/conf/option_string_list.hpp index 4fc401156..cea7bb408 100644 --- a/include/libdnf5/conf/option_string_list.hpp +++ b/include/libdnf5/conf/option_string_list.hpp @@ -36,7 +36,7 @@ namespace libdnf5 { /// Support default value, and check of an input value using the regular expression. // @replaces libdnf:conf/OptionStringList.hpp:class:OptionStringList template -class OptionStringContainer : public Option { +class LIBDNF_API OptionStringContainer : public Option { public: using ValueType = T; @@ -116,10 +116,10 @@ class OptionStringContainer : public Option { void test_item(const std::string & item) const; private: - void init_regex_matcher(); - void test_item_worker(const std::string & item) const; + LIBDNF_LOCAL void init_regex_matcher(); + LIBDNF_LOCAL void test_item_worker(const std::string & item) const; - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/conf/vars.hpp b/include/libdnf5/conf/vars.hpp index aac1be840..9e7aefb4d 100644 --- a/include/libdnf5/conf/vars.hpp +++ b/include/libdnf5/conf/vars.hpp @@ -42,7 +42,7 @@ class ReadOnlyVariableError : public Error { /// /// The class loads the variables from the environment as well as from a list /// of directories. -struct Vars { +struct LIBDNF_API Vars { public: enum class Priority { DEFAULT = 10, @@ -123,12 +123,12 @@ struct Vars { /// /// @param installroot The path to the installroot /// @param directories The directories to load vars from - void load(const std::string & installroot, const std::vector & directories); + LIBDNF_LOCAL void load(const std::string & installroot, const std::vector & directories); /// @brief Detects the system's arch, basearch and relesever. /// /// @param installroot The installroot directory - void detect_vars(const std::string & installroot); + LIBDNF_LOCAL void detect_vars(const std::string & installroot); /// @brief Loads DNF vars from a directory. /// @@ -137,13 +137,13 @@ struct Vars { /// file's contents. /// /// @param directory Path to a directory with DNF vars - void load_from_dir(const std::string & directory); + LIBDNF_LOCAL void load_from_dir(const std::string & directory); /// @brief Loads DNF vars from the environment. /// /// Reads environment variables that match "DNF[0-9]" and /// "DNF_VAR_[A-Za-z0-9_]+" patterns. The "DNF_VAR_" prefix is cut off. - void load_from_env(); + LIBDNF_LOCAL void load_from_env(); /// @brief Set a variable to a value, only obtaining the value if needed using `get_value` /// @@ -151,7 +151,7 @@ struct Vars { /// @param get_value Function that returns the (optional) value for the variable /// @param prio Source/Priority of the value /// @throw ReadOnlyVariableError if the variable is read-only - void set_lazy( + LIBDNF_LOCAL void set_lazy( const std::string & name, const std::function()> & get_value, Priority prio); @@ -161,15 +161,15 @@ struct Vars { /// @param text String with variable expressions /// @param depth The recursive depth /// @return Pair of the resulting string and the number of characters scanned in `text` - std::pair substitute_expression(std::string_view text, unsigned int depth) const; + LIBDNF_LOCAL std::pair substitute_expression(std::string_view text, unsigned int depth) const; /// @brief Split releasever on the first "." into its "major" and "minor" components /// /// @param releasever A releasever string, possibly containing a "." /// @return releasever_major, releasever_minor - static std::tuple split_releasever(const std::string & releasever); + LIBDNF_LOCAL static std::tuple split_releasever(const std::string & releasever); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/logger/factory.hpp b/include/libdnf5/logger/factory.hpp index f17d2c022..966d10c47 100644 --- a/include/libdnf5/logger/factory.hpp +++ b/include/libdnf5/logger/factory.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "logger.hpp" #include "libdnf5/base/base.hpp" +#include "libdnf5/defs.h" namespace libdnf5 { @@ -31,13 +32,14 @@ namespace libdnf5 { /// @param base Reference to Base for loading the configured logger path. /// @param filename Name of the log file. /// @return Instance of a new file logger. -std::unique_ptr create_file_logger(libdnf5::Base & base, const std::string & filename); +LIBDNF_API std::unique_ptr create_file_logger(libdnf5::Base & base, const std::string & filename); /// @brief Helper method for creating a rotating file logger in `logdir` location with given file name. /// @param base Reference to Base for loading the configured parameters. /// @param filename Name of the log file. /// @return Instance of a new rotating file logger. -std::unique_ptr create_rotating_file_logger(libdnf5::Base & base, const std::string & filename); +LIBDNF_API std::unique_ptr create_rotating_file_logger( + libdnf5::Base & base, const std::string & filename); } // namespace libdnf5 diff --git a/include/libdnf5/logger/global_logger.hpp b/include/libdnf5/logger/global_logger.hpp index 62ec025dc..241c81750 100644 --- a/include/libdnf5/logger/global_logger.hpp +++ b/include/libdnf5/logger/global_logger.hpp @@ -27,7 +27,7 @@ namespace libdnf5 { /// GlobalLogger contains methods for setting the target (logger) for global messages - messages that are /// generated by libraries (eg librepo) without binding to the Base object. -class GlobalLogger { +class LIBDNF_API GlobalLogger { public: explicit GlobalLogger(); ~GlobalLogger(); diff --git a/include/libdnf5/logger/log_router.hpp b/include/libdnf5/logger/log_router.hpp index 3daf053e0..b55900d07 100644 --- a/include/libdnf5/logger/log_router.hpp +++ b/include/libdnf5/logger/log_router.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "logger.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include #include @@ -32,7 +33,7 @@ namespace libdnf5 { /// LogRouter is an implementation of logging class that forwards incoming logging messages to several other loggers. /// Loggers can be addressed via index. Index is serial number of the logger starting from zero. -class LogRouter : public Logger { +class LIBDNF_API LogRouter : public Logger { public: /// Constructs a new LogRouter instance with an empty set of destination loggers. explicit LogRouter(); @@ -67,7 +68,7 @@ class LogRouter : public Logger { const std::string & message) noexcept override; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/logger/logger.hpp b/include/libdnf5/logger/logger.hpp index ff33371ee..8907dc3cd 100644 --- a/include/libdnf5/logger/logger.hpp +++ b/include/libdnf5/logger/logger.hpp @@ -20,6 +20,7 @@ along with libdnf. If not, see . #ifndef LIBDNF5_LOGGER_LOGGER_HPP #define LIBDNF5_LOGGER_LOGGER_HPP +#include "libdnf5/defs.h" #include "libdnf5/utils/format.hpp" #include @@ -34,7 +35,7 @@ namespace libdnf5 { /// Logger is an abstract interface used for logging. /// An implementation (inherited class) can call callbacks, log the messages to memory, file, or somewhere else. -class Logger { +class LIBDNF_API Logger { public: explicit Logger(); @@ -99,7 +100,7 @@ class Logger { }; -class StringLogger : public Logger { +class LIBDNF_API StringLogger : public Logger { public: explicit StringLogger(); ~StringLogger() override; diff --git a/include/libdnf5/logger/memory_buffer_logger.hpp b/include/libdnf5/logger/memory_buffer_logger.hpp index 8516c2f46..4618134d0 100644 --- a/include/libdnf5/logger/memory_buffer_logger.hpp +++ b/include/libdnf5/logger/memory_buffer_logger.hpp @@ -23,12 +23,14 @@ along with libdnf. If not, see . #include "logger.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" + namespace libdnf5 { /// MemoryBufferLogger is an implementation of logging class that stores incoming logging messages into memory buffer. /// It is usually used as temporary logger until a final logger is configured. -class MemoryBufferLogger : public Logger { +class LIBDNF_API MemoryBufferLogger : public Logger { public: struct Item { std::chrono::time_point time; @@ -52,7 +54,7 @@ class MemoryBufferLogger : public Logger { void write_to_logger(Logger & logger); private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/logger/null_logger.hpp b/include/libdnf5/logger/null_logger.hpp index 5a079b81f..d8a061f11 100644 --- a/include/libdnf5/logger/null_logger.hpp +++ b/include/libdnf5/logger/null_logger.hpp @@ -22,12 +22,13 @@ along with libdnf. If not, see . #include "logger.hpp" +#include "libdnf5/defs.h" namespace libdnf5 { /// NullLogger is an implementation of logging class that discards all incoming logging messages. /// It can be used in case when no logs are needed. -class NullLogger : public Logger { +class LIBDNF_API NullLogger : public Logger { public: explicit NullLogger(); ~NullLogger() override; diff --git a/include/libdnf5/logger/rotating_file_logger.hpp b/include/libdnf5/logger/rotating_file_logger.hpp index f2a66a0f3..93adca737 100644 --- a/include/libdnf5/logger/rotating_file_logger.hpp +++ b/include/libdnf5/logger/rotating_file_logger.hpp @@ -24,6 +24,7 @@ along with libdnf. If not, see . #include "libdnf5/common/exception.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include @@ -31,7 +32,7 @@ namespace libdnf5 { /// RotatingFileLogger is an implementation of a rotating file logger. /// It can be used simultaneously in multiple processes and threads. -class RotatingFileLogger : public StringLogger { +class LIBDNF_API RotatingFileLogger : public StringLogger { public: /// Construct a new instance of the `RotatingFileLogger` class. /// @@ -59,7 +60,7 @@ class RotatingFileLogger : public StringLogger { void write(const char * line) noexcept override; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/logger/stream_logger.hpp b/include/libdnf5/logger/stream_logger.hpp index 2aa7451d1..a9484023a 100644 --- a/include/libdnf5/logger/stream_logger.hpp +++ b/include/libdnf5/logger/stream_logger.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "logger.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include #include @@ -31,7 +32,7 @@ along with libdnf. If not, see . namespace libdnf5 { /// StreamLogger is an implementation of logging class that writes messages into a stream. -class StreamLogger : public StringLogger { +class LIBDNF_API StreamLogger : public StringLogger { public: explicit StreamLogger(std::unique_ptr && log_stream); ~StreamLogger() override; @@ -39,12 +40,12 @@ class StreamLogger : public StringLogger { void write(const char * line) noexcept override; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; /// Logger that logs to a stream stored as a reference, meant to be used with std::cerr and std::cout. -class StdCStreamLogger : public StringLogger { +class LIBDNF_API StdCStreamLogger : public StringLogger { public: explicit StdCStreamLogger(std::ostream & log_stream); ~StdCStreamLogger() override; @@ -52,7 +53,7 @@ class StdCStreamLogger : public StringLogger { void write(const char * line) noexcept override; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/module/module_dependency.hpp b/include/libdnf5/module/module_dependency.hpp index 24fd4b249..14463095b 100644 --- a/include/libdnf5/module/module_dependency.hpp +++ b/include/libdnf5/module/module_dependency.hpp @@ -20,6 +20,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_MODULE_MODULE_DEPENDENCY_HPP #define LIBDNF5_MODULE_MODULE_DEPENDENCY_HPP +#include "libdnf5/defs.h" + #include #include #include @@ -27,7 +29,7 @@ along with libdnf. If not, see . namespace libdnf5::module { -class ModuleDependency { +class LIBDNF_API ModuleDependency { public: ModuleDependency(const std::string & module_name, const std::vector & streams); @@ -53,7 +55,7 @@ class ModuleDependency { std::string to_string(); private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/module/module_item.hpp b/include/libdnf5/module/module_item.hpp index 84c3c3377..18a377f8d 100644 --- a/include/libdnf5/module/module_item.hpp +++ b/include/libdnf5/module/module_item.hpp @@ -20,6 +20,7 @@ along with libdnf. If not, see . #ifndef LIBDNF5_MODULE_MODULE_ITEM_HPP #define LIBDNF5_MODULE_MODULE_ITEM_HPP +#include "libdnf5/defs.h" #include "libdnf5/module/module_dependency.hpp" #include "libdnf5/module/module_profile.hpp" #include "libdnf5/module/module_sack_weak.hpp" @@ -53,7 +54,7 @@ struct ModuleItemId { // Represents one modulemd document (uniquely described by name:stream:version:context:arch, but there can theoretically be more objects with the same NSVCA) // @replaces libdnf:module/ModuleItem.hpp:class:ModuleItem -class ModuleItem { +class LIBDNF_API ModuleItem { public: bool operator==(const ModuleItem & rhs) const noexcept; bool operator!=(const ModuleItem & rhs) const noexcept; @@ -188,30 +189,31 @@ class ModuleItem { friend class ModuleMetadata; friend ::ModuleTest; - ModuleItem(_ModulemdModuleStream * md_stream, const ModuleSackWeakPtr & module_sack, const std::string & repo_id); + LIBDNF_LOCAL ModuleItem( + _ModulemdModuleStream * md_stream, const ModuleSackWeakPtr & module_sack, const std::string & repo_id); // @replaces libdnf:module/ModuleItem.hpp:method:ModuleItem.getNameCStr() - const char * get_name_cstr() const; + LIBDNF_LOCAL const char * get_name_cstr() const; // @replaces libdnf:module/ModuleItem.hpp:method:ModuleItem.getStreamCStr() - const char * get_stream_cstr() const; + LIBDNF_LOCAL const char * get_stream_cstr() const; // @replaces libdnf:module/ModuleItem.hpp:method:ModuleItem.getContextCStr() - const char * get_context_cstr() const; + LIBDNF_LOCAL const char * get_context_cstr() const; // @replaces libdnf:module/ModuleItem.hpp:method:ModuleItem.getArchCStr() - const char * get_arch_cstr() const; + LIBDNF_LOCAL const char * get_arch_cstr() const; // @replaces libdnf:module/ModuleItem.hpp:method:ModuleItem.getNameStream() - std::string get_name_stream() const; + LIBDNF_LOCAL std::string get_name_stream() const; // @replaces libdnf:module/ModuleItem.hpp:method:ModuleItem.getNameStreamVersion() - std::string get_name_stream_version() const; + LIBDNF_LOCAL std::string get_name_stream_version() const; /// @return The "name:stream:computed_static_context" string if computed_static_context exists, otherwise, /// the "name:stream:version:context" string. - std::string get_name_stream_staticcontext() const; + LIBDNF_LOCAL std::string get_name_stream_staticcontext() const; /// @return The "name:stream:computed_static_context:arch" string if computed_static_context exists, otherwise, /// the "name:stream:version:context:arch" string. - std::string get_name_stream_staticcontext_arch() const; + LIBDNF_LOCAL std::string get_name_stream_staticcontext_arch() const; - std::vector get_profiles_internal(const char * name) const; + LIBDNF_LOCAL std::vector get_profiles_internal(const char * name) const; - static std::vector get_module_dependencies( + LIBDNF_LOCAL static std::vector get_module_dependencies( _ModulemdModuleStream * md_stream, bool remove_platform); // TODO(pkratoch): Make this private once it's not used in tests. @@ -222,10 +224,11 @@ class ModuleItem { /// @since 5.0 // // @replaces libdnf:module/ModuleItem.hpp:method:ModuleItem.getRequires(bool removePlatform=false) - static std::string get_module_dependencies_string(_ModulemdModuleStream * md_stream, bool remove_platform); - std::string get_module_dependencies_string(bool remove_platform = false) const; + LIBDNF_LOCAL static std::string get_module_dependencies_string( + _ModulemdModuleStream * md_stream, bool remove_platform); + LIBDNF_LOCAL std::string get_module_dependencies_string(bool remove_platform = false) const; - static std::string get_name_stream(_ModulemdModuleStream * md_stream); + LIBDNF_LOCAL static std::string get_name_stream(_ModulemdModuleStream * md_stream); /// Create solvable with: /// Name: $name:$stream:$context @@ -235,22 +238,22 @@ class ModuleItem { /// Provides: module($name:$stream) /// Conflicts: module($name) /// Description: $name:$stream - void create_solvable(); - void create_dependencies() const; - void create_solvable_and_dependencies(); + LIBDNF_LOCAL void create_solvable(); + LIBDNF_LOCAL void create_dependencies() const; + LIBDNF_LOCAL void create_solvable_and_dependencies(); /// @brief Create platform solvable. Intended to be used for autodetecting modular platform ID. /// @param module_sack Reference to a modular sack where the target pool with solvables is located. /// @param name Platform name. /// @param stream Platform stream. - static void create_platform_solvable( + LIBDNF_LOCAL static void create_platform_solvable( const ModuleSackWeakPtr & module_sack, const std::string & name, const std::string & stream); - libdnf5::module::ModuleSackWeakPtr get_module_sack() const; + LIBDNF_LOCAL libdnf5::module::ModuleSackWeakPtr get_module_sack() const; - void set_computed_static_context(const std::string & context); + LIBDNF_LOCAL void set_computed_static_context(const std::string & context); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/module/module_profile.hpp b/include/libdnf5/module/module_profile.hpp index a867140d5..853f77514 100644 --- a/include/libdnf5/module/module_profile.hpp +++ b/include/libdnf5/module/module_profile.hpp @@ -20,6 +20,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_MODULE_MODULE_PROFILE_HPP #define LIBDNF5_MODULE_MODULE_PROFILE_HPP +#include "libdnf5/defs.h" + #include #include #include @@ -31,7 +33,7 @@ namespace libdnf5::module { // @replaces libdnf:module:modulemd/ModuleProfile.hpp:class:ModuleProfile -class ModuleProfile { +class LIBDNF_API ModuleProfile { public: /// @return The profile name. /// @since 5.0 @@ -69,9 +71,9 @@ class ModuleProfile { friend class ModuleItem; // @replaces libdnf:module:modulemd/ModuleProfile.hpp:ctor:ModuleProfile.ModuleProfile(ModulemdProfile * profile) - ModuleProfile(_ModulemdProfile * profile, const bool is_default); + LIBDNF_LOCAL ModuleProfile(_ModulemdProfile * profile, const bool is_default); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/module/module_query.hpp b/include/libdnf5/module/module_query.hpp index 67372ea7f..6cfe93ae6 100644 --- a/include/libdnf5/module/module_query.hpp +++ b/include/libdnf5/module/module_query.hpp @@ -24,6 +24,7 @@ along with libdnf. If not, see . #include "libdnf5/common/sack/query.hpp" #include "libdnf5/common/sack/query_cmp.hpp" #include "libdnf5/common/weak_ptr.hpp" +#include "libdnf5/defs.h" #include "libdnf5/module/module_item.hpp" #include "libdnf5/module/nsvcap.hpp" @@ -34,7 +35,7 @@ along with libdnf. If not, see . namespace libdnf5::module { // TODO(pkratoch): Store pointers to ModuleItems instead of ModuleItems to allow faster copying -class ModuleQuery : public libdnf5::sack::Query { +class LIBDNF_API ModuleQuery : public libdnf5::sack::Query { public: /// Create a new ModuleQuery instance. /// @@ -181,7 +182,7 @@ class ModuleQuery : public libdnf5::sack::Query { private: friend ModuleItem; - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/module/module_sack.hpp b/include/libdnf5/module/module_sack.hpp index 28e2397ac..92895fdc3 100644 --- a/include/libdnf5/module/module_sack.hpp +++ b/include/libdnf5/module/module_sack.hpp @@ -25,6 +25,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/base/solver_problems.hpp" #include "libdnf5/common/weak_ptr.hpp" +#include "libdnf5/defs.h" #include "libdnf5/module/module_item.hpp" #include "libdnf5/module/module_sack_weak.hpp" @@ -56,7 +57,7 @@ class RepoSack; namespace libdnf5::module { /// Container with data and methods related to modules -class ModuleSack { +class LIBDNF_API ModuleSack { public: ~ModuleSack(); @@ -94,13 +95,13 @@ class ModuleSack { friend class ModuleGoalPrivate; friend class ModuleQuery; - ModuleSack(const BaseWeakPtr & base); + LIBDNF_LOCAL ModuleSack(const BaseWeakPtr & base); - BaseWeakPtr get_base() const; + LIBDNF_LOCAL BaseWeakPtr get_base() const; /// Load information about modules from file to ModuleSack. It is critical to load all module information from /// all available repositories when modular metadata are available. - void add(const std::string & file_content, const std::string & repo_id); + LIBDNF_LOCAL void add(const std::string & file_content, const std::string & repo_id); // TODO(pkratoch): Implement adding defaults from "/etc/dnf/modules.defaults.d/", which are defined by user. // They are added with priority 1000 after everything else is loaded. @@ -109,13 +110,13 @@ class ModuleSack { // // @replaces libdnf:ModulePackageContainer.hpp:method:ModulePackageContainer.addDefaultsFromDisk() // @replaces libdnf:ModulePackageContainer.hpp:method:ModulePackageContainer.moduleDefaultsResolve() - void add_defaults_from_disk(); + LIBDNF_LOCAL void add_defaults_from_disk(); WeakPtrGuard data_guard; bool active_modules_resolved = false; - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/module/module_status.hpp b/include/libdnf5/module/module_status.hpp index f89278cc0..b67062632 100644 --- a/include/libdnf5/module/module_status.hpp +++ b/include/libdnf5/module/module_status.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define LIBDNF5_MODULE_MODULE_STATUS_HPP #include "libdnf5/common/exception.hpp" +#include "libdnf5/defs.h" #include @@ -32,7 +33,7 @@ namespace libdnf5::module { // AVAILABLE - otherwise. enum class ModuleStatus { AVAILABLE, ENABLED, DISABLED }; -class InvalidModuleStatus : public libdnf5::Error { +class LIBDNF_API InvalidModuleStatus : public libdnf5::Error { public: InvalidModuleStatus(const std::string & status); @@ -41,8 +42,8 @@ class InvalidModuleStatus : public libdnf5::Error { }; -std::string module_status_to_string(ModuleStatus status); -ModuleStatus module_status_from_string(const std::string & status); +LIBDNF_API std::string module_status_to_string(ModuleStatus status); +LIBDNF_API ModuleStatus module_status_from_string(const std::string & status); } // namespace libdnf5::module diff --git a/include/libdnf5/module/nsvcap.hpp b/include/libdnf5/module/nsvcap.hpp index 6bb15330f..581d2bc53 100644 --- a/include/libdnf5/module/nsvcap.hpp +++ b/include/libdnf5/module/nsvcap.hpp @@ -20,6 +20,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_MODULE_NSCVAP_HPP #define LIBDNF5_MODULE_NSCVAP_HPP +#include "libdnf5/defs.h" + #include #include #include @@ -28,7 +30,7 @@ along with libdnf. If not, see . namespace libdnf5::module { -class Nsvcap { +class LIBDNF_API Nsvcap { public: enum class Form { NSVCAP = 1, @@ -116,7 +118,7 @@ class Nsvcap { void set_profile(std::string && profile); private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/plugin/iplugin.hpp b/include/libdnf5/plugin/iplugin.hpp index 03c247c68..bee358c93 100644 --- a/include/libdnf5/plugin/iplugin.hpp +++ b/include/libdnf5/plugin/iplugin.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "plugin_version.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include "libdnf5/version.hpp" #include @@ -44,7 +45,7 @@ namespace libdnf5::plugin { class IPluginData; /// @brief A base class for implementing LIBDNF5 plugins that introduce additional logic into the library using hooks. -class IPlugin { +class LIBDNF_PLUGIN_API IPlugin { public: explicit IPlugin(IPluginData & data); virtual ~IPlugin(); @@ -120,7 +121,7 @@ class IPlugin { Base & get_base() const noexcept; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; @@ -131,22 +132,22 @@ extern "C" { /// Returns the version of the API supported by the plugin. /// Same result as IPlugin::get_api_version(), but can be called without creating an IPlugin instance. -libdnf5::PluginAPIVersion libdnf_plugin_get_api_version(void); +LIBDNF_PLUGIN_API libdnf5::PluginAPIVersion libdnf_plugin_get_api_version(void); /// Returns the name of the plugin. It can be called at any time. /// Same result as IPlugin::get_name(), but can be called without creating an IPlugin instance. -const char * libdnf_plugin_get_name(void); +LIBDNF_PLUGIN_API const char * libdnf_plugin_get_name(void); /// Returns the version of the plugin. It can be called at any time. /// Same result as IPlugin::get_version(), but can be called without creating an IPlugin instance. -libdnf5::plugin::Version libdnf_plugin_get_version(void); +LIBDNF_PLUGIN_API libdnf5::plugin::Version libdnf_plugin_get_version(void); /// Creates a new plugin instance. Passes the API version to the plugin. -libdnf5::plugin::IPlugin * libdnf_plugin_new_instance( +LIBDNF_PLUGIN_API libdnf5::plugin::IPlugin * libdnf_plugin_new_instance( libdnf5::LibraryVersion library_version, libdnf5::plugin::IPluginData & data, libdnf5::ConfigParser & parser); /// Deletes plugin instance. -void libdnf_plugin_delete_instance(libdnf5::plugin::IPlugin * plugin_instance); +LIBDNF_PLUGIN_API void libdnf_plugin_delete_instance(libdnf5::plugin::IPlugin * plugin_instance); } #endif diff --git a/include/libdnf5/plugin/plugin_info.hpp b/include/libdnf5/plugin/plugin_info.hpp index 769cf0950..839aedeb3 100644 --- a/include/libdnf5/plugin/plugin_info.hpp +++ b/include/libdnf5/plugin/plugin_info.hpp @@ -24,11 +24,12 @@ along with libdnf. If not, see . #include "plugin_version.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include "libdnf5/version.hpp" namespace libdnf5::plugin { -class PluginInfo { +class LIBDNF_API PluginInfo { public: ~PluginInfo(); @@ -62,10 +63,10 @@ class PluginInfo { /// @return the value of the `name` attribute or nullptr const char * get_attribute(const char * name) const noexcept; - class Impl; + class LIBDNF_LOCAL Impl; private: - explicit PluginInfo(Impl & p_impl); + LIBDNF_LOCAL explicit PluginInfo(Impl & p_impl); ImplPtr p_impl; }; diff --git a/include/libdnf5/repo/config_repo.hpp b/include/libdnf5/repo/config_repo.hpp index 2386cf8bd..500fe5d84 100644 --- a/include/libdnf5/repo/config_repo.hpp +++ b/include/libdnf5/repo/config_repo.hpp @@ -22,6 +22,7 @@ along with libdnf. If not, see . #include "libdnf5/conf/config_main.hpp" #include "libdnf5/conf/option_child.hpp" +#include "libdnf5/defs.h" #include @@ -29,7 +30,7 @@ along with libdnf. If not, see . namespace libdnf5::repo { /// Holds repo configuration options. Default values of some options are inherited from ConfigMain. -class ConfigRepo : public Config { +class LIBDNF_API ConfigRepo : public Config { public: ConfigRepo(ConfigMain & main_config, const std::string & id); ~ConfigRepo(); @@ -165,7 +166,7 @@ class ConfigRepo : public Config { Option::Priority priority = Option::Priority::REPOCONFIG) override; private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/repo/download_callbacks.hpp b/include/libdnf5/repo/download_callbacks.hpp index f33e42f0a..883107f16 100644 --- a/include/libdnf5/repo/download_callbacks.hpp +++ b/include/libdnf5/repo/download_callbacks.hpp @@ -20,6 +20,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_REPO_DOWNLOAD_CALLBACKS_HPP #define LIBDNF5_REPO_DOWNLOAD_CALLBACKS_HPP +#include "libdnf5/defs.h" + namespace libdnf5 { class Base; @@ -30,7 +32,7 @@ namespace libdnf5::repo { /// Base class for download callbacks. /// To implement a callback, inherit from this class and override the virtual methods. -class DownloadCallbacks { +class LIBDNF_API DownloadCallbacks { public: enum class FastestMirrorStage { /// Fastest mirror detection started. ptr is `nullptr`. diff --git a/include/libdnf5/repo/file_downloader.hpp b/include/libdnf5/repo/file_downloader.hpp index 33c964570..da6fa0b98 100644 --- a/include/libdnf5/repo/file_downloader.hpp +++ b/include/libdnf5/repo/file_downloader.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/common/exception.hpp" #include "libdnf5/conf/config_main.hpp" +#include "libdnf5/defs.h" #include "libdnf5/repo/repo_weak.hpp" #include @@ -36,7 +37,7 @@ class FileDownloadError : public Error { }; -class FileDownloader { +class LIBDNF_API FileDownloader { public: explicit FileDownloader(const libdnf5::BaseWeakPtr & base); explicit FileDownloader(libdnf5::Base & base); @@ -73,7 +74,7 @@ class FileDownloader { void set_resume(bool value); private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/repo/package_downloader.hpp b/include/libdnf5/repo/package_downloader.hpp index 32fa161d5..efce35098 100644 --- a/include/libdnf5/repo/package_downloader.hpp +++ b/include/libdnf5/repo/package_downloader.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define LIBDNF5_REPO_PACKAGE_DOWNLOADER_HPP #include "libdnf5/conf/config_main.hpp" +#include "libdnf5/defs.h" #include "libdnf5/rpm/package.hpp" #include @@ -35,7 +36,7 @@ class PackageDownloadError : public Error { }; -class PackageDownloader { +class LIBDNF_API PackageDownloader { public: explicit PackageDownloader(const libdnf5::BaseWeakPtr & base); explicit PackageDownloader(libdnf5::Base & base); @@ -75,7 +76,7 @@ class PackageDownloader { void force_keep_packages(bool value); private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/repo/repo.hpp b/include/libdnf5/repo/repo.hpp index 4cc9dfb92..a79b0f28a 100644 --- a/include/libdnf5/repo/repo.hpp +++ b/include/libdnf5/repo/repo.hpp @@ -28,6 +28,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/common/exception.hpp" #include "libdnf5/common/weak_ptr.hpp" +#include "libdnf5/defs.h" #include "libdnf5/repo/repo_errors.hpp" #include "libdnf5/repo/repo_weak.hpp" #include "libdnf5/rpm/package.hpp" @@ -55,7 +56,7 @@ class RepoDownloader; /// RPM repository /// Represents a repository used to download packages. /// Remote metadata is cached locally. -class Repo { +class LIBDNF_API Repo { public: enum class Type { AVAILABLE, SYSTEM, COMMANDLINE }; @@ -312,7 +313,7 @@ class Repo { static std::string type_to_string(Type type); private: - class Impl; + class LIBDNF_LOCAL Impl; friend class RepoSack; friend class rpm::Package; friend class rpm::PackageSack; @@ -323,13 +324,13 @@ class Repo { /// Loads the repository objects into sacks. /// /// Also writes the libsolv's solv/solvx cache files. - void load(); + LIBDNF_LOCAL void load(); /// Downloads repository metadata. // @replaces libdnf:repo/Repo.hpp:method:Repo.downloadMetadata(const std::string & destdir) - void download_metadata(const std::string & destdir); + LIBDNF_LOCAL void download_metadata(const std::string & destdir); - void add_libsolv_testcase(const std::string & path); + LIBDNF_LOCAL void add_libsolv_testcase(const std::string & path); /// Adds an RPM package at `path` to the repository. /// @@ -341,38 +342,38 @@ class Repo { /// @param with_hdrid If true, libsolv calculates header checksum and stores it. /// @throws RepoRpmError if the RPM file can't be read or is corrupted. /// @return PackageId of the added package. - libdnf5::rpm::Package add_rpm_package(const std::string & path, bool with_hdrid); + LIBDNF_LOCAL libdnf5::rpm::Package add_rpm_package(const std::string & path, bool with_hdrid); - void make_solv_repo(); + LIBDNF_LOCAL void make_solv_repo(); - void load_available_repo(); - void load_system_repo(); + LIBDNF_LOCAL void load_available_repo(); + LIBDNF_LOCAL void load_system_repo(); - void internalize(); + LIBDNF_LOCAL void internalize(); /// If the repository is not already marked as expired, it checks for the presence of the repository cache /// expiration attribute, and if the metadata_expire configuration value is set, also checks the modification times /// of the main configuration file, the repository configuration file, and the cached primary file. /// Depending on the result, the repository may be marked as expired. - void recompute_expired(); + LIBDNF_LOCAL void recompute_expired(); /// @brief Clones repodata and solv files from the root cache. The original user repository cache is deleted. /// The intended use case is for cloning the root cache when the user one is invalid or empty. /// @return Whether at least the repodata cache cloning was successful. - bool clone_root_metadata(); + LIBDNF_LOCAL bool clone_root_metadata(); - RepoDownloader & get_downloader() const; + LIBDNF_LOCAL RepoDownloader & get_downloader() const; - bool is_loaded() const; + LIBDNF_LOCAL bool is_loaded() const; /// Requires that the repo is loaded - SolvRepo & get_solv_repo() const; + LIBDNF_LOCAL SolvRepo & get_solv_repo() const; /// Mark this repository as fresh (it is not expired). - void mark_fresh(); + LIBDNF_LOCAL void mark_fresh(); // Add xml comps file at `path` to the repository. - void add_xml_comps(const std::string & path); + LIBDNF_LOCAL void add_xml_comps(const std::string & path); std::unique_ptr p_impl; }; diff --git a/include/libdnf5/repo/repo_cache.hpp b/include/libdnf5/repo/repo_cache.hpp index 89aa47ac4..110fe007a 100644 --- a/include/libdnf5/repo/repo_cache.hpp +++ b/include/libdnf5/repo/repo_cache.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/common/exception.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include #include @@ -31,7 +32,7 @@ along with libdnf. If not, see . namespace libdnf5::repo { -struct RepoCacheRemoveStatistics { +struct LIBDNF_API RepoCacheRemoveStatistics { RepoCacheRemoveStatistics(); ~RepoCacheRemoveStatistics(); @@ -50,7 +51,7 @@ struct RepoCacheRemoveStatistics { private: friend class RepoCache; - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; @@ -65,7 +66,7 @@ class RepoCacheError : public Error { /// Repository cache management class. -class RepoCache { +class LIBDNF_API RepoCache { public: using RemoveStatistics = RepoCacheRemoveStatistics; @@ -150,7 +151,7 @@ class RepoCache { private: friend RepoCacheRemoveStatistics; - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/repo/repo_callbacks.hpp b/include/libdnf5/repo/repo_callbacks.hpp index 8440db186..7fa557469 100644 --- a/include/libdnf5/repo/repo_callbacks.hpp +++ b/include/libdnf5/repo/repo_callbacks.hpp @@ -20,6 +20,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_REPO_REPO_CALLBACKS_HPP #define LIBDNF5_REPO_REPO_CALLBACKS_HPP +#include "libdnf5/defs.h" + #include #include @@ -32,7 +34,7 @@ namespace libdnf5::repo { /// Base class for repository callbacks. /// To implement callbacks, inherit from this class and override virtual methods. -class RepoCallbacks { +class LIBDNF_API RepoCallbacks { public: explicit RepoCallbacks(); RepoCallbacks(const RepoCallbacks &) = delete; diff --git a/include/libdnf5/repo/repo_query.hpp b/include/libdnf5/repo/repo_query.hpp index 73de311f3..9b878dbd4 100644 --- a/include/libdnf5/repo/repo_query.hpp +++ b/include/libdnf5/repo/repo_query.hpp @@ -25,6 +25,7 @@ along with libdnf. If not, see . #include "libdnf5/common/sack/query.hpp" #include "libdnf5/common/sack/query_cmp.hpp" #include "libdnf5/common/weak_ptr.hpp" +#include "libdnf5/defs.h" #include "libdnf5/repo/repo.hpp" #include @@ -41,7 +42,7 @@ using RepoSackWeakPtr = WeakPtr; namespace libdnf5::repo { -class RepoQuery : public libdnf5::sack::Query { +class LIBDNF_API RepoQuery : public libdnf5::sack::Query { public: #ifndef SWIG using Query::Query; @@ -123,7 +124,7 @@ class RepoQuery : public libdnf5::sack::Query { void filter_type(Repo::Type type, sack::QueryCmp cmp = libdnf5::sack::QueryCmp::EQ); private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/repo/repo_sack.hpp b/include/libdnf5/repo/repo_sack.hpp index e7194e372..d81e536f1 100644 --- a/include/libdnf5/repo/repo_sack.hpp +++ b/include/libdnf5/repo/repo_sack.hpp @@ -26,6 +26,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/common/sack/sack.hpp" #include "libdnf5/common/weak_ptr.hpp" +#include "libdnf5/defs.h" #include "libdnf5/logger/logger.hpp" @@ -35,7 +36,7 @@ class RepoSack; using RepoSackWeakPtr = WeakPtr; -class RepoSack : public sack::Sack { +class LIBDNF_API RepoSack : public sack::Sack { public: /// Creates a new clear repository with default configuration. /// @param id The new repo id @@ -149,34 +150,35 @@ class RepoSack : public sack::Sack { friend class rpm::PackageSack; friend class libdnf5::Goal; - explicit RepoSack(const libdnf5::BaseWeakPtr & base); - explicit RepoSack(libdnf5::Base & base); + LIBDNF_LOCAL explicit RepoSack(const libdnf5::BaseWeakPtr & base); + LIBDNF_LOCAL explicit RepoSack(libdnf5::Base & base); /// Loads repositories configuration overrides from drop-in directories. No new repositories are created. /// Only the configuration of the corresponding existing repositories is modified. - void load_repos_configuration_overrides(); + LIBDNF_LOCAL void load_repos_configuration_overrides(); /// If not created yet, creates the cmdline repository and returns it. /// @return The cmdline repository. - libdnf5::repo::RepoWeakPtr get_cmdline_repo(); + LIBDNF_LOCAL libdnf5::repo::RepoWeakPtr get_cmdline_repo(); /// If not created yet, creates the stored transaction repository and returns it. /// @return The stored transaction repository. - libdnf5::repo::RepoWeakPtr get_stored_transaction_repo(); + LIBDNF_LOCAL libdnf5::repo::RepoWeakPtr get_stored_transaction_repo(); /// Add given path to comps to the stored_transaction repository. /// @param path Path to a local xml comps file to be inserted to stored_transaction repo. - void add_stored_transaction_comps(const std::string & path); + LIBDNF_LOCAL void add_stored_transaction_comps(const std::string & path); /// Add given path to rpm to the stored_transaction repository. /// @param path Path to a local rpm file to be inserted to stored_transaction repo. /// @param calculate_checksum Whether libsolv should calculate and store checksum of added packages. Setting to true significantly reduces performance. /// @return Newly created rpm::Package object in cmdline repo - libdnf5::rpm::Package add_stored_transaction_package(const std::string & path, bool calculate_checksum = false); + LIBDNF_LOCAL libdnf5::rpm::Package add_stored_transaction_package( + const std::string & path, bool calculate_checksum = false); - void internalize_repos(); + LIBDNF_LOCAL void internalize_repos(); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/rpm/arch.hpp b/include/libdnf5/rpm/arch.hpp index 5849b935b..487ca54b6 100644 --- a/include/libdnf5/rpm/arch.hpp +++ b/include/libdnf5/rpm/arch.hpp @@ -21,6 +21,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_RPM_ARCH_HPP #define LIBDNF5_RPM_ARCH_HPP +#include "libdnf5/defs.h" + #include #include @@ -28,12 +30,12 @@ along with libdnf. If not, see . namespace libdnf5::rpm { /// Returns a list of architectures supported by libdnf5. -std::vector get_supported_arches(); +LIBDNF_API std::vector get_supported_arches(); /// Returns base architecture of the given `arch`. In case the base arch is not /// found the function returns empty string. /// @param arch Architecture. -std::string get_base_arch(const std::string & arch); +LIBDNF_API std::string get_base_arch(const std::string & arch); } // namespace libdnf5::rpm diff --git a/include/libdnf5/rpm/checksum.hpp b/include/libdnf5/rpm/checksum.hpp index 4531b193e..aadc286f4 100644 --- a/include/libdnf5/rpm/checksum.hpp +++ b/include/libdnf5/rpm/checksum.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define LIBDNF5_RPM_CHECKSUM_HPP #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include #include @@ -29,7 +30,7 @@ along with libdnf. If not, see . namespace libdnf5::rpm { /// Class contains checksum and checksum type -class Checksum { +class LIBDNF_API Checksum { public: ~Checksum(); Checksum(const Checksum & src); @@ -50,9 +51,9 @@ class Checksum { friend class Package; /// Require checksum in hex and libsolv checksum type - Checksum(const char * checksum, int libsolv_type); + LIBDNF_LOCAL Checksum(const char * checksum, int libsolv_type); - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/rpm/nevra.hpp b/include/libdnf5/rpm/nevra.hpp index cf2b943f7..15c3d7b6b 100644 --- a/include/libdnf5/rpm/nevra.hpp +++ b/include/libdnf5/rpm/nevra.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "libdnf5/common/exception.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include #include @@ -31,7 +32,7 @@ along with libdnf. If not, see . namespace libdnf5::rpm { -struct NevraIncorrectInputError : public Error { +struct LIBDNF_API NevraIncorrectInputError : public Error { using Error::Error; const char * get_domain_name() const noexcept override { return "libdnf5::rpm"; } const char * get_name() const noexcept override { return "NevraIncorrectInputError"; } @@ -39,7 +40,7 @@ struct NevraIncorrectInputError : public Error { // @replaces hawkey:hawkey/__init__.py:class:Nevra -struct Nevra { +struct LIBDNF_API Nevra { public: enum class Form { NEVRA = 1, NEVR = 2, NEV = 3, NA = 4, NAME = 5 }; @@ -71,7 +72,7 @@ struct Nevra { bool operator==(const Nevra & other) const; // NOTE: required by cppunit asserts - friend std::ostringstream & operator<<(std::ostringstream & out, const Nevra & nevra); + //friend std::ostringstream & operator<<(std::ostringstream & out, const Nevra & nevra); /// Returns false when parsing failed and stored data are in inconsistency state. @@ -108,7 +109,7 @@ struct Nevra { bool has_just_name() const; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; @@ -118,6 +119,9 @@ inline std::vector Nevra::parse(const std::string & nevra_str) { } +LIBDNF_API std::ostringstream & operator<<(std::ostringstream & out, const Nevra & nevra); + + /// Create a full nevra string (always contains epoch) from an object template inline std::string to_full_nevra_string(const T & obj) { @@ -188,7 +192,7 @@ inline void copy_nevra_attributes(const F & from, T & to) { /// Compare alpha and numeric segments of two versions. /// @return 1 if `lhs` < `rhs`, -1 if `lhs` > `rhs`, 0 if they are equal -int rpmvercmp(const char * lhs, const char * rhs); +LIBDNF_API int rpmvercmp(const char * lhs, const char * rhs); /// Compare evr part of two objects diff --git a/include/libdnf5/rpm/package.hpp b/include/libdnf5/rpm/package.hpp index 6da61121b..c240a3d17 100644 --- a/include/libdnf5/rpm/package.hpp +++ b/include/libdnf5/rpm/package.hpp @@ -25,6 +25,7 @@ along with libdnf. If not, see . #include "reldep_list.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include "libdnf5/repo/repo_weak.hpp" #include "libdnf5/transaction/transaction_item_reason.hpp" @@ -64,7 +65,7 @@ struct PackageId { int id{0}; }; -struct Changelog { +struct LIBDNF_API Changelog { public: Changelog(time_t timestamp, const std::string & author, const std::string & text); ~Changelog(); @@ -79,7 +80,7 @@ struct Changelog { const std::string & get_text() const; private: - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; @@ -88,7 +89,7 @@ struct Changelog { // @replaces libdnf:libdnf/hy-package.h:struct:DnfPackage // @replaces dnf:dnf/package.py:class:Package -class Package { +class LIBDNF_API Package { public: ~Package(); Package(const Package & src); @@ -553,11 +554,11 @@ class Package { friend class libdnf5::rpm::Transaction; // TODO(jrohel): Assumes unique `rpmdbid`. Support for opening more rpm databases at once? - Package(const BaseWeakPtr & base, unsigned long long rpmdbid); + LIBDNF_LOCAL Package(const BaseWeakPtr & base, unsigned long long rpmdbid); - bool is_cached() const; + LIBDNF_LOCAL bool is_cached() const; - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/rpm/package_query.hpp b/include/libdnf5/rpm/package_query.hpp index 1df5d1fe4..03d20cafc 100644 --- a/include/libdnf5/rpm/package_query.hpp +++ b/include/libdnf5/rpm/package_query.hpp @@ -30,6 +30,7 @@ along with libdnf. If not, see . #include "libdnf5/common/exception.hpp" #include "libdnf5/common/sack/exclude_flags.hpp" #include "libdnf5/common/sack/query_cmp.hpp" +#include "libdnf5/defs.h" #include #include @@ -47,7 +48,7 @@ namespace libdnf5::rpm { // @replaces libdnf/hy-query.h:struct:HyQuery // @replaces libdnf/sack/query.hpp:struct:Query // @replaces hawkey:hawkey/__init__.py:class:Query -class PackageQuery : public PackageSet { +class LIBDNF_API PackageQuery : public PackageSet { public: using ExcludeFlags = libdnf5::sack::ExcludeFlags; @@ -1003,10 +1004,11 @@ class PackageQuery : public PackageSet { void filter_versionlock(); private: - std::vector> filter_leaves(bool return_grouped_leaves); + LIBDNF_LOCAL std::vector> filter_leaves(bool return_grouped_leaves); friend libdnf5::Goal; - class PQImpl; + + class LIBDNF_LOCAL PQImpl; std::unique_ptr p_pq_impl; }; diff --git a/include/libdnf5/rpm/package_sack.hpp b/include/libdnf5/rpm/package_sack.hpp index a371dc322..05cc56fe7 100644 --- a/include/libdnf5/rpm/package_sack.hpp +++ b/include/libdnf5/rpm/package_sack.hpp @@ -28,6 +28,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/common/exception.hpp" #include "libdnf5/common/weak_ptr.hpp" +#include "libdnf5/defs.h" #include "libdnf5/rpm/versionlock_config.hpp" #include "libdnf5/transaction/transaction_item_reason.hpp" @@ -79,7 +80,7 @@ class PackageSet; class PackageSack; using PackageSackWeakPtr = WeakPtr; -class PackageSack { +class LIBDNF_API PackageSack { public: explicit PackageSack(const libdnf5::BaseWeakPtr & base); explicit PackageSack(libdnf5::Base & base); @@ -197,7 +198,7 @@ class PackageSack { friend libdnf5::base::Transaction; friend class libdnf5::module::ModuleSack; - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/rpm/package_set.hpp b/include/libdnf5/rpm/package_set.hpp index 63e357279..cd86737b9 100644 --- a/include/libdnf5/rpm/package_set.hpp +++ b/include/libdnf5/rpm/package_set.hpp @@ -26,6 +26,7 @@ along with libdnf. If not, see . #include "package_set_iterator.hpp" #include "libdnf5/common/exception.hpp" +#include "libdnf5/defs.h" #include #include @@ -45,7 +46,7 @@ class SolvMap; namespace libdnf5::rpm { // @replaces libdnf:sack/packageset.hpp:struct:PackageSet -class PackageSet { +class LIBDNF_API PackageSet { public: using iterator = PackageSetIterator; @@ -161,8 +162,10 @@ class PackageSet { friend class libdnf5::advisory::AdvisoryPackage; friend libdnf5::Goal; - PackageSet(const BaseWeakPtr & base, libdnf5::solv::SolvMap & solv_map); - class Impl; + + LIBDNF_LOCAL PackageSet(const BaseWeakPtr & base, libdnf5::solv::SolvMap & solv_map); + + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/rpm/package_set_iterator.hpp b/include/libdnf5/rpm/package_set_iterator.hpp index 4dc3826dd..c0fc58d2d 100644 --- a/include/libdnf5/rpm/package_set_iterator.hpp +++ b/include/libdnf5/rpm/package_set_iterator.hpp @@ -23,6 +23,8 @@ along with libdnf. If not, see . #include "package.hpp" +#include "libdnf5/defs.h" + #include #include #include @@ -33,7 +35,7 @@ namespace libdnf5::rpm { class PackageSet; -class PackageSetIterator { +class LIBDNF_API PackageSetIterator { public: using iterator_category = std::forward_iterator_tag; using difference_type = std::ptrdiff_t; @@ -63,7 +65,7 @@ class PackageSetIterator { private: explicit PackageSetIterator(const PackageSet & package_set); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/rpm/reldep.hpp b/include/libdnf5/rpm/reldep.hpp index 0dd0ceb39..436d92d66 100644 --- a/include/libdnf5/rpm/reldep.hpp +++ b/include/libdnf5/rpm/reldep.hpp @@ -22,6 +22,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/common/impl_ptr.hpp" +#include "libdnf5/defs.h" #include #include @@ -46,7 +47,7 @@ struct ReldepId { // @replaces libdnf/dnf-reldep.h:struct:DnfReldep // @replaces libdnf/repo/solvable/Dependency.hpp:struct:Dependency // @replaces hawkey:hawkey/__init__.py:class:Reldep -class Reldep { +class LIBDNF_API Reldep { public: enum class CmpType { NONE = 0, GT = (1 << 0), EQ = (1 << 1), GTE = (GT | EQ), LT = (1 << 2), LTE = (LT | EQ) }; @@ -118,7 +119,7 @@ class Reldep { /// @param cmp_type p_cmpType: ComparisonType, and their combinations // @replaces libdnf/repo/solvable/Dependency.hpp:method:get_id() // @replaces libdnf/dnf-reldep.h:function:dnf_reldep_new(DnfSack *sack, const char *name, int cmp_type, const char *evr) - Reldep(const BaseWeakPtr & base, const char * name, const char * version, CmpType cmp_type); + LIBDNF_LOCAL Reldep(const BaseWeakPtr & base, const char * name, const char * version, CmpType cmp_type); /// @brief Returns Id of parsed reldep /// @@ -129,7 +130,7 @@ class Reldep { /// @param create Whether a new Id should be created when name does not exist /// @return DependencyId // @replaces libdnf/repo/solvable/Dependency.hpp:method:getReldepId(DnfSack *sack, const char *name, const char *version, int cmpType) - static ReldepId get_reldep_id( + LIBDNF_LOCAL static ReldepId get_reldep_id( const BaseWeakPtr & base, const char * name, const char * version, CmpType cmp_type, int create = 1); /// @brief Returns Id of reldep or raises std::runtime_error if parsing fails @@ -139,9 +140,10 @@ class Reldep { /// @return DependencyId /// @param create Whether a new Id should be created when name does not exist // @replaces libdnf/repo/solvable/Dependency.hpp:method:getReldepId(DnfSack *sack, const char * reldepStr) - static ReldepId get_reldep_id(const BaseWeakPtr & base, const std::string & reldep_str, int create = 1); + LIBDNF_LOCAL static ReldepId get_reldep_id( + const BaseWeakPtr & base, const std::string & reldep_str, int create = 1); - class Impl; + class LIBDNF_LOCAL Impl; ImplPtr p_impl; }; diff --git a/include/libdnf5/rpm/reldep_list.hpp b/include/libdnf5/rpm/reldep_list.hpp index 07fc7bf74..ceb058b4d 100644 --- a/include/libdnf5/rpm/reldep_list.hpp +++ b/include/libdnf5/rpm/reldep_list.hpp @@ -25,6 +25,7 @@ along with libdnf. If not, see . #include "reldep_list_iterator.hpp" #include "libdnf5/base/base_weak.hpp" +#include "libdnf5/defs.h" #include @@ -33,7 +34,7 @@ namespace libdnf5::rpm { // @replaces libdnf/dnf-reldep-list.h:struct:DnfReldepList // @replaces libdnf/repo/solvable/DependencyContainer.hpp:struct:DependencyContainer -class ReldepList { +class LIBDNF_API ReldepList { public: // @replaces libdnf/repo/solvable/DependencyContainer.hpp:method:DependencyContainer(const DependencyContainer &src) ReldepList(const ReldepList & src); @@ -119,9 +120,9 @@ class ReldepList { /// @return bool false if parsing or reldep creation fails /// // @replaces libdnf/repo/solvable/DependencyContainer.hpp:method:addReldep(const char *reldepStr) - bool add_reldep(const std::string & reldep_str, int create); + LIBDNF_LOCAL bool add_reldep(const std::string & reldep_str, int create); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/rpm/reldep_list_iterator.hpp b/include/libdnf5/rpm/reldep_list_iterator.hpp index 23e07b425..907b8c15a 100644 --- a/include/libdnf5/rpm/reldep_list_iterator.hpp +++ b/include/libdnf5/rpm/reldep_list_iterator.hpp @@ -23,6 +23,8 @@ along with libdnf. If not, see . #include "reldep.hpp" +#include "libdnf5/defs.h" + #include #include #include @@ -33,7 +35,7 @@ namespace libdnf5::rpm { class ReldepList; -class ReldepListIterator { +class LIBDNF_API ReldepListIterator { public: explicit ReldepListIterator(const ReldepList & reldep_list); ReldepListIterator(const ReldepListIterator & other); @@ -57,7 +59,7 @@ class ReldepListIterator { void end(); private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/rpm/rpm_signature.hpp b/include/libdnf5/rpm/rpm_signature.hpp index 9fa83987e..d2a490748 100644 --- a/include/libdnf5/rpm/rpm_signature.hpp +++ b/include/libdnf5/rpm/rpm_signature.hpp @@ -22,6 +22,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base.hpp" #include "libdnf5/common/exception.hpp" +#include "libdnf5/defs.h" #include "libdnf5/rpm/package.hpp" #include @@ -29,14 +30,14 @@ along with libdnf. If not, see . namespace libdnf5::rpm { -class SignatureCheckError : public Error { +class LIBDNF_API SignatureCheckError : public Error { public: using Error::Error; const char * get_domain_name() const noexcept override { return "libdnf5::rpm"; } const char * get_name() const noexcept override { return "SignatureCheckError"; } }; -class KeyImportError : public Error { +class LIBDNF_API KeyImportError : public Error { public: using Error::Error; const char * get_domain_name() const noexcept override { return "libdnf5::rpm"; } @@ -45,7 +46,7 @@ class KeyImportError : public Error { using RpmKeyPktPtr = std::unique_ptr>; -class KeyInfo { +class LIBDNF_API KeyInfo { public: const std::string & get_key_id() const noexcept; std::string get_short_key_id() const; @@ -77,11 +78,11 @@ class KeyInfo { void add_user_id(const char * user_id); private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; -class RpmSignature { +class LIBDNF_API RpmSignature { public: enum class CheckResult { OK, SKIPPED, FAILED_KEY_MISSING, FAILED_NOT_TRUSTED, FAILED_NOT_SIGNED, FAILED }; @@ -119,7 +120,7 @@ class RpmSignature { static std::string check_result_to_string(CheckResult result); private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/rpm/transaction_callbacks.hpp b/include/libdnf5/rpm/transaction_callbacks.hpp index 6f79e423c..c74ae0f69 100644 --- a/include/libdnf5/rpm/transaction_callbacks.hpp +++ b/include/libdnf5/rpm/transaction_callbacks.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #ifndef LIBDNF5_RPM_TRANSACTION_CALLBACKS_HPP #define LIBDNF5_RPM_TRANSACTION_CALLBACKS_HPP +#include "libdnf5/defs.h" #include "libdnf5/rpm/nevra.hpp" #include @@ -40,7 +41,7 @@ using TransactionItem = base::TransactionPackage; /// Base class for Transaction callbacks /// User implements Transaction callbacks by inheriting this class and overriding its methods. -class TransactionCallbacks { +class LIBDNF_API TransactionCallbacks { public: /// Scriptlet type // TODO(jrohel): Are all scriptlets types present and correct? diff --git a/include/libdnf5/rpm/versionlock_config.hpp b/include/libdnf5/rpm/versionlock_config.hpp index f20807948..b69a3440d 100644 --- a/include/libdnf5/rpm/versionlock_config.hpp +++ b/include/libdnf5/rpm/versionlock_config.hpp @@ -22,6 +22,7 @@ along with libdnf. If not, see . #define LIBDNF5_RPM_VERSIONLOCK_CONFIG_HPP #include "libdnf5/common/sack/query_cmp.hpp" +#include "libdnf5/defs.h" #include #include @@ -35,7 +36,7 @@ namespace libdnf5::rpm { /// Key can be one of "epoch", "evr", "arch". /// Supported comparison operators are "<", "<=", "=", ">=", ">", "!=". /// @since 5.1.13 -class VersionlockCondition { +class LIBDNF_API VersionlockCondition { public: enum class Keys { EPOCH, EVR, ARCH }; @@ -80,7 +81,7 @@ class VersionlockCondition { /// package name and a set of conditions. All conditions must be true /// for package version to get locked. /// @since 5.1.13 -class VersionlockPackage { +class LIBDNF_API VersionlockPackage { public: /// Creates an instance of `VersionlockPackage` class specifying the /// name of package. @@ -122,7 +123,7 @@ class VersionlockPackage { /// Class contains parsed versionlock configuration file. /// @since 5.1.13 -class VersionlockConfig { +class LIBDNF_API VersionlockConfig { public: /// Get list of configured versionlock entries. std::vector & get_packages() { return packages; } @@ -136,7 +137,7 @@ class VersionlockConfig { /// Creates an instance of `VersionlockConfig` specifying the config file /// to read. /// @param path Path to versionlock configuration file. - VersionlockConfig(const std::filesystem::path & path); + LIBDNF_LOCAL VersionlockConfig(const std::filesystem::path & path); std::filesystem::path path; std::vector packages{}; diff --git a/include/libdnf5/transaction/comps_environment.hpp b/include/libdnf5/transaction/comps_environment.hpp index d37fa549a..47821852d 100644 --- a/include/libdnf5/transaction/comps_environment.hpp +++ b/include/libdnf5/transaction/comps_environment.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "comps_group.hpp" #include "libdnf5/comps/group/package.hpp" +#include "libdnf5/defs.h" #include #include @@ -40,7 +41,7 @@ class CompsEnvironmentGroupDbUtils; /// to perform comps transaction and then stored in the transaction (history) database. /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:class:CompsEnvironmentItem -class CompsEnvironment : public TransactionItem { +class LIBDNF_API CompsEnvironment : public TransactionItem { public: /// Get string representation of the object, which equals to environment_id /// @@ -58,69 +59,69 @@ class CompsEnvironment : public TransactionItem { friend CompsEnvironmentDbUtils; friend CompsEnvironmentGroupDbUtils; - explicit CompsEnvironment(const Transaction & trans); + LIBDNF_LOCAL explicit CompsEnvironment(const Transaction & trans); /// Get text id of the environment (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.getEnvironmentId() - const std::string & get_environment_id() const noexcept; + LIBDNF_LOCAL const std::string & get_environment_id() const noexcept; /// Set text id of the environment (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.setEnvironmentId(const std::string & value) - void set_environment_id(const std::string & value); + LIBDNF_LOCAL void set_environment_id(const std::string & value); /// Get name of the environment (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.getName() - const std::string & get_name() const noexcept; + LIBDNF_LOCAL const std::string & get_name() const noexcept; /// Set name of the environment (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.setName(const std::string & value) - void set_name(const std::string & value); + LIBDNF_LOCAL void set_name(const std::string & value); /// Get translated name of the environment in the current locale (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.getTranslatedName() - const std::string & get_translated_name() const noexcept; + LIBDNF_LOCAL const std::string & get_translated_name() const noexcept; /// Set translated name of the environment in the current locale (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.setTranslatedName(const std::string & value) - void set_translated_name(const std::string & value); + LIBDNF_LOCAL void set_translated_name(const std::string & value); /// Get types of the packages to be installed with the environment (related xml elements: ``) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.getPackageTypes() - libdnf5::comps::PackageType get_package_types() const noexcept; + LIBDNF_LOCAL libdnf5::comps::PackageType get_package_types() const noexcept; /// Set types of the packages to be installed with the environment (related xml elements: ``) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.setPackageTypes(libdnf::CompsPackageType value) - void set_package_types(libdnf5::comps::PackageType value); + LIBDNF_LOCAL void set_package_types(libdnf5::comps::PackageType value); /// Create a new CompsEnvironmentGroup object and return a reference to it. /// The object is owned by the CompsEnvironment. - CompsEnvironmentGroup & new_group(); + LIBDNF_LOCAL CompsEnvironmentGroup & new_group(); /// Get list of groups associated with the environment. /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentItem.getGroups() - std::vector & get_groups(); + LIBDNF_LOCAL std::vector & get_groups(); // TODO(dmach): rewrite into TransactionSack.list_installed_environments(); how to deal with references to different transactions? We don't want all of them loaded into memory. //static std::vector< TransactionItemPtr > getTransactionItemsByPattern( // libdnf5::utils::SQLite3Ptr conn, // const std::string &pattern); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:class:CompsEnvironmentGroup -class CompsEnvironmentGroup { +class LIBDNF_API CompsEnvironmentGroup { public: ~CompsEnvironmentGroup(); CompsEnvironmentGroup(const CompsEnvironmentGroup & src); @@ -136,44 +137,44 @@ class CompsEnvironmentGroup { /// Get database id (primary key) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.getId() - int64_t get_id() const noexcept; + LIBDNF_LOCAL int64_t get_id() const noexcept; /// Set database id (primary key) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.setId(int64_t value) - void set_id(int64_t value); + LIBDNF_LOCAL void set_id(int64_t value); /// Get groupid of a group associated with a comps environment (xml element: `VALUE`) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.getGroupId() - const std::string & get_group_id() const noexcept; + LIBDNF_LOCAL const std::string & get_group_id() const noexcept; /// Set groupid of a group associated with a comps environment (xml element: `VALUE`) /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.setGroupId(const std::string & value) - void set_group_id(const std::string & value); + LIBDNF_LOCAL void set_group_id(const std::string & value); /// Get a flag that determines if the group was present after the transaction it's associated with has finished. /// If the group was installed before running the transaction, it's still counted as installed. /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.getInstalled() - bool get_installed() const noexcept; + LIBDNF_LOCAL bool get_installed() const noexcept; /// Set a flag that determines if the group was present after the transaction it's associated with has finished. /// If the group was installed before running the transaction, it's still counted as installed. /// // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.setInstalled(bool value) - void set_installed(bool value); + LIBDNF_LOCAL void set_installed(bool value); // TODO(dmach): this is not entirely clear; investigate and document // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.getGroupType() - libdnf5::comps::PackageType get_group_type() const noexcept; + LIBDNF_LOCAL libdnf5::comps::PackageType get_group_type() const noexcept; // TODO(dmach): this is not entirely clear; investigate and document // @replaces libdnf:transaction/CompsEnvironmentItem.hpp:method:CompsEnvironmentGroup.setGroupType(libdnf::CompsPackageType value) - void set_group_type(libdnf5::comps::PackageType value); + LIBDNF_LOCAL void set_group_type(libdnf5::comps::PackageType value); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/transaction/comps_group.hpp b/include/libdnf5/transaction/comps_group.hpp index 661e3f219..4824ad451 100644 --- a/include/libdnf5/transaction/comps_group.hpp +++ b/include/libdnf5/transaction/comps_group.hpp @@ -23,6 +23,7 @@ along with libdnf. If not, see . #include "transaction_item.hpp" #include "libdnf5/comps/group/package.hpp" +#include "libdnf5/defs.h" #include #include @@ -40,7 +41,7 @@ class CompsGroupPackageDbUtils; /// to perform comps transaction and then stored in the transaction (history) database. /// // @replaces libdnf:transaction/CompsGroupItem.hpp:class:CompsGroupItem -class CompsGroup : public TransactionItem { +class LIBDNF_API CompsGroup : public TransactionItem { public: /// Get string representation of the object, which equals to group_id /// @@ -59,63 +60,63 @@ class CompsGroup : public TransactionItem { friend CompsGroupDbUtils; friend CompsGroupPackageDbUtils; - explicit CompsGroup(const Transaction & trans); + LIBDNF_LOCAL explicit CompsGroup(const Transaction & trans); /// Get text id of the group (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupItem.getGroupId() - const std::string & get_group_id() const noexcept; + LIBDNF_LOCAL const std::string & get_group_id() const noexcept; /// Get text id of the group (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupItem.setGroupId(const std::string & value) - void set_group_id(const std::string & value); + LIBDNF_LOCAL void set_group_id(const std::string & value); /// Get name of the group (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupItem.getName() - const std::string & get_name() const noexcept; + LIBDNF_LOCAL const std::string & get_name() const noexcept; /// Set name of the group (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupItem.setName(const std::string & value) - void set_name(const std::string & value); + LIBDNF_LOCAL void set_name(const std::string & value); /// Get translated name of the group in the current locale (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupItem.getTranslatedName() - const std::string & get_translated_name() const noexcept; + LIBDNF_LOCAL const std::string & get_translated_name() const noexcept; /// Set translated name of the group in the current locale (xml element: `VALUE...`) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupItem.setTranslatedName(const std::string & value) - void set_translated_name(const std::string & value); + LIBDNF_LOCAL void set_translated_name(const std::string & value); /// Get types of the packages to be installed with the group (related xml elements: ``) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupItem.getPackageTypes() - libdnf5::comps::PackageType get_package_types() const noexcept; + LIBDNF_LOCAL libdnf5::comps::PackageType get_package_types() const noexcept; /// Set types of the packages to be installed with the group (related xml elements: ``) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupItem.setPackageTypes(libdnf::CompsPackageType value) - void set_package_types(libdnf5::comps::PackageType value); + LIBDNF_LOCAL void set_package_types(libdnf5::comps::PackageType value); /// Create a new CompsGroupPackage object and return a reference to it. /// The object is owned by the CompsGroup. - CompsGroupPackage & new_package(); + LIBDNF_LOCAL CompsGroupPackage & new_package(); /// Get list of packages associated with the group. /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupItem.getPackages() - std::vector & get_packages(); + LIBDNF_LOCAL std::vector & get_packages(); // TODO(dmach): rewrite into TransactionSack.list_installed_groups(); how to deal with references to different transactions? We don't want all of them loaded into memory. //static std::vector< TransactionItemPtr > getTransactionItemsByPattern( // libdnf5::utils::SQLite3Ptr conn, // const std::string &pattern); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; @@ -123,7 +124,7 @@ class CompsGroup : public TransactionItem { /// CompsGroupPackage represents a package associated with a comps group /// // @replaces libdnf:transaction/CompsGroupItem.hpp:class:CompsGroupPackage -class CompsGroupPackage { +class LIBDNF_API CompsGroupPackage { public: ~CompsGroupPackage(); CompsGroupPackage(const CompsGroupPackage & src); @@ -139,48 +140,48 @@ class CompsGroupPackage { /// Get database id (primary key) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupPackage.getId() - int64_t get_id() const noexcept; + LIBDNF_LOCAL int64_t get_id() const noexcept; /// Set database id (primary key) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupPackage.setId(int64_t value) - void set_id(int64_t value); + LIBDNF_LOCAL void set_id(int64_t value); /// Get name of a package associated with a comps group (xml element: `VALUE`) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupPackage.getName() - const std::string & get_name() const noexcept; + LIBDNF_LOCAL const std::string & get_name() const noexcept; /// Set name of a package associated with a comps group (xml element: `VALUE`) /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupPackage.setName(const std::string & value) - void set_name(const std::string & value); + LIBDNF_LOCAL void set_name(const std::string & value); /// Get a flag that determines if the package was present after the transaction it's associated with has finished. /// If the package was installed before running the transaction, it's still counted as installed. /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupPackage.getInstalled() - bool get_installed() const noexcept; + LIBDNF_LOCAL bool get_installed() const noexcept; /// Set a flag that determines if the package was present after the transaction it's associated with has finished. /// If the package was installed before running the transaction, it's still counted as installed. /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupPackage.setInstalled(bool value) - void set_installed(bool value); + LIBDNF_LOCAL void set_installed(bool value); /// Get type of package associated with a comps group (xml element: ``) /// See `enum class comps::PackageType` documentation for more details. /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupPackage.getPackageType() - libdnf5::comps::PackageType get_package_type() const noexcept; + LIBDNF_LOCAL libdnf5::comps::PackageType get_package_type() const noexcept; /// Set type of package associated with a comps group (xml element: ``) /// See `enum class libdnf5::comps::PackageType` documentation for more details. /// // @replaces libdnf:transaction/CompsGroupItem.hpp:method:CompsGroupPackage.setPackageType(libdnf::PackageType value) - void set_package_type(libdnf5::comps::PackageType value); + LIBDNF_LOCAL void set_package_type(libdnf5::comps::PackageType value); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/transaction/offline.hpp b/include/libdnf5/transaction/offline.hpp index d8115c62d..10d9b8b3a 100644 --- a/include/libdnf5/transaction/offline.hpp +++ b/include/libdnf5/transaction/offline.hpp @@ -20,7 +20,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_TRANSACTION_OFFLINE_HPP #define LIBDNF5_TRANSACTION_OFFLINE_HPP -#include +#include "libdnf5/conf/const.hpp" +#include "libdnf5/defs.h" #include #include @@ -52,7 +53,7 @@ class OfflineTransactionState; /// Data of the initiated offline transaction state, by default stored in the /// /usr/lib/sysimage/libdnf5/offline/offline-transaction-state.toml file. -struct OfflineTransactionStateData { +struct LIBDNF_API OfflineTransactionStateData { public: friend OfflineTransactionState; @@ -103,13 +104,13 @@ struct OfflineTransactionStateData { const std::string & get_module_platform_id() const; private: - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; /// Class to handle offline transaction state. -class OfflineTransactionState { +class LIBDNF_API OfflineTransactionState { public: OfflineTransactionState() = delete; ~OfflineTransactionState(); @@ -133,9 +134,9 @@ class OfflineTransactionState { std::filesystem::path get_path() const; private: - class Impl; + class LIBDNF_LOCAL Impl; /// Read offline transaction state data from the file - void read(); + LIBDNF_LOCAL void read(); std::unique_ptr p_impl; }; diff --git a/include/libdnf5/transaction/rpm_package.hpp b/include/libdnf5/transaction/rpm_package.hpp index 22a2cce88..e20e5268d 100644 --- a/include/libdnf5/transaction/rpm_package.hpp +++ b/include/libdnf5/transaction/rpm_package.hpp @@ -22,6 +22,8 @@ along with libdnf. If not, see . #include "transaction_item.hpp" +#include "libdnf5/defs.h" + #include @@ -35,7 +37,7 @@ class RpmDbUtils; /// to perform rpm transaction and then stored in the transaction (history) database. /// // @replaces libdnf:transaction/RPMItem.hpp:class:RPMItem -class Package : public TransactionItem { +class LIBDNF_API Package : public TransactionItem { public: /// Get package name /// @@ -77,35 +79,35 @@ class Package : public TransactionItem { friend RpmDbUtils; friend Transaction; - explicit Package(const Transaction & trans); + LIBDNF_LOCAL explicit Package(const Transaction & trans); /// Set package name /// // @replaces libdnf:transaction/RPMItem.hpp:method:RPMItem.setName(const std::string & value) - void set_name(const std::string & value); + LIBDNF_LOCAL void set_name(const std::string & value); /// Get package epoch as an integer - uint32_t get_epoch_int() const; + LIBDNF_LOCAL uint32_t get_epoch_int() const; /// Set package epoch /// // @replaces libdnf:transaction/RPMItem.hpp:method:RPMItem.setEpoch(int32_t value) - void set_epoch(const std::string & value); + LIBDNF_LOCAL void set_epoch(const std::string & value); /// Set package version /// // @replaces libdnf:transaction/RPMItem.hpp:method:RPMItem.setVersion(const std::string & value) - void set_version(const std::string & value); + LIBDNF_LOCAL void set_version(const std::string & value); /// Set package release /// // @replaces libdnf:transaction/RPMItem.hpp:method:RPMItem.setRelease(const std::string & value) - void set_release(const std::string & value); + LIBDNF_LOCAL void set_release(const std::string & value); /// Set package arch /// // @replaces libdnf:transaction/RPMItem.hpp:method:RPMItem.setArch(const std::string & value) - void set_arch(const std::string & value); + LIBDNF_LOCAL void set_arch(const std::string & value); /* // TODO(dmach): Implement TransactionSack.new_filter().filter_package_pattern() @@ -117,9 +119,9 @@ class Package : public TransactionItem { libdnf5::utils::SQLite3 & conn, const std::string & name, const std::string & arch, int64_t maxTransactionId); */ - bool operator<(const Package & other) const; + LIBDNF_LOCAL bool operator<(const Package & other) const; - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/transaction/transaction.hpp b/include/libdnf5/transaction/transaction.hpp index b6b89ead7..22525656c 100644 --- a/include/libdnf5/transaction/transaction.hpp +++ b/include/libdnf5/transaction/transaction.hpp @@ -29,6 +29,7 @@ along with libdnf. If not, see . #include "libdnf5/base/transaction_group.hpp" #include "libdnf5/base/transaction_module.hpp" #include "libdnf5/base/transaction_package.hpp" +#include "libdnf5/defs.h" #include #include @@ -57,10 +58,10 @@ class TransactionHistory; // @replaces libdnf:transaction/Types.hpp:enum:TransactionState enum class TransactionState : int { STARTED = 1, OK = 2, ERROR = 3 }; -std::string transaction_state_to_string(TransactionState state); -TransactionState transaction_state_from_string(const std::string & state); +LIBDNF_API std::string transaction_state_to_string(TransactionState state); +LIBDNF_API TransactionState transaction_state_from_string(const std::string & state); -class InvalidTransactionState : public libdnf5::Error { +class LIBDNF_API InvalidTransactionState : public libdnf5::Error { public: InvalidTransactionState(const std::string & state); @@ -76,7 +77,7 @@ class InvalidTransactionState : public libdnf5::Error { /// to change packages on disk. /// // @replaces libdnf:transaction/Transaction.hpp:class:Transaction -class Transaction { +class LIBDNF_API Transaction { public: using State = TransactionState; @@ -176,7 +177,7 @@ class Transaction { /// be filled by the user and saved to the database. /// /// @param base The base. - explicit Transaction(const libdnf5::BaseWeakPtr & base); + LIBDNF_LOCAL explicit Transaction(const libdnf5::BaseWeakPtr & base); /// Constructs the transaction with a known id which needs to exist in the /// database. The data are then lazily loaded from the database on first call @@ -184,78 +185,79 @@ class Transaction { /// /// @param base The base. /// @param id The id of the transaction. - Transaction(const libdnf5::BaseWeakPtr & base, int64_t id); + LIBDNF_LOCAL Transaction(const libdnf5::BaseWeakPtr & base, int64_t id); /// Set Transaction database id (primary key) /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setId(int64_t value) - void set_id(int64_t value); + LIBDNF_LOCAL void set_id(int64_t value); /// Set a user-specified comment describing the transaction - void set_comment(const std::string & value); + LIBDNF_LOCAL void set_comment(const std::string & value); /// Set date and time of the transaction start /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setDtBegin(int64_t value) - void set_dt_start(int64_t value); + LIBDNF_LOCAL void set_dt_start(int64_t value); /// Set date and time of the transaction end /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setDtEnd(int64_t value) - void set_dt_end(int64_t value); + LIBDNF_LOCAL void set_dt_end(int64_t value); /// Set the description of the transaction (e.g. the CLI command that was executed) /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setCmdline(const std::string & value) - void set_description(const std::string & value); + LIBDNF_LOCAL void set_description(const std::string & value); /// Set UID of a user that started the transaction /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setUserId(uint32_t value) - void set_user_id(uint32_t value); + LIBDNF_LOCAL void set_user_id(uint32_t value); /// Set $releasever variable value that was used during the transaction /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setReleasever(const std::string & value) - void set_releasever(const std::string & value); + LIBDNF_LOCAL void set_releasever(const std::string & value); /// Set RPM database version after the transaction /// Format: ``:`` /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setRpmdbVersionEnd(const std::string & value) - void set_rpmdb_version_end(const std::string & value); + LIBDNF_LOCAL void set_rpmdb_version_end(const std::string & value); /// Set RPM database version before the transaction /// Format: ``:`` /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setRpmdbVersionBegin(const std::string & value) - void set_rpmdb_version_begin(const std::string & value); + LIBDNF_LOCAL void set_rpmdb_version_begin(const std::string & value); /// Set transaction state /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.setState(libdnf::TransactionState value) - void set_state(State value); + LIBDNF_LOCAL void set_state(State value); /// Create a new rpm package in the transaction and return a reference to it. /// The package is owned by the transaction. /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.addItem(std::shared_ptr item, const std::string & repoid, libdnf::TransactionItemAction action, libdnf::TransactionItemReason reason) - Package & new_package(); + LIBDNF_LOCAL Package & new_package(); /// Fill the transaction packages. - void fill_transaction_packages(const std::vector & transaction_packages); + LIBDNF_LOCAL void fill_transaction_packages( + const std::vector & transaction_packages); /// Fill the transaction groups. /// @param transaction_groups Groups that are part of the transaction /// @param installed_names Names of currently installed plus inbound packages - void fill_transaction_groups( + LIBDNF_LOCAL void fill_transaction_groups( const std::vector & transaction_groups, const std::set & installed_names); /// Fill the transaction environmental groups. /// @param transaction_groups Environmental groups that are part of the transaction /// @param installed_names Ids of currently installed plus inbound groups - void fill_transaction_environments( + LIBDNF_LOCAL void fill_transaction_environments( const std::vector & transaction_environments, const std::set & installed_group_ids); @@ -263,25 +265,25 @@ class Transaction { /// The group is owned by the transaction. /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.addItem(std::shared_ptr item, const std::string & repoid, libdnf::TransactionItemAction action, libdnf::TransactionItemReason reason) - CompsGroup & new_comps_group(); + LIBDNF_LOCAL CompsGroup & new_comps_group(); /// Create a new comps environment in the transaction and return a reference to it. /// The environment is owned by the transaction. /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.addItem(std::shared_ptr item, const std::string & repoid, libdnf::TransactionItemAction action, libdnf::TransactionItemReason reason) - CompsEnvironment & new_comps_environment(); + LIBDNF_LOCAL CompsEnvironment & new_comps_environment(); /// Start the transaction by inserting it into the database /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.begin() - void start(); + LIBDNF_LOCAL void start(); /// Finish the transaction by updating it's state in the database /// // @replaces libdnf:transaction/private/Transaction.hpp:method:Transaction.finish(libdnf::TransactionState state) - void finish(TransactionState state); + LIBDNF_LOCAL void finish(TransactionState state); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/transaction/transaction_history.hpp b/include/libdnf5/transaction/transaction_history.hpp index a7373f31e..ebe6d206b 100644 --- a/include/libdnf5/transaction/transaction_history.hpp +++ b/include/libdnf5/transaction/transaction_history.hpp @@ -24,6 +24,7 @@ along with libdnf. If not, see . #include "libdnf5/base/base_weak.hpp" #include "libdnf5/common/weak_ptr.hpp" +#include "libdnf5/defs.h" namespace libdnf5::transaction { @@ -32,7 +33,7 @@ class TransactionHistory; using TransactionHistoryWeakPtr = libdnf5::WeakPtr; /// A class for working with transactions recorded in the transaction history database. -class TransactionHistory { +class LIBDNF_API TransactionHistory { public: explicit TransactionHistory(const libdnf5::BaseWeakPtr & base); explicit TransactionHistory(libdnf5::Base & base); @@ -75,9 +76,9 @@ class TransactionHistory { private: /// Create a new Transaction object. - libdnf5::transaction::Transaction new_transaction(); + LIBDNF_LOCAL libdnf5::transaction::Transaction new_transaction(); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/transaction/transaction_item.hpp b/include/libdnf5/transaction/transaction_item.hpp index 2b8f270cd..ad452f603 100644 --- a/include/libdnf5/transaction/transaction_item.hpp +++ b/include/libdnf5/transaction/transaction_item.hpp @@ -24,6 +24,8 @@ along with libdnf. If not, see . #include "transaction_item_reason.hpp" #include "transaction_item_state.hpp" +#include "libdnf5/defs.h" + #include @@ -41,7 +43,7 @@ class CompsGroupPackageDbUtils; class CompsEnvironmentGroupDbUtils; -class TransactionItem { +class LIBDNF_API TransactionItem { public: using Action = TransactionItemAction; using Reason = TransactionItemReason; @@ -85,57 +87,57 @@ class TransactionItem { friend CompsGroupPackageDbUtils; friend CompsEnvironmentGroupDbUtils; - explicit TransactionItem(const Transaction & trans); + LIBDNF_LOCAL explicit TransactionItem(const Transaction & trans); /// Get database id (primary key) of the transaction item (table 'trans_item') - int64_t get_id() const noexcept; + LIBDNF_LOCAL int64_t get_id() const noexcept; /// Set database id (primary key) of the transaction item (table 'trans_item') - void set_id(int64_t value); + LIBDNF_LOCAL void set_id(int64_t value); /// Set action associated with the transaction item in the transaction /// // @replaces libdnf:transaction/TransactionItem.hpp:method:TransactionItemBase.setAction(libdnf::TransactionItemAction value) - void set_action(Action value); + LIBDNF_LOCAL void set_action(Action value); /// Get name of the action associated with the transaction item in the transaction /// // @replaces libdnf:transaction/TransactionItem.hpp:method:TransactionItemBase.getActionName() - std::string get_action_name(); + LIBDNF_LOCAL std::string get_action_name(); /// Get abbreviated name of the action associated with the transaction item in the transaction /// // @replaces libdnf:transaction/TransactionItem.hpp:method:TransactionItemBase.getActionShort() - std::string get_action_short(); + LIBDNF_LOCAL std::string get_action_short(); /// Set reason of the action associated with the transaction item in the transaction /// // @replaces libdnf:transaction/TransactionItem.hpp:method:TransactionItemBase.setReason(libdnf::TransactionItemReason value) - void set_reason(Reason value); + LIBDNF_LOCAL void set_reason(Reason value); /// Set transaction item state /// // @replaces libdnf:transaction/TransactionItem.hpp:method:TransactionItemBase.setState(libdnf::TransactionItemState value) - void set_state(State value); + LIBDNF_LOCAL void set_state(State value); /// Get transaction item repoid (text identifier of a repository) /// // @replaces libdnf:transaction/TransactionItem.hpp:method:TransactionItemBase.setRepoid(const std::string & value) - void set_repoid(const std::string & value); + LIBDNF_LOCAL void set_repoid(const std::string & value); /// Has the item appeared on the system during the transaction? /// // @replaces libdnf:transaction/TransactionItem.hpp:method:TransactionItemBase.isForwardAction() - bool is_inbound_action() const; + LIBDNF_LOCAL bool is_inbound_action() const; /// Has the item got removed from the system during the transaction? /// // @replaces libdnf:transaction/TransactionItem.hpp:method:TransactionItemBase.isBackwardAction() - bool is_outbound_action() const; + LIBDNF_LOCAL bool is_outbound_action() const; // TODO(dmach): Reimplement in Package class; it's most likely not needed in Comps{Group,Environment} // std::vector< TransactionItemPtr > replacedBy; - const Transaction & get_transaction() const; + LIBDNF_LOCAL const Transaction & get_transaction() const; // TODO(dmach): Reimplement in Package class //const std::vector< TransactionItemPtr > &getReplacedBy() const noexcept { return replacedBy; } @@ -146,12 +148,12 @@ class TransactionItem { //void saveState(); /// Get database id (primary key) of the item (table 'item'; other item tables such 'rpm' inherit from it via 1:1 relation) - int64_t get_item_id() const noexcept; + LIBDNF_LOCAL int64_t get_item_id() const noexcept; /// Set database id (primary key) of the item (table 'item'; other item tables such 'rpm' inherit from it via 1:1 relation) - void set_item_id(int64_t value); + LIBDNF_LOCAL void set_item_id(int64_t value); - class Impl; + class LIBDNF_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5/transaction/transaction_item_action.hpp b/include/libdnf5/transaction/transaction_item_action.hpp index 2265e81f8..0e5d2814e 100644 --- a/include/libdnf5/transaction/transaction_item_action.hpp +++ b/include/libdnf5/transaction/transaction_item_action.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define LIBDNF5_TRANSACTION_ITEM_ACTION_HPP #include "libdnf5/common/exception.hpp" +#include "libdnf5/defs.h" #include @@ -47,7 +48,7 @@ enum class TransactionItemAction : int { }; -class InvalidTransactionItemAction : public libdnf5::Error { +class LIBDNF_API InvalidTransactionItemAction : public libdnf5::Error { public: InvalidTransactionItemAction(const std::string & action); @@ -56,13 +57,13 @@ class InvalidTransactionItemAction : public libdnf5::Error { }; -std::string transaction_item_action_to_string(TransactionItemAction action); -TransactionItemAction transaction_item_action_from_string(const std::string & action); +LIBDNF_API std::string transaction_item_action_to_string(TransactionItemAction action); +LIBDNF_API TransactionItemAction transaction_item_action_from_string(const std::string & action); -std::string transaction_item_action_to_letter(TransactionItemAction action); +LIBDNF_API std::string transaction_item_action_to_letter(TransactionItemAction action); -bool transaction_item_action_is_inbound(TransactionItemAction action); -bool transaction_item_action_is_outbound(TransactionItemAction action); +LIBDNF_API bool transaction_item_action_is_inbound(TransactionItemAction action); +LIBDNF_API bool transaction_item_action_is_outbound(TransactionItemAction action); } // namespace libdnf5::transaction diff --git a/include/libdnf5/transaction/transaction_item_reason.hpp b/include/libdnf5/transaction/transaction_item_reason.hpp index 1daf57f63..85d9811ad 100644 --- a/include/libdnf5/transaction/transaction_item_reason.hpp +++ b/include/libdnf5/transaction/transaction_item_reason.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define LIBDNF5_TRANSACTION_TRANSACTION_ITEM_REASON_HPP #include "libdnf5/common/exception.hpp" +#include "libdnf5/defs.h" #include @@ -38,7 +39,7 @@ enum class TransactionItemReason : int { }; -class InvalidTransactionItemReason : public libdnf5::Error { +class LIBDNF_API InvalidTransactionItemReason : public libdnf5::Error { public: InvalidTransactionItemReason(const std::string & reason); @@ -47,8 +48,8 @@ class InvalidTransactionItemReason : public libdnf5::Error { }; -std::string transaction_item_reason_to_string(TransactionItemReason reason); -TransactionItemReason transaction_item_reason_from_string(const std::string & reason); +LIBDNF_API std::string transaction_item_reason_to_string(TransactionItemReason reason); +LIBDNF_API TransactionItemReason transaction_item_reason_from_string(const std::string & reason); /// Compare transaction items and return: @@ -56,13 +57,13 @@ TransactionItemReason transaction_item_reason_from_string(const std::string & re /// 1 if lhs > rhs /// 0 if lhs == rhs /// Higher number means a better (or a stronger) reason. -int transaction_item_reason_compare(TransactionItemReason lhs, TransactionItemReason rhs); +LIBDNF_API int transaction_item_reason_compare(TransactionItemReason lhs, TransactionItemReason rhs); -bool operator<(TransactionItemReason lhs, TransactionItemReason rhs); -bool operator<=(TransactionItemReason lhs, TransactionItemReason rhs); -bool operator>(TransactionItemReason lhs, TransactionItemReason rhs); -bool operator>=(TransactionItemReason lhs, TransactionItemReason rhs); +LIBDNF_API bool operator<(TransactionItemReason lhs, TransactionItemReason rhs); +LIBDNF_API bool operator<=(TransactionItemReason lhs, TransactionItemReason rhs); +LIBDNF_API bool operator>(TransactionItemReason lhs, TransactionItemReason rhs); +LIBDNF_API bool operator>=(TransactionItemReason lhs, TransactionItemReason rhs); } // namespace libdnf5::transaction diff --git a/include/libdnf5/transaction/transaction_item_state.hpp b/include/libdnf5/transaction/transaction_item_state.hpp index 24f0841d8..bea4cf592 100644 --- a/include/libdnf5/transaction/transaction_item_state.hpp +++ b/include/libdnf5/transaction/transaction_item_state.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define LIBDNF5_TRANSACTION_TRANSACTION_ITEM_STATE_HPP #include "libdnf5/common/exception.hpp" +#include "libdnf5/defs.h" #include @@ -30,7 +31,7 @@ namespace libdnf5::transaction { enum class TransactionItemState : int { STARTED = 1, OK = 2, ERROR = 3 }; -class InvalidTransactionItemState : public libdnf5::Error { +class LIBDNF_API InvalidTransactionItemState : public libdnf5::Error { public: InvalidTransactionItemState(const std::string & state); @@ -39,8 +40,8 @@ class InvalidTransactionItemState : public libdnf5::Error { }; -std::string transaction_item_state_to_string(TransactionItemState state); -TransactionItemState transaction_item_state_from_string(const std::string & state); +LIBDNF_API std::string transaction_item_state_to_string(TransactionItemState state); +LIBDNF_API TransactionItemState transaction_item_state_from_string(const std::string & state); } // namespace libdnf5::transaction diff --git a/include/libdnf5/transaction/transaction_item_type.hpp b/include/libdnf5/transaction/transaction_item_type.hpp index 8f534c0f3..c2a7cd655 100644 --- a/include/libdnf5/transaction/transaction_item_type.hpp +++ b/include/libdnf5/transaction/transaction_item_type.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define LIBDNF5_TRANSACTION_ITEM_TYPE_HPP #include "libdnf5/common/exception.hpp" +#include "libdnf5/defs.h" #include @@ -30,7 +31,7 @@ namespace libdnf5::transaction { enum class TransactionItemType : int { PACKAGE, GROUP, ENVIRONMENT, MODULE }; -class InvalidTransactionItemType : public libdnf5::Error { +class LIBDNF_API InvalidTransactionItemType : public libdnf5::Error { public: InvalidTransactionItemType(const std::string & type); @@ -39,8 +40,8 @@ class InvalidTransactionItemType : public libdnf5::Error { }; -std::string transaction_item_type_to_string(TransactionItemType action); -TransactionItemType transaction_item_type_from_string(const std::string & action); +LIBDNF_API std::string transaction_item_type_to_string(TransactionItemType action); +LIBDNF_API TransactionItemType transaction_item_type_from_string(const std::string & action); } // namespace libdnf5::transaction diff --git a/include/libdnf5/utils/fs/file.hpp b/include/libdnf5/utils/fs/file.hpp index 9a5282154..335cb429f 100644 --- a/include/libdnf5/utils/fs/file.hpp +++ b/include/libdnf5/utils/fs/file.hpp @@ -20,6 +20,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_UTILS_FS_FILE_HPP #define LIBDNF5_UTILS_FS_FILE_HPP +#include "libdnf5/defs.h" + #include #include @@ -30,7 +32,7 @@ namespace libdnf5::utils::fs { /// fashion. Errors are handled by raising instances of /// `libdnf5::FileSystemError` so that there's a single exception type /// being raised for all filesystem-related errors. -class File { +class LIBDNF_API File { public: /// Creates an instance of `File` without opening any file. File(); diff --git a/include/libdnf5/utils/fs/temp.hpp b/include/libdnf5/utils/fs/temp.hpp index 7fe53a173..b8566fd3b 100644 --- a/include/libdnf5/utils/fs/temp.hpp +++ b/include/libdnf5/utils/fs/temp.hpp @@ -22,6 +22,8 @@ along with libdnf. If not, see . #include "file.hpp" +#include "libdnf5/defs.h" + #include #include #include @@ -31,7 +33,7 @@ namespace libdnf5::utils::fs { /// Object that creates and holds a temp directory. /// The directory gets removed when the object is deleted. -class TempDir { +class LIBDNF_API TempDir { public: /// Creates a temporary directory in the system temporary directory path. explicit TempDir(const std::string & name_prefix); @@ -60,7 +62,7 @@ class TempDir { /// A mkstemp wrapper that creates and owns a temporary file, which will be /// deleted in the destructor unless released. Throws instances of /// `libdnf5::FileSystemError` on any I/O failure. -class TempFile { +class LIBDNF_API TempFile { public: /// Creates a temporary file in the system temporary directory path. /// diff --git a/include/libdnf5/utils/locker.hpp b/include/libdnf5/utils/locker.hpp index c5de568c9..9837e6158 100644 --- a/include/libdnf5/utils/locker.hpp +++ b/include/libdnf5/utils/locker.hpp @@ -20,13 +20,15 @@ along with libdnf. If not, see . #ifndef LIBDNF5_UTILS_LOCKER_HPP #define LIBDNF5_UTILS_LOCKER_HPP +#include "libdnf5/defs.h" + #include namespace libdnf5::utils { /// Object for implementing a simple file mutex mechanism /// or checking read/write access on a given path. -class Locker { +class LIBDNF_API Locker { public: /// Create a Locker object at a given path explicit Locker(const std::string & path); @@ -47,7 +49,7 @@ class Locker { void unlock(); private: - bool lock(short int type); + LIBDNF_LOCAL bool lock(short int type); std::string path; int lock_fd{-1}; diff --git a/include/libdnf5/version.hpp b/include/libdnf5/version.hpp index a64bcfa9a..a409b137b 100644 --- a/include/libdnf5/version.hpp +++ b/include/libdnf5/version.hpp @@ -20,6 +20,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_VERSION_HPP #define LIBDNF5_VERSION_HPP +#include "defs.h" + #include namespace libdnf5 { @@ -48,11 +50,11 @@ static constexpr PluginAPIVersion PLUGIN_API_VERSION{.major = 2, .minor = 0}; /// @return Library version /// @since 5.0 -LibraryVersion get_library_version() noexcept; +LIBDNF_API LibraryVersion get_library_version() noexcept; /// @return Plugin API version implemented in the library /// @since 5.0 -PluginAPIVersion get_plugin_api_version() noexcept; +LIBDNF_API PluginAPIVersion get_plugin_api_version() noexcept; } // namespace libdnf5 diff --git a/libdnf5-plugins/CMakeLists.txt b/libdnf5-plugins/CMakeLists.txt index d891ee497..f97124f09 100644 --- a/libdnf5-plugins/CMakeLists.txt +++ b/libdnf5-plugins/CMakeLists.txt @@ -1,3 +1,6 @@ +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_C_VISIBILITY_PRESET hidden) + add_subdirectory("actions") add_subdirectory("python_plugins_loader") add_subdirectory("rhsm") diff --git a/libdnf5/CMakeLists.txt b/libdnf5/CMakeLists.txt index 237ac9e42..00d86a4eb 100644 --- a/libdnf5/CMakeLists.txt +++ b/libdnf5/CMakeLists.txt @@ -8,6 +8,8 @@ configure_file("config.h.in" ${CMAKE_CURRENT_SOURCE_DIR}/conf/config.h) list(APPEND LIBDNF5_PC_REQUIRES) list(APPEND LIBDNF5_PC_REQUIRES_PRIVATE) +add_definitions(-DLIBDNF_BUILD_LIBRARY) + # set gettext domain for translations set(GETTEXT_DOMAIN libdnf5) add_definitions(-DGETTEXT_DOMAIN=\"${GETTEXT_DOMAIN}\") @@ -24,6 +26,7 @@ add_library(libdnf5 SHARED ${LIBDNF5_SOURCES}) set(DNF_SO_VERSION 2) set_target_properties(libdnf5 PROPERTIES OUTPUT_NAME "dnf5") set_target_properties(libdnf5 PROPERTIES SOVERSION ${DNF_SO_VERSION}) +set_target_properties(libdnf5 PROPERTIES C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET hidden) # required to have dlopen symbol target_link_libraries(libdnf5 PUBLIC ${CMAKE_DL_LIBS}) diff --git a/libdnf5/utils/bgettext/bgettext.c b/libdnf5/utils/bgettext/bgettext.c index 588673010..7337727a7 100644 --- a/libdnf5/utils/bgettext/bgettext.c +++ b/libdnf5/utils/bgettext/bgettext.c @@ -17,13 +17,14 @@ You should have received a copy of the GNU Lesser General Public License along with libdnf. If not, see . */ +#include "libdnf5/defs.h" #include "libdnf5/utils/bgettext/bgettext-common.h" #include enum { BGETTEXT_PLURAL = 1 << 0, BGETTEXT_CONTEXT = 1 << 1, BGETTEXT_DOMAIN = 1 << 2 }; -const char * b_dpgettext(const char * domain, const char * context, const char * msgId) { +LIBDNF_API const char * b_dpgettext(const char * domain, const char * context, const char * msgId) { size_t context_len = strlen(context) + 1; size_t msgId_len = strlen(msgId) + 1; char ctxMsgId[context_len + msgId_len]; @@ -40,14 +41,14 @@ const char * b_dpgettext(const char * domain, const char * context, const char * return translation; } -const char * b_dpgettext2(const char * domain, const char * ctxMsgId, size_t msgIdOffset) { +LIBDNF_API const char * b_dpgettext2(const char * domain, const char * ctxMsgId, size_t msgIdOffset) { const char * const translation = dgettext(domain, ctxMsgId); if (translation == ctxMsgId) return ctxMsgId + msgIdOffset; return translation; } -const char * b_dnpgettext( +LIBDNF_API const char * b_dnpgettext( const char * domain, const char * context, const char * msgId, const char * msgIdPlural, unsigned long int n) { size_t context_len = strlen(context) + 1; size_t msgId_len = strlen(msgId) + 1; @@ -65,7 +66,7 @@ const char * b_dnpgettext( return translation; } -const char * b_dnpgettext2( +LIBDNF_API const char * b_dnpgettext2( const char * domain, const char * ctxMsgId, size_t msgIdOffset, const char * msgIdPlural, unsigned long int n) { const char * const translation = dngettext(domain, ctxMsgId, msgIdPlural, n); if (translation == ctxMsgId) @@ -73,11 +74,11 @@ const char * b_dnpgettext2( return translation; } -const char * b_gettextmsg_get_domain(struct BgettextMessage message) { +LIBDNF_API const char * b_gettextmsg_get_domain(struct BgettextMessage message) { return *message.bgettextMsg & BGETTEXT_DOMAIN ? message.bgettextMsg + 1 : NULL; } -const char * b_gettextmsg_get_id(struct BgettextMessage message) { +LIBDNF_API const char * b_gettextmsg_get_id(struct BgettextMessage message) { const char * msgId = message.bgettextMsg + 1; if (*message.bgettextMsg & BGETTEXT_DOMAIN) { msgId = strchr(msgId, 0) + 1; @@ -88,7 +89,7 @@ const char * b_gettextmsg_get_id(struct BgettextMessage message) { return msgId; } -const char * b_dmgettext(const char * domain, struct BgettextMessage message, unsigned long int n) { +LIBDNF_API const char * b_dmgettext(const char * domain, struct BgettextMessage message, unsigned long int n) { const char * markedMsg = message.bgettextMsg; if ((*markedMsg & ~(BGETTEXT_PLURAL | BGETTEXT_CONTEXT | BGETTEXT_DOMAIN)) == 0) { const char * msgId; From deb0245b6d59f76b0c43b019768b4d7e022d2032 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Thu, 21 Mar 2024 15:27:40 +0100 Subject: [PATCH 4/9] Disable libdnf5, libdnf5-cli, dnf5 cpr_plugin C++ unit tests Temporarily disabled. They need private symbols. --- test/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 74b44b939..0f97c0486 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,7 +22,7 @@ endif() add_subdirectory(data) # libdnf5 -add_subdirectory(libdnf5) +#add_subdirectory(libdnf5) # performance tests are available only for libdnf5 if(WITH_PERFORMANCE_TESTS) @@ -30,7 +30,7 @@ if(WITH_PERFORMANCE_TESTS) endif() # libdnf5-cli -add_subdirectory(libdnf5-cli) +#add_subdirectory(libdnf5-cli) # tutorial add_subdirectory(tutorial) @@ -43,7 +43,7 @@ add_subdirectory(ruby) # components add_subdirectory(dnf5daemon-server) -add_subdirectory(dnf5-plugins) +#add_subdirectory(dnf5-plugins) # add shared -add_subdirectory(shared) +#add_subdirectory(shared) From 3b0f71301bff45c6d5208b057c98276b824be477 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Mon, 20 May 2024 15:03:48 +0200 Subject: [PATCH 5/9] libdnf5-cli: Define macros for assigning symbol visibility --- include/libdnf5-cli/defs.h | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 include/libdnf5-cli/defs.h diff --git a/include/libdnf5-cli/defs.h b/include/libdnf5-cli/defs.h new file mode 100644 index 000000000..b6671c95a --- /dev/null +++ b/include/libdnf5-cli/defs.h @@ -0,0 +1,52 @@ +/* +Copyright Contributors to the libdnf project. + +This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ + +Libdnf is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +Libdnf is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with libdnf. If not, see . +*/ + +#ifndef LIBDNF5_CLI_DEFS_H +#define LIBDNF5_CLI_DEFS_H + +// Generic helper definitions for shared library support +#if defined _WIN32 || defined __CYGWIN__ +#define LIBDNF_CLI_SYMBOL_IMPORT __declspec(dllimport) +#define LIBDNF_CLI_SYMBOL_EXPORT __declspec(dllexport) +#define LIBDNF_CLI_SYMBOL_LOCAL +#else +#if __GNUC__ >= 4 +#define LIBDNF_CLI_SYMBOL_IMPORT __attribute__((visibility("default"))) +#define LIBDNF_CLI_SYMBOL_EXPORT __attribute__((visibility("default"))) +#define LIBDNF_CLI_SYMBOL_LOCAL __attribute__((visibility("hidden"))) +#else +#define LIBDNF_CLI_SYMBOL_IMPORT +#define LIBDNF_CLI_SYMBOL_EXPORT +#define LIBDNF_CLI_SYMBOL_LOCAL +#endif +#endif + +// Now we use the generic helper definitions above to define LIBDNF_CLI_API and LIBDNF_CLI_LOCAL. +// LIBDNF_CLI_API is used for the public API symbols. It either imports or exports the symbol. +// LIBDNF_CLI_LOCAL is used for non-api symbols. + +#ifdef LIBDNF_CLI_BUILD_LIBRARY // defined if we are building the libdnf-cli library (instead of using it) +#define LIBDNF_CLI_API LIBDNF_CLI_SYMBOL_EXPORT +#else +#define LIBDNF_CLI_API LIBDNF_CLI_SYMBOL_IMPORT +#endif + +#define LIBDNF_CLI_LOCAL LIBDNF_CLI_SYMBOL_LOCAL + +#endif From 96388554e8f670ee8cd27320ea95c4e990d7d6bc Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Mon, 20 May 2024 09:54:35 +0200 Subject: [PATCH 6/9] libdnf5-cli library: Do not export private symbols --- bindings/libdnf5_cli/progressbar.i | 1 + include/libdnf5-cli/argument_parser.hpp | 29 ++++++++------- include/libdnf5-cli/exception.hpp | 8 ++-- .../libdnf5-cli/output/adapters/advisory.hpp | 12 +++--- include/libdnf5-cli/output/adapters/comps.hpp | 8 ++-- .../libdnf5-cli/output/adapters/module.hpp | 8 ++-- .../libdnf5-cli/output/adapters/package.hpp | 4 +- include/libdnf5-cli/output/adapters/repo.hpp | 4 +- .../output/adapters/transaction.hpp | 12 +++--- include/libdnf5-cli/output/advisoryinfo.hpp | 6 ++- include/libdnf5-cli/output/advisorylist.hpp | 6 ++- .../libdnf5-cli/output/advisorysummary.hpp | 5 ++- include/libdnf5-cli/output/changelogs.hpp | 4 +- .../libdnf5-cli/output/environmentinfo.hpp | 4 +- .../libdnf5-cli/output/environmentlist.hpp | 4 +- include/libdnf5-cli/output/groupinfo.hpp | 4 +- include/libdnf5-cli/output/grouplist.hpp | 4 +- include/libdnf5-cli/output/moduleinfo.hpp | 8 ++-- include/libdnf5-cli/output/modulelist.hpp | 6 ++- .../output/package_info_sections.hpp | 4 +- .../output/package_list_sections.hpp | 6 ++- include/libdnf5-cli/output/packageinfo.hpp | 4 +- include/libdnf5-cli/output/pkg_colorizer.hpp | 6 ++- include/libdnf5-cli/output/provides.hpp | 4 +- include/libdnf5-cli/output/repo_info.hpp | 8 ++-- include/libdnf5-cli/output/repolist.hpp | 7 +++- include/libdnf5-cli/output/repoquery.hpp | 12 +++--- include/libdnf5-cli/output/search.hpp | 4 +- .../libdnf5-cli/output/transaction_table.hpp | 10 +++-- .../libdnf5-cli/output/transactioninfo.hpp | 4 +- .../libdnf5-cli/output/transactionlist.hpp | 4 +- .../progressbar/download_progress_bar.hpp | 6 ++- .../progressbar/multi_progress_bar.hpp | 6 ++- .../libdnf5-cli/progressbar/progress_bar.hpp | 5 ++- include/libdnf5-cli/session.hpp | 16 ++++---- include/libdnf5-cli/tty.hpp | 37 ++++++++++--------- include/libdnf5-cli/utils/units.hpp | 6 ++- libdnf5-cli/CMakeLists.txt | 2 + libdnf5-cli/utils/utf8.hpp | 9 +++-- 39 files changed, 186 insertions(+), 111 deletions(-) diff --git a/bindings/libdnf5_cli/progressbar.i b/bindings/libdnf5_cli/progressbar.i index 840bd031d..92ad465a8 100644 --- a/bindings/libdnf5_cli/progressbar.i +++ b/bindings/libdnf5_cli/progressbar.i @@ -16,6 +16,7 @@ #define CV __perl_CV +#define LIBDNF_CLI_API %include "libdnf5-cli/progressbar/progress_bar.hpp" %include "libdnf5-cli/progressbar/download_progress_bar.hpp" diff --git a/include/libdnf5-cli/argument_parser.hpp b/include/libdnf5-cli/argument_parser.hpp index 0934fc8ff..fd2c31f99 100644 --- a/include/libdnf5-cli/argument_parser.hpp +++ b/include/libdnf5-cli/argument_parser.hpp @@ -20,6 +20,7 @@ along with libdnf. If not, see . #ifndef LIBDNF5_CLI_ARGUMENT_PARSER_HPP #define LIBDNF5_CLI_ARGUMENT_PARSER_HPP +#include "libdnf5-cli/defs.h" #include "libdnf5-cli/exception.hpp" #include @@ -153,7 +154,7 @@ class ArgumentParserInvalidValueError : public ArgumentParserError { /// Base class for user data used in ArgumentParser::Argument class ArgumentParserUserData {}; -class ArgumentParser { +class LIBDNF_CLI_API ArgumentParser { public: class Argument; @@ -186,7 +187,7 @@ class ArgumentParser { private: friend class ArgumentParser; - Group(const std::string & id); + LIBDNF_CLI_LOCAL Group(const std::string & id); std::string id; std::string header; @@ -262,7 +263,7 @@ class ArgumentParser { private: friend class ArgumentParser; - Argument(ArgumentParser & owner, std::string id); + LIBDNF_CLI_LOCAL Argument(ArgumentParser & owner, std::string id); ArgumentParser & owner; std::string id; @@ -330,9 +331,9 @@ class ArgumentParser { private: friend class ArgumentParser; - PositionalArg( + LIBDNF_CLI_LOCAL PositionalArg( ArgumentParser & owner, const std::string & id, std::vector> * values); - PositionalArg( + LIBDNF_CLI_LOCAL PositionalArg( ArgumentParser & owner, const std::string & id, int nvals, @@ -341,7 +342,7 @@ class ArgumentParser { /// Parses input. /// Returns number of consumed arguments from the input. - int parse(const char * option, int argc, const char * const argv[]); + LIBDNF_CLI_LOCAL int parse(const char * option, int argc, const char * const argv[]); int nvals; // Number of values required by this positional argument on the command line libdnf5::Option * init_value; @@ -434,16 +435,16 @@ class ArgumentParser { private: friend class ArgumentParser; - NamedArg(ArgumentParser & owner, const std::string & id); + LIBDNF_CLI_LOCAL NamedArg(ArgumentParser & owner, const std::string & id); /// Parses long argument. /// Returns number of consumed arguments from the input. - int parse_long(const char * option, int argc, const char * const argv[]); + LIBDNF_CLI_LOCAL int parse_long(const char * option, int argc, const char * const argv[]); /// Parses short argument. /// Returns the number of arguments consumed from the input. It may be zero. /// Multiple short arguments can be packed in one item. (e.g. "-v -f" -> "-vf"). - int parse_short(const char * option, int argc, const char * const argv[]); + LIBDNF_CLI_LOCAL int parse_short(const char * option, int argc, const char * const argv[]); std::string long_name; char short_name{'\0'}; @@ -557,11 +558,11 @@ class ArgumentParser { private: friend class ArgumentParser; - Command(ArgumentParser & owner, const std::string & id); + LIBDNF_CLI_LOCAL Command(ArgumentParser & owner, const std::string & id); // Prints a completed argument `arg` or a table with suggestions and help to complete // if there is more than one solution. - void print_complete( + LIBDNF_CLI_LOCAL void print_complete( const char * arg, std::vector named_args, size_t used_positional_arguments); Command * parent{nullptr}; @@ -634,7 +635,7 @@ class ArgumentParser { private: friend class ArgumentParser; - CommandOrdinary(ArgumentParser & owner, const std::string & id); + LIBDNF_CLI_LOCAL CommandOrdinary(ArgumentParser & owner, const std::string & id); std::vector cmds; std::vector named_args; @@ -714,7 +715,7 @@ class ArgumentParser { private: friend class ArgumentParser; - CommandAlias(ArgumentParser & owner, const std::string & id, Command & attached_command); + LIBDNF_CLI_LOCAL CommandAlias(ArgumentParser & owner, const std::string & id, Command & attached_command); Command & attached_command; @@ -853,7 +854,7 @@ class ArgumentParser { void complete(int argc, const char * const argv[], int complete_arg_idx); private: - class ArgumentParserImpl; + class LIBDNF_CLI_LOCAL ArgumentParserImpl; const std::unique_ptr p_impl; }; diff --git a/include/libdnf5-cli/exception.hpp b/include/libdnf5-cli/exception.hpp index 445d391ca..05f12c049 100644 --- a/include/libdnf5-cli/exception.hpp +++ b/include/libdnf5-cli/exception.hpp @@ -22,6 +22,8 @@ along with libdnf. If not, see . #include "exit-codes.hpp" +#include "libdnf5-cli/defs.h" + #include #include @@ -37,7 +39,7 @@ class Error : public libdnf5::Error { /// Exception is thrown when the user does not confirm the transaction. -class AbortedByUserError : public Error { +class LIBDNF_CLI_API AbortedByUserError : public Error { public: AbortedByUserError(); const char * get_name() const noexcept override { return "AbortedByUserError"; } @@ -53,7 +55,7 @@ class InsufficientPrivilegesError : public Error { /// Exception is thrown when libdnf5 fails to resolve the transaction. -class GoalResolveError : public Error { +class LIBDNF_CLI_API GoalResolveError : public Error { public: /// Construct Error from a list of string representations of resolve logs. /// @param resolve_logs List of resolve logs @@ -97,7 +99,7 @@ class CommandExitError : public Error { }; /// Exception used when non-standard exit code should be returned without displaying any message to the user -class SilentCommandExitError : public Error { +class LIBDNF_CLI_API SilentCommandExitError : public Error { public: /// Constructs the error with given exit code. /// diff --git a/include/libdnf5-cli/output/adapters/advisory.hpp b/include/libdnf5-cli/output/adapters/advisory.hpp index 6a7da9c40..b3b53c9a8 100644 --- a/include/libdnf5-cli/output/adapters/advisory.hpp +++ b/include/libdnf5-cli/output/adapters/advisory.hpp @@ -23,6 +23,8 @@ along with libdnf. If not, see . #include "advisory_tmpl.hpp" +#include "libdnf5-cli/defs.h" + #include #include #include @@ -31,11 +33,11 @@ along with libdnf. If not, see . namespace libdnf5::cli::output { -extern template class AdvisoryReferenceAdapter; -extern template class AdvisoryPackageAdapter; -extern template class AdvisoryModuleAdapter; -extern template class AdvisoryCollectionAdapter; -extern template class AdvisoryAdapter; +extern template class LIBDNF_CLI_API AdvisoryReferenceAdapter; +extern template class LIBDNF_CLI_API AdvisoryPackageAdapter; +extern template class LIBDNF_CLI_API AdvisoryModuleAdapter; +extern template class LIBDNF_CLI_API AdvisoryCollectionAdapter; +extern template class LIBDNF_CLI_API AdvisoryAdapter; } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/adapters/comps.hpp b/include/libdnf5-cli/output/adapters/comps.hpp index 55f604e72..1123850b8 100644 --- a/include/libdnf5-cli/output/adapters/comps.hpp +++ b/include/libdnf5-cli/output/adapters/comps.hpp @@ -23,15 +23,17 @@ along with libdnf. If not, see . #include "comps_tmpl.hpp" +#include "libdnf5-cli/defs.h" + #include #include #include namespace libdnf5::cli::output { -extern template class GroupPackageAdapter; -extern template class GroupAdapter; -extern template class EnvironmentAdapter; +extern template class LIBDNF_CLI_API GroupPackageAdapter; +extern template class LIBDNF_CLI_API GroupAdapter; +extern template class LIBDNF_CLI_API EnvironmentAdapter; } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/adapters/module.hpp b/include/libdnf5-cli/output/adapters/module.hpp index fee2d6843..0366200f9 100644 --- a/include/libdnf5-cli/output/adapters/module.hpp +++ b/include/libdnf5-cli/output/adapters/module.hpp @@ -23,15 +23,17 @@ along with libdnf. If not, see . #include "module_tmpl.hpp" +#include "libdnf5-cli/defs.h" + #include #include #include namespace libdnf5::cli::output { -extern template class ModuleDependencyAdapter; -extern template class ModuleItemAdapter; -extern template class ModuleProfileAdapter; +extern template class LIBDNF_CLI_API ModuleDependencyAdapter; +extern template class LIBDNF_CLI_API ModuleItemAdapter; +extern template class LIBDNF_CLI_API ModuleProfileAdapter; } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/adapters/package.hpp b/include/libdnf5-cli/output/adapters/package.hpp index 893fe4900..c8b321e1a 100644 --- a/include/libdnf5-cli/output/adapters/package.hpp +++ b/include/libdnf5-cli/output/adapters/package.hpp @@ -23,11 +23,13 @@ along with libdnf. If not, see . #include "package_tmpl.hpp" +#include "libdnf5-cli/defs.h" + #include namespace libdnf5::cli::output { -extern template class PackageAdapter; +extern template class LIBDNF_CLI_API PackageAdapter; } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/adapters/repo.hpp b/include/libdnf5-cli/output/adapters/repo.hpp index 93a0c73f3..7facfcb14 100644 --- a/include/libdnf5-cli/output/adapters/repo.hpp +++ b/include/libdnf5-cli/output/adapters/repo.hpp @@ -23,11 +23,13 @@ along with libdnf. If not, see . #include "repo_tmpl.hpp" +#include "libdnf5-cli/defs.h" + #include namespace libdnf5::cli::output { -extern template class RepoAdapter; +extern template class LIBDNF_CLI_API RepoAdapter; } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/adapters/transaction.hpp b/include/libdnf5-cli/output/adapters/transaction.hpp index 5aff8a3da..d9f9d8563 100644 --- a/include/libdnf5-cli/output/adapters/transaction.hpp +++ b/include/libdnf5-cli/output/adapters/transaction.hpp @@ -23,6 +23,8 @@ along with libdnf. If not, see . #include "transaction_tmpl.hpp" +#include "libdnf5-cli/defs.h" + #include #include #include @@ -31,11 +33,11 @@ along with libdnf. If not, see . namespace libdnf5::cli::output { -extern template class TransactionPackageAdapter; -extern template class TransactionGroupAdapter; -extern template class TransactionEnvironmentAdapter; -extern template class TransactionModuleAdapter; -extern template class TransactionAdapter; +extern template class LIBDNF_CLI_API TransactionPackageAdapter; +extern template class LIBDNF_CLI_API TransactionGroupAdapter; +extern template class LIBDNF_CLI_API TransactionEnvironmentAdapter; +extern template class LIBDNF_CLI_API TransactionModuleAdapter; +extern template class LIBDNF_CLI_API TransactionAdapter; } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/advisoryinfo.hpp b/include/libdnf5-cli/output/advisoryinfo.hpp index 1c3b787af..4f24e9785 100644 --- a/include/libdnf5-cli/output/advisoryinfo.hpp +++ b/include/libdnf5-cli/output/advisoryinfo.hpp @@ -23,9 +23,11 @@ along with libdnf. If not, see . #include "interfaces/advisory.hpp" +#include "libdnf5-cli/defs.h" + namespace libdnf5::cli::output { -class AdvisoryInfo { +class LIBDNF_CLI_API AdvisoryInfo { public: AdvisoryInfo(); ~AdvisoryInfo(); @@ -34,7 +36,7 @@ class AdvisoryInfo { void print(); private: - class Impl; + class LIBDNF_CLI_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5-cli/output/advisorylist.hpp b/include/libdnf5-cli/output/advisorylist.hpp index 45da2240e..b00b306e3 100644 --- a/include/libdnf5-cli/output/advisorylist.hpp +++ b/include/libdnf5-cli/output/advisorylist.hpp @@ -23,16 +23,18 @@ along with libdnf. If not, see . #include "interfaces/advisory.hpp" +#include "libdnf5-cli/defs.h" + #include #include namespace libdnf5::cli::output { -void print_advisorylist_table( +LIBDNF_CLI_API void print_advisorylist_table( std::vector> & advisory_package_list_not_installed, std::vector> & advisory_package_list_installed); -void print_advisorylist_references_table( +LIBDNF_CLI_API void print_advisorylist_references_table( std::vector & advisory_package_list_not_installed, std::vector & advisory_package_list_installed, std::string reference_type); diff --git a/include/libdnf5-cli/output/advisorysummary.hpp b/include/libdnf5-cli/output/advisorysummary.hpp index 729808cba..4ac65b1e1 100644 --- a/include/libdnf5-cli/output/advisorysummary.hpp +++ b/include/libdnf5-cli/output/advisorysummary.hpp @@ -21,11 +21,14 @@ along with libdnf. If not, see . #ifndef LIBDNF5_CLI_OUTPUT_ADVISORYSUMMARY_HPP #define LIBDNF5_CLI_OUTPUT_ADVISORYSUMMARY_HPP +#include "libdnf5-cli/defs.h" + #include namespace libdnf5::cli::output { -void print_advisorysummary_table(const libdnf5::advisory::AdvisoryQuery & advisories, const std::string & mode); +LIBDNF_CLI_API void print_advisorysummary_table( + const libdnf5::advisory::AdvisoryQuery & advisories, const std::string & mode); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/changelogs.hpp b/include/libdnf5-cli/output/changelogs.hpp index 179d1e898..da7e4c5c2 100644 --- a/include/libdnf5-cli/output/changelogs.hpp +++ b/include/libdnf5-cli/output/changelogs.hpp @@ -21,6 +21,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_CLI_OUTPUT_CHANGELOGS_HPP #define LIBDNF5_CLI_OUTPUT_CHANGELOGS_HPP +#include "libdnf5-cli/defs.h" + #include #include @@ -31,7 +33,7 @@ namespace libdnf5::cli::output { enum class ChangelogFilterType { NONE, UPGRADES, COUNT, SINCE }; -void print_changelogs( +LIBDNF_CLI_API void print_changelogs( libdnf5::rpm::PackageQuery & query, std::pair> filter); diff --git a/include/libdnf5-cli/output/environmentinfo.hpp b/include/libdnf5-cli/output/environmentinfo.hpp index 60a26953d..d6b6293f7 100644 --- a/include/libdnf5-cli/output/environmentinfo.hpp +++ b/include/libdnf5-cli/output/environmentinfo.hpp @@ -23,9 +23,11 @@ along with libdnf. If not, see . #include "interfaces/comps.hpp" +#include "libdnf5-cli/defs.h" + namespace libdnf5::cli::output { -void print_environmentinfo_table(IEnvironment & environment); +LIBDNF_CLI_API void print_environmentinfo_table(IEnvironment & environment); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/environmentlist.hpp b/include/libdnf5-cli/output/environmentlist.hpp index 0d3f610f4..e01971754 100644 --- a/include/libdnf5-cli/output/environmentlist.hpp +++ b/include/libdnf5-cli/output/environmentlist.hpp @@ -23,9 +23,11 @@ along with libdnf. If not, see . #include "interfaces/comps.hpp" +#include "libdnf5-cli/defs.h" + namespace libdnf5::cli::output { -void print_environmentlist_table(std::vector> & environment_list); +LIBDNF_CLI_API void print_environmentlist_table(std::vector> & environment_list); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/groupinfo.hpp b/include/libdnf5-cli/output/groupinfo.hpp index 21369a844..181bd649e 100644 --- a/include/libdnf5-cli/output/groupinfo.hpp +++ b/include/libdnf5-cli/output/groupinfo.hpp @@ -23,9 +23,11 @@ along with libdnf. If not, see . #include "interfaces/comps.hpp" +#include "libdnf5-cli/defs.h" + namespace libdnf5::cli::output { -void print_groupinfo_table(IGroup & group); +LIBDNF_CLI_API void print_groupinfo_table(IGroup & group); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/grouplist.hpp b/include/libdnf5-cli/output/grouplist.hpp index 2fb0ed15b..f24f80c89 100644 --- a/include/libdnf5-cli/output/grouplist.hpp +++ b/include/libdnf5-cli/output/grouplist.hpp @@ -23,9 +23,11 @@ along with libdnf. If not, see . #include "interfaces/comps.hpp" +#include "libdnf5-cli/defs.h" + namespace libdnf5::cli::output { -void print_grouplist_table(std::vector> & group_list); +LIBDNF_CLI_API void print_grouplist_table(std::vector> & group_list); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/moduleinfo.hpp b/include/libdnf5-cli/output/moduleinfo.hpp index f9423caef..04cd3a5aa 100644 --- a/include/libdnf5-cli/output/moduleinfo.hpp +++ b/include/libdnf5-cli/output/moduleinfo.hpp @@ -23,16 +23,18 @@ along with libdnf. If not, see . #include "interfaces/module.hpp" +#include "libdnf5-cli/defs.h" + #include #include namespace libdnf5::cli::output { -void print_module_item(IModuleItem & module_item); +LIBDNF_CLI_API void print_module_item(IModuleItem & module_item); -void print_moduleinfo_table(std::vector> & module_list); +LIBDNF_CLI_API void print_moduleinfo_table(std::vector> & module_list); -void print_moduleinfo_table_hint(); +LIBDNF_CLI_API void print_moduleinfo_table_hint(); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/modulelist.hpp b/include/libdnf5-cli/output/modulelist.hpp index 46414a337..4ae3db4d8 100644 --- a/include/libdnf5-cli/output/modulelist.hpp +++ b/include/libdnf5-cli/output/modulelist.hpp @@ -23,14 +23,16 @@ along with libdnf. If not, see . #include "interfaces/module.hpp" +#include "libdnf5-cli/defs.h" + #include #include namespace libdnf5::cli::output { -void print_modulelist_table(const std::vector> & module_list); +LIBDNF_CLI_API void print_modulelist_table(const std::vector> & module_list); -void print_modulelist_table_hint(); +LIBDNF_CLI_API void print_modulelist_table_hint(); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/package_info_sections.hpp b/include/libdnf5-cli/output/package_info_sections.hpp index c6ffb8000..a714331a5 100644 --- a/include/libdnf5-cli/output/package_info_sections.hpp +++ b/include/libdnf5-cli/output/package_info_sections.hpp @@ -23,9 +23,11 @@ along with libdnf. If not, see . #include "package_list_sections.hpp" +#include "libdnf5-cli/defs.h" + namespace libdnf5::cli::output { -class PackageInfoSections : public PackageListSections { +class LIBDNF_CLI_API PackageInfoSections : public PackageListSections { public: PackageInfoSections(); ~PackageInfoSections(); diff --git a/include/libdnf5-cli/output/package_list_sections.hpp b/include/libdnf5-cli/output/package_list_sections.hpp index 7a2e4d2ec..84345ca50 100644 --- a/include/libdnf5-cli/output/package_list_sections.hpp +++ b/include/libdnf5-cli/output/package_list_sections.hpp @@ -23,6 +23,8 @@ along with libdnf. If not, see . #include "pkg_colorizer.hpp" +#include "libdnf5-cli/defs.h" + #include #include @@ -34,7 +36,7 @@ along with libdnf. If not, see . namespace libdnf5::cli::output { /// Print list packages divided into sections. -class PackageListSections { +class LIBDNF_CLI_API PackageListSections { public: PackageListSections(); virtual ~PackageListSections(); @@ -54,7 +56,7 @@ class PackageListSections { const std::map> & obsoletes = {}); protected: - class Impl; + class LIBDNF_CLI_LOCAL Impl; std::unique_ptr p_impl; }; diff --git a/include/libdnf5-cli/output/packageinfo.hpp b/include/libdnf5-cli/output/packageinfo.hpp index 48e6627a8..c9df0dfe7 100644 --- a/include/libdnf5-cli/output/packageinfo.hpp +++ b/include/libdnf5-cli/output/packageinfo.hpp @@ -24,9 +24,11 @@ along with libdnf. If not, see . #include "interfaces/package.hpp" #include "pkg_colorizer.hpp" +#include "libdnf5-cli/defs.h" + namespace libdnf5::cli::output { -void print_package_info( +LIBDNF_CLI_API void print_package_info( IPackage & pkg, const std::unique_ptr & colorizer = nullptr, const std::vector & obsoletes = {}); diff --git a/include/libdnf5-cli/output/pkg_colorizer.hpp b/include/libdnf5-cli/output/pkg_colorizer.hpp index 8b200b2ec..b6e9d7d46 100644 --- a/include/libdnf5-cli/output/pkg_colorizer.hpp +++ b/include/libdnf5-cli/output/pkg_colorizer.hpp @@ -23,6 +23,8 @@ along with libdnf. If not, see . #include "interfaces/package.hpp" +#include "libdnf5-cli/defs.h" + #include #include @@ -30,7 +32,7 @@ along with libdnf. If not, see . namespace libdnf5::cli::output { -class PkgColorizer { +class LIBDNF_CLI_API PkgColorizer { public: /// Class is used to compute output color of the package based on the package /// version and version in `base_versions`. Colors can be either names (e.g. red, @@ -53,7 +55,7 @@ class PkgColorizer { std::string get_pkg_color(const IPackage & package); private: - std::string to_escape(const std::string & color); + LIBDNF_CLI_LOCAL std::string to_escape(const std::string & color); // map N.A of the package to the version std::unordered_map base_na_version; diff --git a/include/libdnf5-cli/output/provides.hpp b/include/libdnf5-cli/output/provides.hpp index ee82108a2..b3f00b554 100644 --- a/include/libdnf5-cli/output/provides.hpp +++ b/include/libdnf5-cli/output/provides.hpp @@ -22,11 +22,13 @@ along with libdnf. If not, see . #include "interfaces/package.hpp" +#include "libdnf5-cli/defs.h" + namespace libdnf5::cli::output { enum ProvidesMatchedBy : int { NO_MATCH = 0, PROVIDES = 1, FILENAME = 2, BINARY = 3 }; -void print_provides_table(IPackage & package, const char * spec, int match); +LIBDNF_CLI_API void print_provides_table(IPackage & package, const char * spec, int match); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/repo_info.hpp b/include/libdnf5-cli/output/repo_info.hpp index 4ef6d1369..81641924f 100644 --- a/include/libdnf5-cli/output/repo_info.hpp +++ b/include/libdnf5-cli/output/repo_info.hpp @@ -23,11 +23,13 @@ along with libdnf. If not, see . #include "interfaces/repo.hpp" +#include "libdnf5-cli/defs.h" + #include namespace libdnf5::cli::output { -class RepoInfo { +class LIBDNF_CLI_API RepoInfo { public: RepoInfo(); ~RepoInfo(); @@ -36,11 +38,11 @@ class RepoInfo { void print(); private: - class Impl; + class LIBDNF_CLI_LOCAL Impl; std::unique_ptr p_impl; }; -void print_repoinfo_json(const std::vector> & repos); +LIBDNF_CLI_API void print_repoinfo_json(const std::vector> & repos); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/repolist.hpp b/include/libdnf5-cli/output/repolist.hpp index 45680b0d2..b2eef61f6 100644 --- a/include/libdnf5-cli/output/repolist.hpp +++ b/include/libdnf5-cli/output/repolist.hpp @@ -23,6 +23,8 @@ along with libdnf. If not, see . #include "interfaces/repo.hpp" +#include "libdnf5-cli/defs.h" + #include namespace libdnf5::cli::output { @@ -30,8 +32,9 @@ namespace libdnf5::cli::output { // repository list table columns enum { COL_REPO_ID, COL_REPO_NAME, COL_REPO_STATUS }; -void print_repolist_table(const std::vector> & repos, bool with_status, size_t sort_column); -void print_repolist_json(const std::vector> & repos); +LIBDNF_CLI_API void print_repolist_table( + const std::vector> & repos, bool with_status, size_t sort_column); +LIBDNF_CLI_API void print_repolist_json(const std::vector> & repos); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/repoquery.hpp b/include/libdnf5-cli/output/repoquery.hpp index bb616daaa..665a5e7ab 100644 --- a/include/libdnf5-cli/output/repoquery.hpp +++ b/include/libdnf5-cli/output/repoquery.hpp @@ -21,21 +21,23 @@ along with libdnf. If not, see . #ifndef LIBDNF5_CLI_OUTPUT_REPOQUERY_HPP #define LIBDNF5_CLI_OUTPUT_REPOQUERY_HPP +#include "libdnf5-cli/defs.h" + #include namespace libdnf5::cli::output { -bool requires_filelists(const std::string & queryformat); +LIBDNF_CLI_API bool requires_filelists(const std::string & queryformat); -void print_pkg_set_with_format( +LIBDNF_CLI_API void print_pkg_set_with_format( std::FILE * target, const libdnf5::rpm::PackageSet & pkgs, const std::string & queryformat); -void print_pkg_attr_uniq_sorted( +LIBDNF_CLI_API void print_pkg_attr_uniq_sorted( std::FILE * target, const libdnf5::rpm::PackageSet & pkgs, const std::string & getter_name); -void print_available_pkg_attrs(std::FILE * target); +LIBDNF_CLI_API void print_available_pkg_attrs(std::FILE * target); -libdnf5::rpm::ReldepList get_reldeplist_for_attr( +LIBDNF_CLI_API libdnf5::rpm::ReldepList get_reldeplist_for_attr( const libdnf5::rpm::PackageSet & pkgs, const std::string & getter_name); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/search.hpp b/include/libdnf5-cli/output/search.hpp index 94bee324b..378bf429f 100644 --- a/include/libdnf5-cli/output/search.hpp +++ b/include/libdnf5-cli/output/search.hpp @@ -21,6 +21,8 @@ along with libdnf. If not, see . #ifndef LIBDNF5_CLI_OUTPUT_SEARCH_HPP #define LIBDNF5_CLI_OUTPUT_SEARCH_HPP +#include "libdnf5-cli/defs.h" + #include #include @@ -66,7 +68,7 @@ struct SearchResults { /// @brief Write the search results to the standard output. /// @param results Structure with already computed search results. -void print_search_results(const SearchResults & results); +LIBDNF_CLI_API void print_search_results(const SearchResults & results); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/transaction_table.hpp b/include/libdnf5-cli/output/transaction_table.hpp index d4334868c..781a49406 100644 --- a/include/libdnf5-cli/output/transaction_table.hpp +++ b/include/libdnf5-cli/output/transaction_table.hpp @@ -23,6 +23,8 @@ along with libdnf. If not, see . #include "interfaces/transaction.hpp" +#include "libdnf5-cli/defs.h" + #include #include @@ -30,7 +32,7 @@ along with libdnf. If not, see . namespace libdnf5::cli::output { -class TransactionTable { +class LIBDNF_CLI_API TransactionTable { public: explicit TransactionTable(ITransaction & transaction); ~TransactionTable(); @@ -49,13 +51,13 @@ class TransactionTable { void set_output_stream(std::FILE * fd); private: - class Impl; + class LIBDNF_CLI_LOCAL Impl; ImplPtr p_impl; }; -void print_resolve_logs(const ITransaction & transaction, std::ostream & stream = std::cerr); +LIBDNF_CLI_API void print_resolve_logs(const ITransaction & transaction, std::ostream & stream = std::cerr); -bool print_transaction_table(ITransaction & transaction); +LIBDNF_CLI_API bool print_transaction_table(ITransaction & transaction); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/transactioninfo.hpp b/include/libdnf5-cli/output/transactioninfo.hpp index fef5679b5..c417fd88b 100644 --- a/include/libdnf5-cli/output/transactioninfo.hpp +++ b/include/libdnf5-cli/output/transactioninfo.hpp @@ -21,11 +21,13 @@ along with libdnf. If not, see . #ifndef LIBDNF5_CLI_OUTPUT_TRANSACTIONINFO_HPP #define LIBDNF5_CLI_OUTPUT_TRANSACTIONINFO_HPP +#include "libdnf5-cli/defs.h" + #include namespace libdnf5::cli::output { -void print_transaction_info(libdnf5::transaction::Transaction & transaction); +LIBDNF_CLI_API void print_transaction_info(libdnf5::transaction::Transaction & transaction); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/output/transactionlist.hpp b/include/libdnf5-cli/output/transactionlist.hpp index 333d4274c..99afe13f0 100644 --- a/include/libdnf5-cli/output/transactionlist.hpp +++ b/include/libdnf5-cli/output/transactionlist.hpp @@ -21,11 +21,13 @@ along with libdnf. If not, see . #ifndef LIBDNF5_CLI_OUTPUT_TRANSACTIONLIST_HPP #define LIBDNF5_CLI_OUTPUT_TRANSACTIONLIST_HPP +#include "libdnf5-cli/defs.h" + #include namespace libdnf5::cli::output { -void print_transaction_list(std::vector & ts_list); +LIBDNF_CLI_API void print_transaction_list(std::vector & ts_list); } // namespace libdnf5::cli::output diff --git a/include/libdnf5-cli/progressbar/download_progress_bar.hpp b/include/libdnf5-cli/progressbar/download_progress_bar.hpp index 590a711d1..f64f3ba56 100644 --- a/include/libdnf5-cli/progressbar/download_progress_bar.hpp +++ b/include/libdnf5-cli/progressbar/download_progress_bar.hpp @@ -31,11 +31,13 @@ along with libdnf. If not, see . #include "widgets/speed.hpp" #include "widgets/time.hpp" +#include "libdnf5-cli/defs.h" + namespace libdnf5::cli::progressbar { -class DownloadProgressBar : public ProgressBar { +class LIBDNF_CLI_API DownloadProgressBar : public ProgressBar { public: explicit DownloadProgressBar(int64_t download_size, const std::string & description); @@ -54,7 +56,7 @@ class DownloadProgressBar : public ProgressBar { private: // TODO(dmach): fix inconsistency - MultiProgresBar::operator<< erases previously printed lines, DownloadProgressBar::operator<< does not - friend std::ostream & operator<<(std::ostream & stream, DownloadProgressBar & bar); + LIBDNF_CLI_API friend std::ostream & operator<<(std::ostream & stream, DownloadProgressBar & bar); // widgets libdnf5::cli::progressbar::NumberWidget number_widget; diff --git a/include/libdnf5-cli/progressbar/multi_progress_bar.hpp b/include/libdnf5-cli/progressbar/multi_progress_bar.hpp index e6ba7b452..f20fe9fd5 100644 --- a/include/libdnf5-cli/progressbar/multi_progress_bar.hpp +++ b/include/libdnf5-cli/progressbar/multi_progress_bar.hpp @@ -25,6 +25,8 @@ along with libdnf. If not, see . #include "download_progress_bar.hpp" #include "progress_bar.hpp" +#include "libdnf5-cli/defs.h" + #include #include #include @@ -33,7 +35,7 @@ along with libdnf. If not, see . namespace libdnf5::cli::progressbar { -class MultiProgressBar { +class LIBDNF_CLI_API MultiProgressBar { public: static constexpr std::size_t NEVER_VISIBLE_LIMIT = static_cast(-1); @@ -45,7 +47,7 @@ class MultiProgressBar { std::cout << *this; std::cout << std::flush; } - friend std::ostream & operator<<(std::ostream & stream, MultiProgressBar & mbar); + LIBDNF_CLI_API friend std::ostream & operator<<(std::ostream & stream, MultiProgressBar & mbar); /// Sets the minimum number of registered progress bars to show the total bar. void set_total_bar_visible_limit(std::size_t value) noexcept { total_bar_visible_limit = value; } diff --git a/include/libdnf5-cli/progressbar/progress_bar.hpp b/include/libdnf5-cli/progressbar/progress_bar.hpp index 3c63c7dc7..d352f4251 100644 --- a/include/libdnf5-cli/progressbar/progress_bar.hpp +++ b/include/libdnf5-cli/progressbar/progress_bar.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #ifndef LIBDNF5_CLI_PROGRESSBAR_PROGRESS_BAR_HPP #define LIBDNF5_CLI_PROGRESSBAR_PROGRESS_BAR_HPP +#include "libdnf5-cli/defs.h" #include #include @@ -47,7 +48,7 @@ enum class MessageType : int { }; -class ProgressBar { +class LIBDNF_CLI_API ProgressBar { public: using Message = std::pair; @@ -110,7 +111,7 @@ class ProgressBar { std::chrono::time_point get_begin() { return begin; } - friend std::ostream & operator<<(std::ostream & os, ProgressBar & bar); + LIBDNF_CLI_API friend std::ostream & operator<<(std::ostream & os, ProgressBar & bar); protected: virtual void to_stream(std::ostream & stream) = 0; diff --git a/include/libdnf5-cli/session.hpp b/include/libdnf5-cli/session.hpp index 37f2d4674..82066451e 100644 --- a/include/libdnf5-cli/session.hpp +++ b/include/libdnf5-cli/session.hpp @@ -24,6 +24,8 @@ along with libdnf. If not, see . #include "argument_parser.hpp" +#include "libdnf5-cli/defs.h" + #include #include #include @@ -36,7 +38,7 @@ namespace libdnf5::cli::session { class Command; -class Session { +class LIBDNF_CLI_API Session { public: explicit Session(); ~Session(); @@ -79,12 +81,12 @@ class Session { void clear(); private: - class Impl; + class LIBDNF_CLI_LOCAL Impl; ImplPtr p_impl; }; -class Command : public libdnf5::cli::ArgumentParserUserData { +class LIBDNF_CLI_API Command : public libdnf5::cli::ArgumentParserUserData { public: explicit Command(Session & session, const std::string & name); virtual ~Command(); @@ -161,7 +163,7 @@ class Command : public libdnf5::cli::ArgumentParserUserData { }; -class Option { +class LIBDNF_CLI_API Option { public: Option(const Option & src) = delete; Option(Option && src) = delete; @@ -175,7 +177,7 @@ class Option { }; -class BoolOption : public Option { +class LIBDNF_CLI_API BoolOption : public Option { public: explicit BoolOption( libdnf5::cli::session::Command & command, @@ -208,7 +210,7 @@ class BoolOption : public Option { /// AppendStringListOption is a wrapper around NamedArg and OptionStringList /// which allows specifying the argument multiple times and merging their values. /// E.g. --whatrequires=tree --whatrequires=plant -> option contains: "tree, plant" -class AppendStringListOption : public Option { +class LIBDNF_CLI_API AppendStringListOption : public Option { public: explicit AppendStringListOption( libdnf5::cli::session::Command & command, @@ -241,7 +243,7 @@ class AppendStringListOption : public Option { }; -class StringArgumentList : public Option { +class LIBDNF_CLI_API StringArgumentList : public Option { public: explicit StringArgumentList( libdnf5::cli::session::Command & command, const std::string & name, const std::string & desc, int nargs); diff --git a/include/libdnf5-cli/tty.hpp b/include/libdnf5-cli/tty.hpp index 3c5817f05..6db12b0aa 100644 --- a/include/libdnf5-cli/tty.hpp +++ b/include/libdnf5-cli/tty.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #ifndef LIBDNF5_CLI_TTY_HPP #define LIBDNF5_CLI_TTY_HPP +#include "libdnf5-cli/defs.h" #include @@ -28,30 +29,30 @@ along with libdnf. If not, see . namespace libdnf5::cli::tty { -std::ostream & reset(std::ostream & stream); +LIBDNF_CLI_API std::ostream & reset(std::ostream & stream); -std::ostream & bold(std::ostream & stream); -std::ostream & underline(std::ostream & stream); -std::ostream & blink(std::ostream & stream); +LIBDNF_CLI_API std::ostream & bold(std::ostream & stream); +LIBDNF_CLI_API std::ostream & underline(std::ostream & stream); +LIBDNF_CLI_API std::ostream & blink(std::ostream & stream); -std::ostream & black(std::ostream & stream); -std::ostream & red(std::ostream & stream); -std::ostream & green(std::ostream & stream); -std::ostream & yellow(std::ostream & stream); -std::ostream & blue(std::ostream & stream); -std::ostream & magenta(std::ostream & stream); -std::ostream & cyan(std::ostream & stream); -std::ostream & white(std::ostream & stream); +LIBDNF_CLI_API std::ostream & black(std::ostream & stream); +LIBDNF_CLI_API std::ostream & red(std::ostream & stream); +LIBDNF_CLI_API std::ostream & green(std::ostream & stream); +LIBDNF_CLI_API std::ostream & yellow(std::ostream & stream); +LIBDNF_CLI_API std::ostream & blue(std::ostream & stream); +LIBDNF_CLI_API std::ostream & magenta(std::ostream & stream); +LIBDNF_CLI_API std::ostream & cyan(std::ostream & stream); +LIBDNF_CLI_API std::ostream & white(std::ostream & stream); -std::ostream & clear_line(std::ostream & stream); -std::ostream & cursor_up(std::ostream & stream); +LIBDNF_CLI_API std::ostream & clear_line(std::ostream & stream); +LIBDNF_CLI_API std::ostream & cursor_up(std::ostream & stream); -std::ostream & cursor_hide(std::ostream & stream); -std::ostream & cursor_show(std::ostream & stream); +LIBDNF_CLI_API std::ostream & cursor_hide(std::ostream & stream); +LIBDNF_CLI_API std::ostream & cursor_show(std::ostream & stream); -int get_width(); -bool is_interactive(); +LIBDNF_CLI_API int get_width(); +LIBDNF_CLI_API bool is_interactive(); } // namespace libdnf5::cli::tty diff --git a/include/libdnf5-cli/utils/units.hpp b/include/libdnf5-cli/utils/units.hpp index 32dec3d5b..6fb46f9df 100644 --- a/include/libdnf5-cli/utils/units.hpp +++ b/include/libdnf5-cli/utils/units.hpp @@ -21,6 +21,8 @@ along with libdnf. If not, see . #ifndef LIBDNF_CLI_UTILS_UNITS #define LIBDNF_CLI_UTILS_UNITS +#include "libdnf5-cli/defs.h" + #include #include @@ -28,9 +30,9 @@ along with libdnf. If not, see . namespace libdnf5::cli::utils::units { -std::pair to_size(int64_t num); +LIBDNF_CLI_API std::pair to_size(int64_t num); -std::string format_size_aligned(int64_t num); +LIBDNF_CLI_API std::string format_size_aligned(int64_t num); } // namespace libdnf5::cli::utils::units diff --git a/libdnf5-cli/CMakeLists.txt b/libdnf5-cli/CMakeLists.txt index 8025730db..0874fcf5b 100644 --- a/libdnf5-cli/CMakeLists.txt +++ b/libdnf5-cli/CMakeLists.txt @@ -2,6 +2,7 @@ if(NOT WITH_LIBDNF5_CLI) return() endif() +add_definitions(-DLIBDNF_CLI_BUILD_LIBRARY) set(GETTEXT_DOMAIN libdnf5-cli) add_definitions(-DGETTEXT_DOMAIN=\"${GETTEXT_DOMAIN}\") @@ -22,6 +23,7 @@ add_library(libdnf5-cli SHARED ${LIBDNF5_CLI_SOURCES}) set(DNF_CLI_SO_VERSION 2) set_target_properties(libdnf5-cli PROPERTIES OUTPUT_NAME "dnf5-cli") set_target_properties(libdnf5-cli PROPERTIES SOVERSION ${DNF_CLI_SO_VERSION}) +set_target_properties(libdnf5-cli PROPERTIES C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET hidden) # required by clang target_link_libraries(libdnf5-cli PUBLIC stdc++) diff --git a/libdnf5-cli/utils/utf8.hpp b/libdnf5-cli/utils/utf8.hpp index 50886b6aa..4b5af001f 100644 --- a/libdnf5-cli/utils/utf8.hpp +++ b/libdnf5-cli/utils/utf8.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #ifndef LIBDNF_CLI_UTILS_UTF8 #define LIBDNF_CLI_UTILS_UTF8 +#include "libdnf5-cli/defs.h" #include @@ -29,20 +30,20 @@ namespace libdnf5::cli::utils::utf8 { /// return length of an utf-8 encoded string -std::size_t length(const std::string & str); +LIBDNF_CLI_API std::size_t length(const std::string & str); /// return printable width of an utf-8 encoded string (considers non-printable and wide characters) -std::size_t width(const std::string & str); +LIBDNF_CLI_API std::size_t width(const std::string & str); /// return an utf-8 sub-string that matches specified character count -std::string substr_length( +LIBDNF_CLI_API std::string substr_length( const std::string & str, std::string::size_type pos = 0, std::string::size_type len = std::string::npos); /// return an utf-8 sub-string that matches specified printable width -std::string substr_width( +LIBDNF_CLI_API std::string substr_width( const std::string & str, std::string::size_type pos = 0, std::string::size_type wid = std::string::npos); From e21bd2069ad1bbb583f56c772099c3f6b031d1e6 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Mon, 20 May 2024 11:31:36 +0200 Subject: [PATCH 7/9] dnf5: Define macros for assigning symbol visibility --- dnf5/include/dnf5/defs.h | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 dnf5/include/dnf5/defs.h diff --git a/dnf5/include/dnf5/defs.h b/dnf5/include/dnf5/defs.h new file mode 100644 index 000000000..ad01c8a20 --- /dev/null +++ b/dnf5/include/dnf5/defs.h @@ -0,0 +1,59 @@ +/* +Copyright Contributors to the libdnf project. + +This file is part of libdnf: https://github.com/rpm-software-management/libdnf/ + +Libdnf is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2.1 of the License, or +(at your option) any later version. + +Libdnf is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with libdnf. If not, see . +*/ + +#ifndef DNF5_DEFS_H +#define DNF5_DEFS_H + +// Generic helper definitions for shared library support +#if defined _WIN32 || defined __CYGWIN__ +#define DNF_SYMBOL_IMPORT __declspec(dllimport) +#define DNF_SYMBOL_EXPORT __declspec(dllexport) +#define DNF_SYMBOL_LOCAL +#else +#if __GNUC__ >= 4 +#define DNF_SYMBOL_IMPORT __attribute__((visibility("default"))) +#define DNF_SYMBOL_EXPORT __attribute__((visibility("default"))) +#define DNF_SYMBOL_LOCAL __attribute__((visibility("hidden"))) +#else +#define DNF_SYMBOL_IMPORT +#define DNF_SYMBOL_EXPORT +#define DNF_SYMBOL_LOCAL +#endif +#endif + +// Now define DNF_API, DNF_LOCAL and DNF_PLUGIN_API. +// DNF_API and DNF_PLUGIN_API are used for public API symbols. It either imports or exports the symbol. +// DNF_LOCAL is used for non-api symbols. + +#ifdef DNF_BUILD_APPLICATION // defined if we are building the dnf application +#define DNF_API DNF_SYMBOL_EXPORT +#else +#define DNF_API DNF_SYMBOL_IMPORT +#endif + +#define DNF_LOCAL DNF_SYMBOL_LOCAL + +// DNF exports its symbols but imports plugin symbols. +#ifdef DNF_BUILD_APPLICATION // defined if we are building the dnf application +#define DNF_PLUGIN_API DNF_SYMBOL_IMPORT +#else +#define DNF_PLUGIN_API DNF_SYMBOL_EXPORT +#endif + +#endif From 929760e0bbdb941b0a263fae4a1725a86b742192 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Mon, 20 May 2024 14:40:26 +0200 Subject: [PATCH 8/9] dnf5 app, dnf5 plugins: Do not export private symbols --- dnf5-plugins/CMakeLists.txt | 3 +++ dnf5/CMakeLists.txt | 4 ++++ dnf5/include/dnf5/context.hpp | 19 ++++++++++--------- dnf5/include/dnf5/iplugin.hpp | 14 ++++++++------ dnf5/include/dnf5/offline.hpp | 5 +++-- dnf5/include/dnf5/shared_options.hpp | 20 +++++++++++--------- dnf5/include/dnf5/version.hpp | 6 ++++-- 7 files changed, 43 insertions(+), 28 deletions(-) diff --git a/dnf5-plugins/CMakeLists.txt b/dnf5-plugins/CMakeLists.txt index 635c5b504..503bfe4bc 100644 --- a/dnf5-plugins/CMakeLists.txt +++ b/dnf5-plugins/CMakeLists.txt @@ -2,6 +2,9 @@ if(NOT WITH_DNF5_PLUGINS) return() endif() +set(CMAKE_CXX_VISIBILITY_PRESET hidden) +set(CMAKE_C_VISIBILITY_PRESET hidden) + include_directories("${PROJECT_SOURCE_DIR}/dnf5/include/") # These plugins use symbols from dnf5 program, hence the symbold are undefined # at link time and cannot pass "-z defs" linker check. Disable the check. diff --git a/dnf5/CMakeLists.txt b/dnf5/CMakeLists.txt index 47f911e4f..ca9d91302 100644 --- a/dnf5/CMakeLists.txt +++ b/dnf5/CMakeLists.txt @@ -5,6 +5,8 @@ endif() find_package(Threads) +add_definitions(-DDNF_BUILD_APPLICATION) + # set gettext domain for translations set(GETTEXT_DOMAIN dnf5) add_definitions(-DGETTEXT_DOMAIN=\"${GETTEXT_DOMAIN}\") @@ -28,6 +30,8 @@ add_executable(dnf5 ${DNF5_SOURCES}) # Enable symbol export. Needed for loadable modules (dnf5 plugins). set_property(TARGET dnf5 PROPERTY ENABLE_EXPORTS 1) +# Export only explicitly marked symbols. +set_target_properties(dnf5 PROPERTIES C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET hidden) target_link_libraries(dnf5 PRIVATE common libdnf5 libdnf5-cli Threads::Threads) install(TARGETS dnf5 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/dnf5/include/dnf5/context.hpp b/dnf5/include/dnf5/context.hpp index cf1c530a3..ab9148d97 100644 --- a/dnf5/include/dnf5/context.hpp +++ b/dnf5/include/dnf5/context.hpp @@ -20,6 +20,7 @@ along with libdnf. If not, see . #ifndef DNF5_CONTEXT_HPP #define DNF5_CONTEXT_HPP +#include "defs.h" #include "version.hpp" #include @@ -44,7 +45,7 @@ namespace dnf5 { class Plugins; -class Context : public libdnf5::cli::session::Session { +class DNF_API Context : public libdnf5::cli::session::Session { public: enum class LoadAvailableRepos { NONE, ENABLED, ALL }; @@ -164,12 +165,12 @@ class Context : public libdnf5::cli::session::Session { const std::vector, bool>> & get_libdnf_plugins_enablement() const; private: - class Impl; + class DNF_LOCAL Impl; std::unique_ptr p_impl; }; -class Command : public libdnf5::cli::session::Command { +class DNF_API Command : public libdnf5::cli::session::Command { public: using libdnf5::cli::session::Command::Command; @@ -183,7 +184,7 @@ class Command : public libdnf5::cli::session::Command { }; -class RpmTransCB : public libdnf5::rpm::TransactionCallbacks { +class DNF_API RpmTransCB : public libdnf5::rpm::TransactionCallbacks { public: RpmTransCB(Context & context); ~RpmTransCB(); @@ -252,25 +253,25 @@ class RpmTransCB : public libdnf5::rpm::TransactionCallbacks { void verify_stop([[maybe_unused]] uint64_t total) override; private: - void new_progress_bar(int64_t total, const std::string & descr); + DNF_LOCAL void new_progress_bar(int64_t total, const std::string & descr); - static bool is_time_to_print(); + DNF_LOCAL static bool is_time_to_print(); - static std::chrono::time_point prev_print_time; + DNF_LOCAL static std::chrono::time_point prev_print_time; libdnf5::cli::progressbar::MultiProgressBar multi_progress_bar; libdnf5::cli::progressbar::DownloadProgressBar * active_progress_bar{nullptr}; Context & context; }; -void run_transaction(libdnf5::rpm::Transaction & transaction); +DNF_API void run_transaction(libdnf5::rpm::Transaction & transaction); /// Returns the names of matching packages and paths of matching package file names and directories. /// If `nevra_for_same_name` is true, it returns a full nevra for packages with the same name. /// Only files whose names match `file_name_regex` are returned. /// NOTE: This function is intended to be used only for autocompletion purposes as the argument parser's /// complete hook argument. It does the base setup and repos loading inside. -std::vector match_specs( +DNF_API std::vector match_specs( Context & ctx, const std::string & pattern, bool installed, diff --git a/dnf5/include/dnf5/iplugin.hpp b/dnf5/include/dnf5/iplugin.hpp index a11f3db84..c643928e2 100644 --- a/dnf5/include/dnf5/iplugin.hpp +++ b/dnf5/include/dnf5/iplugin.hpp @@ -21,6 +21,7 @@ along with libdnf. If not, see . #define DNF5_PLUGIN_IPLUGIN_HPP #include "context.hpp" +#include "defs.h" #include #include @@ -35,7 +36,7 @@ struct PluginVersion { }; /// @brief A base class for implementing DNF5 plugins that provide one or more commands to users. -class IPlugin { +class DNF_PLUGIN_API IPlugin { public: explicit IPlugin(Context & context); virtual ~IPlugin(); @@ -83,21 +84,22 @@ extern "C" { /// Returns the version of the API required by the plugin. /// Same result as IPlugin::get_api_version(), but can be called without creating an IPlugin instance. -dnf5::PluginAPIVersion dnf5_plugin_get_api_version(void); +DNF_PLUGIN_API dnf5::PluginAPIVersion dnf5_plugin_get_api_version(void); /// Returns the name of the plugin. It can be called at any time. /// Same result as IPlugin::get_name(), but can be called without creating an IPlugin instance. -const char * dnf5_plugin_get_name(void); +DNF_PLUGIN_API const char * dnf5_plugin_get_name(void); /// Returns the version of the plugin. It can be called at any time. /// Same result as IPlugin::get_version(), but can be called without creating an IPlugin instance. -dnf5::PluginVersion dnf5_plugin_get_version(void); +DNF_PLUGIN_API dnf5::PluginVersion dnf5_plugin_get_version(void); /// Creates a new plugin instance. Passes the API version to the plugin. -dnf5::IPlugin * dnf5_plugin_new_instance(dnf5::ApplicationVersion application_version, dnf5::Context & context); +DNF_PLUGIN_API dnf5::IPlugin * dnf5_plugin_new_instance( + dnf5::ApplicationVersion application_version, dnf5::Context & context); /// Deletes plugin instance. -void dnf5_plugin_delete_instance(dnf5::IPlugin * plugin_instance); +DNF_PLUGIN_API void dnf5_plugin_delete_instance(dnf5::IPlugin * plugin_instance); } #endif diff --git a/dnf5/include/dnf5/offline.hpp b/dnf5/include/dnf5/offline.hpp index 0c369c861..56f9cc84c 100644 --- a/dnf5/include/dnf5/offline.hpp +++ b/dnf5/include/dnf5/offline.hpp @@ -20,13 +20,14 @@ along with libdnf. If not, see . #ifndef DNF5_OFFLINE_HPP #define DNF5_OFFLINE_HPP -#include +#include "context.hpp" +#include "defs.h" #include namespace dnf5::offline { -void log_status( +DNF_API void log_status( Context & context, const std::string & message, const std::string & message_id, diff --git a/dnf5/include/dnf5/shared_options.hpp b/dnf5/include/dnf5/shared_options.hpp index 522794006..eaa84ddc6 100644 --- a/dnf5/include/dnf5/shared_options.hpp +++ b/dnf5/include/dnf5/shared_options.hpp @@ -20,27 +20,29 @@ along with libdnf. If not, see . #ifndef DNF5_COMMANDS_SHARED_OPTIONS_HPP #define DNF5_COMMANDS_SHARED_OPTIONS_HPP +#include "defs.h" + #include #include #include namespace dnf5 { -class AllowErasingOption : public libdnf5::cli::session::BoolOption { +class DNF_API AllowErasingOption : public libdnf5::cli::session::BoolOption { public: explicit AllowErasingOption(libdnf5::cli::session::Command & command); ~AllowErasingOption(); }; -class SkipBrokenOption : public libdnf5::cli::session::BoolOption { +class DNF_API SkipBrokenOption : public libdnf5::cli::session::BoolOption { public: explicit SkipBrokenOption(dnf5::Command & command); ~SkipBrokenOption(); }; -class SkipUnavailableOption : public libdnf5::cli::session::BoolOption { +class DNF_API SkipUnavailableOption : public libdnf5::cli::session::BoolOption { public: explicit SkipUnavailableOption(dnf5::Command & command); ~SkipUnavailableOption(); @@ -49,25 +51,25 @@ class SkipUnavailableOption : public libdnf5::cli::session::BoolOption { /// Create two options (`--allow-downgrade` and `--no-allow-downgrade`) for a command provided as an argument command. /// The values are stored in the `allow_downgrade` configuration option -void create_allow_downgrade_options(dnf5::Command & command); +DNF_API void create_allow_downgrade_options(dnf5::Command & command); /// Create the `--destdir` option for a command provided as an argument. /// The values are stored in the `destdir` configuration option -void create_destdir_option(dnf5::Command & command); +DNF_API void create_destdir_option(dnf5::Command & command); /// Create the `--downloadonly` option for a command provided as an argument. /// The values are stored in the `downloadonly` configuration option -void create_downloadonly_option(dnf5::Command & command); +DNF_API void create_downloadonly_option(dnf5::Command & command); /// Create the `--store` option for a command provided as an argument. /// The value is stored in Context::transaction_store_path. -void create_store_option(dnf5::Command & command); +DNF_API void create_store_option(dnf5::Command & command); /// Create the `--offline` option for a command provided as an argument. -void create_offline_option(dnf5::Command & command); +DNF_API void create_offline_option(dnf5::Command & command); /// Create the `--json` option for a command provided as an argument. -void create_json_option(dnf5::Command & command); +DNF_API void create_json_option(dnf5::Command & command); } // namespace dnf5 diff --git a/dnf5/include/dnf5/version.hpp b/dnf5/include/dnf5/version.hpp index 4329cedf5..d7bfe217a 100644 --- a/dnf5/include/dnf5/version.hpp +++ b/dnf5/include/dnf5/version.hpp @@ -20,6 +20,8 @@ along with libdnf. If not, see . #ifndef DNF5_CONFIG_HPP #define DNF5_CONFIG_HPP +#include "defs.h" + #include namespace dnf5 { @@ -49,11 +51,11 @@ static constexpr PluginAPIVersion PLUGIN_API_VERSION{.major = 2, .minor = 0}; /// @return Application version /// @since 5.0 -ApplicationVersion get_application_version() noexcept; +DNF_API ApplicationVersion get_application_version() noexcept; /// @return API version implemented in the application /// @since 5.0 -PluginAPIVersion get_plugin_api_version() noexcept; +DNF_API PluginAPIVersion get_plugin_api_version() noexcept; } // namespace dnf5 From 7a864474d7eacb5663eb3892c08b50a9be1f5bbd Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Tue, 21 May 2024 07:15:47 +0200 Subject: [PATCH 9/9] Do not export symbols from private "/common/utils" Libraries and applications (libdnf5.so, dnf5, dnf5daemon-client...) use (and statically link) private utilities from "/common/utils". And they also publicly export the symbols of these private utilities. This modification hides the symbols of utilities linked from "/common/utils". --- common/CMakeLists.txt | 1 + libdnf5-cli/CMakeLists.txt | 2 ++ 2 files changed, 3 insertions(+) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index a3f0de058..d2db89030 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -4,6 +4,7 @@ include_directories(.) add_library(common OBJECT ${COMMON_SOURCES}) set_property(TARGET common PROPERTY POSITION_INDEPENDENT_CODE ON) +set_target_properties(common PROPERTIES C_VISIBILITY_PRESET hidden CXX_VISIBILITY_PRESET hidden) # required by clang target_link_libraries(common PUBLIC stdc++) diff --git a/libdnf5-cli/CMakeLists.txt b/libdnf5-cli/CMakeLists.txt index 0874fcf5b..2367fc406 100644 --- a/libdnf5-cli/CMakeLists.txt +++ b/libdnf5-cli/CMakeLists.txt @@ -33,6 +33,8 @@ install(TARGETS libdnf5-cli LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}) # link libraries and set pkg-config requires +target_link_libraries(libdnf5-cli PRIVATE common) + target_link_libraries(libdnf5-cli PUBLIC libdnf5) pkg_check_modules(LIBFMT REQUIRED fmt)