From a6591fcaf3792951e7214f9a866b4a6730bfa0a5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 19 Feb 2024 01:21:25 +0100 Subject: [PATCH] [libcalamares] Make symbols visible as needed --- src/libcalamares/GlobalStorage.h | 4 ++- src/libcalamares/ProcessJob.h | 11 ++++---- src/libcalamares/locale/TimeZone.h | 2 +- src/libcalamares/locale/Translation.h | 2 +- src/libcalamares/modulesystem/Descriptor.h | 8 +++--- src/libcalamares/modulesystem/InstanceKey.h | 6 +++-- .../modulesystem/RequirementsChecker.h | 3 ++- src/libcalamares/network/Manager.h | 2 +- src/libcalamares/packages/Globals.h | 5 ++-- src/libcalamares/partition/KPMManager.h | 4 ++- .../partition/PartitionIterator.h | 4 ++- src/libcalamares/partition/PartitionQuery.h | 16 +++++++----- src/libcalamares/partition/PartitionSize.h | 3 ++- src/libcalamares/python/PythonJob.h | 12 ++++----- src/libcalamares/utils/CommandList.h | 7 ++--- src/libcalamares/utils/Logger.h | 6 ++--- src/libcalamares/utils/PluginFactory.h | 8 +++--- src/libcalamares/utils/Retranslator.h | 2 +- src/libcalamares/utils/StringExpander.h | 2 +- src/libcalamares/utils/System.h | 2 +- src/libcalamares/utils/Yaml.h | 26 ++++++++++--------- 21 files changed, 76 insertions(+), 59 deletions(-) diff --git a/src/libcalamares/GlobalStorage.h b/src/libcalamares/GlobalStorage.h index da17243d3..5bb6d4e97 100644 --- a/src/libcalamares/GlobalStorage.h +++ b/src/libcalamares/GlobalStorage.h @@ -12,6 +12,8 @@ #ifndef CALAMARES_GLOBALSTORAGE_H #define CALAMARES_GLOBALSTORAGE_H +#include "DllMacro.h" + #include #include #include @@ -42,7 +44,7 @@ namespace Calamares * has locking. All methods are thread-safe, use data() to make a snapshot * copy for use outside of the thread-safe API. */ -class GlobalStorage : public QObject +class DLLEXPORT GlobalStorage : public QObject { Q_OBJECT public: diff --git a/src/libcalamares/ProcessJob.h b/src/libcalamares/ProcessJob.h index ab47f30dd..19d886bb5 100644 --- a/src/libcalamares/ProcessJob.h +++ b/src/libcalamares/ProcessJob.h @@ -11,6 +11,7 @@ #ifndef CALAMARES_PROCESSJOB_H #define CALAMARES_PROCESSJOB_H +#include "DllMacro.h" #include "Job.h" #include @@ -22,11 +23,11 @@ class ProcessJob : public Job { Q_OBJECT public: - explicit ProcessJob( const QString& command, - const QString& workingPath, - bool runInChroot = false, - std::chrono::seconds secondsTimeout = std::chrono::seconds( 30 ), - QObject* parent = nullptr ); + explicit DLLEXPORT ProcessJob( const QString& command, + const QString& workingPath, + bool runInChroot = false, + std::chrono::seconds secondsTimeout = std::chrono::seconds( 30 ), + QObject* parent = nullptr ); ~ProcessJob() override; QString prettyName() const override; diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 88f841ffd..1fcfc71b0 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -39,7 +39,7 @@ class Private; class RegionalZonesModel; class ZonesModel; -class TimeZoneData : public QObject, TranslatableString +class DLLEXPORT TimeZoneData : public QObject, TranslatableString { friend class RegionalZonesModel; friend class ZonesModel; diff --git a/src/libcalamares/locale/Translation.h b/src/libcalamares/locale/Translation.h index bdc58adf3..cec70f525 100644 --- a/src/libcalamares/locale/Translation.h +++ b/src/libcalamares/locale/Translation.h @@ -36,7 +36,7 @@ namespace Locale * - `ca@valencia` is the Catalan dialect spoken in Valencia. * There is no Qt code for it. */ -class Translation : public QObject +class DLLEXPORT Translation : public QObject { Q_OBJECT diff --git a/src/libcalamares/modulesystem/Descriptor.h b/src/libcalamares/modulesystem/Descriptor.h index 6ed70fd42..aab7293d8 100644 --- a/src/libcalamares/modulesystem/Descriptor.h +++ b/src/libcalamares/modulesystem/Descriptor.h @@ -11,6 +11,7 @@ #ifndef MODULESYSTEM_DESCRIPTOR_H #define MODULESYSTEM_DESCRIPTOR_H +#include "DllMacro.h" #include "utils/NamedEnum.h" #include @@ -30,7 +31,7 @@ enum class Type Job, View }; -const NamedEnumTable< Type >& typeNames(); +DLLEXPORT const NamedEnumTable< Type >& typeNames(); /** * @brief The Interface enum represents the interface through which the module @@ -43,8 +44,7 @@ enum class Interface Python, // Jobs only Process, // Deprecated interface }; -const NamedEnumTable< Interface >& interfaceNames(); - +DLLEXPORT const NamedEnumTable< Interface >& interfaceNames(); /** * @brief Description of a module (obtained from module.desc) @@ -53,7 +53,7 @@ const NamedEnumTable< Interface >& interfaceNames(); * determine which specialized fields make sense for a given * descriptor (e.g. a Python module has no shared-library path). */ -class Descriptor +class DLLEXPORT Descriptor { public: ///@brief an invalid, and empty, descriptor diff --git a/src/libcalamares/modulesystem/InstanceKey.h b/src/libcalamares/modulesystem/InstanceKey.h index a37bbc320..5153090ab 100644 --- a/src/libcalamares/modulesystem/InstanceKey.h +++ b/src/libcalamares/modulesystem/InstanceKey.h @@ -11,6 +11,8 @@ #ifndef MODULESYSTEM_INSTANCEKEY_H #define MODULESYSTEM_INSTANCEKEY_H +#include "DllMacro.h" + #include #include #include @@ -36,7 +38,7 @@ namespace ModuleSystem * This is supported by the *instances* configuration entry * in `settings.conf`. */ -class InstanceKey +class DLLEXPORT InstanceKey { public: /// @brief Create an instance key from explicit module and id. @@ -102,7 +104,7 @@ private: using InstanceKeyList = QList< InstanceKey >; -QDebug& operator<<( QDebug& s, const Calamares::ModuleSystem::InstanceKey& i ); +DLLEXPORT QDebug& operator<<( QDebug& s, const Calamares::ModuleSystem::InstanceKey& i ); inline QDebug& operator<<( QDebug&& s, const Calamares::ModuleSystem::InstanceKey& i ) { diff --git a/src/libcalamares/modulesystem/RequirementsChecker.h b/src/libcalamares/modulesystem/RequirementsChecker.h index b933a29a8..befa32b53 100644 --- a/src/libcalamares/modulesystem/RequirementsChecker.h +++ b/src/libcalamares/modulesystem/RequirementsChecker.h @@ -10,6 +10,7 @@ #ifndef CALAMARES_REQUIREMENTSCHECKER_H #define CALAMARES_REQUIREMENTSCHECKER_H +#include "DllMacro.h" #include "modulesystem/Requirement.h" #include @@ -28,7 +29,7 @@ class RequirementsModel; * Asynchronously checks the requirements for each module, and * emits progress signals as appropriate. */ -class RequirementsChecker : public QObject +class DLLEXPORT RequirementsChecker : public QObject { Q_OBJECT diff --git a/src/libcalamares/network/Manager.h b/src/libcalamares/network/Manager.h index 9afb706e4..75203881d 100644 --- a/src/libcalamares/network/Manager.h +++ b/src/libcalamares/network/Manager.h @@ -84,7 +84,7 @@ struct RequestStatus State status; }; -QDebug& operator<<( QDebug& s, const RequestStatus& e ); +DLLEXPORT QDebug& operator<<( QDebug& s, const RequestStatus& e ); class DLLEXPORT Manager : public QObject { diff --git a/src/libcalamares/packages/Globals.h b/src/libcalamares/packages/Globals.h index 222d6cedb..4b12e76a3 100644 --- a/src/libcalamares/packages/Globals.h +++ b/src/libcalamares/packages/Globals.h @@ -10,6 +10,7 @@ #ifndef LIBCALAMARES_PACKAGES_GLOBALS_H #define LIBCALAMARES_PACKAGES_GLOBALS_H +#include "DllMacro.h" #include "GlobalStorage.h" #include "modulesystem/InstanceKey.h" @@ -24,7 +25,7 @@ namespace Packages * * Returns @c true if anything was changed, @c false otherwise. */ -bool setGSPackageAdditions( Calamares::GlobalStorage* gs, +DLLEXPORT bool setGSPackageAdditions( Calamares::GlobalStorage* gs, const Calamares::ModuleSystem::InstanceKey& module, const QVariantList& installPackages, const QVariantList& tryInstallPackages ); @@ -33,7 +34,7 @@ bool setGSPackageAdditions( Calamares::GlobalStorage* gs, * This replaces previously-set install-packages lists. Use this with * plain lists of package names. It does not support try-install. */ -bool setGSPackageAdditions( Calamares::GlobalStorage* gs, +DLLEXPORT bool setGSPackageAdditions( Calamares::GlobalStorage* gs, const Calamares::ModuleSystem::InstanceKey& module, const QStringList& installPackages ); // void setGSPackageRemovals( const Calamares::ModuleSystem::InstanceKey& key, const QVariantList& removePackages ); diff --git a/src/libcalamares/partition/KPMManager.h b/src/libcalamares/partition/KPMManager.h index 6111505fa..45a403b31 100644 --- a/src/libcalamares/partition/KPMManager.h +++ b/src/libcalamares/partition/KPMManager.h @@ -16,6 +16,8 @@ #ifndef PARTITION_KPMMANAGER_H #define PARTITION_KPMMANAGER_H +#include "DllMacro.h" + #include class CoreBackend; @@ -39,7 +41,7 @@ class InternalManager; * environment variable KPMCORE_BACKEND. Setting it to * "dummy" will load the dummy plugin instead. */ -class KPMManager +class DLLEXPORT KPMManager { public: KPMManager(); diff --git a/src/libcalamares/partition/PartitionIterator.h b/src/libcalamares/partition/PartitionIterator.h index c90b925fb..b447ca061 100644 --- a/src/libcalamares/partition/PartitionIterator.h +++ b/src/libcalamares/partition/PartitionIterator.h @@ -19,6 +19,8 @@ #ifndef PARTITION_PARTITIONITERATOR_H #define PARTITION_PARTITIONITERATOR_H +#include "DllMacro.h" + class Device; class Partition; class PartitionTable; @@ -39,7 +41,7 @@ namespace Partition * * A nullptr is valid, for an empty iterator. */ -class PartitionIterator +class DLLEXPORT PartitionIterator { public: ::Partition* operator*() const; diff --git a/src/libcalamares/partition/PartitionQuery.h b/src/libcalamares/partition/PartitionQuery.h index f7dc6eee6..24567be3f 100644 --- a/src/libcalamares/partition/PartitionQuery.h +++ b/src/libcalamares/partition/PartitionQuery.h @@ -18,6 +18,8 @@ #ifndef PARTITION_PARTITIONQUERY_H #define PARTITION_PARTITIONQUERY_H +#include "DllMacro.h" + #include #include @@ -36,23 +38,23 @@ using ::Partition; using ::PartitionTable; /** @brief Get partition table */ -const PartitionTable* getPartitionTable( const Partition* partition ); +DLLEXPORT const PartitionTable* getPartitionTable( const Partition* partition ); /** @brief Is this a free-space area? */ -bool isPartitionFreeSpace( const Partition* ); +DLLEXPORT bool isPartitionFreeSpace( const Partition* ); /** @brief Is this partition newly-to-be-created? * * Returns true if the partition is planned to be created by the installer as * opposed to already existing on the disk. */ -bool isPartitionNew( const Partition* ); +DLLEXPORT bool isPartitionNew( const Partition* ); /** * Iterates on all devices and return the first partition which is (already) * mounted on @p mountPoint. */ -Partition* findPartitionByCurrentMountPoint( const QList< Device* >& devices, const QString& mountPoint ); +DLLEXPORT Partition* findPartitionByCurrentMountPoint( const QList< Device* >& devices, const QString& mountPoint ); // TODO: add this distinction // Partition* findPartitionByIntendedMountPoint( const QList< Device* >& devices, const QString& mountPoint ); @@ -61,14 +63,14 @@ Partition* findPartitionByCurrentMountPoint( const QList< Device* >& devices, co * Iterates on all devices and partitions and returns a pointer to the Partition object * for the given path, or nullptr if a Partition for the given path cannot be found. */ -Partition* findPartitionByPath( const QList< Device* >& devices, const QString& path ); +DLLEXPORT Partition* findPartitionByPath( const QList< Device* >& devices, const QString& path ); /** * Iterates on all devices and partitions and returns a list of pointers to the Partition * objects that satisfy the conditions defined in the criterion function. */ -QList< Partition* > findPartitions( const QList< Device* >& devices, - std::function< bool( Partition* ) > criterionFunction ); +DLLEXPORT QList< Partition* > findPartitions( const QList< Device* >& devices, + std::function< bool( Partition* ) > criterionFunction ); } // namespace Partition } // namespace Calamares diff --git a/src/libcalamares/partition/PartitionSize.h b/src/libcalamares/partition/PartitionSize.h index cea857808..f7a1aa2cc 100644 --- a/src/libcalamares/partition/PartitionSize.h +++ b/src/libcalamares/partition/PartitionSize.h @@ -12,6 +12,7 @@ #ifndef PARTITION_PARTITIONSIZE_H #define PARTITION_PARTITIONSIZE_H +#include "DllMacro.h" #include "utils/NamedSuffix.h" #include "utils/Units.h" @@ -42,7 +43,7 @@ enum class SizeUnit * the available drive space are on). This class handles parsing * of such strings from the config file. */ -class PartitionSize : public NamedSuffix< SizeUnit, SizeUnit::None > +class DLLEXPORT PartitionSize : public NamedSuffix< SizeUnit, SizeUnit::None > { public: PartitionSize() diff --git a/src/libcalamares/python/PythonJob.h b/src/libcalamares/python/PythonJob.h index 9349d7cc8..62f86d628 100644 --- a/src/libcalamares/python/PythonJob.h +++ b/src/libcalamares/python/PythonJob.h @@ -12,7 +12,7 @@ // This file is called PythonJob.h because it would otherwise // clashwith the Job.h in libcalamares proper. - +#include "DllMacro.h" #include "Job.h" #include @@ -27,10 +27,10 @@ class Job : public ::Calamares::Job { Q_OBJECT public: - explicit Job( const QString& scriptFile, - const QString& workingPath, - const QVariantMap& moduleConfiguration = QVariantMap(), - QObject* parent = nullptr ); + explicit DLLEXPORT Job( const QString& scriptFile, + const QString& workingPath, + const QVariantMap& moduleConfiguration = QVariantMap(), + QObject* parent = nullptr ); ~Job() override; QString prettyName() const override; @@ -48,7 +48,7 @@ public: * a character literal or something that lives longer than the * job. Pass in @c nullptr to switch off pre-run code. */ - static void setInjectedPreScript( const char* script ); + static DLLEXPORT void setInjectedPreScript( const char* script ); /** @brief Accessors for JobProxy */ QString workingPath() const; diff --git a/src/libcalamares/utils/CommandList.h b/src/libcalamares/utils/CommandList.h index 1814ff49e..9969dc165 100644 --- a/src/libcalamares/utils/CommandList.h +++ b/src/libcalamares/utils/CommandList.h @@ -11,6 +11,7 @@ #ifndef UTILS_COMMANDLIST_H #define UTILS_COMMANDLIST_H +#include "DllMacro.h" #include "Job.h" #include @@ -58,13 +59,13 @@ struct CommandLine * This will normally be a Calamares::String::DictionaryExpander * instance, which handles the ROOT and USER variables. */ - CommandLine expand( KMacroExpanderBase& expander ) const; + DLLEXPORT CommandLine expand( KMacroExpanderBase& expander ) const; /** @brief As above, with a default macro-expander. * * The default macro-expander assumes RunInHost (e.g. ROOT will * expand to the RootMountPoint set in Global Storage). */ - CommandLine expand() const; + DLLEXPORT CommandLine expand() const; private: QString first; @@ -82,7 +83,7 @@ using CommandList_t = QList< CommandLine >; * Documentation for the format of commands can be found in * `shellprocess.conf`. */ -class CommandList : protected CommandList_t +class DLLEXPORT CommandList : protected CommandList_t { public: /** @brief empty command-list with timeout to apply to entries. */ diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index 6f3b031aa..8d3301df6 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -228,7 +228,7 @@ struct RedactedCommand const QStringList& list; }; -QDebug& operator<<( QDebug& s, const RedactedCommand& l ); +DLLEXPORT QDebug& operator<<( QDebug& s, const RedactedCommand& l ); /** @brief When logging "private" identifiers, keep them consistent but private * @@ -236,7 +236,7 @@ QDebug& operator<<( QDebug& s, const RedactedCommand& l ); * it logs the same way, but without revealing the actual contents. * This can be applied to user names, UUIDs, etc. */ -struct RedactedName +struct DLLEXPORT RedactedName { RedactedName( const char* context, const QString& s ); RedactedName( const QString& context, const QString& s ); @@ -312,7 +312,7 @@ operator<<( QDebug& s, const DebugListT< T >& c ) } /** @brief supporting method for outputting a DebugMap */ -QString toString( const QVariant& v ); +DLLEXPORT QString toString( const QVariant& v ); /** @brief output operator for DebugMap */ inline QDebug& diff --git a/src/libcalamares/utils/PluginFactory.h b/src/libcalamares/utils/PluginFactory.h index a5c0359ba..3c975ac88 100644 --- a/src/libcalamares/utils/PluginFactory.h +++ b/src/libcalamares/utils/PluginFactory.h @@ -12,6 +12,8 @@ #ifndef UTILS_PLUGINFACTORY_H #define UTILS_PLUGINFACTORY_H +#include "DllMacro.h" + #include #define CalamaresPluginFactory_iid "io.calamares.PluginFactory" @@ -24,7 +26,7 @@ * the function is set when registerPlugin() is called in a subclass. * */ -class CalamaresPluginFactory : public QObject +class DLLEXPORT CalamaresPluginFactory : public QObject { Q_OBJECT public: @@ -104,9 +106,7 @@ protected: { \ pluginRegistrations; \ } \ - name::~name() \ - { \ - } + name::~name() {} Q_DECLARE_INTERFACE( CalamaresPluginFactory, CalamaresPluginFactory_iid ) diff --git a/src/libcalamares/utils/Retranslator.h b/src/libcalamares/utils/Retranslator.h index ac2b022cb..0075562ef 100644 --- a/src/libcalamares/utils/Retranslator.h +++ b/src/libcalamares/utils/Retranslator.h @@ -81,7 +81,7 @@ DLLEXPORT void setAllowLocalTranslation( bool allow ); * but use the macros `CALAMARES_RETRANSLATE*` to set things up * in code -- the macros will connect to the Retranslator's signals. */ -class Retranslator : public QObject +class DLLEXPORT Retranslator : public QObject { Q_OBJECT public: diff --git a/src/libcalamares/utils/StringExpander.h b/src/libcalamares/utils/StringExpander.h index e0b21bee8..fa46bf983 100644 --- a/src/libcalamares/utils/StringExpander.h +++ b/src/libcalamares/utils/StringExpander.h @@ -40,7 +40,7 @@ namespace String * `expand()` implicitly clears the errors before starting * a new expansion, as well. */ -class DictionaryExpander : public KWordMacroExpander +class DLLEXPORT DictionaryExpander : public KWordMacroExpander { public: DictionaryExpander(); diff --git a/src/libcalamares/utils/System.h b/src/libcalamares/utils/System.h index 8385287cf..6b6eba12b 100644 --- a/src/libcalamares/utils/System.h +++ b/src/libcalamares/utils/System.h @@ -60,7 +60,7 @@ public: * @param timeout Timeout passed to the process runner, for explaining * error code -4 (timeout). */ - static Calamares::JobResult + static DLLEXPORT Calamares::JobResult explainProcess( int errorCode, const QString& command, const QString& output, std::chrono::seconds timeout ); /// @brief Convenience wrapper for explainProcess() diff --git a/src/libcalamares/utils/Yaml.h b/src/libcalamares/utils/Yaml.h index 4e626eb5d..68b51c334 100644 --- a/src/libcalamares/utils/Yaml.h +++ b/src/libcalamares/utils/Yaml.h @@ -21,6 +21,8 @@ #ifndef UTILS_YAML_H #define UTILS_YAML_H +#include "DllMacro.h" + #include #include #include @@ -48,7 +50,7 @@ class QFileInfo; #endif /// @brief Appends all the elements of @p node to the string list @p v -void operator>>( const ::YAML::Node& node, QStringList& v ); +DLLEXPORT void operator>>( const ::YAML::Node& node, QStringList& v ); namespace Calamares { @@ -60,29 +62,29 @@ namespace YAML * malformed in some way, returns an empty map and sets * @p *ok to false. Otherwise sets @p *ok to true. */ -QVariantMap load( const QString& filename, bool* ok = nullptr ); +DLLEXPORT QVariantMap load( const QString& filename, bool* ok = nullptr ); /** Convenience overload. */ -QVariantMap load( const QFileInfo&, bool* ok = nullptr ); +DLLEXPORT QVariantMap load( const QFileInfo&, bool* ok = nullptr ); -QVariant toVariant( const ::YAML::Node& node ); -QVariant scalarToVariant( const ::YAML::Node& scalarNode ); -QVariantList sequenceToVariant( const ::YAML::Node& sequenceNode ); -QVariantMap mapToVariant( const ::YAML::Node& mapNode ); +DLLEXPORT QVariant toVariant( const ::YAML::Node& node ); +DLLEXPORT QVariant scalarToVariant( const ::YAML::Node& scalarNode ); +DLLEXPORT QVariantList sequenceToVariant( const ::YAML::Node& sequenceNode ); +DLLEXPORT QVariantMap mapToVariant( const ::YAML::Node& mapNode ); /// @brief Returns all the elements of @p listNode in a StringList -QStringList toStringList( const ::YAML::Node& listNode ); +DLLEXPORT QStringList toStringList( const ::YAML::Node& listNode ); /// @brief Save a @p map to @p filename as YAML -bool save( const QString& filename, const QVariantMap& map ); +DLLEXPORT bool save( const QString& filename, const QVariantMap& map ); /** * Given an exception from the YAML parser library, explain * what is going on in terms of the data passed to the parser. * Uses @p label when labeling the data source (e.g. "netinstall data") */ -void explainException( const ::YAML::Exception& e, const QByteArray& data, const char* label ); -void explainException( const ::YAML::Exception& e, const QByteArray& data, const QString& label ); -void explainException( const ::YAML::Exception& e, const QByteArray& data ); +DLLEXPORT void explainException( const ::YAML::Exception& e, const QByteArray& data, const char* label ); +DLLEXPORT void explainException( const ::YAML::Exception& e, const QByteArray& data, const QString& label ); +DLLEXPORT void explainException( const ::YAML::Exception& e, const QByteArray& data ); } // namespace YAML } // namespace Calamares