Variable expansion: Difference between revisions
m edit category |
wikify; create separate categories |
||
| Line 1: | Line 1: | ||
[[Category:User Documentation]] | [[Category:User Documentation]] | ||
== Syntax == | == Syntax == | ||
Code::Blocks treats the following functionally identical character sequences inside pre-build, post-build, or build steps as variables: | Code::Blocks treats the following functionally identical character sequences inside pre-build, post-build, or build steps as variables: | ||
< | * <code>$VARIABLE</code> | ||
* <code>$(VARIABLE)</code> | |||
* <code>${VARIABLE}</code> | |||
* <code>%VARIABLE%</code> | |||
Variable names must consist of alphanumeric characters and are not case-sensitive. Variables starting with a single hash sign (<code>#</code>) are interpreted as [[global user variables]]. | |||
Variable names must consist of alphanumeric characters and are not case-sensitive. Variables starting with a single hash sign (< | |||
The names listed below are interpreted as builtin types. | The names listed below are interpreted as builtin types. | ||
Variables which are neither global user variables nor builtin types are replaced with a value provided in the project file, or with an environment variable if the latter should fail. | Variables which are neither global user variables nor builtin types are replaced with a value provided in the project file, or with an environment variable if the latter should fail. | ||
Per-target definitions have precedence over per-project definitions. | |||
'''Per-target definitions have precedence over per-project definitions.''' | |||
== List of available builtins == | == List of available builtins == | ||
< | === Files and directories === | ||
The | |||
<code>$(PROJECT_FILENAME)</code>, <code>$(PROJECT_FILE)</code>, <code>$(PROJECTFILE)</code> | |||
:The filename of the currently compiling project. | |||
<code>$(PROJECT_NAME)</code> | |||
:The name of the currently compiling project. | |||
<code>$(PROJECT_DIR)</code>, <code>$(PROJECTDIR)</code>, <code>$(PROJECT_DIRECTORY)</code> | |||
:The common top-level directory of the currently compiling project. | |||
<code>$(ACTIVE_EDITOR_FILENAME)</code> | |||
:The filename of the file opened in the currently active editor. | |||
<code>$(ACTIVE_EDITOR_FILENAME)</code>, <code>$(ACTIVE_EDITOR_DIRNAME)</code>, <code>$(ACTIVE_EDITOR_STEM)</code>, <code>$(ACTIVE_EDITOR_EXT)</code> | |||
:The filename of the file being open in the active editor, its containing directory (relative to the common toplevel path), its base name (without extension), and its extension. | |||
< | <code>$(ALL_PROJECT_FILES)</code> | ||
:A string containing the names of all files in the current project. | |||
< | <code>$(MAKEFILE)</code> | ||
The | :The filename of the makefile. | ||
< | <code>$(CODEBLOCKS)</code>, <code>$(APP_PATH)</code>, <code>$(APPPATH)</code>, <code>$(APP-PATH)</code> | ||
The path to the currently running instance of Code::Blocks | :The path to the currently running instance of Code::Blocks | ||
< | <code>$(DATAPATH)</code>, <code>$(DATA_PATH)</code>, <code>$(DATA-PATH)</code> | ||
The 'shared' | :The 'shared' directory of the currently running instance of Code::Blocks | ||
< | <code>$(PLUGINS)</code> | ||
The plugins | :The 'plugins' directory of the currently running instance of Code::Blocks | ||
=== Build targets === | |||
< | <code>$(FOOBAR_OUTPUT_FILE)</code> | ||
A | :A ''specific'' target's output file. | ||
< | <code>$(FOOBAR_OUTPUT_DIR)</code> | ||
:A ''specific'' target's output directory. | |||
< | <code>$(TARGET_OUTPUT_DIR)</code> | ||
:The ''current'' target's output directory. | |||
< | <code>$(TARGET_NAME)</code> | ||
:The ''current'' target's name. | |||
=== Language and encoding === | |||
< | <code>$(LANGUAGE)</code> | ||
The | :The system language in human readable form. | ||
< | <code>$(ENCODING)</code> | ||
The | :The character encoding in human readable form. | ||
=== Time and date === | |||
< | <code>$(TDAY)</code> | ||
:Current date in the form <code>YYYYMMDD</code> (for example 20051228) | |||
< | <code>$(TODAY)</code> | ||
Current date in the form | :Current date in the form <code>YYYY-MM-DD</code> (for example 2005-12-28) | ||
< | <code>$(NOW)</code> | ||
:Timestamp in the form <code>YYYY-MM-DD-hh.mm</code> (for example 2005-12-28-07.15) | |||
< | <code>$(NOW_L)</code> | ||
Timestamp in the form 2005-12-28-07.15 | :Timestamp in the form <code>YYYY-MM-DD-hh.mm.ss</code> (for example 2005-12-28-07.15.45) | ||
< | <code>$(WEEKDAY)</code> | ||
:Human-readable day of the week (for example "Wednesday") | |||
< | <code>$(TDAY_UTC)</code>, <code>$(TODAY_UTC)</code>, <code>$(NOW_UTC)</code>, <code>$(NOW_L_UTC)</code>, <code>$(WEEKDAY_UTC)</code> | ||
:These are identical to the preceding types, but are expressed relative to UTC. | |||
=== Random values === | |||
< | <code>$(COIN)</code> | ||
This variable tosses a virtual coin (once per invokation) and returns 0 or 1. | :This variable tosses a virtual coin (once per invokation) and returns 0 or 1. | ||
< | <code>$(RANDOM)</code> | ||
A 16bit positive random number (0-65535) | :A 16bit positive random number (0-65535) | ||
Revision as of 10:50, 10 July 2006
Syntax
Code::Blocks treats the following functionally identical character sequences inside pre-build, post-build, or build steps as variables:
$VARIABLE$(VARIABLE)${VARIABLE}%VARIABLE%
Variable names must consist of alphanumeric characters and are not case-sensitive. Variables starting with a single hash sign (#) are interpreted as global user variables.
The names listed below are interpreted as builtin types.
Variables which are neither global user variables nor builtin types are replaced with a value provided in the project file, or with an environment variable if the latter should fail.
Per-target definitions have precedence over per-project definitions.
List of available builtins
Files and directories
$(PROJECT_FILENAME), $(PROJECT_FILE), $(PROJECTFILE)
- The filename of the currently compiling project.
$(PROJECT_NAME)
- The name of the currently compiling project.
$(PROJECT_DIR), $(PROJECTDIR), $(PROJECT_DIRECTORY)
- The common top-level directory of the currently compiling project.
$(ACTIVE_EDITOR_FILENAME)
- The filename of the file opened in the currently active editor.
$(ACTIVE_EDITOR_FILENAME), $(ACTIVE_EDITOR_DIRNAME), $(ACTIVE_EDITOR_STEM), $(ACTIVE_EDITOR_EXT)
- The filename of the file being open in the active editor, its containing directory (relative to the common toplevel path), its base name (without extension), and its extension.
$(ALL_PROJECT_FILES)
- A string containing the names of all files in the current project.
$(MAKEFILE)
- The filename of the makefile.
$(CODEBLOCKS), $(APP_PATH), $(APPPATH), $(APP-PATH)
- The path to the currently running instance of Code::Blocks
$(DATAPATH), $(DATA_PATH), $(DATA-PATH)
- The 'shared' directory of the currently running instance of Code::Blocks
$(PLUGINS)
- The 'plugins' directory of the currently running instance of Code::Blocks
Build targets
$(FOOBAR_OUTPUT_FILE)
- A specific target's output file.
$(FOOBAR_OUTPUT_DIR)
- A specific target's output directory.
$(TARGET_OUTPUT_DIR)
- The current target's output directory.
$(TARGET_NAME)
- The current target's name.
Language and encoding
$(LANGUAGE)
- The system language in human readable form.
$(ENCODING)
- The character encoding in human readable form.
Time and date
$(TDAY)
- Current date in the form
YYYYMMDD(for example 20051228)
$(TODAY)
- Current date in the form
YYYY-MM-DD(for example 2005-12-28)
$(NOW)
- Timestamp in the form
YYYY-MM-DD-hh.mm(for example 2005-12-28-07.15)
$(NOW_L)
- Timestamp in the form
YYYY-MM-DD-hh.mm.ss(for example 2005-12-28-07.15.45)
$(WEEKDAY)
- Human-readable day of the week (for example "Wednesday")
$(TDAY_UTC), $(TODAY_UTC), $(NOW_UTC), $(NOW_L_UTC), $(WEEKDAY_UTC)
- These are identical to the preceding types, but are expressed relative to UTC.
Random values
$(COIN)
- This variable tosses a virtual coin (once per invokation) and returns 0 or 1.
$(RANDOM)
- A 16bit positive random number (0-65535)
