Broken single-file compile in "empty" (generic) project [PATCH]

Roland Krause rokrau at yahoo.com
Thu Jul 18 21:28:06 UTC 2002


Kuba, 
have you tested this? Do you want me to apply this? 

Roland, who doesn't have any qmake based projects. 

--- Kuba Ober <kuba at mareimbrium.org> wrote:
> Hi,
> 
> The single-file compile in empty project types is broken. It doesn't
> call the 
> gmake in proper working directory, and generally doesn't feel the
> clue about 
> what it does.
> 
> I've noticed it when I switched from standard autoconf-based projects
> to 
> playing with qmake-generated makefiles.
> 
> The attached patch makes it reasonably work (notably taking care of
> make 
> options specified in project options, etc.), although I must look
> into the 
> case when make would be run in project's root directory (say 
> ~/src/kdevelop-2.1) and the target would be somewhere deeper (say 
> ./kdevelop/kwrite/blah.cpp) -- then it will handle non-recursive make
> 
> invocations allrighty (yep, there are some people who don't use
> recursive 
> make).
> 
> Cheers, Kuba Ober
> 
> PS. On monday or tuesday I'll have some more, revamped indent patches
> which 
> hopefully will make indenting quite user-friendly (I use it
> constantly so I 
> know ;-). This stuff seems generic enough to be ported into current
> kate's 
> sources, and that will be my next step.> ---
kdevelop-2.1-org/kdevelop/ckdevelop.cpp	Sun Mar 24 13:27:03 2002
> +++ kdevelop-2.1/kdevelop/ckdevelop.cpp	Sat Jun  8 12:30:03 2002
> @@ -976,25 +976,51 @@
>    }
>    else
>    {
> -    QString makefile=actualDir+"/Makefile";
> +    // Find the pertinent makefile. Search order is:
> +    // 1. Current file's path
> +    // 2. Project's subdirectory (say xyz/src)
> +    // 3. Project's main directory
> +    QString makefile = fileinfo.dirPath(true) + "/Makefile";
> +    if (! QFileInfo(makefile).exists()) {
> +      makefile = prj->getProjectDir() + prj->getSubDir() +
> "Makefile";
> +    }
> +    if (! QFileInfo(makefile).exists()) {
> +      makefile = prj->getProjectDir() + "Makefile";
> +    }
> +    bool gotMakefile = QFileInfo(makefile).exists();
> +    if (! gotMakefile) {
> +      debug("note: makefile not found, gmake will probably use
> default rules");
> +    }
> +    // Working directory has to be set, and we *don't* touch
> kdevelop's current't
> +    // directory (via QDir::setCurrent()).
> +    // Working directory is tried to be set to (priority is 3, 2, 1)
> +    // 1. Absolute directory of current file, then to
> +    // 2. Absolute directory of the makefile, then to
> +    // 3. Directory where make should be called, from project
> options
> +    QString cwd = fileinfo.dirPath(true);
> +    if (gotMakefile) {
> +      cwd = QFileInfo(makefile).dirPath(true);      
> +    }
> +    cwd = prj->getDirWhereMakeWillBeCalled(cwd); // this is
> typically relative
> +    if (QDir::isRelativePath(cwd)) {
> +      cwd = prj->getProjectDir() + cwd;     
> +    }
> +    cwd = QDir(cwd).absPath();
> +    // Invoke make with proper options
> +    debug("run: %s in: %s", make_cmd.data(), cwd.data());
> +    process.setWorkingDirectory(cwd);
>      process << make_cmd;
> -	  debug("run: %s ", make_cmd.data());
> -    if (!QFileInfo(makefile).exists())
> -    {
> -      makefile=prj->getProjectDir()+prj->getSubDir()+"Makefile";
> -      if (!QFileInfo(makefile).exists())
> -        makefile=prj->getProjectDir()+"Makefile";
> -      if (QFileInfo(makefile).exists())
> -      {
> -			  process << "-f" << makefile;
> -	      debug("-f %s ", makefile.data());
> -			}
> +    QString makeOptions = prj->getMakeOptions();
> +    if (gotMakefile &&
> +        (QFileInfo(makefile).dirPath(true) != cwd)) {
> +      makeOptions += " -f " + makefile;
>      }
> -	  debug("%s.o\n",fileinfo.baseName().data());
> +    debug("make options: %s", makeOptions.data());
> +    process << prj->getMakeOptions();
> +    debug("%s.o\n",fileinfo.baseName().data());
>      process << fileinfo.baseName()+".o";
>    }
>  
> -
>    process.start(KProcess::NotifyOnExit,KProcess::AllOutput);
>  }
>  
> 

__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com




More information about the KDevelop-devel mailing list