Scons plugin

Description

The scons plugin is used for executing scons.

Mandatory settings

There are no mandatory settings for this plugin.

Optional settings

patterns

A list of patterns to apply on the command line. See Patterns (5).

enviroment

A list of environment variables that should be set before the commands are executed. See Environment (5).

command-line

Additional command line parameters to pass as a list of separate arguments. By default no additional arguments are added.

working-dir

The working directory of the command. Can be an absolute path are a relative one w.r.t. the path to the considered configuration file. Commands that should be executed relative to the current working dir can use the {EH_WORKING_DIR} pattern.

build-dir

The path to the build directory. This is either an absolute path are a path relative to the location of this file. Default: . (the current working directory).

Example

Configuration

commands:                       # Define the commands that can be run
    example: Run the scons example
    clean: Clean all built files
    run: Run the built binaries

patterns:                       # Define the patterns that can be used
    SCONS_TARGET:            # Define the EXAMPLE_PATTERN.
        default-values:         # Only define the default value
            - hello
            - world

example:
    - clean
    - scons                     # Use the command-line-command plugin when running the 'example' command
    - run

clean:
    - command-line-command

run:
    - command-line-command

scons:
    patterns:                   # The patterns that are used by the make plugins
        - SCONS_TARGET
    example:                    # Specific settings for the 'example' command
        command-line:           # Define additional command line arguments
            - --keep-going      # Pass additional options to scons
            - "{SCONS_TARGET}"  # Define the make target to execute

command-line-command:
    clean:
        command-line: [rm, -rf, build]
    run:
        patterns:
            - SCONS_TARGET
        command-line: ["build/{SCONS_TARGET}"]

Additional files

In order for the above example to work, the following file hierarchy needs to be created in the directory:

SConstruct:

env = Environment()
Export('env')

SConscript('src/SConscript', variant_dir='build', duplicate=0)

Default(None)

SConscript:

Import('env')

hello = env.Program('hello.cpp')
env.Alias('hello', hello)

world = env.Program('world.cpp')
env.Alias('world', world)

hello.cpp:

#include <cstdlib>
#include <iostream>

auto main() -> int {
    std::cout << "Hello" << std::endl;
    return EXIT_SUCCESS;
}

world.cpp:

#include <cstdlib>
#include <iostream>

auto main() -> int {
    std::cout << "World!" << std::endl;
    return EXIT_SUCCESS;
}

Usage

Save the example to an exec-helper configuration file and execute in the same directory:

eh example

See also

See exec-helper (1) for information about the usage of exec-helper.

See Custom plugins (5) for the available plugins and their configuration options.

See Configuration (5) for information about the configuration file format.