Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 346103

Summary: Copy / paste project breaks managed make
Product: [Tools] PTP Reporter: Daniel Harenberg <dharenberg>
Component: Photran.Managed MakeAssignee: Jeffrey Overbey <com-eclipse-dot-org>
Status: CLOSED WORKSFORME QA Contact:
Severity: minor    
Priority: P2 CC: com-eclipse-dot-org, dharenberg
Version: 8.0.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Daniel Harenberg CLA 2011-05-17 11:08:05 EDT
Problem: 
After copy and paste of a project in the 'Fortran projects' view, making a clean build or switching the build configuration doesn't work anymore, if you have a module in a subdirectory and more than one build configuration. The new files 'subdir.mk' will wrongly have 'Debug_IA-32/' in the path to the object file of the module. This error is basically the same as the one in Bug 326333: that bug has been fixed, but the same thing still happens after a copy and paste.

To reproduce:
0. Create a new fortran project
1. Create a simple F90 program, e.g. Hello World
2. Insert a line at the top using a module, eg. use mod_hello
3. Create a new source folder, e.g. modules
4. Create the used module and put it in the source folder, e.g. mod_hello.f90
in the folder modules (only needs opening and ending lines 'module mod_hello'
and 'end module mod_hello')
5. Select build environment, e.g. 'Debug_IA-32'
6. Build 
7. Change build environment, e.g. to 'Release_IA-32'
8. Build
9. In the Fortran projects view, copy and paste the project
10. Rightclick on new project -> clean project

Now the error should appear:

make: *** No rule to make target `Debug_IA-32/modules/mod_hello.o', needed by
`main.o'.  Stop.

More info:
Look at the file Release_IA-32/subdir.mk to see the erroneous build commands.
Alternative to step 10 resulting in same error: switch build configuration and build. I am pretty sure all steps are necessary, in particular building both configurations before copy and paste. I set severity to major because I think it is highly important that managed make works (see my arguments in Bug 326333), and the presented use case should be common.
Comment 1 Jeffrey Overbey CLA 2012-02-29 20:26:03 EST
It looks like this is a bug in the dependency calculator.  The following output...

Configuration is Release
Found dependencies [L/Bug346103Copy/modules/mod.f90]
Configuration is Release
Found dependencies [L/Bug346103Copy/hello.f90, L/Bug346103Copy/Release/Debug/modules/mod.o]

...results after adding output to DefaultFortranDependencyCalculator#findDependencies:

		System.out.println("Configuration is " + config.getName());
		System.out.println("Found dependencies " + dependencies);
Comment 2 Daniel Harenberg CLA 2012-06-13 03:36:15 EDT
Jeff,

I saw that you just changed the target milestone from 8.0 to future. That is bad news, at least for me. Maybe I am getting something wrong, but shouldn't it be one of the main usages of an IDE to copy and paste an entire project? If that breaks the make process, this seems like a bad bug that needs a high priority.

Anyway, I am looking forward to the new release and will try to replicate this bug using the latest Eclipse and Photran as soon as they get out.

Daniel
Comment 3 Jeffrey Overbey CLA 2012-06-13 10:50:00 EDT
Oh right, I forgot to comment... the final builds for Juno were yesterday, and it wasn't possible to get a fix in by then, which is why the target is "Future" now.

The underlying cause is the Managed Build dependency calculator, which desperately needs to be rewritten.  Unfortunately, no one (including me) is being paid to work on Photran at the moment, so bug fixes are happening on a "best effort" basis.  This is still a high priority (P2), definitely, and I hope we can address it soon...
Comment 4 Daniel Harenberg CLA 2012-10-03 12:34:58 EDT
Alas - all hope is lost! I confirm that this bug is still present in Eclipse Juno with PTP 6.0.2/Photran 8.0.2
Comment 5 Daniel Harenberg CLA 2012-10-03 13:31:20 EDT
I tried a hundred ways to find a workaround - in vain.

One thing I did notice that might be of value: when you copy and paste a project in the Fortran Projects view, then the file .cproject will be the same in both projects. This seems very strange, as it contains several references to the old project (in lines that have to do with the build configurations). Sadly, manually replacing the old project names with the new project names does not resolve the bug. Notice that the same happens when you copy and paste with a file manager of your choice and then choose 'Import -> Existing project' from the Fortran Projects view. In contrast to .cproject, the file .project will always have the new project name (quite naturally, I guess).
Comment 6 Daniel Harenberg CLA 2012-10-25 08:09:28 EDT
I have a 'workaround'.

Eclipse Juno makes it really easy to use the version control system Git. For my use case, this is even better than the 'copy/paste project'-approach. Creating branches and merging does not trigger this bug, so I can use managed make with multiple configurations when I create a new branch.

Since there is this (superior) workaround and since nobody else here ever complained about this problem, I am downgrading the importance of the bug to minor.

For beginners (like me), a straightforward step-by-step tutorial for Git with Eclipse (EGit) can be found on http://www.vogella.com/articles/EGit/article.html
Comment 7 Daniel Harenberg CLA 2015-11-10 03:19:11 EST
Since the 'workaround' using Egit, which is actually the better practice, has been perfectly stable for 3 years and there were no further comments here, I am closing this bug report.