Difference between revisions of "Variable expansion"

From Code::Blocks
Line 64: Line 64:
 
The character encoding in human readable form.
 
The character encoding in human readable form.
  
<tt>$(ACTIVE_EDITOR_FILENAME)</tt><br/>
+
<tt>$(ACTIVE_EDITOR_FILENAME)<br />$(ACTIVE_EDITOR_DIRNAME) $(ACTIVE_EDITOR_STEM) $(ACTIVE_EDITOR_EXT)</tt><br/>
 +
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.
  
 
<tt>$(TDAY)</tt><br/>
 
<tt>$(TDAY)</tt><br/>

Revision as of 12:37, 12 May 2006

Scope

This article refers to builtin variables to be used in during the build process, using Code::Blocks revision 1996 and newer.
Older versions may not support all of the listed types.

Syntax

Code::Blocks treats the following functionally identical character sequences inside pre-build, post-build, or build steps as variables:

$VARIABLE, $(VARIABLE), ${VARIABLE}, and %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

$(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.

$(CODEBLOCKS) $(APP_PATH) $(APPPATH) $(APP-PATH)
The path to the currently running instance of Code::Blocks

$(DATAPATH) $(DATA_PATH) $(DATA-PATH)
The 'shared' folder of the currently running instance of Code::Blocks

$(PLUGINS)
The plugins folder of the currently running instance of Code::Blocks

$(ACTIVE_EDITOR_FILENAME)
The filename of the file opened in the currently active editor.

$(ALL_PROJECT_FILES)
A string containing the names of all files in the current project.

$(MAKEFILE)
The filename of the makefile.

$(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)
The system language in human readable form.

$(ENCODING)
The character encoding in human readable form.

$(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.

$(TDAY)
Current date in the form 20051228

$(TODAY)
Current date in the form 2005-12-28

$(NOW)
Timestamp in the form 2005-12-28-07.15

$(NOW_L)
Timestamp in the form 2005-12-28-07.15.45

$(WEEKDAY)
Human-readable day of the week ("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.

$(COIN)
This variable tosses a virtual coin (once per invokation) and returns 0 or 1.

$(RANDOM)
A 16bit positive random number (0-65535)