Skip to content

Commit dccf010

Browse files
committed
Fix building with -DWITH_BINDINGS=OFF
1 parent 620ad41 commit dccf010

File tree

5 files changed

+64
-6
lines changed

5 files changed

+64
-6
lines changed

CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ IF (WITH_BINDINGS)
105105
SET (WITH_QSCIAPI TRUE CACHE BOOL "Whether to generate PyQGIS QScintilla2 API file. (For devs) run 'make qsci-pap-src' in between QGIS build and install to regenerate .pap file in source tree for console auto-completion.")
106106
# keep casual users from updating their source tree via WITH_QSCIAPI
107107
MARK_AS_ADVANCED (WITH_QSCIAPI)
108+
ADD_DEFINITIONS(-DWITH_BINDINGS)
108109
ENDIF (WITH_BINDINGS)
109110

110111
#BUILD WITH QtMobility by default on android only. Other platform can force it

src/app/pluginmanager/qgspluginmanager.cpp

+15-4
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
#include "qgisplugin.h"
4545
#include "qgslogger.h"
4646
#include "qgspluginitemdelegate.h"
47+
#ifdef WITH_BINDINGS
48+
#include "qgspythonutils.h"
49+
#endif
4750

4851
// Do we need this?
4952
// #define TESTLIB
@@ -552,16 +555,22 @@ void QgsPluginManager::reloadModelData()
552555
}
553556
}
554557

558+
#ifdef WITH_BINDINGS
555559
// Add spacers for sort by status
556560
if ( mPythonUtils && mPythonUtils->isEnabled() )
557561
{
558562
// TODO: implement better sort method instead of these dummy -Z statuses
559563
mModelPlugins->appendRow( createSpacerItem( tr( "Only locally available", "category: plugins that are only locally available" ), QStringLiteral( "orphanZ" ) ) );
560-
if ( hasReinstallablePlugins() ) mModelPlugins->appendRow( createSpacerItem( tr( "Reinstallable", "category: plugins that are installed and available" ), QStringLiteral( "installedZ" ) ) );
561-
if ( hasUpgradeablePlugins() ) mModelPlugins->appendRow( createSpacerItem( tr( "Upgradeable", "category: plugins that are installed and there is a newer version available" ), QStringLiteral( "upgradeableZ" ) ) );
562-
if ( hasNewerPlugins() ) mModelPlugins->appendRow( createSpacerItem( tr( "Downgradeable", "category: plugins that are installed and there is an OLDER version available" ), QStringLiteral( "newerZ" ) ) );
563-
if ( hasAvailablePlugins() ) mModelPlugins->appendRow( createSpacerItem( tr( "Installable", "category: plugins that are available for installation" ), QStringLiteral( "not installedZ" ) ) );
564+
if ( hasReinstallablePlugins() )
565+
mModelPlugins->appendRow( createSpacerItem( tr( "Reinstallable", "category: plugins that are installed and available" ), QStringLiteral( "installedZ" ) ) );
566+
if ( hasUpgradeablePlugins() )
567+
mModelPlugins->appendRow( createSpacerItem( tr( "Upgradeable", "category: plugins that are installed and there is a newer version available" ), QStringLiteral( "upgradeableZ" ) ) );
568+
if ( hasNewerPlugins() )
569+
mModelPlugins->appendRow( createSpacerItem( tr( "Downgradeable", "category: plugins that are installed and there is an OLDER version available" ), QStringLiteral( "newerZ" ) ) );
570+
if ( hasAvailablePlugins() )
571+
mModelPlugins->appendRow( createSpacerItem( tr( "Installable", "category: plugins that are available for installation" ), QStringLiteral( "not installedZ" ) ) );
564572
}
573+
#endif
565574

566575
updateWindowTitle();
567576

