Bug 144063 - QMake manager, error parsing .pro when using 'include' function and an environment variable
Summary: QMake manager, error parsing .pro when using 'include' function and an enviro...
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Unclassified
Component: general (show other bugs)
Version: 3.4.0
Platform: unspecified Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-11 10:54 UTC by Rui L. Pires
Modified: 2007-04-11 18:25 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rui L. Pires 2007-04-11 10:54:18 UTC
Version:           3.4.0 (using KDE 3.5.4, compiled sources)
Compiler:          Target: i586-mandriva-linux-gnu
OS:                Linux (i686) release 2.6.17-6mdv

Setup: Kdevelop SVN/3.4 branch, export of 10/04/2007, 16h00

All our .pro files must begin with the inclusion of a file external to the project for project-wide setup.

This directive reads:

include( $$(VAR_DIR_NAME)/file.pro )

VAR_DIR_NAME holds an absolute path.

When opening Kdevelop an error is reported regarding the parsing of the .pro files at the include directive.

include( /absolute/path/to/file.pro ) yields no such error.
Comment 1 Andreas Pakulat 2007-04-11 18:25:42 UTC
SVN commit 652641 by apaku:

Substitute shell variables with real values. Note: The shell variables need to be set when starting KDevelop
Also fix a small bug along the way wrt. opening include( foobar.pri ).
BUG:144063


 M  +18 -1     scope.cpp  


--- branches/KDE/3.5/kdevelop/buildtools/qmake/scope.cpp #652640:652641
@@ -883,7 +883,7 @@
         {
             QMake::IncludeAST * i = static_cast<QMake::IncludeAST*>( *it );
             QString filename = i->projectName;
-            if( i->projectName.startsWith("$") )
+            if( i->projectName.stripWhiteSpace().startsWith("$") )
             {
                 filename = resolveVariables(i->projectName, *it);
             }
@@ -1250,6 +1250,23 @@
                 pos += re.matchedLength();
             }
         }
+        re = QRegExp("\\$\\$\\(([^\\)\\}]*)\\)");
+        pos = 0;
+        QMap<QString, QString> envvars;
+        while( pos >= 0 )
+        {
+            pos = re.search( (*it), pos );
+            if( pos > -1 )
+            {
+                if( !envvars.contains( re.cap(1) ) && ::getenv( re.cap(1).local8Bit() ) != 0 )
+                    envvars[re.cap(1)] = QString::fromLocal8Bit(::getenv( re.cap(1).local8Bit() ) );
+                pos += re.matchedLength();
+            }
+        }
+        for( QMap<QString, QString>::const_iterator it2 = envvars.begin(); it2 != envvars.end(); ++it2 )
+        {
+            (*it).replace("$$("+it2.key()+")", it2.data() );
+        }
         for( QMap<QString, QStringList>::const_iterator it2 = variables.begin(); it2 != variables.end(); ++it2 )
         {
             for( QStringList::const_iterator it3 = it2.data().begin(); it3 != it2.data().end(); ++it3 )