From 2fb491711188d413f65bdd8193644d25ae03c2c2 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 27 Sep 2015 13:29:04 +0100 Subject: Changes to go with cleaned up archive library --- src/SConscript | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/SConscript') diff --git a/src/SConscript b/src/SConscript index 6783fd8b..540b2343 100644 --- a/src/SConscript +++ b/src/SConscript @@ -72,7 +72,11 @@ env.AppendUnique(CPPDEFINES = [ 'QT_MESSAGELOGCONTEXT' ]) -env.AppendUnique(CPPFLAGS = [ '-wd4100', '-wd4127', '-wd4512', '-wd4189' ]) +# Boost produces very long names with msvc truncates. Doesn't seem to cause +# problems. +# Also note to remove the -wd4100 I hacked the boost headers (tagged_argument.hpp) +# appropriately. +env.AppendUnique(CPPFLAGS = [ '-wd4503' ]) env.AppendUnique(LINKFLAGS = [ '/SUBSYSTEM:WINDOWS', -- cgit v1.3.1 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. --- qtmappings.imp | 195 ++++++++++++++++++++++++++++++++++++++++++++ scons_configure_template.py | 3 + 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 +-- 15 files changed, 223 insertions(+), 23 deletions(-) create mode 100644 qtmappings.imp (limited to 'src/SConscript') diff --git a/qtmappings.imp b/qtmappings.imp new file mode 100644 index 00000000..3dc2e5f5 --- /dev/null +++ b/qtmappings.imp @@ -0,0 +1,195 @@ +[ +# Overrides. Some classes are defined by the spec to reside in their own headers but actually use the same +# header as another class. It might make some sense using this for every class in QT... + { symbol: [ "QAbstractTableModel", "private", "", "public" ] }, + { symbol: [ "QAtomicInt", "private", "", "public"] }, + { symbol: [ "QDate", "private", "", "public"] }, + { symbol: [ "QKeyEvent", "private", "", "public" ] }, + { symbol: [ "QDragEnterEvent", "private", "", "public" ] }, + { symbol: [ "QListWidgetItem", "private", "", "public" ] }, + { symbol: [ "QModelIndex", "private", "", "public" ] }, + { symbol: [ "QMouseEvent", "private", "", "public" ] }, + { symbol: [ "QMutableHashIterator", "private", "", "public" ] }, + { symbol: [ "QScopedArrayPointer", "private", "", "public" ] }, + { symbol: [ "QStyleOptionSlider", "private", "", "public" ] }, + { symbol: [ "QStyleOptionViewItem", "private", "", "public" ] }, + { symbol: [ "QTime", "private", "", "public"] }, + { symbol: [ "QTableWidgetItem", "private", "", "public" ] }, + { symbol: [ "QTreeWidgetItem", "private", "", "public" ] }, + { symbol: [ "QVBoxLayout", "private", "", "public" ] }, + { symbol: [ "QWebHitTestResult", "private", "", "public" ] }, + { symbol: [ "qobject_cast", "private", "", "public"] }, + + +# these are in QMetaType but the documentation is slightly unclear as to where they are meant to be defined. + { symbol: [ "QVariantMap", "private", "", "public" ] }, + { symbol: [ "QVariantList", "private", "", "public" ] }, + +#Normal header overrides + + { include: [ "@\"(QtCore/)?qabstractitemmodel\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qalgorithms\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qbytearray\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qchar\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qcoreapplication\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qcoreevent\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qdatastream\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qdatetime\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qdir\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qfile\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qfileinfo\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qflags\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qglobal\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qiodevice\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qitemselectionmodel\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qjsonvalue\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qlist\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qlocale\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qlogging\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qmap\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qnamespace\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qobject\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qobjectdefs\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qpoint\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qrect\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qregexp\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qscopedpointer\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qset\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qsharedpointer_impl\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qsize\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qstring\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qstringlist\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qurl\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qvariant\\.h\"", "private", "", "public" ] }, + + { include: [ "@\"(QtGui/)?qbrush\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtGui/)?qcolor\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtGui/)?qfont\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtGui/)?qicon\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtGui/)?qimage\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtGui/)?qkeysequence\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtGui/)?qpalette\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtGui/)?qpen\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtGui/)?qpixmap\\.h\"", "private", "", "public" ] }, + + { include: [ "@\"(QtNetwork/)?qnetworkaccessmanager\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtNetwork/)?qnetworkrequest\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtNetwork/)?qhostaddress\\.h\"", "private", "", "public" ] }, + + { include: [ "\"QtWebKit/qwebsettings.h\"", "private", "", "public" ] }, + + { include: [ "@\"(QtWidgets/)?qabstractbutton\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qabstractitemview\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qaction\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qboxlayout\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qdialog\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qframe\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qlayout\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qlayoutitem\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qlineedit\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qstyle\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qstyleoption\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qtabwidget\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qwidget\\.h\"", "private", "", "public" ] }, + + { include: [ "\"qabstractproxymodel.h\"", "private", "", "public" ] }, + { include: [ "\"qapplication.h\"", "private", "", "public" ] }, + { include: [ "\"qcheckbox.h\"", "private", "", "public" ] }, + { include: [ "\"qclipboard.h\"", "private", "", "public" ] }, + { include: [ "\"qcombobox.h\"", "private", "", "public" ] }, + { include: [ "\"qcommandlinkbutton.h\"", "private", "", "public" ] }, + { include: [ "\"qcryptographichash.h\"", "private", "", "public" ] }, + { include: [ "\"qdatetime.h\"", "private", "", "public" ] }, + { include: [ "\"qdebug.h\"", "private", "", "public" ] }, + { include: [ "\"qdesktopwidget.h\"", "private", "", "public" ] }, + { include: [ "\"qdialog.h\"", "private", "", "public" ] }, + { include: [ "\"qdialogbuttonbox.h\"", "private", "", "public" ] }, + { include: [ "\"qdiriterator.h\"", "private", "", "public" ] }, + { include: [ "\"qfiledialog.h\"", "private", "", "public" ] }, + { include: [ "\"qfilesystemmodel.h\"", "private", "", "public" ] }, + { include: [ "\"qfilesystemwatcher.h\"", "private", "", "public" ] }, + { include: [ "\"qhash.h\"", "private", "", "public" ] }, + { include: [ "\"qheaderview.h\"", "private", "", "public" ] }, + { include: [ "\"qinputdialog.h\"", "private", "", "public" ] }, + { include: [ "\"qitemdelegate.h\"", "private", "", "public" ] }, + { include: [ "\"qjsonarray.h\"", "private", "", "public" ] }, + { include: [ "\"qjsondocument.h\"", "private", "", "public" ] }, + { include: [ "\"qlabel.h\"", "private", "", "public" ] }, + { include: [ "\"qlibrary.h\"", "private", "", "public" ] }, + { include: [ "\"qlistwidget.h\"", "private", "", "public" ] }, + { include: [ "\"qlocalserver.h\"", "private", "", "public" ] }, + { include: [ "\"qlocalsocket.h\"", "private", "", "public" ] }, + { include: [ "\"qmainwindow.h\"", "private", "", "public" ] }, + { include: [ "\"qmenu.h\"", "private", "", "public" ] }, + { include: [ "\"qmessagebox.h\"", "private", "", "public" ] }, + { include: [ "\"qmetatype.h\"", "private", "", "public" ] }, + { include: [ "\"qmimedata.h\"", "private", "", "public" ] }, + { include: [ "\"qmutex.h\"", "private", "", "public" ] }, + { include: [ "\"qnetworkcookie.h\"", "private", "", "public" ] }, + { include: [ "\"qnetworkcookiejar.h\"", "private", "", "public" ] }, + { include: [ "\"qnetworkinterface.h\"", "private", "", "public" ] }, + { include: [ "\"qnetworkreply.h\"", "private", "", "public" ] }, + { include: [ "\"qpainter.h\"", "private", "", "public" ] }, + { include: [ "\"qprocess.h\"", "private", "", "public" ] }, + { include: [ "\"qprogressbar.h\"", "private", "", "public" ] }, + { include: [ "\"qprogressdialog.h\"", "private", "", "public" ] }, + { include: [ "\"qproxystyle.h\"", "private", "", "public" ] }, + { include: [ "\"qpushbutton.h\"", "private", "", "public" ] }, + { include: [ "\"qregexp.h\"", "private", "", "public" ] }, + { include: [ "\"qscrollbar.h\"", "private", "", "public" ] }, + { include: [ "\"qsettings.h\"", "private", "", "public" ] }, + { include: [ "\"qsharedmemory.h\"", "private", "", "public" ] }, + { include: [ "\"qshortcut.h\"", "private", "", "public" ] }, + { include: [ "\"qsortfilterproxymodel.h\"", "private", "", "public" ] }, + { include: [ "\"qstackedwidget.h\"", "private", "", "public" ] }, + { include: [ "\"qstyleditemdelegate.h\"", "private", "", "public" ] }, + { include: [ "\"qstylefactory.h\"", "private", "", "public" ] }, + { include: [ "\"qtablewidget.h\"", "private", "", "public" ] }, + { include: [ "\"qtemporaryfile.h\"", "private", "", "public" ] }, + { include: [ "\"qtextbrowser.h\"", "private", "", "public" ] }, + { include: [ "\"qtextcodec.h\"", "private", "", "public" ] }, + { include: [ "\"qtextedit.h\"", "private", "", "public" ] }, + { include: [ "\"qtextstream.h\"", "private", "", "public" ] }, + { include: [ "\"qthread.h\"", "private", "", "public" ] }, + { include: [ "\"qtimer.h\"", "private", "", "public" ] }, + { include: [ "\"qtreeview.h\"", "private", "", "public" ] }, + { include: [ "\"qtreewidget.h\"", "private", "", "public" ] }, + { include: [ "\"qurlquery.h\"", "private", "", "public" ] }, + { include: [ "\"qvalidator.h\"", "private", "", "public" ] }, + { include: [ "\"qwebframe.h\"", "private", "", "public" ] }, + { include: [ "\"qwebhistory.h\"", "private", "", "public" ] }, + { include: [ "\"qwebpage.h\"", "private", "", "public" ] }, + { include: [ "\"qwebview.h\"", "private", "", "public" ] }, + { include: [ "\"qwhatsthis.h\"", "private", "", "public" ] }, + { include: [ "\"qnetworkdiskcache.h\"", "private", "", "public" ] }, + { include: [ "\"qmimedata.h\"", "private", "", "public" ] }, + { include: [ "\"qtgroupingproxy.h\"", "private", "", "public" ] }, + +# Microsft visual C? + + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + +# Windows + + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + +# And for boost??? + +] + + + + + +#include "QtCore/qiterator.h" +#include "QtCore/qtypeinfo.h" // for swap +#include "QtCore/qtypetraits.h" // for remove_reference<>::type +#include "QtGui/qfontmetrics.h" +#include "QtGui/qwindowdefs_win.h" // for HINSTANCE +#include // for _Simple_types<>::value_type +#include // for _Tree_const_iterator diff --git a/scons_configure_template.py b/scons_configure_template.py index 67a8fad6..e4116adf 100644 --- a/scons_configure_template.py +++ b/scons_configure_template.py @@ -31,3 +31,6 @@ ZLIBPATH = r"C:\Apps\zlib-1.2.8" # though you have to set it up in the configuration GIT = r"C:\Program Files\git\bin\git.exe" MERCURIAL = r"C:\Program Files\TortoiseHg\hg.exe" + +# Path to include-what-you-use. This is currently rather experimental +#IWYU = r"C:\Apps\include-what-you-use\bin\include-what-you-use.exe" 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 From b1cfc45853705163da0641eb8cf1cd77783e009d Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sun, 25 Oct 2015 08:36:30 +0000 Subject: Make the IWYU generation generic --- SConstruct | 117 +++++++++++++++++++++++++++++++++++++++------------------ qtmappings.imp | 117 +++++++++++++++++++++++++++++++++++++++++---------------- src/SConscript | 8 ---- 3 files changed, 164 insertions(+), 78 deletions(-) (limited to 'src/SConscript') diff --git a/SConstruct b/SConstruct index 94097f3c..fbc7e3fe 100644 --- a/SConstruct +++ b/SConstruct @@ -245,6 +245,83 @@ def DisableQtModules(self, *modules): for module in modules: self['CPPPATH'].remove(os.path.join('$QTDIR', 'include', 'QT' + module)) +def setup_IWYU(env): + import SCons.Defaults + import SCons.Builder + original_shared = SCons.Defaults.SharedObjectEmitter + original_static = SCons.Defaults.StaticObjectEmitter + + def DoIWYU(env, source, target): + for i in range(len(source)): + s = source[i] + dir, name = os.path.split(str(s)) # I'm sure theres a way of getting this from scons + # Don't bother looking at moc files and 7zip source + if not name.startswith('moc_') and \ + not dir.startswith(env['SEVENZIPPATH']): + # Put the .iwyu in the same place as the .obj + targ = os.path.splitext(str(target[i]))[0] + env.IWYU(targ + '.iwyu', s) + + def shared_emitter(target, source, env): + DoIWYU(env, source, target) + return original_shared(target, source, env) + + def static_emitter(target, source, env): + DoIWYU(env, source, target) + return original_static(target, source, env) + + SCons.Defaults.SharedObjectEmitter = shared_emitter + SCons.Defaults.StaticObjectEmitter = static_emitter + + def emitter(target, source, env): + env.Depends(target, '$IWYU_MAPPING_FILE') + return target, source + + iwyu = SCons.Builder.Builder( + action=[ + '-$IWYU $IWYU_FLAGS -Xiwyu --mapping_file=$IWYU_MAPPING_FILE $IWYU_COMCOM $SOURCE', + Touch('$TARGET') + ], + emitter=emitter, + suffix='.iwyu', + src_suffix='.cpp') + + env.Append(BUILDERS={'IWYU': iwyu}) + + # Sigh - IWYU is a right bum as it doesn't recognise /I so I have to duplicate most of the usual stuff. Worse, half the + # flags are irrelevant immaterial and incompetent and I can't use an environment clone because it takes stuff from the + # wrong environment. + + # There has to be a better way of doing this. 'begins with Q means system header'??? + # Also, I can't get this to show issues in the issue window which sucks + env['IWYU_FLAGS'] = [ + # This might turn down the output a bit. I hope + '-Xiwyu', '--transitive_includes_only', + '-D_MT', '-D_DLL', '-m32', + # This is something to do with clang, windows and boost headers + '-DBOOST_USE_WINDOWS_H', + # There's a lot of this, disabled for now + '-Wno-inconsistent-missing-override', + '--system-header-prefix=Q', + '--system-header-prefix=boost/', + # Attempt to get QT to recognise clang output. So far it has not worked well. + '-fdiagnostics-format=msvc', + '-fno-show-column', + # clang says it sets this to 1700 but pretty sure vc12 is 1800 + '-fmsc-version=1800', + ] + if env['CONFIG'] == 'debug': + env['IWYU_FLAGS'] += [ '-D_DEBUG' ] + + env['IWYU_DEFPREFIX'] = '-D' + env['IWYU_DEFSUFFIX'] = '' + env['IWYU_INCPREFIX'] = '-I' + env['IWYU_INCSUFFIX'] = '' + env['IWYU_COMCOM'] = '$IWYU_CPPDEFFLAGS $IWYU_CPPINCFLAGS $CCPDBFLAGS' + env['IWYU_CPPDEFFLAGS'] = '${_defines(IWYU_DEFPREFIX, CPPDEFINES, IWYU_DEFSUFFIX, __env__)}' + env['IWYU_CPPINCFLAGS'] = '$( ${_concat(IWYU_INCPREFIX, CPPPATH, IWYU_INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)' + env['IWYU_MAPPING_FILE'] = env.File('#/qtmappings.imp') + # Create base environment vars = setup_config_variables() @@ -361,44 +438,10 @@ else: env.AppendUnique(CPPFLAGS = [ '/O2', '/MD' ]) env.AppendUnique(LINKFLAGS = [ '/OPT:REF', '/OPT:ICF' ]) -# Add in env variables for include-what-you-use -################################################################ -# I really want to make this a post action for building a .o +# Set up include what you use. Add this as an extra compile step. Note it +# doesn't currently generate an output file (use the output instead!). if 'IWYU' in env: - # Sigh - IWYU is a right bum as it doesn't recognise /I so I have to duplicate most of the usual stuff. Worse, half the - # flags are irrelevant immaterial and incompetent and I can't use an environment clone because it takes stuff from the - # wrong environment. - - # There has to be a better way of doing this. 'begins with Q means system header'??? - # Also, I can't get this to show issues in the issue window which sucks - env['IWYU_FLAGS'] = [ - # This might turn down the output a bit. I hope - '-Xiwyu', '--transitive_includes_only', - '-D_MT', '-D_DLL', '-m32', - # This is something to do with clang, windows and boost headers - '-DBOOST_USE_WINDOWS_H', - # There's a lot of this, disabled for now - '-Wno-inconsistent-missing-override', - '--system-header-prefix=Q', - '--system-header-prefix=boost/', - # Attempt to get QT to recognise clang output. So far it has not worked well. - '-fdiagnostics-format=msvc', - '-fno-show-column', - # clang says it sets this to 1700 but pretty sure vc12 is 1800 - '-fmsc-version=1800', - ] - if env['CONFIG'] == 'debug': - env['IWYU_FLAGS'] += [ '-D_DEBUG' ] - - env['IWYU_DEFPREFIX'] = '-D' - env['IWYU_DEFSUFFIX'] = '' - env['IWYU_INCPREFIX'] = '-I' - env['IWYU_INCSUFFIX'] = '' - env['IWYU_COMCOM'] = '$IWYU_CPPDEFFLAGS $IWYU_CPPINCFLAGS $CCPCHFLAGS $CCPDBFLAGS' - env['IWYU_CPPDEFFLAGS'] = '${_defines(IWYU_DEFPREFIX, CPPDEFINES, IWYU_DEFSUFFIX, __env__)}' - env['IWYU_CPPINCFLAGS'] = '$( ${_concat(IWYU_INCPREFIX, CPPPATH, IWYU_INCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)' - env['IWYU_MAPPING_FILE'] = env.File('#/qtmappings.imp') - + setup_IWYU(env) # /OPT:REF removes unreferenced code # for release, use /OPT:ICF (comdat folding: coalesce identical blocks of code) diff --git a/qtmappings.imp b/qtmappings.imp index db59f67f..17073ddd 100644 --- a/qtmappings.imp +++ b/qtmappings.imp @@ -1,19 +1,23 @@ [ # Overrides. Some classes are defined by the spec to reside in their own headers but actually use the same # header as another class. It might make some sense using this for every class in QT... + { symbol: [ "QAbstractItemModel", "private", "", "public" ] }, { symbol: [ "QAbstractTableModel", "private", "", "public" ] }, { symbol: [ "QAtomicInt", "private", "", "public"] }, + { symbol: [ "QCloseEvent", "private", "", "public" ] }, { symbol: [ "QDate", "private", "", "public"] }, { symbol: [ "QDragEnterEvent", "private", "", "public" ] }, + { symbol: [ "QDropEvent", "private", "", "public" ] }, { symbol: [ "QIntValidator", "private", "", "public" ] }, { symbol: [ "QKeyEvent", "private", "", "public" ] }, { symbol: [ "QListWidgetItem", "private", "", "public" ] }, { symbol: [ "QModelIndex", "private", "", "public" ] }, - { symbol: [ "QModelIndexList", "private", "", "public" ] }, + { symbol: [ "QModelIndexList", "private", "", "public" ] }, { symbol: [ "QMouseEvent", "private", "", "public" ] }, { symbol: [ "@QMutableHashIterator(::.*)?", "private", "", "public" ] }, + { symbol: [ "QPersistentModelIndex", "private", "", "public" ] }, + { symbol: [ "QResizeEvent", "private", "", "public" ] }, { symbol: [ "QScopedArrayPointer", "private", "", "public" ] }, - { symbol: [ "QResizeEvent", "private", "", "public" ] }, { symbol: [ "QStyleOptionSlider", "private", "", "public" ] }, { symbol: [ "QStyleOptionViewItem", "private", "", "public" ] }, { symbol: [ "QTableWidgetItem", "private", "", "public" ] }, @@ -32,7 +36,6 @@ { include: [ "@\"(QtConcurrent/)?qtconcurrentrun\\.h\"", "private", "", "public" ] }, - { include: [ "@\"(QtCore/)?qabstractitemmodel\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qabstractproxymodel\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qalgorithms\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qbytearray\\.h\"", "private", "", "public" ] }, @@ -41,6 +44,7 @@ { include: [ "@\"(QtCore/)?qcoreevent\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qdatastream\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qdatetime\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qdebug\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qdir\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qdiriterator\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qfile\\.h\"", "private", "", "public" ] }, @@ -67,17 +71,17 @@ { include: [ "@\"(QtCore/)?qset\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qsharedpointer_impl\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qsize\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtCore/)?qstandardpaths\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qstring\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qstringlist\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qurl\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtCore/)?qvariant\\.h\"", "private", "", "public" ] }, - { include: [ "@\"(QtCore/)?qdebug\\.h\"", "private", "", "public" ] }, - { include: [ "@\"(QtCore/)?qstandardpaths\\.h\"", "private", "", "public" ] }, - + { include: [ "@\"(QtGui/)?qbrush\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtGui/)?qcolor\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtGui/)?qcursor\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtGui/)?qfont\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtGui/)?qfontmetrics\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtGui/)?qicon\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtGui/)?qimage\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtGui/)?qkeysequence\\.h\"", "private", "", "public" ] }, @@ -85,7 +89,6 @@ { include: [ "@\"(QtGui/)?qpalette\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtGui/)?qpen\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtGui/)?qpixmap\\.h\"", "private", "", "public" ] }, - { include: [ "@\"(QtGui/)?qfontmetrics\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtNetwork/)?qhostaddress\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtNetwork/)?qnetworkaccessmanager\\.h\"", "private", "", "public" ] }, @@ -105,14 +108,16 @@ { include: [ "@\"(QtWidgets/)?qstyleoption\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtWidgets/)?qtabbar\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtWidgets/)?qtabwidget\\.h\"", "private", "", "public" ] }, - { include: [ "@\"(QtWidgets/)?qwidget\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtWidgets/)?qtextedit\\.h\"", "private", "", "public" ] }, + { include: [ "@\"(QtWidgets/)?qwidget\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtWebKit/)?qwebsettings\\.h\"", "private", "", "public" ] }, { include: [ "@\"(QtWebKitWidgets/)?qwebpage\\.h\"", "private", "", "public" ] }, + # I need to find out where these are and group them as above. { include: [ "\"qapplication.h\"", "private", "", "public" ] }, + { include: [ "\"qbuffer.h\"", "private", "", "public" ] }, { include: [ "\"qcheckbox.h\"", "private", "", "public" ] }, { include: [ "\"qclipboard.h\"", "private", "", "public" ] }, { include: [ "\"qcombobox.h\"", "private", "", "public" ] }, @@ -123,11 +128,13 @@ { include: [ "\"qfiledialog.h\"", "private", "", "public" ] }, { include: [ "\"qfilesystemmodel.h\"", "private", "", "public" ] }, { include: [ "\"qfilesystemwatcher.h\"", "private", "", "public" ] }, + { include: [ "\"qgroupbox.h\"", "private", "", "public" ] }, { include: [ "\"qheaderview.h\"", "private", "", "public" ] }, { include: [ "\"qinputdialog.h\"", "private", "", "public" ] }, { include: [ "\"qitemdelegate.h\"", "private", "", "public" ] }, { include: [ "\"qjsonarray.h\"", "private", "", "public" ] }, { include: [ "\"qjsondocument.h\"", "private", "", "public" ] }, + { include: [ "\"qjsonobject.h\"", "private", "", "public" ] }, { include: [ "\"qlabel.h\"", "private", "", "public" ] }, { include: [ "\"qlcdnumber.h\"", "private", "", "public" ] }, { include: [ "\"qlistwidget.h\"", "private", "", "public" ] }, @@ -144,12 +151,14 @@ { include: [ "\"qnetworkdiskcache.h\"", "private", "", "public" ] }, { include: [ "\"qnetworkinterface.h\"", "private", "", "public" ] }, { include: [ "\"qnetworkreply.h\"", "private", "", "public" ] }, + { include: [ "\"qpixmapcache.h\"", "private", "", "public" ] }, { include: [ "\"qprocess.h\"", "private", "", "public" ] }, { include: [ "\"qprogressbar.h\"", "private", "", "public" ] }, { include: [ "\"qprogressdialog.h\"", "private", "", "public" ] }, { include: [ "\"qproxystyle.h\"", "private", "", "public" ] }, { include: [ "\"qpushbutton.h\"", "private", "", "public" ] }, { include: [ "\"qqueue.h\"", "private", "", "public" ] }, + { include: [ "\"qradiobutton.h\"", "private", "", "public" ] }, { include: [ "\"qscrollbar.h\"", "private", "", "public" ] }, { include: [ "\"qsettings.h\"", "private", "", "public" ] }, { include: [ "\"qsharedmemory.h\"", "private", "", "public" ] }, @@ -157,18 +166,24 @@ { include: [ "\"qsignalmapper.h\"", "private", "", "public" ] }, { include: [ "\"qsortfilterproxymodel.h\"", "private", "", "public" ] }, { include: [ "\"qsplashscreen.h\"", "private", "", "public" ] }, + { include: [ "\"qsplitter.h\"", "private", "", "public" ] }, { include: [ "\"qsslsocket.h\"", "private", "", "public" ] }, { include: [ "\"qstackedwidget.h\"", "private", "", "public" ] }, + { include: [ "\"qstatusbar.h\"", "private", "", "public" ] }, { include: [ "\"qstyleditemdelegate.h\"", "private", "", "public" ] }, { include: [ "\"qstylefactory.h\"", "private", "", "public" ] }, + { include: [ "\"qsyntaxhighlighter.h\"", "private", "", "public" ] }, { include: [ "\"qtablewidget.h\"", "private", "", "public" ] }, { include: [ "\"qtemporaryfile.h\"", "private", "", "public" ] }, { include: [ "\"qtextbrowser.h\"", "private", "", "public" ] }, { include: [ "\"qtextcodec.h\"", "private", "", "public" ] }, { include: [ "\"qtextstream.h\"", "private", "", "public" ] }, - { include: [ "\"qtgroupingproxy.h\"", "private", "", "public" ] }, { include: [ "\"qthread.h\"", "private", "", "public" ] }, { include: [ "\"qtimer.h\"", "private", "", "public" ] }, + { include: [ "\"qtoolbar.h\"", "private", "", "public" ] }, + { include: [ "\"qtoolbutton.h\"", "private", "", "public" ] }, + { include: [ "\"qtooltip.h\"", "private", "", "public" ] }, + { include: [ "\"qtranslator.h\"", "private", "", "public" ] }, { include: [ "\"qtreeview.h\"", "private", "", "public" ] }, { include: [ "\"qtreewidget.h\"", "private", "", "public" ] }, { include: [ "\"qurlquery.h\"", "private", "", "public" ] }, @@ -178,48 +193,68 @@ { include: [ "\"qwebhistory.h\"", "private", "", "public" ] }, { include: [ "\"qwebview.h\"", "private", "", "public" ] }, { include: [ "\"qwhatsthis.h\"", "private", "", "public" ] }, + { include: [ "\"qwidgetaction.h\"", "private", "", "public" ] }, + { include: [ "\"qimagereader.h\"", "private", "", "public" ] }, -# Microsft visual C? + + # Microsft visual C? + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, { include: [ "", "private", "", "public" ] }, { include: [ "", "private", "", "public" ] }, # Windows +# Looks like the doucmentation says the 1st char is u/c the rest are l/c # You have to be kidding me. ULONG is defined in winsmcrd.h? { symbol: [ "ULONG", "private", "", "private" ] }, -# These are all in windef.h apparently. Which m/s then says 'use windows.h' + { include: [ "", "private", "", "private" ] }, # Stringapiset.h + { include: [ "", "private", "", "public" ] }, # Windows.h + +# These are all in windef.h apparently. Which m/s then says 'use Windows.h' { include: [ "", "private", "", "private" ] }, # or in winnt apparently { include: [ "", "private", "", "private" ] }, { include: [ "", "private", "", "private" ] }, { include: [ "", "private", "", "private" ] }, # Similary, but for winbase.h - { include: [ "", "private", "", "private" ] }, - { include: [ "", "private", "", "private" ] }, + { include: [ "", "private", "", "private" ] }, { include: [ "", "private", "", "private" ] }, + { include: [ "", "private", "", "private" ] }, + { include: [ "", "private", "", "private" ] }, + { include: [ "", "private", "", "private" ] }, + { include: [ "", "private", "", "private" ] }, -# These ones say xxxx.h (include windows.h) on the ms web site - { include: [ "", "private", "", "public" ] }, - { include: [ "", "private", "", "public" ] }, # check this - { include: [ "", "private", "", "public" ] }, - { include: [ "", "private", "", "public" ] }, - { include: [ "", "private", "", "public" ] }, - { include: [ "", "private", "", "public" ] }, - { include: [ "", "private", "", "public" ] }, +# These ones say xxxx.h (include Windows.h) on the ms web site + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, # VerRsrc.h + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, -# These ones are in windows.h but the documentation post windows 8 says they are individual headers, +# These ones are in Windows.h but the documentation post windows 8 says they are individual headers, # which looks like M/S are trying to get their act together. Maybe. - { include: [ "", "private", "", "public" ] }, #recheck - { include: [ "", "private", "", "public" ] }, - { include: [ "", "private", "", "public" ] }, - { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, -# These ones are *not* defined to be in windows.h, but it seems to work. These should probably be cleaned up - { include: [ "", "private", "", "public" ] }, - { include: [ "", "private", "", "public" ] }, - { include: [ "", "private", "", "public" ] }, - { include: [ "", "private", "", "public" ] }, +# These ones are *not* defined to be in Windows.h, but it seems to work. These should probably be cleaned up + { include: [ "", "private", "", "public" ] }, + # These 3 should go to Shellapi.h + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, + { include: [ "", "private", "", "public" ] }, +# combaseapi.h is for objbase.h but objbase.h appears to come free with Windows.h +# Windows.h is a pile of ... + { include: [ "", "private", "", "private" ] }, + { include: [ "", "private", "", "public" ] }, + +# Huh? This one is sane? + { include: [ "", "private", "", "public" ] }, # And for boost??? # These are probably correct but might need a revisit as if you look at the boost documentation pages, it @@ -229,7 +264,10 @@ { include: [ "@\"boost/bind/.*\"", "private", "", "public" ] }, { include: [ "@\"boost/algorithm/string/.*\"", "private", "", "public" ] }, { include: [ "@\"boost/assign/.*\"", "private", "", "public" ] }, + { include: [ "@\"boost/filesystem/.*\"", "private", "", "public" ] }, + { include: [ "@\"boost/format/.*\"", "private", "", "public" ] }, { include: [ "@\"boost/function/.*\"", "private", "", "public" ] }, + { include: [ "@\"boost/python/.*\"", "private", "", "public" ] }, { include: [ "@\"boost/signals2/.*\"", "private", "", "public" ] }, { include: [ "\"boost/smart_ptr/scoped_array.hpp\"", "private", "", "public" ] }, { include: [ "\"boost/smart_ptr/shared_ptr.hpp\"", "private", "", "public" ] }, @@ -239,7 +277,17 @@ ] +# Warning: QtGroupingProxy is not provided by Qt + +#include "qdeclarativecontext.h" // for QDeclarativeContext +#include "qdeclarativeview.h" // for QDeclarativeView, etc +#include "qgraphicsitem.h" // for QGraphicsObject + +#include "qpluginloader.h" +#include "qnetworkproxy.h" + # Ones I don't yet know how to deal with +#include #include "boost/fusion/container/vector/vector10_fwd.hpp" // for fusion #include "boost/iterator/iterator_facade.hpp" // for operator!= #include // for operator delete[], etc @@ -248,10 +296,13 @@ #include "QtCore/qtypeinfo.h" // for swap #include "QtCore/qtypetraits.h" #include "QtCore/qtypetraits.h" // for remove_reference<>::type -#include "QtGui/qfontmetrics.h" -#include "QtGui/qvalidator.h" // for QIntValidator #include "QtGui/qwindowdefs_win.h" // for HINSTANCE #include "QtWidgets/qabstractitemdelegate.h" #include "boost/iterator/iterator_facade.hpp" #include // for _Simple_types<>::value_type #include // for _Tree_const_iterator + +# typical error on stdout (?) +#source\hookdll\dllmain.cpp(220) : warning C4244: '=' : conversion from 'int' to 'char', possible loss of data +# error from include-what-you-use (on stderr? at least it's in red) +#source\hookdll\dllmain.cpp(2220) : warning: case value not in enumerated type 'FILE_INFORMATION_CLASS' (aka '_FILE_INFORMATION_CLASS') [-Wswitch] diff --git a/src/SConscript b/src/SConscript index cd2d8a52..d88bee30 100644 --- a/src/SConscript +++ b/src/SConscript @@ -143,14 +143,6 @@ 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'): -- cgit v1.3.1 From c07e48075e86c855f147e084a50ee1c7f0c00e40 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 5 Dec 2015 06:51:57 +0000 Subject: Most of work for savegame --- src/SConscript | 6 + src/mainwindow.cpp | 21 ++- src/organizer.pro | 4 + src/savegamegamebryo.cpp | 348 +++++--------------------------------------- src/savegamegamebyro.h | 42 ++---- src/shared/fallout3info.h | 2 - src/shared/falloutnvinfo.h | 2 - src/shared/gameinfo.h | 12 -- src/shared/oblivioninfo.h | 2 - src/shared/skyriminfo.h | 2 - src/transfersavesdialog.cpp | 4 +- 11 files changed, 78 insertions(+), 367 deletions(-) (limited to 'src/SConscript') diff --git a/src/SConscript b/src/SConscript index f09db093..8e0280ef 100644 --- a/src/SConscript +++ b/src/SConscript @@ -96,6 +96,12 @@ env['CPPPATH'] += [ '${BOOSTPATH}', ] +#########################FUDGE############################### +env['CPPPATH'] += [ + '../plugins/gameGamebryo', + ] +############################################################# + env.AppendUnique(CPPDEFINES = [ '_UNICODE', '_CRT_SECURE_NO_WARNINGS', diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 152baee7..1101f3fa 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -59,6 +59,10 @@ along with Mod Organizer. If not, see . #include "browserdialog.h" #include "aboutdialog.h" #include "safewritefile.h" +//? +//#include "isavegame.h" +//#include "savegameinfo.h" +//? #include "nxmaccessmanager.h" #include #include @@ -826,9 +830,22 @@ void MainWindow::setBrowserGeometry(const QByteArray &geometry) } -SaveGameGamebryo *MainWindow::getSaveGame(const QString &name) +SaveGameGamebryo *MainWindow::getSaveGame(const QString &name__) { - return new SaveGameGamebryo(this, name); + IPluginGame const *game = m_OrganizerCore.managedGame(); + QString name(name__); + + //fudge with me +// game = m_PluginContainer.managedGame("Fallout 3"); +// name = "C:\\Users\\Dad\\Downloads\\Games\\Both good and evil saves -10416\\Save 106 - New Start Good, Vault 101 Entrance, 00.33.34.fos"; + +// game = m_PluginContainer.managedGame("New Vegas"); +// name = "C:\\Users\\Dad\\Downloads\\Games\\Crossroads - Clean Save-44883-1-0\\Crossroads.fos"; + +// game = m_PluginContainer.managedGame("Oblivion"); +// name = "C:\\Users\\Dad\\Saved Games\\Oblivion\\Saves\\Save 1537 - Hilary - Xirethard, Level 45, Playing Time 458.48.17.ess"; + + return new SaveGameGamebryo(this, name, game); } diff --git a/src/organizer.pro b/src/organizer.pro index 2869fda5..f472bd80 100644 --- a/src/organizer.pro +++ b/src/organizer.pro @@ -232,6 +232,10 @@ INCLUDEPATH += "E:/Visual Leak Detector/include" LIBS += -L"E:/Visual Leak Detector/lib/Win32" #DEFINES += LEAK_CHECK_WITH_VLD +#########################FUDGE############################### +INCLUDEPATH += ../plugins/gameGamebro +############################################################# + # custom leak detection #LIBS += -lDbgHelp diff --git a/src/savegamegamebryo.cpp b/src/savegamegamebryo.cpp index 7b012e22..457cbdf2 100644 --- a/src/savegamegamebryo.cpp +++ b/src/savegamegamebryo.cpp @@ -18,321 +18,49 @@ along with Mod Organizer. If not, see . */ #include "savegamegamebyro.h" -#include "gameinfo.h" -#include -#include -#include -#include -#include -#include - - -using namespace MOShared; - - -template -static void FileRead(QFile &file, T &value) -{ - int read = file.read(reinterpret_cast(&value), sizeof(T)); - if (read != sizeof(T)) { - throw std::runtime_error("unexpected end of file"); - } -} - - -template -static void FileSkip(QFile &file, int count = 1) -{ - char ignore[sizeof(T)]; - for (int i = 0; i < count; ++i) { - if (file.read(ignore, sizeof(T)) != sizeof(T)) { - throw std::runtime_error("unexpected end of file"); - } - } -} - - -static QString ReadBString(QFile &file) -{ - char buffer[256]; - file.read(buffer, 1); // size including zero termination - unsigned char size = buffer[0]; - file.read(buffer, size); - return QString::fromLatin1(buffer, size); -} - - -static QString ReadFOSString(QFile &file, bool delimiter) -{ - union { - char lengthBuffer[2]; - unsigned short length; - }; - - file.read(lengthBuffer, 2); - if (delimiter) { - FileSkip(file); // 0x7c - } - char *buffer = new char[length]; - file.read(buffer, length); - - QString result = QString::fromLatin1(buffer, length); - delete [] buffer; - - return result; -} - - -SaveGameGamebryo::SaveGameGamebryo(QObject *parent) - : SaveGame(parent), m_Plugins() -{ -} - - -SaveGameGamebryo::SaveGameGamebryo(QObject *parent, const QString &fileName) - : SaveGame(parent, fileName), m_Plugins() -{ - readFile(fileName); -} - - -SaveGameGamebryo::SaveGameGamebryo(const SaveGameGamebryo& reference) - : SaveGame(reference), m_Plugins(reference.m_Plugins) -{ -} - - -SaveGameGamebryo& SaveGameGamebryo::operator=(const SaveGameGamebryo &reference) -{ - if (&reference != this) { - SaveGame::operator =(reference); - m_Plugins = reference.m_Plugins; - } - return *this; -} - - -SaveGameGamebryo::~SaveGameGamebryo() -{ -} - - - - - -void SaveGameGamebryo::readSkyrimFile(QFile &saveFile) -{ - char fileID[14]; - - saveFile.read(fileID, 13); - fileID[13] = '\0'; - if (strncmp(fileID, "TESV_SAVEGAME", 13) != 0) { - throw std::runtime_error(QObject::tr("wrong file format").toUtf8().constData()); - } - - FileSkip(saveFile); // header size - FileSkip(saveFile); // header version, -> 8 - FileRead(saveFile, m_SaveNumber); - m_PCName = ReadFOSString(saveFile, false); +#include "isavegame.h" +#include "savegameinfo.h" +#include "iplugingame.h" +#include "gamebryosavegame.h" - unsigned long temp; - FileRead(saveFile, temp); // player level - m_PCLevel = static_cast(temp); - - m_PCLocation = ReadFOSString(saveFile, false); - ReadFOSString(saveFile, false); // playtime as ascii hhh.mm.ss - ReadFOSString(saveFile, false); // race name (i.e. BretonRace) - - - FileSkip(saveFile); // ??? - FileSkip(saveFile, 2); // ??? - FileSkip(saveFile, 8); // filetime - -// FileSkip(saveFile, 18); // ??? 18 bytes of data. not completely random, maybe a time stamp? maybe - - unsigned long width, height; - FileRead(saveFile, width); // 320 - FileRead(saveFile, height); // 192 - - QScopedArrayPointer buffer(new unsigned char[width * height * 3]); - saveFile.read(reinterpret_cast(buffer.data()), width * height * 3); - // why do I have to copy here? without the copy, the buffer seems to get deleted after the - // temporary vanishes, but Qts implicit sharing should handle that? - m_Screenshot = QImage(buffer.data(), width, height, QImage::Format_RGB888).copy(); - - FileSkip(saveFile); // form version - FileSkip(saveFile); // plugin info size - - unsigned char pluginCount; - FileRead(saveFile, pluginCount); - - for (int i = 0; i < pluginCount; ++i) { - m_Plugins.push_back(ReadFOSString(saveFile, false)); - } -} - - -void SaveGameGamebryo::readESSFile(QFile &saveFile) -{ - char fileID[13]; - unsigned char versionMinor; - unsigned long headerVersion, saveHeaderSize; -// *** format is different for fallout! - saveFile.read(fileID, 12); - fileID[12] = '\0'; - FileSkip(saveFile); FileRead(saveFile, versionMinor); - FileSkip(saveFile); // modified time - FileRead(saveFile, headerVersion); FileRead(saveFile, saveHeaderSize); - - if (strncmp(fileID, "TES4SAVEGAME", 12) != 0) { - throw std::runtime_error(QObject::tr("wrong file format").toUtf8().constData()); - } - - FileRead(saveFile, m_SaveNumber); - - m_PCName = ReadBString(saveFile); - - FileRead(saveFile, m_PCLevel); - m_PCLocation = ReadBString(saveFile); - FileSkip(saveFile); // game days - FileSkip(saveFile); // game ticks - FileRead(saveFile, m_CreationTime); - - unsigned long size; - FileRead(saveFile, size); // screenshot size - - unsigned long width, height; - FileRead(saveFile, width); FileRead(saveFile, height); - QScopedArrayPointer buffer(new unsigned char[width * height * 3]); - saveFile.read(reinterpret_cast(buffer.data()), width * height * 3); - // why do I have to copy here? without the copy, the buffer seems to get deleted after the - // temporary vanishes, but Qts implicit sharing should handle that? - m_Screenshot = QImage(buffer.data(), width, height, QImage::Format_RGB888).copy(); - - unsigned char pluginCount; - FileRead(saveFile, pluginCount); - - for (int i = 0; i < pluginCount; ++i) { - QString name = ReadBString(saveFile); - m_Plugins.push_back(name); - } -} - - -void SaveGameGamebryo::readFOSFile(QFile &saveFile, bool newVegas) -{ - char fileID[13]; - saveFile.read(fileID, 12); - // the signature is only 11 characters, the 12th is random? - fileID[11] = '\0'; - - if (strncmp(fileID, "FO3SAVEGAME", 11) != 0) { - throw std::runtime_error(QObject::tr("wrong file format").toUtf8().constData()); - } - - char ignore = 0x00; - while (ignore != 0x7c) { - FileRead(saveFile, ignore); // unknown - } - if (newVegas) { - ignore = 0x00; - // in new vegas there is another block of uninteresting (?) information - FileSkip(saveFile); // 0x7c - while (ignore != 0x7c) { - FileRead(saveFile, ignore); // unknown - } - } - - unsigned long width, height; - FileRead(saveFile, width); - FileSkip(saveFile); // 0x7c - FileRead(saveFile, height); - FileSkip(saveFile); // 0x7c - - FileRead(saveFile, m_SaveNumber); - FileSkip(saveFile); // 0x7c - - m_PCName = ReadFOSString(saveFile, true); - FileSkip(saveFile); // 0x7c - - ReadFOSString(saveFile, true); - FileSkip(saveFile); // 0x7c - - long Level; - FileRead(saveFile, Level); - m_PCLevel = Level; - FileSkip(saveFile); // 0x7c - - m_PCLocation = ReadFOSString(saveFile, true); - FileSkip(saveFile); // 0x7c - - ReadFOSString(saveFile, true); // playtime - - FileSkip(saveFile); - - QScopedArrayPointer buffer(new unsigned char[width * height * 3]); - saveFile.read(reinterpret_cast(buffer.data()), width * height * 3); - // why do I have to copy here? without the copy, the buffer seems to get deleted after the - // temporary vanishes, but Qts implicit sharing should handle that? - m_Screenshot = QImage(buffer.data(), width, height, QImage::Format_RGB888).scaledToWidth(256); - - FileSkip(saveFile, 5); // unknown - - unsigned char pluginCount = 0; - FileRead(saveFile, pluginCount); - FileSkip(saveFile); // 0x7c - - for (int i = 0; i < pluginCount; ++i) { - QString name = ReadFOSString(saveFile, true); - m_Plugins.push_back(name); - FileSkip(saveFile); // 0x7c - } -} - - -void SaveGameGamebryo::setCreationTime(const QString &fileName) -{ - QFileInfo creationTime(fileName); - QDateTime modified = creationTime.lastModified(); - memset(&m_CreationTime, 0, sizeof(SYSTEMTIME)); +#include +#include - m_CreationTime.wDay = static_cast(modified.date().day()); - m_CreationTime.wDayOfWeek = static_cast(modified.date().dayOfWeek()); - m_CreationTime.wMonth = static_cast(modified.date().month()); - m_CreationTime.wYear =static_cast( modified.date().year()); +using namespace MOBase; - m_CreationTime.wHour = static_cast(modified.time().hour()); - m_CreationTime.wMinute = static_cast(modified.time().minute()); - m_CreationTime.wSecond = static_cast(modified.time().second()); - m_CreationTime.wMilliseconds = static_cast(modified.time().msec()); -} - -void SaveGameGamebryo::readFile(const QString &fileName) +SaveGameGamebryo::SaveGameGamebryo(QObject *parent, const QString &fileName, IPluginGame const *game) + : SaveGame(parent, fileName) + , m_Plugins() { - m_FileName = fileName; - QFile saveFile(fileName); - if (!saveFile.open(QIODevice::ReadOnly)) { - throw std::runtime_error(QObject::tr("failed to open %1").arg(fileName).toUtf8().constData()); - } - switch (GameInfo::instance().getType()) { - case GameInfo::TYPE_FALLOUT3: { - setCreationTime(fileName); - readFOSFile(saveFile, false); - } break; - case GameInfo::TYPE_FALLOUTNV: { - setCreationTime(fileName); - readFOSFile(saveFile, true); - } break; - case GameInfo::TYPE_OBLIVION: { - readESSFile(saveFile); - } break; - case GameInfo::TYPE_SKYRIM: { - setCreationTime(fileName); - readSkyrimFile(saveFile); - } break; + SaveGameInfo const *info = game->feature(); + if (info != nullptr) { + ISaveGame const *save = info->getSaveGameInfo(fileName); + m_Save = save; + + //Kludgery + GamebryoSaveGame const *s = dynamic_cast(save); + m_PCName = s->getPCName(); + m_PCLevel = s->getPCLevel(); + m_PCLocation = s->getPCLocation(); + m_SaveNumber = s->getSaveNumber(); + + QDateTime modified = s->getCreationTime(); + memset(&m_CreationTime, 0, sizeof(SYSTEMTIME)); + + m_CreationTime.wDay = static_cast(modified.date().day()); + m_CreationTime.wDayOfWeek = static_cast(modified.date().dayOfWeek()); + m_CreationTime.wMonth = static_cast(modified.date().month()); + m_CreationTime.wYear =static_cast( modified.date().year()); + + m_CreationTime.wHour = static_cast(modified.time().hour()); + m_CreationTime.wMinute = static_cast(modified.time().minute()); + m_CreationTime.wSecond = static_cast(modified.time().second()); + m_CreationTime.wMilliseconds = static_cast(modified.time().msec()); + + m_Screenshot = s->getScreenshot(); + + m_Plugins = s->getPlugins(); } - - saveFile.close(); } diff --git a/src/savegamegamebyro.h b/src/savegamegamebyro.h index e08e1044..bce08018 100644 --- a/src/savegamegamebyro.h +++ b/src/savegamegamebyro.h @@ -20,17 +20,13 @@ along with Mod Organizer. If not, see . #ifndef SAVEGAMEGAMEBRYO_H #define SAVEGAMEGAMEBRYO_H - #include "savegame.h" -#include -#include #include -#include - -#define WIN32_LEAN_AND_MEAN -#include +#include +#include +namespace MOBase { class IPluginGame; class ISaveGame; } /** * @brief represents a single save game @@ -41,31 +37,21 @@ Q_OBJECT public: - /** - * @brief construct an empty object - **/ - SaveGameGamebryo(QObject *parent = 0); - /** * @brief construct a save game and immediately read out information from the file * * @param filename absolute path of the save game file **/ - SaveGameGamebryo(QObject *parent, const QString &filename); + SaveGameGamebryo(QObject *parent, const QString &filename, MOBase::IPluginGame const *game); + /* SaveGameGamebryo(const SaveGameGamebryo &reference); SaveGameGamebryo &operator=(const SaveGameGamebryo &reference); ~SaveGameGamebryo(); - - /** - * @brief read out information from a savegame - * - * @param fileName absolute path of the save game file - **/ - virtual void readFile(const QString &fileName); + */ /** * @return number of plugins that were enabled when the save game was created @@ -80,22 +66,12 @@ public: **/ const QString &plugin(int index) const { return m_Plugins.at(index); } - private: - void readESSFile(QFile &saveFile); - void readFOSFile(QFile &saveFile, bool newVegas); - void readSkyrimFile(QFile &saveFile); - - void setCreationTime(const QString &fileName); - -private: - - std::vector m_Plugins; + QStringList m_Plugins; + //Note: This isn't owned by us so safe to copy + MOBase::ISaveGame const *m_Save; }; -Q_DECLARE_METATYPE(SaveGameGamebryo) -Q_DECLARE_METATYPE(SaveGameGamebryo*) - #endif // SAVEGAMEGAMEBRYO_H diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index 69eb9c45..489ac038 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -38,8 +38,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() { return getRegPathStatic(); } - virtual GameInfo::Type getType() { return TYPE_FALLOUT3; } - virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index a7ee089e..a0bc5bd4 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -38,8 +38,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() { return getRegPathStatic(); } - virtual GameInfo::Type getType() { return TYPE_FALLOUTNV; } - virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index 01d51f8a..9e6a35ef 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -38,15 +38,6 @@ namespace MOShared { class GameInfo { -public: - - enum Type { - TYPE_OBLIVION, - TYPE_FALLOUT3, - TYPE_FALLOUTNV, - TYPE_SKYRIM - }; - public: virtual ~GameInfo() {} @@ -54,9 +45,6 @@ public: //**USED IN HOOKDLL and savegame code static GameInfo& instance(); - //**Used only in savegame which needs refactoring a lot. - virtual GameInfo::Type getType() = 0; - //**Used only in savegame which needs refactoring a lot. // get a list of file extensions for additional files belonging to a save game virtual std::vector getSavegameAttachmentExtensions() = 0; diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index e0a861bf..1e48b742 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -36,8 +36,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() { return getRegPathStatic(); } - virtual GameInfo::Type getType() { return TYPE_OBLIVION; } - virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index 17b542ab..ce2510f1 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -38,8 +38,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() { return getRegPathStatic(); } - virtual GameInfo::Type getType() { return TYPE_SKYRIM; } - virtual std::vector getSavegameAttachmentExtensions(); // file name of this games ini (no path) diff --git a/src/transfersavesdialog.cpp b/src/transfersavesdialog.cpp index 4cb20944..48fc4548 100644 --- a/src/transfersavesdialog.cpp +++ b/src/transfersavesdialog.cpp @@ -63,7 +63,7 @@ void TransferSavesDialog::refreshGlobalSaves() QStringList files = savesDir.entryList(QDir::Files, QDir::Time); for (const QString &filename : files) { - SaveGameGamebryo *save = new SaveGameGamebryo(this, savesDir.absoluteFilePath(filename)); + SaveGameGamebryo *save = new SaveGameGamebryo(this, savesDir.absoluteFilePath(filename), m_GamePlugin); save->setParent(this); m_GlobalSaves.push_back(save); } @@ -81,7 +81,7 @@ void TransferSavesDialog::refreshLocalSaves() QStringList files = savesDir.entryList(QDir::Files, QDir::Time); foreach (const QString &filename, files) { - SaveGameGamebryo *save = new SaveGameGamebryo(this, savesDir.absoluteFilePath(filename)); + SaveGameGamebryo *save = new SaveGameGamebryo(this, savesDir.absoluteFilePath(filename), m_GamePlugin); save->setParent(this); m_LocalSaves.push_back(save); } -- cgit v1.3.1