@@ -1064,6 +1073,7 @@ void QgsPluginManager::addToRepositoryList( const QMap<QString, QString>& reposi
10641073
// "Close" button clicked
10651074
void QgsPluginManager::reject()
10661075
{
1076+
#ifdef WITH_BINDINGS
10671077
if ( mPythonUtils && mPythonUtils->isEnabled() )
10681078
{
10691079
// get the QSettings group from the installer
@@ -1074,6 +1084,7 @@ void QgsPluginManager::reject()
10741084
settings.setValue( settingsGroup + "/checkOnStartInterval", QVariant( mCheckingOnStartIntervals.value( comboInterval->currentIndex() ) ) );
10751085
QgsPythonRunner::run( QStringLiteral( "pyplugin_installer.instance().onManagerClose()" ) );
10761086
}
1087+
#endif
10771088
done( 1 );
10781089
}
10791090

src/app/pluginmanager/qgspluginmanager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
#include "qgisgui.h"
2929
#include "qgshelp.h"
3030
#include "qgsmessagebar.h"
31-
#include "qgspythonutils.h"
3231

3332
class QgsPluginSortFilterProxyModel;
33+
class QgsPythonUtils;
3434

3535
const int PLUGMAN_TAB_ALL = 0;
3636
const int PLUGMAN_TAB_INSTALLED = 1;

src/app/qgisapp.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,9 @@ extern "C"
352352
#include "qgsnewspatialitelayerdialog.h"
353353
#include "qgsnewgeopackagelayerdialog.h"
354354

355+
#ifdef WITH_BINDINGS
355356
#include "qgspythonutils.h"
357+
#endif
356358

357359
#ifndef Q_OS_WIN
358360
#include <dlfcn.h>
@@ -965,6 +967,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
965967
}
966968
}
967969

970+
#ifdef WITH_BINDINGS
968971
if ( mPythonUtils && mPythonUtils->isEnabled() )
969972
{
970973
startProfile( QStringLiteral( "initPluginInstaller" ) );
@@ -976,6 +979,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
976979
endProfile();
977980
}
978981
else if ( mActionShowPythonDialog || mActionInstallFromZip )
982+
#endif
979983
{
980984
// python is disabled so get rid of the action for python console
981985
// and installing plugin from ZUIP
@@ -1846,6 +1850,7 @@ void QgisApp::showStyleManager()
18461850

18471851
void QgisApp::showPythonDialog()
18481852
{
1853+
#ifdef WITH_BINDINGS
18491854
if ( !mPythonUtils || !mPythonUtils->isEnabled() )
18501855
return;
18511856

@@ -1865,6 +1870,7 @@ void QgisApp::showPythonDialog()
18651870
addWindow( mActionShowPythonDialog );
18661871
}
18671872
#endif
1873+
#endif
18681874
}
18691875

18701876
void QgisApp::createActionGroups()
@@ -5019,6 +5025,7 @@ bool QgisApp::addProject( const QString& projectFile )
50195025

50205026
QSettings settings;
50215027

5028+
#ifdef WITH_BINDINGS
50225029
// does the project have any macros?
50235030
if ( mPythonUtils && mPythonUtils->isEnabled() )
50245031
{
@@ -5061,6 +5068,7 @@ bool QgisApp::addProject( const QString& projectFile )
50615068
}
50625069
}
50635070
}
5071+
#endif
50645072

50655073
emit projectRead(); // let plug-ins know that we've read in a new
50665074
// project so that they can check any project
@@ -5330,13 +5338,15 @@ void QgisApp::openProject( QAction *action )
53305338

53315339
void QgisApp::runScript( const QString &filePath )
53325340
{
5341+
#ifdef WITH_BINDINGS
53335342
if ( !mPythonUtils || !mPythonUtils->isEnabled() )
53345343
return;
53355344

53365345
mPythonUtils->runString(
53375346
QString( "import sys\n"
53385347
"exec(open(\"%1\".replace(\"\\\\\", \"/\").encode(sys.getfilesystemencoding())).read())\n" ).arg( filePath )
53395348
, tr( "Failed to run Python script:" ), false );
5349+
#endif
53405350
}
53415351

53425352

@@ -8918,13 +8928,14 @@ void QgisApp::zoomToLayerExtent()
89188928

