Skip to content
Permalink
Browse files
fix building of process without bindings
  • Loading branch information
3nids authored and nyalldawson committed Aug 17, 2021
1 parent ca6de5b commit 70f6649530d14b188028055ce23cb7d3331e22e4
Showing with 26 additions and 5 deletions.
  1. +5 −3 src/process/CMakeLists.txt
  2. +14 −1 src/process/qgsprocess.cpp
  3. +7 −1 src/process/qgsprocess.h
@@ -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
@@ -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
@@ -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()
{
@@ -220,6 +220,7 @@ std::unique_ptr< QgsPythonUtils > QgsProcessingExec::loadPythonSupport()

return pythonUtils;
}
#endif

QgsProcessingExec::QgsProcessingExec()
{
@@ -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 )
@@ -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;
}

@@ -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;
@@ -476,6 +481,7 @@ void QgsProcessingExec::loadPlugins()
}
}
}
#endif

void QgsProcessingExec::listAlgorithms( bool useJson )
{
@@ -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 )
@@ -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 )
@@ -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 ) )
{
@@ -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 )
@@ -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>

@@ -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

0 comments on commit 70f6649

Please sign in to comment.