[PATCH] qmake4 -recursive, root *.pro handling

Andreas Pakulat apaku at gmx.de
Sat Jul 28 22:44:02 UTC 2007


On 28.07.07 22:19:45, Thomas Hasart wrote:
> On Saturday 28 July 2007 21:53:32 Andreas Pakulat wrote:
> > On 28.07.07 17:14:45, Thomas Hasart wrote:
> > > On Saturday 28 July 2007 14:16:20 you wrote:
> > > > Unless I'm totally mistaken (didn't look at the code for quite some
> > > > weeks) this is wrong. It breaks with relative files.
> > >
> > > This is to show the file name, instead the pathFromPro/filename;
> >
> > I don't want that, it hides from the user where the file is and thats
> > not good.
> I think its not usable for users, i have an project with 30 - 50 files in the 
> pri files. its terrible to find an file in the tree if everyitem starts with 
> the same path.
> I think its suffices to show the path in the parent include item. Its like a 
> directory tree. On the file items only showed the filename.

You're missing the point, its possible to have a .pro file with this:

SOURCES = foo.cpp ../bar/bar.cpp ../../../otherproject/foo.cpp

And when you now only show the filenames you never know which foo.cpp
you're using. So its not possible to change this. And until now nobody
was complaining about that, in fact every user I talked to wanted to see
the path as it is in the .pro file. 

> > > > >  void TrollProjectWidget::emitAddedFile( const QString &fileName )
> > > > > @@ -2289,16 +2294,21 @@
> > > > >
> > > > >  void TrollProjectWidget::runQMakeRecursive( QMakeScopeItem* proj )
> > > > >  {
> > > > > -    if ( proj->scope->scopeType() == Scope::ProjectScope )
> > > > > +    if(m_part->isQt4Project())
> > > > >      {
> > > > > -        m_part->startQMakeCommand( proj->scope->projectDir() );
> > > > > +            m_part->startQMakeCommand(
> > > > > proj->scope->projectDir(),true); +    }else{
> > > >
> > > > Please stick to the existing code style here, i.e. whitespace around
> > > > else and { on a new line.
> > > >
> > > > > Index: kdevelop-3.5/buildtools/qmake/scope.cpp
> > > > > ===================================================================
> > > > > --- kdevelop-3.5/buildtools/qmake/scope.cpp    (revision 693442)
> > > > > +++ kdevelop-3.5/buildtools/qmake/scope.cpp    (working copy)
> > > > > @@ -971,6 +971,10 @@
> > > > >
> > > > >  QString Scope::projectDir() const
> > > > >  {
> > > > > +    if(scopeType()==IncludeScope)
> > > > > +    {
> > > > > +       return  parent()->projectDir();
> > > > > +    }
> > > >
> > > > This is not correct I think. A include'd file is always evaluated by
> > > > qmake in its directory, not in the directory of the file that includes
> > > > it, i.e. if I have
> > > >
> > > > src/foo.pro
> > > > src/f1/f1.pri
> > > >
> > > > foo.pro: include(f1/f1.pri)
> > > >
> > > > then all stuff inside f1.pri is evaluated with src/f1 as current
> > > > directory.
> > >
> > > Oh thats new for me, I've tested it without "src/" in pri an it worked.
> > > The .pro and .pri for an large project i have create for a time for Qt
> > > 4.0.x and there the files are evaluated in the .pro dir (I had tested it
> > > at this time, before i changed the pri files in this way). May be that
> > > this was changed by newer qt versions, but the other way is also working.
> > > Have a look at the qt-sources, there are all pri file SOURCES with path
> > > from from pro file.
> >
> > Hmm, maybe I was wrong. I remembered this from a thread on the
> > qt-interest mailinglist... However I can't reproduce this with qmake
> >
> > >from Qt4 here, i.e. the include() is always evaluated in the context of
> >
> > the file where it is written in. So for
> >
> > src/src.pro
> > bar/bar.pri
> > bar/foo/foo.pri
> >
> > and include(foo/foo.pri) in bar.pri I get the expected result.
> >
> > > Without the patch pri filese with path inside not handled correct and
> > > with the patch without path inside not handled correct.
> > > So it's not easy to correct the handling for both cases because i think
> > > the entire filepath is also builded outside from the Scope with
> > > projectDir()+$SOURCES....
> >
> > Hmm, do you have a testcase for both problems? I can't even reproduce
> > your original problem here with the above sample, i.e. the
> > include(../bar/bar.pri) properly finds bar.pri and the
> > include(foo/foo.pri) in bar.pri is also properly visible in qmake
> > manager, without any changes from you.
> 
> 
> files:
> prj.pro
> src/src.pri
> src/test.cpp
> 
> prj.pro
> include(src/src.pri)
> 
> src/src.pri
> SOURCES += src/test.cpp
> 
> in this case filename = "src/test.cpp" and project dir of includeScope 
> = "$(projectRoot)/src" -> resulting in "$(projectRoot)/src/src/test.cpp" 
> which is one "src" to much. thatswhy kdevelop cannot open this file test.cpp 
> by clicking it.

Hmm... I'm convinced, the include-file-stuff works even with your patch
as the creation of the subscope for the actual .pri file is done while
iterating the statements of a ProjectAST (so nodeType() doesn't return
IncldeAST at that point). 

So please provide an updated patch with the warning removed and also
without the changes regarding qmakescopeitem::text() and I will commit
it.

Andreas

-- 
Don't read everything you believe.




More information about the KDevelop-devel mailing list