Skip to content

Commit

Permalink
make tests & qgis work from the build directory (python still doesn't)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Apr 15, 2012
1 parent 561d069 commit d1963e8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
22 changes: 19 additions & 3 deletions src/core/qgsapplication.cpp
Expand Up @@ -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 );

Expand Down Expand Up @@ -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
Expand All @@ -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 + "/";
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgsapplication.h
Expand Up @@ -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 ); }
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsrasterdataprovider.h
Expand Up @@ -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
Expand Down

0 comments on commit d1963e8

Please sign in to comment.