Skip to content

Commit

Permalink
fix building of process without bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids authored and nyalldawson committed Jul 30, 2021
1 parent 521df10 commit 6ca5557
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/process/CMakeLists.txt
Expand Up @@ -64,9 +64,6 @@ if (WITH_3D)
)
endif()

if (WITH_BINDINGS)
target_link_libraries(qgis_process qgispython)
endif()

target_link_libraries(qgis_process
qgis_core
Expand All @@ -83,6 +80,11 @@ if (WITH_3D)
)
endif()

if (WITH_BINDINGS)
target_link_libraries(qgis_process qgispython)
add_definitions(-DWITH_BINDINGS)
endif()

# install

install (TARGETS qgis_process
Expand Down
15 changes: 14 additions & 1 deletion src/process/qgsprocess.cpp
Expand Up @@ -176,7 +176,7 @@ void ConsoleFeedback::showTerminalProgress( double progress )
fflush( stdout );
}


#ifdef WITH_BINDINGS
//! load Python support if possible
std::unique_ptr< QgsPythonUtils > QgsProcessingExec::loadPythonSupport()
{
Expand Down Expand Up @@ -220,6 +220,7 @@ std::unique_ptr< QgsPythonUtils > QgsProcessingExec::loadPythonSupport()

return pythonUtils;
}
#endif

QgsProcessingExec::QgsProcessingExec()
{
Expand Down Expand Up @@ -259,6 +260,8 @@ int QgsProcessingExec::run( const QStringList &constArgs )
QgsApplication::processingRegistry()->addProvider( new Qgs3DAlgorithms( QgsApplication::processingRegistry() ) );
#endif

#ifdef WITH_BINDINGS

// give Python plugins a chance to load providers
mPythonUtils = loadPythonSupport();
if ( !mPythonUtils )
Expand Down Expand Up @@ -431,6 +434,7 @@ int QgsProcessingExec::run( const QStringList &constArgs )
{
std::cerr << QStringLiteral( "Command %1 not known!\n" ).arg( command ).toLocal8Bit().constData();
}
#endif
return 1;
}

Expand All @@ -456,6 +460,7 @@ void QgsProcessingExec::showUsage( const QString &appName )
std::cout << msg.join( QString() ).toLocal8Bit().constData();
}

#ifdef WITH_BINDINGS
void QgsProcessingExec::loadPlugins()
{
QgsSettings settings;
Expand All @@ -476,6 +481,7 @@ void QgsProcessingExec::loadPlugins()
}
}
}
#endif

void QgsProcessingExec::listAlgorithms( bool useJson )
{
Expand Down Expand Up @@ -559,6 +565,7 @@ void QgsProcessingExec::listPlugins( bool useJson, bool showLoaded )
addVersionInformation( json );
}

#ifdef WITH_BINDINGS
QVariantMap jsonPlugins;
const QStringList plugins = mPythonUtils->pluginList();
for ( const QString &plugin : plugins )
Expand Down Expand Up @@ -587,6 +594,7 @@ void QgsProcessingExec::listPlugins( bool useJson, bool showLoaded )
json.insert( QStringLiteral( "plugins" ), jsonPlugins );
std::cout << QgsJsonUtils::jsonFromVariant( json ).dump( 2 );
}
#endif
}

int QgsProcessingExec::enablePlugin( const QString &name, bool enabled )
Expand All @@ -596,6 +604,7 @@ int QgsProcessingExec::enablePlugin( const QString &name, bool enabled )
else
std::cout << QStringLiteral( "Disabling plugin: \"%1\"\n" ).arg( name ).toLocal8Bit().constData();

#ifdef WITH_BINDINGS
const QStringList plugins = mPythonUtils->pluginList();
if ( !plugins.contains( name ) )
{
Expand Down Expand Up @@ -645,6 +654,10 @@ int QgsProcessingExec::enablePlugin( const QString &name, bool enabled )
listPlugins( false, false );

return 0;
#else
std::cerr << "No Python support\n";
return 1;
#endif
}

int QgsProcessingExec::showAlgorithmHelp( const QString &id, bool useJson )
Expand Down
8 changes: 7 additions & 1 deletion src/process/qgsprocess.h
Expand Up @@ -17,9 +17,12 @@
#ifndef QGSPROCESS_H
#define QGSPROCESS_H

#include "qgsprocessingfeedback.h"
#ifdef WITH_BINDINGS
#include "qgspythonrunner.h"
#include "qgspythonutils.h"
#endif

#include "qgsprocessingfeedback.h"
#include "qgsunittypes.h"
#include <QElapsedTimer>

Expand Down Expand Up @@ -88,8 +91,11 @@ class QgsProcessingExec
void addAlgorithmInformation( QVariantMap &json, const QgsProcessingAlgorithm *algorithm );
void addProviderInformation( QVariantMap &json, QgsProcessingProvider *provider );


#ifdef WITH_BINDINGS
std::unique_ptr< QgsPythonUtils > mPythonUtils;
std::unique_ptr<QgsPythonUtils> loadPythonSupport();
#endif
};

#endif // QGSPROCESS_H
Expand Down

0 comments on commit 6ca5557

Please sign in to comment.