89198929
void QgisApp::showPluginManager()
89208930
{
8921-
8931+
#ifdef WITH_BINDINGS
89228932
if ( mPythonUtils && mPythonUtils->isEnabled() )
89238933
{
89248934
// Call pluginManagerInterface()->showPluginManager() as soon as the plugin installer says the remote data is fetched.
89258935
QgsPythonRunner::run( QStringLiteral( "pyplugin_installer.instance().showPluginManagerWhenReady()" ) );
89268936
}
89278937
else
8938+
#endif
89288939
{
89298940
// Call the pluginManagerInterface directly
89308941
mQgisInterface->pluginManagerInterface()->showPluginManager();
@@ -8933,10 +8944,12 @@ void QgisApp::showPluginManager()
89338944

89348945
void QgisApp::installPluginFromZip()
89358946
{
8947+
#ifdef WITH_BINDINGS
89368948
if ( mPythonUtils && mPythonUtils->isEnabled() )
89378949
{
89388950
QgsPythonRunner::run( QStringLiteral( "pyplugin_installer.instance().installFromZipFile()" ) );
89398951
}
8952+
#endif
89408953
}
89418954

89428955

@@ -8948,19 +8961,23 @@ class QgsPythonRunnerImpl : public QgsPythonRunner
89488961

89498962
virtual bool runCommand( QString command, QString messageOnError = QString() ) override
89508963
{
8964+
#ifdef WITH_BINDINGS
89518965
if ( mPythonUtils && mPythonUtils->isEnabled() )
89528966
{
89538967
return mPythonUtils->runString( command, messageOnError, false );
89548968
}
8969+
#endif
89558970
return false;
89568971
}
89578972

89588973
virtual bool evalCommand( QString command, QString &result ) override
89598974
{
8975+
#ifdef WITH_BINDINGS
89608976
if ( mPythonUtils && mPythonUtils->isEnabled() )
89618977
{
89628978
return mPythonUtils->evalString( command, result );
89638979
}
8980+
#endif
89648981
return false;
89658982
}
89668983

@@ -8993,6 +9010,8 @@ void QgisApp::loadPythonSupport()
89939010
}
89949011
}
89959012

9013+
#ifdef WITH_BINDINGS
9014+
89969015
//QgsDebugMsg("Python support library loaded successfully.");
89979016
typedef QgsPythonUtils*( *inst )();
89989017
inst pythonlib_inst = reinterpret_cast< inst >( cast_to_fptr( pythonlib.resolve( "instance" ) ) );
@@ -9019,6 +9038,7 @@ void QgisApp::loadPythonSupport()
90199038

90209039
QgsMessageLog::logMessage( tr( "Python support ENABLED :-) " ), QString::null, QgsMessageLog::INFO );
90219040
}
9041+
#endif
90229042
}
90239043

90249044
void QgisApp::checkQgisVersion()

src/app/qgspluginregistry.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
#include "qgspluginregistry.h"
2929
#include "qgspluginmetadata.h"
3030
#include "qgisplugin.h"
31+
#ifdef WITH_BINDINGS
3132
#include "qgspythonutils.h"
33+
#endif
3234
#include "qgisapp.h"
3335
#include "qgslogger.h"
3436
#include "qgsmessagelog.h"
@@ -74,10 +76,12 @@ bool QgsPluginRegistry::isLoaded( const QString& key ) const
7476
if ( it != mPlugins.end() ) // found a c++ plugin?
7577
return true;
7678

79+
#ifdef WITH_BINDINGS
7780
if ( mPythonUtils && mPythonUtils->isEnabled() )
7881
{
7982
return mPythonUtils->isPluginLoaded( key );
8083
}
84+
#endif
8185

8286
return false;
8387
}
@@ -88,11 +92,13 @@ QString QgsPluginRegistry::library( const QString& key )
8892
if ( it != mPlugins.constEnd() )
8993
return it->library();
9094

95+
#ifdef WITH_BINDINGS
9196
if ( mPythonUtils && mPythonUtils->isEnabled() )
9297
{
9398
if ( mPythonUtils->isPluginLoaded( key ) )
9499
return key;
95100
}
101+
#endif
96102

97103
return QString();
98104
}
@@ -110,11 +116,13 @@ QgisPlugin *QgsPluginRegistry::plugin( const QString& key )
110116

111117
bool QgsPluginRegistry::isPythonPlugin( const QString& key ) const
112118
{
119+
#ifdef WITH_BINDINGS
113120
if ( mPythonUtils && mPythonUtils->isEnabled() )
114121
{
115122
if ( mPythonUtils->isPluginLoaded( key ) )
116123
return true;
117124
}
125+
#endif
118126
return false;
119127
}
120128

@@ -136,6 +144,7 @@ void QgsPluginRegistry::dump()
136144
it->library() ) );
137145
}
138146

