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

Bug 360744

Summary: pre-build path builder does not properly escape backslash characters
Product: [Tools] CDT Reporter: Bret Mising name <bret.foreman>
Component: cdt-buildAssignee: cdt-build-inbox <cdt-build-inbox>
Status: NEW --- QA Contact: Jonah Graham <jonah>
Severity: major    
Priority: P3 CC: cdtdoug, dcrocker, qdaemon.fr, yevshif
Version: 8.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Bret Mising name CLA 2011-10-12 19:32:53 EDT
Build Identifier: 20110916-0149

In the pre-build step for the project, "SubWCRev ${workspace_loc:/MyProject} ${workspace_loc:/MyProject/template} ${workspace_loc:/MyProject/result}"

Generates the error: C:Usersmyusernameworkspacemyprojecttemplate file not found.
 In other words, the pre-build path builder is not generating the proper delimiter for the backslashes before it passes the path to bash. And then bash is stripping the improperly delimited backslashes.

I can run SubWCRev by hand outside of eclipse before I do a build but that will not scale to other users who have their workspace under different user names.

Reproducible: Always

Steps to Reproduce:
1.Put a command into the pre-build step of the project like the one shown above. Any command that requires a path expansion will do.
2. Do a build.
3. Note the error in the build console.
Comment 1 Bret Mising name CLA 2011-10-12 19:34:23 EDT
There is a discussion forum topic around this issue at: http://www.eclipse.org/forums/index.php/m/735867/#msg_735867
Comment 2 David Crocker CLA 2018-10-09 06:34:28 EDT
I have this problem too. Specifically, using this linker option:

-T${workspace_loc:/${CoreName}/variants/duetNG/linker_scripts/gcc/flash.ld}

expands to this on the ld command line:

-TC:\Eclipse\Firmware\CoreNG\variants\duetNG\linker_scripts\gcc\flash.ld

and gives this error message:

ld.exe: cannot open linker script file C:EclipseFirmwareCoreNGvariantsduetNGlinker_scriptsgccflash.ld: No such file or directory

Eclipse has even replaced the forward slashes in the path by backslashes. Please can we have an option for Eclipse under Windows to use forward slashes in all paths generated by Eclipse.

Note, the symptoms depend on what builder I use, and on the external build tools if I am using them. With 'make' from Arduino, this was not a problem, however I ran into the 32K limit on command line length. So I installed GNU ARM Eclipse to get around that, and now I have this problem. So I guess the make.exe supplied with Arduino is converting or escaping the backslashes.
Comment 3 David Crocker CLA 2018-10-09 06:48:30 EDT
I found a workaround for this particular instance. If the path containing $workspace_loc is enclosed in double quote marks, then in the command line it still contains backslashes but the ld command works.
Comment 4 Julien Devillers CLA 2019-08-08 12:03:12 EDT
@David, please can you post an example of your workaround.

I tries something like "${workspace_loc:\foor\bar}" and it's not better.
Comment 5 David Crocker CLA 2019-08-08 15:59:47 EDT
What I was actually using would in your example be:

"${workspace_loc:/foor/bar}"

but I don't know whether thos will work for you. If you have Eclipse configured to us external tools, it depends on what Make program you use. The one I currently use (from Gnu Arm Eclipse) seems to escape the backslash characters when the path is enclosed in double quotes.

There is a second bug that affects paths of this form. Sometimes Eclipse fails to expand the {$workspace_loc:...} at all, leaving it empty on the command line. In such cases, the workaround is to use this instead:

"${workspace_loc}/foor/bar"

I've had this happen to me; and even when it doesn't, other users building from my Github files sometimes report it.