Bug 239004 - Custom Makefile Project has wrong working directory
Summary: Custom Makefile Project has wrong working directory
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Build tools: Custom Makefiles (show other bugs)
Version: 4.0.0
Platform: Exherbo Linux
: NOR major
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-27 13:15 UTC by António Oliveira
Modified: 2016-09-07 22:04 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.0.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description António Oliveira 2010-05-27 13:15:14 UTC
Version:           4.0.0 (using KDE 4.4.2) 
OS:                Linux

When working on a custom makefile project, I notice that when invoking make, the working directory is set to ${HOME} instead of the Makefile's own location.

This brings up all sorts of headaches on projects that rely on other directories which would be referenced as relative paths.

This is a minor issue, but if the working directory was set to the Makefile's location or if the user had a chance to define the directory himself, kdevelop's usability would be much greater.

Thanks.

Reproducible: Always

Steps to Reproduce:
Have a Makefile with:

WDIR:=$(shell pwd)
all:
    echo ${WDIR}


Actual Results:  
Invoking this makefile from kdevelop 4 from anywhere yelds the user home directory.

Expected Results:  
Should print the same directory where make is located

OS: Linux (x86_64) release 2.6.32-22-generic
Compiler: cc
Comment 1 Andreas Pakulat 2010-05-27 18:24:30 UTC
Actually that is not the case. The custom makefile manager returns the folder of the project or the parent folder of the current item (if the item is not a folder itself). The item it gets as input is whatever is to be built (usually whats in the project selection).

So what is in your project selection? Where is your project directory?
Comment 2 John 2012-03-23 19:25:30 UTC
Using KDE 4.3.0:

1. Create a project with the following Makefile.

== Makefile ===========

build :
	echo $(PWD)

=======================

2. Right click "build" target and add to build set.

3. Build (F8 by default).

4. I receive the following wrong output.

== Output =============

/home/john/projects/pwd_test_project/> make
echo /home/john
/home/john
*** Finished ***

=======================

5 Run the same from the command line and get the following correct output:

== Commandline ========

[john@ALAP pwd_test_project]$ make
echo /home/john/projects/pwd_test_project
/home/john/projects/pwd_test_project

=======================
Comment 3 John 2012-03-23 19:26:58 UTC
(In reply to comment #2)
> Using KDE 4.3.0:

I of course meant KDevelop 4.3.0 :-s
Comment 4 Milian Wolff 2012-03-29 16:59:20 UTC
test case provided
Comment 5 Milian Wolff 2016-09-07 21:21:55 UTC
still valid in 5.0, looking into it now
Comment 6 Milian Wolff 2016-09-07 21:41:41 UTC
Git commit d28d5179632b42238fc0ac9a2d667082756f39e4 by Milian Wolff.
Committed on 07/09/2016 at 21:40.
Pushed by mwolff into branch '5.0'.

Update PWD env var when setting working directory on execute jobs.

We actually properly set the working directory, but when scripts
rely on the PWD env var, and we don't update that, things can break.
This patch simply updates the PWD env var if set before to the new
working directory before running the job.

M  +8    -3    outputview/outputexecutejob.cpp

http://commits.kde.org/kdevplatform/d28d5179632b42238fc0ac9a2d667082756f39e4