Eclipse Build Variables
Join the DZone community and get the full member experience.Join For Free
this post is not about variables in my application code (which i debug). it is about using variables in eclipse for building projects. eclipse variables allow me to make my projects ‘position independent’ whenever i cannot use a path relative to my projects or workspace.
which variables are used where in eclipse might be sometimes not very clear. depending in which context variables are used, not everything might be available. this link for example gives a list of variables which can be used to invoke an external tool.
eclipse comes with many built-in variables, especially for the build system. if i want to see what variables are already defined, i can show them in the project properties, under c/c++ build > build variables with enabled option ‘show system variables’:
with the ‘add…’ button i can define and add my own variables, available for that project:
if above operation is done on a project, then the setting is for the project only. if i want to add a variable for the workspace, i can do this using the menu window > preferences :
global system variables
eclipse automatically includes the system (e.g. windows) environment variables. many dialogs have the ‘variables…’ button where i can use my variables, including the variables defined on system level:
system variables: one way or the other
so if i want to have a variable for every workspace, one way is to define it at the system level. however, this is not a good way as this clutter the variables for every application.
a solution to this to create my custom batch file where i define my variables, and at the end of this batch file i launch eclipse. that way the extra variables are only for this eclipse session.
another very nice way codewarrior eclipse offers is using the cwide-env file located in the eclipse sub-folder of the installation:
i can define variables here, or extend existing ones:
- -add : add string to the variable at the end
- -prepend : add string to the variable at the beginning
that way i can easily manipulate existing system variables or create new ones which then are used by eclipse.
variables in eclipse help me to define paths to source files and folders outside of a project or workspace. with variables i avoid using absolute paths which would make porting projects from one machine to another difficult. i can define variables for projects, for the workspace or use system variables. with codewarrior i have a cwide-env file which is used to extend the system variables.
Published at DZone with permission of Erich Styger, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Tech Hiring: Trends, Predictions, and Strategies for Success
What Is Envoy Proxy?
Knowing and Valuing Apache Kafka’s ISR (In-Sync Replicas)
Effortlessly Streamlining Test-Driven Development and CI Testing for Kafka Developers