Patterns¶
Description¶
Patterns are parts of the configuration that will be replaced by its value when evaluated by exec-helper. The patterns keyword describes a list of patterns identified by their key. See the ‘patterns’ section for more information about how to define a pattern.
Patterns can be used to:
- add options to the exec-helper command line
- centralize a value in a variable
- allow iterating over multiple configurations
- control the configurations to iterate over
Patterns¶
A pattern can contain the following fields:
-
default-values
A list of default values to use when no values have been defined.
-
short-option
The short option on the command line associated with this pattern
-
long-option
The long option on the command line associated with this pattern
Predefined patterns¶
Exec-helper predefines some specific patterns for convenience:
- EH_ROOT_DIR: contains the absolute path to the directory where the exec-helper configuration is located. Useful for converting relative paths to absolute paths for tools that require it (e.g. when setting your
PATH
) - EH_WORKING_DIR: contains the working directory from where the exec-helper executable is called.
Example configuration¶
commands: # The mandatory commands key
build: Build the project # A map of command keys with their explanation
clean: Clean the project
rebuild: Build + clean
patterns: # Declare the patterns for this configuration file
COMPILER: # Declare the COMPILER pattern
default-values: # Default values to use for the pattern
- g++
- clang++
short-option: c # Declare values for this pattern by using the -c [VALUES] option when calling exec-helper
long-option: compiler # Declare values for this pattern by using the --compiler [VALUES] option when calling exec-helper
MODE: # Declare the MODE pattern
default-values:
- debug
- release
short-option: m
long-option: mode
additional-search-paths:
- /tmp
# Define the commands listed under 'commands'
build:
- command-line-command # Use the command-line-command plugin when using the 'build' command
clean:
- command-line-command # Use the command-line-command plugin when using the 'clean' command
rebuild:
- clean # Call the 'clean' command when calling the 'rebuild' command
- build # Call the 'build' command when calling the 'rebuild' command
command-line-command: # Configure the command-line-command
patterns: # Define the default patterns to use
- COMPILER
- MODE
command-line: # Configure the execution when the specific command is not listed. Will be executed from the directory of this configuration file
- echo
- building
- using
- "{COMPILER}" # This value will be replaced by the COMPILER pattern value
- in
- "{MODE}" # This value will be replaced by the MODE pattern value
- mode.
- wd=$(pwd) # This command will be executed in a subshell and replaced by its value before the actual command is executed
clean: # Configure the execution of the build command
patterns: # Overwrite the parent patterns
- MODE
- EH_WORKING_DIR # Use the EH_WORKING_DIR pattern
command-line:
- echo
- cleaning
- mode.
- "{MODE}" # This value will be replaced by the MODE pattern value
- wd=$(pwd)
working-dir: "{EH_WORKING_DIR}" # The command will be executed from the current working directory rather than from the directory of this configuration file
See also¶
See Configuration (5) for information about the configuration file.