Issue
I'm having trouble setting up my Eclipse C++ project. I need to link in source from different directories here and there and in my environment the source I need actually moves sometimes (for example when i always want the latest version of a sub system currently located in a directory like /aaa/bbb/v1.2.3/src
). I always know the location of the source I want through linux environment variables, like $SYSTEM1_LATEST_ROOT
. Without this I need to update all my projects whenever i should pick the source from a new location.
I cannot find a way to include the environment variables in the paths for linked resources. Include directories work perfectly (these are defined in my .cproject
file), for example (.cproject
):
<option id="..." name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
...
<listOptionValue builtIn="false" value="${SYSTEM1_LATEST_ROOT}/src"/>
...
</option>
For linked resources (defined in the .project file) I know I can use path variables but these are defined inside Eclipse only and I find no way to have them based on environment variables, but only to be relative to my own project location, which is not what I want to do.
In short, I want to link in source code from locations based on environment variables. The variable name is constant, but the actual location (known through the environment variable) of the source is not.
Working example with path relative to project. This is not what i want (.project):
<linkedResources>
<link>
<name>System1_src</name>
<type>2</type>
<locationURI>PARENT-6-PROJECT_LOC/src</locationURI>
</link>
</linkedResources>
Non-working example of what i want to do (.project):
<linkedResources>
<link>
<name>System1_src</name>
<type>2</type>
<locationURI>${SYSTEM1_LATEST_ROOT}/src</locationURI>
</link>
</linkedResources>
Any suggestions?
Solution
After waiting for a month i figure it's time I answer with my own findings..
First, the concept of path variables (http://help.eclipse.org/indigo/index.jsp?topic=/org.eclipse.platform.doc.user/concepts/cpathvars.htm);
"Linked resource target paths can be either defined
as absolute paths, or relative to a path variable."
Two options; absolute paths or relative to path variable.
Specifically it says about path variables:
"Each project contain a pre-defined set of path
variables available for defining linked resources,
including ECLIPSE_HOME, PARENT_LOC, PROJECT_LOC and
WORKSPACE_LOC.
New path variables can be defined relative to
existing path variables by using the ${VAR} syntax.
For example, a path variable FOO can be defined
relative to BAR by defining it to "${BAR}../foo"."
In other words, path variables are always relative to the project location in some way, using a liberal interpretation of the word project.
So the next option would be absolute path. An absolute path containing an environment variable would work!
"The linked resource target path can be changed by
selecting the Edit... button in the File > Properties >
Resource property page of the linked resource. "
Trying this it gets painfully obvious that only path variables are supported as part of the path to the linked resource. And we already know the definition of a path variable.
The answer is...
Eclipse does not contain this very basic feature.
Anyone, please prove me wrong!
Answered By - Martin G
Answer Checked By - Marie Seifert (JavaFixing Admin)