Don't compile files for features that are disabled. (#2561)

Don't wrap whole cpp file in ifdef, it confuses clang-format.
This commit is contained in:
karliss 2021-01-11 23:49:54 +02:00 committed by GitHub
parent 562979bcff
commit 18e98e7868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 16 additions and 45 deletions

View File

@ -64,7 +64,6 @@ set(SOURCES
widgets/HeadersWidget.cpp widgets/HeadersWidget.cpp
widgets/SearchWidget.cpp widgets/SearchWidget.cpp
CutterApplication.cpp CutterApplication.cpp
common/PythonAPI.cpp
dialogs/RizinPluginsDialog.cpp dialogs/RizinPluginsDialog.cpp
widgets/CutterDockWidget.cpp widgets/CutterDockWidget.cpp
widgets/CutterTreeWidget.cpp widgets/CutterTreeWidget.cpp
@ -100,7 +99,6 @@ set(SOURCES
widgets/CutterTreeView.cpp widgets/CutterTreeView.cpp
widgets/ComboQuickFilterView.cpp widgets/ComboQuickFilterView.cpp
dialogs/HexdumpRangeDialog.cpp dialogs/HexdumpRangeDialog.cpp
common/QtResImporter.cpp
common/CutterSeekable.cpp common/CutterSeekable.cpp
common/RefreshDeferrer.cpp common/RefreshDeferrer.cpp
dialogs/WelcomeDialog.cpp dialogs/WelcomeDialog.cpp
@ -108,7 +106,6 @@ set(SOURCES
dialogs/EditMethodDialog.cpp dialogs/EditMethodDialog.cpp
dialogs/TypesInteractionDialog.cpp dialogs/TypesInteractionDialog.cpp
widgets/SdbWidget.cpp widgets/SdbWidget.cpp
common/PythonManager.cpp
plugins/PluginManager.cpp plugins/PluginManager.cpp
common/BasicBlockHighlighter.cpp common/BasicBlockHighlighter.cpp
common/BasicInstructionHighlighter.cpp common/BasicInstructionHighlighter.cpp
@ -120,7 +117,6 @@ set(SOURCES
dialogs/preferences/ColorThemeEditDialog.cpp dialogs/preferences/ColorThemeEditDialog.cpp
common/UpdateWorker.cpp common/UpdateWorker.cpp
widgets/MemoryDockWidget.cpp widgets/MemoryDockWidget.cpp
common/CrashHandler.cpp
common/BugReporting.cpp common/BugReporting.cpp
common/HighDpiPixmap.cpp common/HighDpiPixmap.cpp
widgets/GraphGridLayout.cpp widgets/GraphGridLayout.cpp
@ -211,7 +207,6 @@ set(HEADER_FILES
widgets/TypesWidget.h widgets/TypesWidget.h
widgets/HeadersWidget.h widgets/HeadersWidget.h
widgets/SearchWidget.h widgets/SearchWidget.h
common/PythonAPI.h
dialogs/RizinPluginsDialog.h dialogs/RizinPluginsDialog.h
widgets/CutterDockWidget.h widgets/CutterDockWidget.h
widgets/CutterTreeWidget.h widgets/CutterTreeWidget.h
@ -251,7 +246,6 @@ set(HEADER_FILES
widgets/CutterTreeView.h widgets/CutterTreeView.h
widgets/ComboQuickFilterView.h widgets/ComboQuickFilterView.h
dialogs/HexdumpRangeDialog.h dialogs/HexdumpRangeDialog.h
common/QtResImporter.h
common/CutterSeekable.h common/CutterSeekable.h
common/RefreshDeferrer.h common/RefreshDeferrer.h
dialogs/WelcomeDialog.h dialogs/WelcomeDialog.h
@ -261,7 +255,6 @@ set(HEADER_FILES
common/CrashHandler.h common/CrashHandler.h
dialogs/TypesInteractionDialog.h dialogs/TypesInteractionDialog.h
widgets/SdbWidget.h widgets/SdbWidget.h
common/PythonManager.h
plugins/PluginManager.h plugins/PluginManager.h
common/BasicBlockHighlighter.h common/BasicBlockHighlighter.h
common/BasicInstructionHighlighter.h common/BasicInstructionHighlighter.h
@ -376,6 +369,15 @@ set(QRC_FILES
themes/lightstyle/light.qrc themes/lightstyle/light.qrc
) )
if (CUTTER_ENABLE_PYTHON)
list(APPEND SOURCES common/QtResImporter.cpp common/PythonManager.cpp common/PythonAPI.cpp)
list(APPEND HEADER_FILES common/QtResImporter.h common/PythonManager.h common/PythonAPI.h)
endif()
if(CUTTER_ENABLE_CRASH_REPORTS)
list(APPEND SOURCES common/CrashHandler.cpp)
endif()
if(CUTTER_ENABLE_PYTHON_BINDINGS) if(CUTTER_ENABLE_PYTHON_BINDINGS)
set(BINDINGS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bindings") set(BINDINGS_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/bindings")
set(BINDINGS_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/bindings") set(BINDINGS_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/bindings")

View File

@ -54,6 +54,7 @@ static void connectToConsole()
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#ifdef CUTTER_ENABLE_CRASH_REPORTS
if (argc >= 3 && QString::fromLocal8Bit(argv[1]) == "--start-crash-handler") { if (argc >= 3 && QString::fromLocal8Bit(argv[1]) == "--start-crash-handler") {
QApplication app(argc, argv); QApplication app(argc, argv);
QString dumpLocation = QString::fromLocal8Bit(argv[2]); QString dumpLocation = QString::fromLocal8Bit(argv[2]);
@ -62,6 +63,7 @@ int main(int argc, char *argv[])
} }
initCrashHandler(); initCrashHandler();
#endif
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
connectToConsole(); connectToConsole();

View File

@ -7,8 +7,6 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QTime> #include <QTime>
#ifdef CUTTER_ENABLE_CRASH_REPORTS
#include <QApplication> #include <QApplication>
#include <QString> #include <QString>
#include <QFile> #include <QFile>
@ -106,16 +104,6 @@ void initCrashHandler()
atexit(finishCrashHandler); atexit(finishCrashHandler);
} }
#else // CUTTER_ENABLE_CRASH_REPORTS
void initCrashHandler()
{
}
#endif // CUTTER_ENABLE_CRASH_REPORTS
void showCrashDialog(const QString &dumpFile) void showCrashDialog(const QString &dumpFile)
{ {
QMessageBox mb; QMessageBox mb;

View File

@ -1,6 +1,3 @@
#ifdef CUTTER_ENABLE_PYTHON
#include "PythonAPI.h" #include "PythonAPI.h"
#include "core/Cutter.h" #include "core/Cutter.h"
@ -83,5 +80,3 @@ PyObject *PyInit_api()
{ {
return PyModule_Create(&CutterModule); return PyModule_Create(&CutterModule);
} }
#endif // CUTTER_ENABLE_PYTHON

View File

@ -1,13 +1,9 @@
#ifndef PYTHONAPI_H #ifndef PYTHONAPI_H
#define PYTHONAPI_H #define PYTHONAPI_H
#ifdef CUTTER_ENABLE_PYTHON
#define Py_LIMITED_API 0x03050000 #define Py_LIMITED_API 0x03050000
#include <Python.h> #include <Python.h>
PyObject *PyInit_api(); PyObject *PyInit_api();
#endif
#endif // PYTHONAPI_H #endif // PYTHONAPI_H

View File

@ -1,5 +1,3 @@
#ifdef CUTTER_ENABLE_PYTHON
#include <cassert> #include <cassert>
#include "PythonAPI.h" #include "PythonAPI.h"
@ -184,5 +182,3 @@ void PythonManager::saveThread()
pyThreadState = PyEval_SaveThread(); pyThreadState = PyEval_SaveThread();
} }
} }
#endif

View File

@ -1,8 +1,4 @@
#ifdef CUTTER_ENABLE_PYTHON #include "PythonAPI.h"
#define Py_LIMITED_API 0x03050000
#include <Python.h>
#include "QtResImporter.h" #include "QtResImporter.h"
#include <QFile> #include <QFile>
@ -87,5 +83,3 @@ PyObject *PyInit_qtres()
{ {
return PyModule_Create(&QtResModule); return PyModule_Create(&QtResModule);
} }
#endif // CUTTER_ENABLE_PYTHON

View File

@ -1,14 +1,10 @@
#ifndef QTRESIMPORTER_H #ifndef QTRESIMPORTER_H
#define QTRESIMPORTER_H #define QTRESIMPORTER_H
#ifdef CUTTER_ENABLE_PYTHON
PyObject *PyInit_qtres(); PyObject *PyInit_qtres();
PyObject *QtResImport(const char *name); PyObject *QtResImport(const char *name);
#define RegQtResImporter() Py_DecRef(QtResImport("reg_qtres_importer")) #define RegQtResImporter() Py_DecRef(QtResImport("reg_qtres_importer"))
#endif // CUTTER_ENABLE_PYTHON
#endif // QTRESIMPORTER_H #endif // QTRESIMPORTER_H

View File

@ -19,8 +19,9 @@
#include <QMessageBox> #include <QMessageBox>
#include "common/Configuration.h" #include "common/Configuration.h"
#include "CutterConfig.h" #include "CutterConfig.h"
#endif
#if CUTTER_UPDATE_WORKER_AVAILABLE
UpdateWorker::UpdateWorker(QObject *parent) : UpdateWorker::UpdateWorker(QObject *parent) :
QObject(parent), pending(false) QObject(parent), pending(false)
{ {

View File

@ -10,14 +10,15 @@
#endif #endif
#if CUTTER_UPDATE_WORKER_AVAILABLE #if CUTTER_UPDATE_WORKER_AVAILABLE
#include <QDir> #include <QDir>
#include <QTimer> #include <QTimer>
#include <QObject> #include <QObject>
#include <QtNetwork/QNetworkAccessManager> #include <QtNetwork/QNetworkAccessManager>
#include <QVersionNumber> #include <QVersionNumber>
#endif
#if CUTTER_UPDATE_WORKER_AVAILABLE
class QNetworkReply; class QNetworkReply;
/** /**