147+
#ifdef WITH_BINDINGS
139148
if ( mPythonUtils && mPythonUtils->isEnabled() )
140149
{
141150
QgsDebugMsg( "PYTHON PLUGINS IN REGISTRY:" );
@@ -145,6 +154,7 @@ void QgsPluginRegistry::dump()
145154
QgsDebugMsg( pluginName );
146155
}
147156
}
157+
#endif
148158
}
149159

150160

@@ -176,13 +186,15 @@ void QgsPluginRegistry::unloadAll()
176186
}
177187
}
178188

189+
#ifdef WITH_BINDINGS
179190
if ( mPythonUtils && mPythonUtils->isEnabled() )
180191
{
181192
Q_FOREACH ( const QString& pluginName, mPythonUtils->listActivePlugins() )
182193
{
183194
mPythonUtils->unloadPlugin( pluginName );
184195
}
185196
}
197+
#endif
186198
}
187199

188200

@@ -263,6 +275,7 @@ bool QgsPluginRegistry::checkQgisVersion( const QString& minVersion, const QStri
263275

264276
void QgsPluginRegistry::loadPythonPlugin( const QString& packageName )
265277
{
278+
#ifdef WITH_BINDINGS
266279
if ( !mPythonUtils || !mPythonUtils->isEnabled() )
267280
{
268281
QgsMessageLog::logMessage( QObject::tr( "Python is not enabled in QGIS." ), QObject::tr( "Plugins" ) );
@@ -296,6 +309,7 @@ void QgsPluginRegistry::loadPythonPlugin( const QString& packageName )
296309

297310
settings.remove( "/PythonPlugins/watchDog/" + packageName );
298311
}
312+
#endif
299313
}
300314

301315

@@ -404,6 +418,7 @@ void QgsPluginRegistry::loadCppPlugin( const QString& theFullPathName )
404418

405419
void QgsPluginRegistry::unloadPythonPlugin( const QString& packageName )
406420
{
421+
#ifdef WITH_BINDINGS
407422
if ( !mPythonUtils || !mPythonUtils->isEnabled() )
408423
{
409424
QgsMessageLog::logMessage( QObject::tr( "Python is not enabled in QGIS." ), QObject::tr( "Plugins" ) );
@@ -419,6 +434,7 @@ void QgsPluginRegistry::unloadPythonPlugin( const QString& packageName )
419434
// disable the plugin no matter if successfully loaded or not
420435
QSettings settings;
421436
settings.setValue( "/PythonPlugins/" + packageName, false );
437+
#endif
422438
}
423439

424440

@@ -488,6 +504,7 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
488504
}
489505
}
490506

507+
#ifdef WITH_BINDINGS
491508
if ( mPythonUtils && mPythonUtils->isEnabled() )
492509
{
493510
// check for python plugins system-wide
@@ -551,6 +568,7 @@ void QgsPluginRegistry::restoreSessionPlugins( const QString& thePluginDirString
551568
}
552569
// end - temporary fix for issue #5879
553570
}
571+
#endif
554572

555573
QgsDebugMsg( "Plugin loading completed" );
556574
}
@@ -581,6 +599,7 @@ bool QgsPluginRegistry::checkCppPlugin( const QString& pluginFullPath )
581599

582600
bool QgsPluginRegistry::checkPythonPlugin( const QString& packageName )
583601
{
602+
#ifdef WITH_BINDINGS
584603
QString pluginName, description, /*category,*/ version;
585604

586605
// get information from the plugin
@@ -599,14 +618,21 @@ bool QgsPluginRegistry::checkPythonPlugin( const QString& packageName )
599618
}
600619

601620
return true;
621+
#else
622+
return false;
623+
#endif
602624
}
603625

604626
bool QgsPluginRegistry::isPythonPluginCompatible( const QString& packageName ) const
605627
{
628+
#ifdef WITH_BINDINGS
606629
QString minVersion = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "qgisMinimumVersion" ) );
607630
// try to read qgisMaximumVersion. Note checkQgisVersion can cope with "__error__" value.
608631
QString maxVersion = mPythonUtils->getPluginMetadata( packageName, QStringLiteral( "qgisMaximumVersion" ) );
609632
return minVersion != QLatin1String( "__error__" ) && checkQgisVersion( minVersion, maxVersion );
633+
#else
634+
return false;
635+
#endif
610636
}
611637

612638
QList<QgsPluginMetadata*> QgsPluginRegistry::pluginData()

0 commit comments

Comments
 (0)