Skip to content

Commit d1963e8

Browse files
committed
make tests & qgis work from the build directory (python still doesn't)
1 parent 561d069 commit d1963e8

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/core/qgsapplication.cpp

+19-3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ QStringList ABISYM( QgsApplication::mDefaultSvgPaths );
5050
QString ABISYM( QgsApplication::mConfigPath );
5151
bool ABISYM( QgsApplication::mRunningFromBuildDir ) = false;
5252
QString ABISYM( QgsApplication::mBuildSourcePath );
53+
#ifdef _MSC_VER
54+
QString ABISYM( QgsApplication::mCfgIntDir );
55+
#endif
5356
QString ABISYM( QgsApplication::mBuildOutputPath );
5457
QStringList ABISYM( QgsApplication::mGdalSkipList );
5558

@@ -81,14 +84,23 @@ void QgsApplication::init( QString customConfigPath )
8184

8285
// check if QGIS is run from build directory (not the install directory)
8386
QDir appDir( applicationDirPath() );
84-
if ( appDir.exists( "source_path.txt" ) )
87+
#ifndef _MSC_VER
88+
#define SOURCE_PATH "source_path.txt"
89+
#else
90+
#define SOURCE_PATH "../source_path.txt"
91+
#endif
92+
if ( appDir.exists( SOURCE_PATH ) )
8593
{
86-
QFile f( applicationDirPath() + "/source_path.txt" );
94+
QFile f( applicationDirPath() + "/" + SOURCE_PATH );
8795
if ( f.open( QIODevice::ReadOnly ) )
8896
{
8997
ABISYM( mRunningFromBuildDir ) = true;
9098
ABISYM( mBuildSourcePath ) = f.readAll();
91-
#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
99+
#if _MSC_VER
100+
QStringList elems = applicationDirPath().split( "/", QString::SkipEmptyParts );
101+
ABISYM( mCfgIntDir ) = elems.last();
102+
ABISYM( mBuildOutputPath ) = applicationDirPath() + "/../..";
103+
#elif defined(Q_WS_MACX)
92104
ABISYM( mBuildOutputPath ) = applicationDirPath();
93105
#else
94106
ABISYM( mBuildOutputPath ) = applicationDirPath() + "/.."; // on linux
@@ -103,7 +115,11 @@ void QgsApplication::init( QString customConfigPath )
103115
{
104116
// we run from source directory - not installed to destination (specified prefix)
105117
ABISYM( mPrefixPath ) = QString(); // set invalid path
118+
#ifdef _MSC_VER
119+
setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) + "/" + ABISYM( mCfgIntDir ) );
120+
#else
106121
setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
122+
#endif
107123
setPkgDataPath( ABISYM( mBuildSourcePath ) ); // directly source path - used for: doc, resources, svg
108124
ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) + "/" + QGIS_LIB_SUBDIR + "/";
109125
ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) + "/" + QGIS_LIBEXEC_SUBDIR + "/";

src/core/qgsapplication.h

+7
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ class CORE_EXPORT QgsApplication: public QApplication
222222
/** Indicates whether running from build directory (not installed)
223223
@note added in 2.0 */
224224
static bool isRunningFromBuildDir() { return ABISYM( mRunningFromBuildDir ); }
225+
#ifdef _MSC_VER
226+
static QString cfgIntDir() { return ABISYM( mCfgIntDir ); }
227+
#endif
225228
/** Returns path to the source directory. Valid only when running from build directory
226229
@note added in 2.0 */
227230
static QString buildSourcePath() { return ABISYM( mBuildSourcePath ); }
@@ -277,6 +280,10 @@ class CORE_EXPORT QgsApplication: public QApplication
277280
static bool ABISYM( mRunningFromBuildDir );
278281
/** path to the source directory. valid only when running from build directory. */
279282
static QString ABISYM( mBuildSourcePath );
283+
#ifdef _MSC_VER
284+
/** configuration internal dir */
285+
static QString ABISYM( mCfgIntDir );
286+
#endif
280287
/** path to the output directory of the build. valid only when running from build directory */
281288
static QString ABISYM( mBuildOutputPath );
282289
/** List of gdal drivers to be skipped. Uses GDAL_SKIP to exclude them.

src/core/qgsrasterdataprovider.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
379379
QString generateBandName( int theBandNumber )
380380
{
381381
return tr( "Band" ) + QString( " %1" ) .arg( theBandNumber, 1 + ( int ) log10(( float ) bandCount() ), 10, QChar( '0' ) );
382-
};
382+
}
383383

384384
/**
385385
* Get metadata in a format suitable for feeding directly

0 commit comments

Comments
 (0)