From 0f8ae514592c46dc8465bc5830d7a830b68affe2 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 17 Oct 2015 19:05:00 +0100 Subject: Added support for include-what-you-use in a very simplistic fashion to the Scons build. This isn't exactly production ready because the qt headers are a nightmarish web of interdependencies but it's useful for checking. I've also removed a few unused include files it detected and corrected some things that upset clang in a big way. --- src/SConscript | 14 +++++++++++--- src/bbcode.cpp | 4 +--- src/browserdialog.cpp | 2 -- src/browserview.h | 4 +++- src/downloadmanager.cpp | 1 - src/helper.h | 2 +- src/loadmechanism.cpp | 2 +- src/loadmechanism.h | 2 +- src/modinfo.cpp | 1 - src/modinfo.h | 4 ++-- src/nxmaccessmanager.cpp | 1 - src/settings.cpp | 1 - src/settings.h | 10 +++++----- 13 files changed, 25 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/SConscript b/src/SConscript index f09db093..cd2d8a52 100644 --- a/src/SConscript +++ b/src/SConscript @@ -67,7 +67,6 @@ env.Uic(env.Glob('*.ui')) env.RequireLibraries('uibase', 'shared', 'bsatk', 'esptk') - env.AppendUnique(LIBS = [ 'shell32', 'user32', @@ -114,8 +113,9 @@ env.AppendUnique(LINKFLAGS = [ # modeltest is optional and it doesn't compile anyway... cpp_files = [ - x for x in Glob('*.cpp') - if x.name != 'modeltest.cpp' and x.name != 'aboutdialog.cpp' + x for x in env.Glob('*.cpp', source = True) + if x.name != 'modeltest.cpp' and x.name != 'aboutdialog.cpp' and \ + not x.name.startswith('moc_') # I think this is a strange bug ] about_env = env.Clone() @@ -143,6 +143,14 @@ env.AppendUnique(LIBS = 'zlibstatic') prog = env.Program('ModOrganizer', cpp_files + env.Glob('*.qrc') + other_sources) +############################################################################### +# I'd like to automatically add this to every .o generation. +if 'IWYU' in env: + for f in cpp_files + [ env.File('aboutdialog.cpp') ]: + env.AddPostAction(prog, "-$IWYU $IWYU_FLAGS -Xiwyu --mapping_file=$IWYU_MAPPING_FILE $IWYU_COMCOM " + str(f)) + env.Depends(prog, env['IWYU_MAPPING_FILE']) +############################################################################### + env.InstallModule(prog) for subdir in ('tutorials', 'stylesheets'): diff --git a/src/bbcode.cpp b/src/bbcode.cpp index 0f9170d4..56369538 100644 --- a/src/bbcode.cpp +++ b/src/bbcode.cpp @@ -21,8 +21,6 @@ along with Mod Organizer. If not, see . #include #include -#include -#include namespace BBCode { @@ -80,7 +78,7 @@ public: if (tagName == "color") { QString color = tagIter->second.first.cap(1); QString content = tagIter->second.first.cap(2); - if (color.at(0) == "#") { + if (color.at(0) == '#') { return temp.replace(tagIter->second.first, QString("%2").arg(color, content)); } else { auto colIter = m_ColorMap.find(color.toLower()); diff --git a/src/browserdialog.cpp b/src/browserdialog.cpp index c382c112..5e6bec00 100644 --- a/src/browserdialog.cpp +++ b/src/browserdialog.cpp @@ -25,8 +25,6 @@ along with Mod Organizer. If not, see . #include "report.h" #include "persistentcookiejar.h" -#include "json.h" - #include #include #include "settings.h" diff --git a/src/browserview.h b/src/browserview.h index f8b132b8..6a89752a 100644 --- a/src/browserview.h +++ b/src/browserview.h @@ -21,9 +21,11 @@ along with Mod Organizer. If not, see . #define NEXUSVIEW_H +class QEvent; +class QUrl; +class QWidget; #include #include -#include /** * @brief web view used to display a nexus page diff --git a/src/downloadmanager.cpp b/src/downloadmanager.cpp index bc78cdc6..1aaf4122 100644 --- a/src/downloadmanager.cpp +++ b/src/downloadmanager.cpp @@ -25,7 +25,6 @@ along with Mod Organizer. If not, see . #include #include #include "utility.h" -#include "json.h" #include "selectiondialog.h" #include "bbcode.h" #include diff --git a/src/helper.h b/src/helper.h index 36f10db1..410e2527 100644 --- a/src/helper.h +++ b/src/helper.h @@ -21,7 +21,7 @@ along with Mod Organizer. If not, see . #define HELPER_H -#include +#include /** diff --git a/src/loadmechanism.cpp b/src/loadmechanism.cpp index 4d06bea9..c01955f2 100644 --- a/src/loadmechanism.cpp +++ b/src/loadmechanism.cpp @@ -56,7 +56,7 @@ void LoadMechanism::writeHintFile(const QDir &targetDirectory) } -void LoadMechanism::removeHintFile(QDir &targetDirectory) +void LoadMechanism::removeHintFile(QDir targetDirectory) { targetDirectory.remove("mo_path.txt"); } diff --git a/src/loadmechanism.h b/src/loadmechanism.h index 43a8dd6c..c04473ab 100644 --- a/src/loadmechanism.h +++ b/src/loadmechanism.h @@ -91,7 +91,7 @@ private: void writeHintFile(const QDir &targetDirectory); // remove the hint file if it exists. does nothing if the file doesn't exist - void removeHintFile(QDir &targetDirectory); + void removeHintFile(QDir targetDirectory); // compare the two files by md5-hash, returns true if they are identical bool hashIdentical(const QString &fileNameLHS, const QString &fileNameRHS); diff --git a/src/modinfo.cpp b/src/modinfo.cpp index e0d888e6..ae64b81f 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -25,7 +25,6 @@ along with Mod Organizer. If not, see . #include "report.h" #include "modinfodialog.h" #include "overwriteinfodialog.h" -#include "json.h" #include "messagedialog.h" #include "filenamestring.h" diff --git a/src/modinfo.h b/src/modinfo.h index da97b09b..d9de60e8 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -1047,7 +1047,7 @@ public: virtual QString notes() const { return ""; } virtual QDateTime creationTime() const { return QDateTime(); } virtual QString absolutePath() const; - virtual MOBase::VersionInfo getNewestVersion() const { return ""; } + virtual MOBase::VersionInfo getNewestVersion() const { return QString(); } virtual QString getInstallationFile() const { return ""; } virtual int getFixedPriority() const { return INT_MAX; } virtual int getNexusID() const { return -1; } @@ -1099,7 +1099,7 @@ public: virtual QString notes() const { return ""; } virtual QDateTime creationTime() const; virtual QString absolutePath() const; - virtual MOBase::VersionInfo getNewestVersion() const { return ""; } + virtual MOBase::VersionInfo getNewestVersion() const { return QString(); } virtual QString getInstallationFile() const { return ""; } virtual int getNexusID() const { return -1; } virtual std::vector getIniTweaks() const { return std::vector(); } diff --git a/src/nxmaccessmanager.cpp b/src/nxmaccessmanager.cpp index 0763bb71..6ec282f6 100644 --- a/src/nxmaccessmanager.cpp +++ b/src/nxmaccessmanager.cpp @@ -25,7 +25,6 @@ along with Mod Organizer. If not, see . #include "persistentcookiejar.h" #include "settings.h" #include -#include #include #include #include diff --git a/src/settings.cpp b/src/settings.cpp index 4c2a34c8..b51ba71e 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -22,7 +22,6 @@ along with Mod Organizer. If not, see . #include "settingsdialog.h" #include "utility.h" #include "helper.h" -#include "json.h" #include #include #include diff --git a/src/settings.h b/src/settings.h index def1dc5c..580ffe42 100644 --- a/src/settings.h +++ b/src/settings.h @@ -328,7 +328,7 @@ private: }; /** Display/store the configuration in the 'general' tab of the settings dialogue */ - class GeneralTab : SettingsTab + class GeneralTab : public SettingsTab { public: GeneralTab(Settings *m_parent, SettingsDialog &m_dialog); @@ -347,7 +347,7 @@ private: }; /** Display/store the configuration in the 'nexus' tab of the settings dialogue */ - class NexusTab : SettingsTab + class NexusTab : public SettingsTab { public: NexusTab(Settings *m_parent, SettingsDialog &m_dialog); @@ -365,7 +365,7 @@ private: }; /** Display/store the configuration in the 'steam' tab of the settings dialogue */ - class SteamTab : SettingsTab + class SteamTab : public SettingsTab { public: SteamTab(Settings *m_parent, SettingsDialog &m_dialog); @@ -378,7 +378,7 @@ private: }; /** Display/store the configuration in the 'plugins' tab of the settings dialogue */ - class PluginsTab : SettingsTab + class PluginsTab : public SettingsTab { public: PluginsTab(Settings *m_parent, SettingsDialog &m_dialog); @@ -391,7 +391,7 @@ private: }; /** Display/store the configuration in the 'workarounds' tab of the settings dialogue */ - class WorkaroundsTab : SettingsTab + class WorkaroundsTab : public SettingsTab { public: WorkaroundsTab(Settings *m_parent, SettingsDialog &m_dialog); -- cgit v1.3.1