Bug 69035

Summary: Run Options not honored
Product: [Applications] kdevelop Reporter: Karl Robillard <karlr>
Component: Build tools: Custom MakefilesAssignee: KDevelop Developers <kdevelop-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 3.0.0b1   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Karl Robillard 2003-11-26 02:06:31 UTC
Version:           3.0.0b1 (using KDE KDE 3.1.3)
Installed from:    Unlisted Binary Package
OS:          Linux

My options are set similar to this:
  Custom directory:  /home/blah/run
  Main program:      /usr/local/bin/prog
  Program arguments: myargs
  

I would expect KDevelop to do something equivalent to "cd /home/blah/run; /usr/local/bin/prog myargs".  However, it seems to do "cd /usr/local/bin; ./prog myargs".  The program should be run from the Custom directory specified and should NOT strip the path from the Main program line.

There is also an inconsistency in the dialog where the Main program line is followed by "(absolute path)" but the popup help states "The path ... defined relative ...".


-Karl
Comment 1 Jens Dagerbo 2003-11-26 06:51:42 UTC
What project manager is this? QMake?
Comment 2 Jens Dagerbo 2003-11-26 19:59:24 UTC
Karl replied: 
>>>
I have no idea.  I see nothing in the Project options dialog which refers to a 
'project manager' or QMake.  If you are asking about the project type, then I 
started the project by importing an existing project of "Generic C++ 
Application (Custom Makefiles)".
<<<

Looks like another problem in custom project
Comment 3 Dietrich Foethke 2004-01-29 18:51:15 UTC
Hello,

I have exactly the same problem as Karl with kdevelop 3.0.0rc1. The run-path is not correctly set if I change it in the project-settings. Whatever you type in the settings, kdevelop always seems to cd to the directory where the binary is and than execute it from there. Quite annoying! Actually my project is also a custom-project.

Greetings,
Dietrich
Comment 4 Amilcar do Carmo Lucas 2004-01-29 19:09:42 UTC
Yes this is a custom-project known issue.
If you use autotools it works fine I'll try to fix it in the next few days.
Comment 5 Amilcar do Carmo Lucas 2004-01-29 21:45:40 UTC
Subject: KDE_3_2_BRANCH: kdevelop/buildtools/custommakefiles

CVS commit by aclu: 

fix: Bug 69035: Run Options not honored (custommakefiles)

CCMAIL: 69035-done@bugs.kde.org


  M +19 -24    customprojectpart.cpp   1.68.2.1


--- kdevelop/buildtools/custommakefiles/customprojectpart.cpp  #1.68:1.68.2.1
@@ -592,23 +592,9 @@ void CustomProjectPart::slotExecute()
     }
 
-    QString directory;
-    QString program = project()->mainProgram();
-    int pos = program.findRev('/');
-    if (pos != -1) {
-        // Directory where the executable is
-        directory = program.left(pos+1);
-        // Executable name with a "./" prepended for execution with bash shells
-        program   = "./" + (project()->mainProgram()).mid(pos+1);
-    }
-
-    program += " " + DomUtil::readEntry(*projectDom(), "/kdevcustomproject/run/programargs");
-
     // Get the run environment variables pairs into the environstr string
     // in the form of: "ENV_VARIABLE=ENV_VALUE"
     // Note that we quote the variable value due to the possibility of
     // embedded spaces
-    DomUtil::PairList envvars =
-        DomUtil::readPairListEntry(*projectDom(), "/kdevcustomproject/run/envvars", "envvar", "name", "value");
-
+    DomUtil::PairList envvars = runEnvironmentVars();
     QString environstr;
     DomUtil::PairList::ConstIterator it;
@@ -616,18 +602,27 @@ void CustomProjectPart::slotExecute()
         environstr += (*it).first;
         environstr += "=";
-/*
-#if (KDE_VERSION > 305)
-        environstr += KProcess::quote((*it).second);
-#else
-        environstr += KShellProcess::quote((*it).second);
-#endif
-*/
         environstr += EnvVarTools::quote((*it).second);
         environstr += " ";
     }
-    program.prepend(environstr);
+
+    if (mainProgram(true).isEmpty())
+    // Do not execute non executable targets
+        return;
+
+    QString program = environstr;
+    // Adds the ./ that is necessary to execute the program in bash shells
+    if (!mainProgram(true).startsWith("/"))
+        program += "./";
+    program += mainProgram(true);
+    program += " " + runArguments();
 
     bool inTerminal = DomUtil::readBoolEntry(*projectDom(), "/kdevcustomproject/run/terminal");
-    appFrontend()->startAppCommand(directory, program, inTerminal);
+
+    kdDebug(9025) << "runDirectory: <" << runDirectory() << ">" <<endl;
+    kdDebug(9025) << "environstr  : <" << environstr << ">" <<endl;
+    kdDebug(9025) << "mainProgram : <" << mainProgram(true) << ">" <<endl;
+    kdDebug(9025) << "runArguments: <" << runArguments() << ">" <<endl;
+
+    appFrontend()->startAppCommand(runDirectory(), program, inTerminal);
 }