Bug 371297 - Problem with environment variables set in builder using workspace_loc on Linux
Summary: Problem with environment variables set in builder using workspace_loc on Linux
Status: NEW
Alias: None
Product: CDT
Classification: Tools
Component: cdt-build (show other bugs)
Version: 8.1.0   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: cdt-build-inbox@eclipse.org CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-10 17:53 EST by Josh Davidson CLA
Modified: 2020-09-04 15:24 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Josh Davidson CLA 2012-02-10 17:53:51 EST
Build Identifier: 20110916-0149

Our build scripts need to have a couple crucial environment variables configured, which we set in C/C++ Build->Environment.

As one example, we set PYTHONPATH to ${workspace_loc:/SimCommon/src/Python}

This works wonderfully on Windows, but on linux the colon is detected as the path separator and the variable adds two separate entries to PYTHONPATH:
* ${workspace_loc
* /SimCommon/srcPython}

I tried escaping, but to no avail. I can't simply use ${WorkspaceDirPath} since it assumes that all projects are physically located in the workspace directory which is often not the case.

Reproducible: Always

Steps to Reproduce:
1. Set an environment variable based on a project in the workspace, e.g. ${workspace_loc:/MyProject}
2. Attempt to use that variable in your Makefile
3. Boom goes the dynamite
Comment 1 Josh Davidson CLA 2012-02-13 12:31:13 EST
I think what's happening is that the values are first "split" based on the system's path separator prior to variable substitution.  I believe if the order of these steps were reversed or if the substitution ignored separators nested in "${}" it would probably work.
Comment 2 Josh Davidson CLA 2012-02-17 17:52:06 EST
In my previous comment, I said it appeared as if Eclipse was splitting the variables using ${workspace_loc:/<proj>} syntax before performing varible lookup. That was incorrect. Since the variable I was setting is multi-valued, the script in my build that uses the variable splits it based on the system path separator. Well, since Eclipse isn't doing any variable substitution when using this syntax, my script got the variable as-is and proceeded to split.

As another test, I created a project called "tools" and allowed it to be stored directly in my workspace directory. Then, under C/C++ Build->Environment, I added two variables:

zomg = ${workspace_loc:/tools}
blah = ${workspace_loc}/tools

As part of my build, I printed what the environment variabes are set to. Here are the results:
$zomg=${workspace_loc:/tools}
$blah=/disk01/data/davidsj2/workspace/tools

As you can see, "zomg" wasn't set correctly.
Comment 3 Axel Mueller CLA 2012-02-27 08:03:18 EST
(In reply to comment #2)
Finally, I found out why it was working on my side but not in your setup.

Open the file org.eclipse.cdt.core.prefs in the (hidden) folder .settings in your project folder. There you will your defined environment variables
Code: [Select all] [Show/ hide]
...value=${workspace_loc\:/tools}

Two lines above you see the parameter
Code: [Select all] [Show/ hide]
delimiter=\:

which also belongs to your variable and denotes the list delimiter symbol.
If you open this file with a text editor and change the above line to
Code: [Select all] [Show/ hide]
delimiter=;

resolving of ${workspace_loc:/tools} will work as expected.

The default value for the list delimiter is identical to the path delimiter for the chosen platform. I think this is not correct here (btw, same problem for {env_var:HOME} )