Skip to content
Permalink
Browse files
make tests & qgis work from the build directory (python still doesn't)
  • Loading branch information
jef-n committed Apr 15, 2012
1 parent 561d069 commit d1963e825e772dd4176ff5ce3d7b5b8318bee0c8
Showing with 27 additions and 4 deletions.
  1. +19 −3 src/core/qgsapplication.cpp
  2. +7 −0 src/core/qgsapplication.h
  3. +1 −1 src/core/qgsrasterdataprovider.h
@@ -50,6 +50,9 @@ QStringList ABISYM( QgsApplication::mDefaultSvgPaths );
QString ABISYM( QgsApplication::mConfigPath );
bool ABISYM( QgsApplication::mRunningFromBuildDir ) = false;
QString ABISYM( QgsApplication::mBuildSourcePath );
#ifdef _MSC_VER
QString ABISYM( QgsApplication::mCfgIntDir );
#endif
QString ABISYM( QgsApplication::mBuildOutputPath );
QStringList ABISYM( QgsApplication::mGdalSkipList );

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

// check if QGIS is run from build directory (not the install directory)
QDir appDir( applicationDirPath() );
if ( appDir.exists( "source_path.txt" ) )
#ifndef _MSC_VER
#define SOURCE_PATH "source_path.txt"
#else
#define SOURCE_PATH "../source_path.txt"
#endif
if ( appDir.exists( SOURCE_PATH ) )
{
QFile f( applicationDirPath() + "/source_path.txt" );
QFile f( applicationDirPath() + "/" + SOURCE_PATH );
if ( f.open( QIODevice::ReadOnly ) )
{
ABISYM( mRunningFromBuildDir ) = true;
ABISYM( mBuildSourcePath ) = f.readAll();
#if defined(Q_WS_MACX) || defined(Q_WS_WIN32) || defined(WIN32)
#if _MSC_VER
QStringList elems = applicationDirPath().split( "/", QString::SkipEmptyParts );
ABISYM( mCfgIntDir ) = elems.last();
ABISYM( mBuildOutputPath ) = applicationDirPath() + "/../..";
#elif defined(Q_WS_MACX)
ABISYM( mBuildOutputPath ) = applicationDirPath();
#else
ABISYM( mBuildOutputPath ) = applicationDirPath() + "/.."; // on linux
@@ -103,7 +115,11 @@ void QgsApplication::init( QString customConfigPath )
{
// we run from source directory - not installed to destination (specified prefix)
ABISYM( mPrefixPath ) = QString(); // set invalid path
#ifdef _MSC_VER
setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) + "/" + ABISYM( mCfgIntDir ) );
#else
setPluginPath( ABISYM( mBuildOutputPath ) + "/" + QString( QGIS_PLUGIN_SUBDIR ) );
#endif
setPkgDataPath( ABISYM( mBuildSourcePath ) ); // directly source path - used for: doc, resources, svg
ABISYM( mLibraryPath ) = ABISYM( mBuildOutputPath ) + "/" + QGIS_LIB_SUBDIR + "/";
ABISYM( mLibexecPath ) = ABISYM( mBuildOutputPath ) + "/" + QGIS_LIBEXEC_SUBDIR + "/";
@@ -222,6 +222,9 @@ class CORE_EXPORT QgsApplication: public QApplication
/** Indicates whether running from build directory (not installed)
@note added in 2.0 */
static bool isRunningFromBuildDir() { return ABISYM( mRunningFromBuildDir ); }
#ifdef _MSC_VER
static QString cfgIntDir() { return ABISYM( mCfgIntDir ); }
#endif
/** Returns path to the source directory. Valid only when running from build directory
@note added in 2.0 */
static QString buildSourcePath() { return ABISYM( mBuildSourcePath ); }
@@ -277,6 +280,10 @@ class CORE_EXPORT QgsApplication: public QApplication
static bool ABISYM( mRunningFromBuildDir );
/** path to the source directory. valid only when running from build directory. */
static QString ABISYM( mBuildSourcePath );
#ifdef _MSC_VER
/** configuration internal dir */
static QString ABISYM( mCfgIntDir );
#endif
/** path to the output directory of the build. valid only when running from build directory */
static QString ABISYM( mBuildOutputPath );
/** List of gdal drivers to be skipped. Uses GDAL_SKIP to exclude them.
@@ -379,7 +379,7 @@ class CORE_EXPORT QgsRasterDataProvider : public QgsDataProvider
QString generateBandName( int theBandNumber )
{
return tr( "Band" ) + QString( " %1" ) .arg( theBandNumber, 1 + ( int ) log10(( float ) bandCount() ), 10, QChar( '0' ) );
};
}

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

0 comments on commit d1963e8

Please sign in to comment.