From aaa6f6bd55ea64dd29cccdf55c296d4b5ce8e17d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 11:32:28 +0100 Subject: [PATCH 01/10] [libcalamaresui] Drop UiDllMacro.h - The scattering of DLL export macro's is kind of useless; there are several headers, and then the export macro isn't even applied consistently. Just drop the one for UI exports, which was only used in libcalamaresui. --- src/calamares/CMakeLists.txt | 2 -- src/libcalamaresui/Branding.h | 4 +-- src/libcalamaresui/CMakeLists.txt | 2 +- src/libcalamaresui/UiDllMacro.h | 32 ------------------- src/libcalamaresui/ViewManager.h | 4 +-- .../modulesystem/CppJobModule.h | 4 +-- src/libcalamaresui/modulesystem/Module.h | 4 +-- .../modulesystem/ProcessJobModule.h | 4 +-- .../modulesystem/PythonJobModule.h | 4 +-- .../modulesystem/PythonQtViewModule.h | 4 +-- src/libcalamaresui/modulesystem/ViewModule.h | 4 +-- src/libcalamaresui/utils/CalamaresUtilsGui.h | 22 ++++++------- src/libcalamaresui/utils/ImageRegistry.h | 4 +-- src/libcalamaresui/viewpages/ViewStep.h | 4 +-- 14 files changed, 32 insertions(+), 66 deletions(-) delete mode 100644 src/libcalamaresui/UiDllMacro.h diff --git a/src/calamares/CMakeLists.txt b/src/calamares/CMakeLists.txt index a55e26b6d..9327af8e3 100644 --- a/src/calamares/CMakeLists.txt +++ b/src/calamares/CMakeLists.txt @@ -1,5 +1,3 @@ -add_definitions( -DUIDLLEXPORT_PRO ) - set( calamaresSources main.cpp CalamaresApplication.cpp diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index e3952881e..4c051981c 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -22,7 +22,7 @@ #ifndef BRANDING_H #define BRANDING_H -#include "UiDllMacro.h" +#include "DllMacro.h" #include "utils/NamedSuffix.h" @@ -40,7 +40,7 @@ namespace Calamares class GlobalStorage; -class UIDLLEXPORT Branding : public QObject +class DLLEXPORT Branding : public QObject { Q_OBJECT public: diff --git a/src/libcalamaresui/CMakeLists.txt b/src/libcalamaresui/CMakeLists.txt index c603ca22d..9f87ed009 100644 --- a/src/libcalamaresui/CMakeLists.txt +++ b/src/libcalamaresui/CMakeLists.txt @@ -66,7 +66,7 @@ endif() calamares_add_library( calamaresui SOURCES ${calamaresui_SOURCES} - EXPORT_MACRO UIDLLEXPORT_PRO + EXPORT_MACRO DLLEXPORT_PRO LINK_PRIVATE_LIBRARIES ${OPTIONAL_PYTHON_LIBRARIES} LINK_LIBRARIES diff --git a/src/libcalamaresui/UiDllMacro.h b/src/libcalamaresui/UiDllMacro.h deleted file mode 100644 index 3064ca68c..000000000 --- a/src/libcalamaresui/UiDllMacro.h +++ /dev/null @@ -1,32 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014, Teo Mrnjavac - * - * Calamares is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Calamares 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Calamares. If not, see . - */ - -#ifndef UIDLLMACRO_H -#define UIDLLMACRO_H - -#include - -#ifndef UIDLLEXPORT -#if defined( UIDLLEXPORT_PRO ) -#define UIDLLEXPORT Q_DECL_EXPORT -#else -#define UIDLLEXPORT Q_DECL_IMPORT -#endif -#endif - -#endif diff --git a/src/libcalamaresui/ViewManager.h b/src/libcalamaresui/ViewManager.h index fca74a367..50838f780 100644 --- a/src/libcalamaresui/ViewManager.h +++ b/src/libcalamaresui/ViewManager.h @@ -20,7 +20,7 @@ #ifndef VIEWMANAGER_H #define VIEWMANAGER_H -#include "UiDllMacro.h" +#include "DllMacro.h" #include "viewpages/ViewStep.h" #include @@ -33,7 +33,7 @@ namespace Calamares * @brief The ViewManager class handles progression through view pages. * @note Singleton object, only use through ViewManager::instance(). */ -class UIDLLEXPORT ViewManager : public QObject +class DLLEXPORT ViewManager : public QObject { Q_OBJECT public: diff --git a/src/libcalamaresui/modulesystem/CppJobModule.h b/src/libcalamaresui/modulesystem/CppJobModule.h index feb0f22bb..758b44459 100644 --- a/src/libcalamaresui/modulesystem/CppJobModule.h +++ b/src/libcalamaresui/modulesystem/CppJobModule.h @@ -22,14 +22,14 @@ #define CALAMARES_CPPJOBMODULE_H #include "Module.h" -#include "UiDllMacro.h" +#include "DllMacro.h" class QPluginLoader; namespace Calamares { -class UIDLLEXPORT CppJobModule : public Module +class DLLEXPORT CppJobModule : public Module { public: Type type() const override; diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index bf2f1cb5d..4ebbdf2a2 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -22,7 +22,7 @@ #include "Job.h" #include "Requirement.h" -#include "UiDllMacro.h" +#include "DllMacro.h" #include "modulesystem/Descriptor.h" #include "modulesystem/InstanceKey.h" @@ -40,7 +40,7 @@ namespace Calamares * takes care of creating an object of the correct type starting from a module * descriptor structure. */ -class UIDLLEXPORT Module +class DLLEXPORT Module { public: /** diff --git a/src/libcalamaresui/modulesystem/ProcessJobModule.h b/src/libcalamaresui/modulesystem/ProcessJobModule.h index 96fb2ed47..31e3b1219 100644 --- a/src/libcalamaresui/modulesystem/ProcessJobModule.h +++ b/src/libcalamaresui/modulesystem/ProcessJobModule.h @@ -22,14 +22,14 @@ #include "Module.h" -#include "UiDllMacro.h" +#include "DllMacro.h" #include namespace Calamares { -class UIDLLEXPORT ProcessJobModule : public Module +class DLLEXPORT ProcessJobModule : public Module { public: Type type() const override; diff --git a/src/libcalamaresui/modulesystem/PythonJobModule.h b/src/libcalamaresui/modulesystem/PythonJobModule.h index 8fa137f71..1d70b5f6c 100644 --- a/src/libcalamaresui/modulesystem/PythonJobModule.h +++ b/src/libcalamaresui/modulesystem/PythonJobModule.h @@ -21,12 +21,12 @@ #include "Module.h" -#include "UiDllMacro.h" +#include "DllMacro.h" namespace Calamares { -class UIDLLEXPORT PythonJobModule : public Module +class DLLEXPORT PythonJobModule : public Module { public: Type type() const override; diff --git a/src/libcalamaresui/modulesystem/PythonQtViewModule.h b/src/libcalamaresui/modulesystem/PythonQtViewModule.h index 6ebb5c433..eeee69a78 100644 --- a/src/libcalamaresui/modulesystem/PythonQtViewModule.h +++ b/src/libcalamaresui/modulesystem/PythonQtViewModule.h @@ -20,14 +20,14 @@ #define CALAMARES_PYTHONQTVIEWMODULE_H #include "Module.h" -#include "UiDllMacro.h" +#include "DllMacro.h" namespace Calamares { class ViewStep; -class UIDLLEXPORT PythonQtViewModule : public Module +class DLLEXPORT PythonQtViewModule : public Module { public: Type type() const override; diff --git a/src/libcalamaresui/modulesystem/ViewModule.h b/src/libcalamaresui/modulesystem/ViewModule.h index e9db1347b..dfe9bed92 100644 --- a/src/libcalamaresui/modulesystem/ViewModule.h +++ b/src/libcalamaresui/modulesystem/ViewModule.h @@ -21,7 +21,7 @@ #define CALAMARES_VIEWMODULE_H #include "Module.h" -#include "UiDllMacro.h" +#include "DllMacro.h" class QPluginLoader; @@ -30,7 +30,7 @@ namespace Calamares class ViewStep; -class UIDLLEXPORT ViewModule : public Module +class DLLEXPORT ViewModule : public Module { public: Type type() const override; diff --git a/src/libcalamaresui/utils/CalamaresUtilsGui.h b/src/libcalamaresui/utils/CalamaresUtilsGui.h index 0c10dcc30..884e603e3 100644 --- a/src/libcalamaresui/utils/CalamaresUtilsGui.h +++ b/src/libcalamaresui/utils/CalamaresUtilsGui.h @@ -20,7 +20,7 @@ #ifndef CALAMARESUTILSGUI_H #define CALAMARESUTILSGUI_H -#include "UiDllMacro.h" +#include "DllMacro.h" #include #include @@ -83,7 +83,7 @@ enum ImageMode * @param size the target pixmap size (default: original SVG size). * @return the new pixmap. */ -UIDLLEXPORT QPixmap defaultPixmap( ImageType type, +DLLEXPORT QPixmap defaultPixmap( ImageType type, ImageMode mode = CalamaresUtils::Original, const QSize& size = QSize( 0, 0 ) ); @@ -95,27 +95,27 @@ UIDLLEXPORT QPixmap defaultPixmap( ImageType type, * @return the transformed pixmap. * This one is currently unused. */ -UIDLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, const QSize& size, float frameWidthPct = 0.20f ); +DLLEXPORT QPixmap createRoundedImage( const QPixmap& avatar, const QSize& size, float frameWidthPct = 0.20f ); /** * @brief unmarginLayout recursively walks the QLayout tree and removes all margins. * @param layout the layout to unmargin. */ -UIDLLEXPORT void unmarginLayout( QLayout* layout ); +DLLEXPORT void unmarginLayout( QLayout* layout ); /** * @brief clearLayout recursively walks the QLayout tree and deletes all the child * widgets and layouts. * @param layout the layout to clear. */ -UIDLLEXPORT void clearLayout( QLayout* layout ); +DLLEXPORT void clearLayout( QLayout* layout ); -UIDLLEXPORT void setDefaultFontSize( int points ); -UIDLLEXPORT int defaultFontSize(); // in points -UIDLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific -UIDLLEXPORT QFont defaultFont(); -UIDLLEXPORT QFont largeFont(); -UIDLLEXPORT QSize defaultIconSize(); +DLLEXPORT void setDefaultFontSize( int points ); +DLLEXPORT int defaultFontSize(); // in points +DLLEXPORT int defaultFontHeight(); // in pixels, DPI-specific +DLLEXPORT QFont defaultFont(); +DLLEXPORT QFont largeFont(); +DLLEXPORT QSize defaultIconSize(); /** * @brief Size constants for the main Calamares window. diff --git a/src/libcalamaresui/utils/ImageRegistry.h b/src/libcalamaresui/utils/ImageRegistry.h index 454cb500d..a7d04fa9a 100644 --- a/src/libcalamaresui/utils/ImageRegistry.h +++ b/src/libcalamaresui/utils/ImageRegistry.h @@ -28,10 +28,10 @@ #include -#include "UiDllMacro.h" +#include "DllMacro.h" #include "utils/CalamaresUtilsGui.h" -class UIDLLEXPORT ImageRegistry +class DLLEXPORT ImageRegistry { public: static ImageRegistry* instance(); diff --git a/src/libcalamaresui/viewpages/ViewStep.h b/src/libcalamaresui/viewpages/ViewStep.h index c5903d6f5..55b2e200a 100644 --- a/src/libcalamaresui/viewpages/ViewStep.h +++ b/src/libcalamaresui/viewpages/ViewStep.h @@ -21,7 +21,7 @@ #define VIEWSTEP_H #include "Job.h" -#include "UiDllMacro.h" +#include "DllMacro.h" #include "modulesystem/InstanceKey.h" #include "modulesystem/Requirement.h" @@ -45,7 +45,7 @@ namespace Calamares * (which shows all of the things which have been collected to be done in the * next exec-step) through prettyStatus() and createSummaryWidget(). */ -class UIDLLEXPORT ViewStep : public QObject +class DLLEXPORT ViewStep : public QObject { Q_OBJECT public: From b0445490138dbd29f4698a938091bd59ea4a7143 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 11:37:35 +0100 Subject: [PATCH 02/10] [libcalamares] Merge PluginDllMacro.h into DllMacro.h - Let's just have one header definining export- and visibility- macros for Calamares. They are still selected based on the export flags (*_PRO), just defined in one header instead of two. --- src/libcalamares/DllMacro.h | 8 +++++ src/libcalamares/PluginDllMacro.h | 32 ------------------- .../contextualprocess/ContextualProcessJob.h | 2 +- src/modules/dracutlukscfg/DracutLuksCfgJob.h | 2 +- src/modules/dummycpp/DummyCppJob.h | 2 +- src/modules/finished/FinishedViewStep.h | 2 +- src/modules/fsresizer/ResizeFSJob.h | 2 +- src/modules/hostinfo/HostInfoJob.h | 2 +- src/modules/initcpio/InitcpioJob.h | 2 +- src/modules/initramfs/InitramfsJob.h | 2 +- .../InteractiveTerminalViewStep.h | 2 +- src/modules/keyboard/KeyboardViewStep.h | 2 +- src/modules/license/LicenseViewStep.h | 2 +- src/modules/locale/LocaleViewStep.h | 2 +- .../luksbootkeyfile/LuksBootKeyFileJob.h | 2 +- src/modules/machineid/MachineIdJob.h | 2 +- src/modules/netinstall/NetInstallViewStep.h | 2 +- src/modules/notesqml/NotesQmlViewStep.h | 2 +- src/modules/oemid/OEMViewStep.h | 2 +- .../packagechooser/PackageChooserViewStep.h | 2 +- src/modules/partition/gui/PartitionViewStep.h | 2 +- src/modules/plasmalnf/PlasmaLnfViewStep.h | 2 +- src/modules/preservefiles/PreserveFiles.h | 2 +- src/modules/shellprocess/ShellProcessJob.h | 2 +- src/modules/summary/SummaryViewStep.h | 2 +- src/modules/tracking/TrackingViewStep.h | 2 +- src/modules/users/UsersViewStep.h | 2 +- src/modules/webview/WebViewStep.h | 2 +- src/modules/welcome/WelcomeViewStep.h | 2 +- src/modules/welcomeq/WelcomeQmlViewStep.h | 2 +- 30 files changed, 36 insertions(+), 60 deletions(-) delete mode 100644 src/libcalamares/PluginDllMacro.h diff --git a/src/libcalamares/DllMacro.h b/src/libcalamares/DllMacro.h index d3e1c8098..865d91d57 100644 --- a/src/libcalamares/DllMacro.h +++ b/src/libcalamares/DllMacro.h @@ -29,4 +29,12 @@ #endif #endif +#ifndef PLUGINDLLEXPORT +#if defined( PLUGINDLLEXPORT_PRO ) +#define PLUGINDLLEXPORT Q_DECL_EXPORT +#else +#define PLUGINDLLEXPORT Q_DECL_IMPORT +#endif +#endif + #endif diff --git a/src/libcalamares/PluginDllMacro.h b/src/libcalamares/PluginDllMacro.h deleted file mode 100644 index d790230b9..000000000 --- a/src/libcalamares/PluginDllMacro.h +++ /dev/null @@ -1,32 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014, Teo Mrnjavac - * - * Calamares is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Calamares 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Calamares. If not, see . - */ - -#ifndef PLUGINDLLMACRO_H -#define PLUGINDLLMACRO_H - -#include - -#ifndef PLUGINDLLEXPORT -#if defined( PLUGINDLLEXPORT_PRO ) -#define PLUGINDLLEXPORT Q_DECL_EXPORT -#else -#define PLUGINDLLEXPORT Q_DECL_IMPORT -#endif -#endif - -#endif diff --git a/src/modules/contextualprocess/ContextualProcessJob.h b/src/modules/contextualprocess/ContextualProcessJob.h index 2efbc5082..3a252d2d3 100644 --- a/src/modules/contextualprocess/ContextualProcessJob.h +++ b/src/modules/contextualprocess/ContextualProcessJob.h @@ -23,7 +23,7 @@ #include #include "CppJob.h" -#include "PluginDllMacro.h" +#include "DllMacro.h" #include "utils/PluginFactory.h" diff --git a/src/modules/dracutlukscfg/DracutLuksCfgJob.h b/src/modules/dracutlukscfg/DracutLuksCfgJob.h index e9e5a54a2..ccf0adb70 100644 --- a/src/modules/dracutlukscfg/DracutLuksCfgJob.h +++ b/src/modules/dracutlukscfg/DracutLuksCfgJob.h @@ -27,7 +27,7 @@ #include -#include +#include class PLUGINDLLEXPORT DracutLuksCfgJob : public Calamares::CppJob { diff --git a/src/modules/dummycpp/DummyCppJob.h b/src/modules/dummycpp/DummyCppJob.h index 4a79d0378..c60b01d57 100644 --- a/src/modules/dummycpp/DummyCppJob.h +++ b/src/modules/dummycpp/DummyCppJob.h @@ -27,7 +27,7 @@ #include -#include +#include class PLUGINDLLEXPORT DummyCppJob : public Calamares::CppJob { diff --git a/src/modules/finished/FinishedViewStep.h b/src/modules/finished/FinishedViewStep.h index 7b3881099..2df37e9b6 100644 --- a/src/modules/finished/FinishedViewStep.h +++ b/src/modules/finished/FinishedViewStep.h @@ -25,7 +25,7 @@ #include "utils/PluginFactory.h" #include "viewpages/ViewStep.h" -#include "PluginDllMacro.h" +#include "DllMacro.h" class FinishedPage; diff --git a/src/modules/fsresizer/ResizeFSJob.h b/src/modules/fsresizer/ResizeFSJob.h index 76ca6c219..985942b99 100644 --- a/src/modules/fsresizer/ResizeFSJob.h +++ b/src/modules/fsresizer/ResizeFSJob.h @@ -27,7 +27,7 @@ #include "partition/PartitionSize.h" #include "utils/PluginFactory.h" -#include +#include class CoreBackend; // From KPMCore class Device; // From KPMCore diff --git a/src/modules/hostinfo/HostInfoJob.h b/src/modules/hostinfo/HostInfoJob.h index fa3342192..5db169b0e 100644 --- a/src/modules/hostinfo/HostInfoJob.h +++ b/src/modules/hostinfo/HostInfoJob.h @@ -20,7 +20,7 @@ #define HOSTINFOJOB_H #include "CppJob.h" -#include "PluginDllMacro.h" +#include "DllMacro.h" #include "utils/PluginFactory.h" #include diff --git a/src/modules/initcpio/InitcpioJob.h b/src/modules/initcpio/InitcpioJob.h index 11358d749..cdc48f6ce 100644 --- a/src/modules/initcpio/InitcpioJob.h +++ b/src/modules/initcpio/InitcpioJob.h @@ -20,7 +20,7 @@ #define INITCPIOJOB_H #include "CppJob.h" -#include "PluginDllMacro.h" +#include "DllMacro.h" #include "utils/PluginFactory.h" #include diff --git a/src/modules/initramfs/InitramfsJob.h b/src/modules/initramfs/InitramfsJob.h index 9eeb81fea..3239c6929 100644 --- a/src/modules/initramfs/InitramfsJob.h +++ b/src/modules/initramfs/InitramfsJob.h @@ -20,7 +20,7 @@ #define INITRAMFSJOB_H #include "CppJob.h" -#include "PluginDllMacro.h" +#include "DllMacro.h" #include "utils/PluginFactory.h" #include diff --git a/src/modules/interactiveterminal/InteractiveTerminalViewStep.h b/src/modules/interactiveterminal/InteractiveTerminalViewStep.h index 55486691d..f0af35d3c 100644 --- a/src/modules/interactiveterminal/InteractiveTerminalViewStep.h +++ b/src/modules/interactiveterminal/InteractiveTerminalViewStep.h @@ -25,7 +25,7 @@ #include #include -#include +#include class InteractiveTerminalPage; diff --git a/src/modules/keyboard/KeyboardViewStep.h b/src/modules/keyboard/KeyboardViewStep.h index a5bdd579e..9f362e116 100644 --- a/src/modules/keyboard/KeyboardViewStep.h +++ b/src/modules/keyboard/KeyboardViewStep.h @@ -25,7 +25,7 @@ #include #include -#include +#include class KeyboardPage; diff --git a/src/modules/license/LicenseViewStep.h b/src/modules/license/LicenseViewStep.h index 957110f3d..cc1a92896 100644 --- a/src/modules/license/LicenseViewStep.h +++ b/src/modules/license/LicenseViewStep.h @@ -20,7 +20,7 @@ #ifndef LICENSEPAGEPLUGIN_H #define LICENSEPAGEPLUGIN_H -#include +#include #include #include diff --git a/src/modules/locale/LocaleViewStep.h b/src/modules/locale/LocaleViewStep.h index eb8d64177..841aba97f 100644 --- a/src/modules/locale/LocaleViewStep.h +++ b/src/modules/locale/LocaleViewStep.h @@ -25,7 +25,7 @@ #include "utils/PluginFactory.h" #include "viewpages/ViewStep.h" -#include "PluginDllMacro.h" +#include "DllMacro.h" #include #include diff --git a/src/modules/luksbootkeyfile/LuksBootKeyFileJob.h b/src/modules/luksbootkeyfile/LuksBootKeyFileJob.h index 2d4d6d319..de9b9c677 100644 --- a/src/modules/luksbootkeyfile/LuksBootKeyFileJob.h +++ b/src/modules/luksbootkeyfile/LuksBootKeyFileJob.h @@ -20,7 +20,7 @@ #define LUKSBOOTKEYFILEJOB_H #include "CppJob.h" -#include "PluginDllMacro.h" +#include "DllMacro.h" #include "utils/PluginFactory.h" #include diff --git a/src/modules/machineid/MachineIdJob.h b/src/modules/machineid/MachineIdJob.h index 5d44b2017..3e450accb 100644 --- a/src/modules/machineid/MachineIdJob.h +++ b/src/modules/machineid/MachineIdJob.h @@ -26,7 +26,7 @@ #include -#include +#include class PLUGINDLLEXPORT MachineIdJob : public Calamares::CppJob { diff --git a/src/modules/netinstall/NetInstallViewStep.h b/src/modules/netinstall/NetInstallViewStep.h index b07d3f96d..f26ba74ed 100644 --- a/src/modules/netinstall/NetInstallViewStep.h +++ b/src/modules/netinstall/NetInstallViewStep.h @@ -23,7 +23,7 @@ #include #include -#include +#include #include diff --git a/src/modules/notesqml/NotesQmlViewStep.h b/src/modules/notesqml/NotesQmlViewStep.h index 445b34c81..5ffd4598e 100644 --- a/src/modules/notesqml/NotesQmlViewStep.h +++ b/src/modules/notesqml/NotesQmlViewStep.h @@ -20,7 +20,7 @@ #ifndef NOTESQMLVIEWSTEP_H #define NOTESQMLVIEWSTEP_H -#include "PluginDllMacro.h" +#include "DllMacro.h" #include "locale/TranslatableConfiguration.h" #include "utils/CalamaresUtilsSystem.h" #include "utils/Variant.h" diff --git a/src/modules/oemid/OEMViewStep.h b/src/modules/oemid/OEMViewStep.h index d8722594a..57e2bba66 100644 --- a/src/modules/oemid/OEMViewStep.h +++ b/src/modules/oemid/OEMViewStep.h @@ -22,7 +22,7 @@ #include #include -#include +#include #include diff --git a/src/modules/packagechooser/PackageChooserViewStep.h b/src/modules/packagechooser/PackageChooserViewStep.h index 29e65ef82..9e9087971 100644 --- a/src/modules/packagechooser/PackageChooserViewStep.h +++ b/src/modules/packagechooser/PackageChooserViewStep.h @@ -19,7 +19,7 @@ #ifndef PACKAGECHOOSERVIEWSTEP_H #define PACKAGECHOOSERVIEWSTEP_H -#include "PluginDllMacro.h" +#include "DllMacro.h" #include "locale/TranslatableConfiguration.h" #include "utils/PluginFactory.h" #include "viewpages/ViewStep.h" diff --git a/src/modules/partition/gui/PartitionViewStep.h b/src/modules/partition/gui/PartitionViewStep.h index 0a62b3aa3..f60dff1df 100644 --- a/src/modules/partition/gui/PartitionViewStep.h +++ b/src/modules/partition/gui/PartitionViewStep.h @@ -24,7 +24,7 @@ #include #include -#include +#include #include "core/PartitionActions.h" diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h index 01db17821..e99418549 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.h +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include #include diff --git a/src/modules/preservefiles/PreserveFiles.h b/src/modules/preservefiles/PreserveFiles.h index ed2fe889c..587ac9bab 100644 --- a/src/modules/preservefiles/PreserveFiles.h +++ b/src/modules/preservefiles/PreserveFiles.h @@ -24,7 +24,7 @@ #include #include "CppJob.h" -#include "PluginDllMacro.h" +#include "DllMacro.h" #include "utils/PluginFactory.h" diff --git a/src/modules/shellprocess/ShellProcessJob.h b/src/modules/shellprocess/ShellProcessJob.h index d532aac99..708a43087 100644 --- a/src/modules/shellprocess/ShellProcessJob.h +++ b/src/modules/shellprocess/ShellProcessJob.h @@ -20,7 +20,7 @@ #define SHELLPROCESSJOB_H #include "CppJob.h" -#include "PluginDllMacro.h" +#include "DllMacro.h" #include "utils/CommandList.h" #include "utils/PluginFactory.h" diff --git a/src/modules/summary/SummaryViewStep.h b/src/modules/summary/SummaryViewStep.h index 88f177a4d..2c873e168 100644 --- a/src/modules/summary/SummaryViewStep.h +++ b/src/modules/summary/SummaryViewStep.h @@ -24,7 +24,7 @@ #include #include -#include +#include class SummaryPage; diff --git a/src/modules/tracking/TrackingViewStep.h b/src/modules/tracking/TrackingViewStep.h index dc952253a..df6497d68 100644 --- a/src/modules/tracking/TrackingViewStep.h +++ b/src/modules/tracking/TrackingViewStep.h @@ -21,7 +21,7 @@ #include "TrackingType.h" -#include +#include #include #include diff --git a/src/modules/users/UsersViewStep.h b/src/modules/users/UsersViewStep.h index 6fced76b9..74bdb84c4 100644 --- a/src/modules/users/UsersViewStep.h +++ b/src/modules/users/UsersViewStep.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include diff --git a/src/modules/webview/WebViewStep.h b/src/modules/webview/WebViewStep.h index c588318fa..9ee2dfac9 100644 --- a/src/modules/webview/WebViewStep.h +++ b/src/modules/webview/WebViewStep.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include diff --git a/src/modules/welcome/WelcomeViewStep.h b/src/modules/welcome/WelcomeViewStep.h index 4d8fa160f..217f827e9 100644 --- a/src/modules/welcome/WelcomeViewStep.h +++ b/src/modules/welcome/WelcomeViewStep.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include diff --git a/src/modules/welcomeq/WelcomeQmlViewStep.h b/src/modules/welcomeq/WelcomeQmlViewStep.h index 5486d8d31..468dd7621 100644 --- a/src/modules/welcomeq/WelcomeQmlViewStep.h +++ b/src/modules/welcomeq/WelcomeQmlViewStep.h @@ -25,7 +25,7 @@ #include "utils/PluginFactory.h" #include "viewpages/ViewStep.h" -#include +#include #include #include From 92260e7d0bbe5915f1c63f9036d6b7fd255bee22 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 11:43:20 +0100 Subject: [PATCH 03/10] [libcalamares] Document DllMacro.h and add STATICTEST - document the export macros - introduce a "static" that is switched off when re-building code for tests. --- src/libcalamares/DllMacro.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/libcalamares/DllMacro.h b/src/libcalamares/DllMacro.h index 865d91d57..9bb789c94 100644 --- a/src/libcalamares/DllMacro.h +++ b/src/libcalamares/DllMacro.h @@ -21,6 +21,10 @@ #include +/* + * Mark symbols exported from Calamares libraries with DLLEXPORT. + * These are the public API of the libraries. + */ #ifndef DLLEXPORT #if defined( DLLEXPORT_PRO ) #define DLLEXPORT Q_DECL_EXPORT @@ -29,6 +33,11 @@ #endif #endif +/* + * Mark symbols exported from Calamares C++ plugins with PLUGINDLLEXPORT. + * These are the public API of the libraries (generally, the plugin + * entry point) + */ #ifndef PLUGINDLLEXPORT #if defined( PLUGINDLLEXPORT_PRO ) #define PLUGINDLLEXPORT Q_DECL_EXPORT @@ -37,4 +46,17 @@ #endif #endif +/* + * For functions that should be static in production but also need to + * be tested, use STATICTEST as linkage specifier. When built as part + * of a test, the function will be given normal linkage. + */ +#ifndef STATICTEST +#if defined( BUILD_AS_TEST ) +#define STATICTEST +#else +#define STATICTEST static +#endif +#endif + #endif From b42520b0ef9d05586a840fa5957daca2cb633521 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 11:51:56 +0100 Subject: [PATCH 04/10] [machineid] Apply new STATICTEST specifier, hide implementation details --- src/modules/machineid/Tests.cpp | 7 ++-- src/modules/machineid/Workers.cpp | 55 ++++++++++++++++--------------- src/modules/machineid/Workers.h | 3 -- 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/modules/machineid/Tests.cpp b/src/modules/machineid/Tests.cpp index 53abd0482..874fac3cb 100644 --- a/src/modules/machineid/Tests.cpp +++ b/src/modules/machineid/Tests.cpp @@ -28,6 +28,9 @@ #include #include +// Internals of Workers.cpp +extern int getUrandomPoolSize(); + class MachineIdTests : public QObject { Q_OBJECT @@ -93,10 +96,10 @@ MachineIdTests::testPoolSize() { #ifdef Q_OS_FREEBSD // It hardly makes sense, but also the /proc entry is missing - QCOMPARE( MachineId::getUrandomPoolSize(), 512 ); + QCOMPARE( getUrandomPoolSize(), 512 ); #else // Based on a sample size of 1, Netrunner - QCOMPARE( MachineId::getUrandomPoolSize(), 4096 ); + QCOMPARE( getUrandomPoolSize(), 4096 ); #endif } diff --git a/src/modules/machineid/Workers.cpp b/src/modules/machineid/Workers.cpp index 39acdfbf2..76e466435 100644 --- a/src/modules/machineid/Workers.cpp +++ b/src/modules/machineid/Workers.cpp @@ -27,6 +27,34 @@ #include +/// @brief Returns a recommended size for the entropy pool (in bytes) +STATICTEST int +getUrandomPoolSize() +{ + QFile f( "/proc/sys/kernel/random/poolsize" ); + constexpr const int minimumPoolSize = 512; + int poolSize = minimumPoolSize; + + if ( f.exists() && f.open( QIODevice::ReadOnly | QIODevice::Text ) ) + { + QByteArray v = f.read( 16 ); + if ( v.length() > 2 ) + { + if ( v.endsWith( '\n' ) ) + { + v.chop( 1 ); + } + bool ok = false; + poolSize = v.toInt( &ok ); + if ( !ok ) + { + poolSize = minimumPoolSize; + } + } + } + return ( poolSize >= minimumPoolSize ) ? poolSize : minimumPoolSize; +} + namespace MachineId { @@ -59,33 +87,6 @@ copyFile( const QString& rootMountPoint, const QString& fileName ) return Calamares::JobResult::ok(); } -int -getUrandomPoolSize() -{ - QFile f( "/proc/sys/kernel/random/poolsize" ); - constexpr const int minimumPoolSize = 512; - int poolSize = minimumPoolSize; - - if ( f.exists() && f.open( QIODevice::ReadOnly | QIODevice::Text ) ) - { - QByteArray v = f.read( 16 ); - if ( v.length() > 2 ) - { - if ( v.endsWith( '\n' ) ) - { - v.chop( 1 ); - } - bool ok = false; - poolSize = v.toInt( &ok ); - if ( !ok ) - { - poolSize = minimumPoolSize; - } - } - } - return ( poolSize >= minimumPoolSize ) ? poolSize : minimumPoolSize; -} - Calamares::JobResult createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fileName ) { diff --git a/src/modules/machineid/Workers.h b/src/modules/machineid/Workers.h index 31561af1b..8cb8d74ff 100644 --- a/src/modules/machineid/Workers.h +++ b/src/modules/machineid/Workers.h @@ -48,9 +48,6 @@ enum class EntropyGeneration CopyFromHost }; -/// @brief Returns a recommended size for the entropy pool (in bytes) -int getUrandomPoolSize(); - /// @brief Creates a new entropy file @p fileName in the target system at @p rootMountPoint Calamares::JobResult createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fileName ); From 6bdc4a55de09c3b66fe43d661aecc0a774089602 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 12:02:53 +0100 Subject: [PATCH 05/10] CMake: new convenience module CalamaresAddTest --- CMakeLists.txt | 7 ++-- CMakeModules/CalamaresAddTest.cmake | 57 +++++++++++++++++++++++++++++ src/CMakeLists.txt | 1 + 3 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 CMakeModules/CalamaresAddTest.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5bfe0fbab..479009faf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -549,10 +549,11 @@ install( "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake" "${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake" "${PROJECT_BINARY_DIR}/CalamaresUse.cmake" - "CMakeModules/CalamaresAddPlugin.cmake" - "CMakeModules/CalamaresAddModuleSubdirectory.cmake" - "CMakeModules/CalamaresAddLibrary.cmake" "CMakeModules/CalamaresAddBrandingSubdirectory.cmake" + "CMakeModules/CalamaresAddLibrary.cmake" + "CMakeModules/CalamaresAddModuleSubdirectory.cmake" + "CMakeModules/CalamaresAddPlugin.cmake" + "CMakeModules/CalamaresAddTest.cmake" "CMakeModules/CalamaresAddTranslations.cmake" "CMakeModules/CalamaresAutomoc.cmake" "CMakeModules/CMakeColors.cmake" diff --git a/CMakeModules/CalamaresAddTest.cmake b/CMakeModules/CalamaresAddTest.cmake new file mode 100644 index 000000000..2f8b1adb3 --- /dev/null +++ b/CMakeModules/CalamaresAddTest.cmake @@ -0,0 +1,57 @@ +# === This file is part of Calamares - === +# +# Calamares is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Calamares 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Calamares. If not, see . +# +# SPDX-License-Identifier: GPL-3.0+ +# License-Filename: LICENSE +# +### +# +# Support functions for building Calamares tests. +# This extends KDE's ECM tests with some custom patterns. +# +# calamares_add_test( +# +# [GUI] +# SOURCES +# ) + +include( CMakeParseArguments ) +include( CalamaresAutomoc ) + +function( calamares_add_test ) + # parse arguments (name needs to be saved before passing ARGN into the macro) + set( NAME ${ARGV0} ) + set( options GUI ) + set( multiValueArgs SOURCES ) + cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} ) + set( TEST_NAME ${NAME} ) + + if( ECM_FOUND AND BUILD_TESTING ) + ecm_add_test( + ${TEST_SOURCES} + TEST_NAME + ${TEST_NAME} + LINK_LIBRARIES + calamares + Qt5::Core + Qt5::Test + ) + calamares_automoc( ${TEST_NAME} ) + target_compile_definitions( ${TEST_NAME} PRIVATE -DBUILD_AS_TEST ) + if( TEST_GUI ) + target_link_libraries( ${TEST_NAME} PRIVATE calamaresui Qt5::Gui ) + endif() + endif() +endfunction() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b73fecda0..1445b18f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,7 @@ include( CalamaresAddPlugin ) include( CalamaresAddModuleSubdirectory ) include( CalamaresAddLibrary ) include( CalamaresAddBrandingSubdirectory ) +include( CalamaresAddTest ) # library add_subdirectory( libcalamares ) From 637a57d534cb49f95ab313e5b6783a17ab7d108c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 12:04:18 +0100 Subject: [PATCH 06/10] [machineid] Change to calamares_add_test - The test-macro handles cases without ECM or testing transparently. - Adds compile defines for STATICTEST. --- src/modules/machineid/CMakeLists.txt | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/modules/machineid/CMakeLists.txt b/src/modules/machineid/CMakeLists.txt index a57d5163d..4a916334c 100644 --- a/src/modules/machineid/CMakeLists.txt +++ b/src/modules/machineid/CMakeLists.txt @@ -9,17 +9,10 @@ calamares_add_plugin( machineid SHARED_LIB ) -if ( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - Tests.cpp - MachineIdJob.cpp - Workers.cpp - TEST_NAME - machineidtest - LINK_LIBRARIES - calamares - Qt5::Core - Qt5::Test - ) - calamares_automoc( machineidtest ) -endif() +calamares_add_test( + machineidtest + SOURCES + Tests.cpp + MachineIdJob.cpp + Workers.cpp +) From 4495a4c739f3c3586b8f03425d6982aa5a0aac5d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 14:36:52 +0100 Subject: [PATCH 07/10] CMake: Allow extra libraries in calamares_add_test - Extra libraries specified via LIBRARIES part of CMake function - Convert all the other module tests --- CMakeModules/CalamaresAddTest.cmake | 5 ++-- src/modules/contextualprocess/CMakeLists.txt | 24 ++++++++------------ src/modules/fsresizer/CMakeLists.txt | 24 ++++++++------------ src/modules/hostinfo/CMakeLists.txt | 24 ++++++++------------ src/modules/initcpio/CMakeLists.txt | 24 ++++++++------------ src/modules/initramfs/CMakeLists.txt | 24 ++++++++------------ src/modules/locale/CMakeLists.txt | 18 +++++---------- src/modules/packagechooser/CMakeLists.txt | 24 ++++++++------------ src/modules/partition/tests/CMakeLists.txt | 18 ++++++--------- src/modules/shellprocess/CMakeLists.txt | 22 +++++++----------- src/modules/users/CMakeLists.txt | 22 +++++++----------- 11 files changed, 86 insertions(+), 143 deletions(-) diff --git a/CMakeModules/CalamaresAddTest.cmake b/CMakeModules/CalamaresAddTest.cmake index 2f8b1adb3..f1f6fdf3f 100644 --- a/CMakeModules/CalamaresAddTest.cmake +++ b/CMakeModules/CalamaresAddTest.cmake @@ -34,7 +34,7 @@ function( calamares_add_test ) # parse arguments (name needs to be saved before passing ARGN into the macro) set( NAME ${ARGV0} ) set( options GUI ) - set( multiValueArgs SOURCES ) + set( multiValueArgs SOURCES LIBRARIES ) cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} ) set( TEST_NAME ${NAME} ) @@ -45,13 +45,14 @@ function( calamares_add_test ) ${TEST_NAME} LINK_LIBRARIES calamares + ${TEST_LIBRARIES} Qt5::Core Qt5::Test ) calamares_automoc( ${TEST_NAME} ) target_compile_definitions( ${TEST_NAME} PRIVATE -DBUILD_AS_TEST ) if( TEST_GUI ) - target_link_libraries( ${TEST_NAME} PRIVATE calamaresui Qt5::Gui ) + target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui ) endif() endif() endfunction() diff --git a/src/modules/contextualprocess/CMakeLists.txt b/src/modules/contextualprocess/CMakeLists.txt index a7e9ed05b..05ed9a91b 100644 --- a/src/modules/contextualprocess/CMakeLists.txt +++ b/src/modules/contextualprocess/CMakeLists.txt @@ -8,18 +8,12 @@ calamares_add_plugin( contextualprocess SHARED_LIB ) -if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - Tests.cpp - ContextualProcessJob.cpp # Builds it a second time - TEST_NAME - contextualprocesstest - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - calamaresui - ${YAMLCPP_LIBRARY} - Qt5::Core - Qt5::Test - ) - calamares_automoc( contextualprocesstest ) -endif() +calamares_add_test( + contextualprocesstest + GUI # It's not + SOURCES + Tests.cpp + ContextualProcessJob.cpp # Builds it a second time + LIBRARIES + ${YAMLCPP_LIBRARY} +) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 3d82489b7..37890f66e 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -30,21 +30,15 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND SHARED_LIB ) - if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - Tests.cpp - TEST_NAME - fsresizertest - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - calamares - calamares_job_fsresizer # From above - ${YAMLCPP_LIBRARY} - Qt5::Core - Qt5::Test - ) - set_target_properties( fsresizertest PROPERTIES AUTOMOC TRUE ) - target_include_directories( fsresizertest PRIVATE /usr/local/include ) + calamares_add_test( + fsresizertest + SOURCES + Tests.cpp + LIBRARIES + calamares_job_fsresizer # From above + ${YAMLCPP_LIBRARY} + ) + if( TARGET fsresizertest ) target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} ) endif() else() diff --git a/src/modules/hostinfo/CMakeLists.txt b/src/modules/hostinfo/CMakeLists.txt index caf888625..125254ef9 100644 --- a/src/modules/hostinfo/CMakeLists.txt +++ b/src/modules/hostinfo/CMakeLists.txt @@ -32,18 +32,12 @@ if ( KF5CoreAddons_FOUND AND KF5CoreAddons_VERSION VERSION_GREATER_EQUAL 5.58 ) target_compile_definitions( calamares_job_hostinfo PRIVATE WITH_KOSRelease ) endif() -if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - Tests.cpp - HostInfoJob.cpp # Builds it a second time - TEST_NAME - hostinfotest - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - calamaresui - ${YAMLCPP_LIBRARY} - Qt5::Core - Qt5::Test - ) - calamares_automoc( hostinfotest ) -endif() +calamares_add_test( + hostinfotest + GUI # It's not + SOURCES + Tests.cpp + HostInfoJob.cpp + LIBRARIES + ${YAMLCPP_LIBRARY} +) diff --git a/src/modules/initcpio/CMakeLists.txt b/src/modules/initcpio/CMakeLists.txt index af217fb1a..fc0daea6f 100644 --- a/src/modules/initcpio/CMakeLists.txt +++ b/src/modules/initcpio/CMakeLists.txt @@ -8,18 +8,12 @@ calamares_add_plugin( initcpio SHARED_LIB ) -if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - Tests.cpp - TEST_NAME - initcpiotest - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - calamares - calamares_job_initcpio # From above - ${YAMLCPP_LIBRARY} - Qt5::Core - Qt5::Test - ) - calamares_automoc( initcpiotest ) -endif() +calamares_add_test( + initcpiotest + GUI # It's not + SOURCES + Tests.cpp + LIBRARIES + calamares_job_initcpio # From above + ${YAMLCPP_LIBRARY} +) diff --git a/src/modules/initramfs/CMakeLists.txt b/src/modules/initramfs/CMakeLists.txt index d7da12d55..7b59e140d 100644 --- a/src/modules/initramfs/CMakeLists.txt +++ b/src/modules/initramfs/CMakeLists.txt @@ -8,18 +8,12 @@ calamares_add_plugin( initramfs SHARED_LIB ) -if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - Tests.cpp - TEST_NAME - initramfstest - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - calamares - calamares_job_initramfs # From above - ${YAMLCPP_LIBRARY} - Qt5::Core - Qt5::Test - ) - calamares_automoc( initramfstest ) -endif() +calamares_add_test( + initramfstest + GUI # It's not + SOURCES + Tests.cpp + LIBRARIES + calamares_job_initramfs # From above + ${YAMLCPP_LIBRARY} +) diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 768a67543..58788541e 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -31,15 +31,9 @@ calamares_add_plugin( locale SHARED_LIB ) -if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - Tests.cpp - LocaleConfiguration.cpp - TEST_NAME - localetest - LINK_LIBRARIES - calamares - Qt5::Test - ) - calamares_automoc( localetest ) -endif() +calamares_add_test( + localetest + SOURCES + Tests.cpp + LocaleConfiguration.cpp +) diff --git a/src/modules/packagechooser/CMakeLists.txt b/src/modules/packagechooser/CMakeLists.txt index eeae655c9..d85eda8e2 100644 --- a/src/modules/packagechooser/CMakeLists.txt +++ b/src/modules/packagechooser/CMakeLists.txt @@ -53,18 +53,12 @@ calamares_add_plugin( packagechooser SHARED_LIB ) -if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - Tests.cpp - TEST_NAME - packagechoosertest - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - calamares_viewmodule_packagechooser - Qt5::Core - Qt5::Test - Qt5::Gui - ${_extra_libraries} - ) - calamares_automoc( packagechoosertest) -endif() +calamares_add_test( + packagechoosertest + GUI + SOURCES + Tests.cpp + LIBRARIES + calamares_viewmodule_packagechooser + ${_extra_libraries} +) diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index ac3968df9..fdba7e688 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -21,16 +21,12 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) -if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( ${partitionjobtests_SRCS} - TEST_NAME partitionjobtests - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - kpmcore - Qt5::Core - Qt5::Test - ) - - set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE ) +calamares_add_test( + partitionjobtests + SOURCES ${partitionjobtests_SRCS} + LIBRARIES + kpmcore +) +if( TARGET partitionjobtests ) target_compile_definitions( partitionjobtests PRIVATE ${_partition_defs} ) endif() diff --git a/src/modules/shellprocess/CMakeLists.txt b/src/modules/shellprocess/CMakeLists.txt index 166dff17d..3899ef642 100644 --- a/src/modules/shellprocess/CMakeLists.txt +++ b/src/modules/shellprocess/CMakeLists.txt @@ -8,17 +8,11 @@ calamares_add_plugin( shellprocess SHARED_LIB ) -if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - Tests.cpp - TEST_NAME - shellprocesstest - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - calamaresui - ${YAMLCPP_LIBRARY} - Qt5::Core - Qt5::Test - ) - calamares_automoc( shellprocesstest ) -endif() +calamares_add_test( + shellprocesstest + GUI # It's not + SOURCES + Tests.cpp + LIBRARIES + ${YAMLCPP_LIBRARY} +) diff --git a/src/modules/users/CMakeLists.txt b/src/modules/users/CMakeLists.txt index d0e7b6d9d..75d2233c4 100644 --- a/src/modules/users/CMakeLists.txt +++ b/src/modules/users/CMakeLists.txt @@ -39,17 +39,11 @@ calamares_add_plugin( users SHARED_LIB ) -if( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - PasswordTests.cpp - SetPasswordJob.cpp - TEST_NAME - passwordtest - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - Qt5::Core - Qt5::Test - ${CRYPT_LIBRARIES} - ) - calamares_automoc( passwordtest ) -endif() +calamares_add_test( + passwordtest + SOURCES + PasswordTests.cpp + SetPasswordJob.cpp + LIBRARIES + ${CRYPT_LIBRARIES} +) From 6f996d8eedb80d9d53de14595f26f2119ef3bdcb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 14:55:12 +0100 Subject: [PATCH 08/10] CMake: give yamlcpp a proper imported target - This makes linking easier, - Adds the right includes (needed on FreeBSD), - Lets us drop silly GUI setting for non-GUI tests (I think this was a side-effect of compiling on FreeBSD, where UI would pull in /usr/local/include). --- CMakeModules/FindYAMLCPP.cmake | 17 ++++++++++++++--- src/modules/contextualprocess/CMakeLists.txt | 3 +-- src/modules/fsresizer/CMakeLists.txt | 2 +- src/modules/hostinfo/CMakeLists.txt | 3 +-- src/modules/initcpio/CMakeLists.txt | 3 +-- src/modules/initramfs/CMakeLists.txt | 3 +-- src/modules/locale/CMakeLists.txt | 2 +- src/modules/shellprocess/CMakeLists.txt | 3 +-- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/CMakeModules/FindYAMLCPP.cmake b/CMakeModules/FindYAMLCPP.cmake index 1ec9798d5..395c794bb 100644 --- a/CMakeModules/FindYAMLCPP.cmake +++ b/CMakeModules/FindYAMLCPP.cmake @@ -1,9 +1,11 @@ # Locate yaml-cpp # # This module defines -# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp -# YAMLCPP_LIBRARY, where to find yaml-cpp -# YAMLCPP_INCLUDE_DIR, where to find yaml.h +# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp +# YAMLCPP_LIBRARY, where to find yaml-cpp +# YAMLCPP_INCLUDE_DIR, where to find yaml.h +# There is also one IMPORTED library target, +# yamlcpp # # By default, the dynamic libraries of yaml-cpp will be found. To find the static ones instead, # you must set the YAMLCPP_STATIC_LIBRARY variable to TRUE before calling find_package(YamlCpp ...). @@ -48,3 +50,12 @@ find_library(YAMLCPP_LIBRARY include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY) + +# Add an imported target +if( YAMLCPP_LIBRARY ) + add_library( yamlcpp UNKNOWN IMPORTED ) + set_property( TARGET yamlcpp PROPERTY IMPORTED_LOCATION ${YAMLCPP_LIBRARY} ) + if ( YAMLCPP_INCLUDE_DIR ) + set_property( TARGET yamlcpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${YAMLCPP_INCLUDE_DIR} ) + endif() +endif() diff --git a/src/modules/contextualprocess/CMakeLists.txt b/src/modules/contextualprocess/CMakeLists.txt index 05ed9a91b..2df4cfe37 100644 --- a/src/modules/contextualprocess/CMakeLists.txt +++ b/src/modules/contextualprocess/CMakeLists.txt @@ -10,10 +10,9 @@ calamares_add_plugin( contextualprocess calamares_add_test( contextualprocesstest - GUI # It's not SOURCES Tests.cpp ContextualProcessJob.cpp # Builds it a second time LIBRARIES - ${YAMLCPP_LIBRARY} + yamlcpp ) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 37890f66e..01f673eb8 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -36,7 +36,7 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND Tests.cpp LIBRARIES calamares_job_fsresizer # From above - ${YAMLCPP_LIBRARY} + yamlcpp ) if( TARGET fsresizertest ) target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} ) diff --git a/src/modules/hostinfo/CMakeLists.txt b/src/modules/hostinfo/CMakeLists.txt index 125254ef9..3d6e0973f 100644 --- a/src/modules/hostinfo/CMakeLists.txt +++ b/src/modules/hostinfo/CMakeLists.txt @@ -34,10 +34,9 @@ endif() calamares_add_test( hostinfotest - GUI # It's not SOURCES Tests.cpp HostInfoJob.cpp LIBRARIES - ${YAMLCPP_LIBRARY} + yamlcpp ) diff --git a/src/modules/initcpio/CMakeLists.txt b/src/modules/initcpio/CMakeLists.txt index fc0daea6f..5140c97e0 100644 --- a/src/modules/initcpio/CMakeLists.txt +++ b/src/modules/initcpio/CMakeLists.txt @@ -10,10 +10,9 @@ calamares_add_plugin( initcpio calamares_add_test( initcpiotest - GUI # It's not SOURCES Tests.cpp LIBRARIES calamares_job_initcpio # From above - ${YAMLCPP_LIBRARY} + yamlcpp ) diff --git a/src/modules/initramfs/CMakeLists.txt b/src/modules/initramfs/CMakeLists.txt index 7b59e140d..b3287c896 100644 --- a/src/modules/initramfs/CMakeLists.txt +++ b/src/modules/initramfs/CMakeLists.txt @@ -10,10 +10,9 @@ calamares_add_plugin( initramfs calamares_add_test( initramfstest - GUI # It's not SOURCES Tests.cpp LIBRARIES calamares_job_initramfs # From above - ${YAMLCPP_LIBRARY} + yamlcpp ) diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 58788541e..cae2ea41c 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -27,7 +27,7 @@ calamares_add_plugin( locale calamaresui Qt5::Network ${geoip_libs} - ${YAMLCPP_LIBRARY} + yamlcpp SHARED_LIB ) diff --git a/src/modules/shellprocess/CMakeLists.txt b/src/modules/shellprocess/CMakeLists.txt index 3899ef642..ec1cf0bcf 100644 --- a/src/modules/shellprocess/CMakeLists.txt +++ b/src/modules/shellprocess/CMakeLists.txt @@ -10,9 +10,8 @@ calamares_add_plugin( shellprocess calamares_add_test( shellprocesstest - GUI # It's not SOURCES Tests.cpp LIBRARIES - ${YAMLCPP_LIBRARY} + yamlcpp ) From 51e135cfbd3a24ec5b23b18ed99f195911455143 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 15:01:05 +0100 Subject: [PATCH 09/10] CMake: chase introduction of IMPORTED yamlcpp --- src/libcalamares/CMakeLists.txt | 6 ++---- src/modules/CMakeLists.txt | 2 +- src/modules/netinstall/CMakeLists.txt | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index cad7e7a6e..ae927eda1 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -74,7 +74,6 @@ mark_thirdparty_code( ${kdsagSources} ) include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} - ${YAMLCPP_INCLUDE_DIR} ) ### OPTIONAL Python support @@ -126,7 +125,7 @@ target_link_libraries( calamares LINK_PRIVATE ${OPTIONAL_PRIVATE_LIBRARIES} LINK_PUBLIC - ${YAMLCPP_LIBRARY} + yamlcpp Qt5::Core KF5::CoreAddons ${OPTIONAL_PUBLIC_LIBRARIES} @@ -191,7 +190,6 @@ if ( ECM_FOUND AND BUILD_TESTING ) LINK_LIBRARIES calamares Qt5::Test - ${YAMLCPP_LIBRARY} ) calamares_automoc( geoiptest ) @@ -238,6 +236,6 @@ endif() if( BUILD_TESTING ) add_executable( test_geoip geoip/test_geoip.cpp ${geoip_src} ) - target_link_libraries( test_geoip calamares Qt5::Network ${YAMLCPP_LIBRARY} ) + target_link_libraries( test_geoip calamares Qt5::Network yamlcpp ) calamares_automoc( test_geoip ) endif() diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 9e9621106..b72b755d3 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -12,7 +12,7 @@ include_directories( if( BUILD_TESTING ) add_executable( test_conf test_conf.cpp ) - target_link_libraries( test_conf ${YAMLCPP_LIBRARY} Qt5::Core ) + target_link_libraries( test_conf yamlcpp Qt5::Core ) target_include_directories( test_conf PUBLIC ${YAMLCPP_INCLUDE_DIR} ) endif() diff --git a/src/modules/netinstall/CMakeLists.txt b/src/modules/netinstall/CMakeLists.txt index 67f805734..c5eddd32b 100644 --- a/src/modules/netinstall/CMakeLists.txt +++ b/src/modules/netinstall/CMakeLists.txt @@ -1,5 +1,3 @@ -include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui ) - calamares_add_plugin( netinstall TYPE viewmodule EXPORT_MACRO PLUGINDLLEXPORT_PRO @@ -15,6 +13,6 @@ calamares_add_plugin( netinstall LINK_PRIVATE_LIBRARIES calamaresui Qt5::Network - ${YAMLCPP_LIBRARY} + yamlcpp SHARED_LIB ) From 6719a41aef0af3776a4d0a55443d6c4131bbb39f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Feb 2020 15:05:00 +0100 Subject: [PATCH 10/10] [libcalamares] Switch tests to calamares_add_test() --- src/libcalamares/CMakeLists.txt | 105 +++++++++++--------------------- 1 file changed, 36 insertions(+), 69 deletions(-) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index ae927eda1..803c46870 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -158,81 +158,48 @@ install( FILES ${utilsHeaders} DESTINATION include/libcalam ### TESTING # # -if ( ECM_FOUND AND BUILD_TESTING ) - ecm_add_test( - utils/Tests.cpp - TEST_NAME - libcalamarestest - LINK_LIBRARIES - calamares - Qt5::Core - Qt5::Test - ) - calamares_automoc( libcalamarestest ) +calamares_add_test( + libcalamarestest + SOURCES + utils/Tests.cpp +) - ecm_add_test( - utils/TestPaths.cpp - TEST_NAME - libcalamarestestpaths - LINK_LIBRARIES - calamares - Qt5::Core - Qt5::Test - ) - calamares_automoc( libcalamarestestpaths ) +calamares_add_test( + libcalamarestestpaths + SOURCES + utils/TestPaths.cpp +) +calamares_add_test( + geoiptest + SOURCES + geoip/GeoIPTests.cpp + ${geoip_src} +) - ecm_add_test( - geoip/GeoIPTests.cpp - ${geoip_src} - TEST_NAME - geoiptest - LINK_LIBRARIES - calamares - Qt5::Test - ) - calamares_automoc( geoiptest ) +calamares_add_test( + libcalamarespartitiontest + SOURCES + partition/Tests.cpp +) - ecm_add_test( - partition/Tests.cpp - TEST_NAME - libcalamarespartitiontest - LINK_LIBRARIES - calamares - Qt5::Test - ) - calamares_automoc( libcalamarespartitiontest ) +calamares_add_test( + libcalamareslocaletest + SOURCES + locale/Tests.cpp +) - ecm_add_test( - locale/Tests.cpp - TEST_NAME - libcalamareslocaletest - LINK_LIBRARIES - calamares - Qt5::Test - ) - calamares_automoc( libcalamareslocaletest ) +calamares_add_test( + libcalamaresnetworktest + SOURCES + network/Tests.cpp +) - ecm_add_test( - network/Tests.cpp - TEST_NAME - libcalamaresnetworktest - LINK_LIBRARIES - calamares - Qt5::Test - ) - calamares_automoc( libcalamaresnetworktest ) - - ecm_add_test( - modulesystem/Tests.cpp - TEST_NAME - libcalamaresmodulesystemtest - LINK_LIBRARIES - calamares - Qt5::Test - ) - calamares_automoc( libcalamaresmodulesystemtest ) -endif() +calamares_add_test( + libcalamaresmodulesystemtest + SOURCES + modulesystem/Tests.cpp +) if( BUILD_TESTING ) add_executable( test_geoip geoip/test_geoip.cpp ${geoip_src} )