Jambase Rules

Introduction

In the Jambase.jam that ships with JamPlus, the default build configuration is Release.

The Jambase.jam rules attempt to detect the compiler on the machine. It can successfully detect and run Visual C++ 6, Visual Studio 2003, Visual Studio 2005, and Visual Studio 2008.

If [square] brackets are used the argument is optional.

Here is an alphabetically sorted list of all commands with references to their documentation:

The following is a list of rules available in bin/Jambase.jam.


rule ActiveProject PROJECT

Set the default project target to use when the target isn't specified. This works with a good number of the Jambase commands.

Parameters:
PROJECT The default target name to use for upcoming rules.

rule AutoSourceGroup TARGET : SOURCES

For workspace projects that support grouping of files into folders, the AutoSourceGroup rule is used to tell the jam --workspace generator to create folders within a project based on the relative paths of the SOURCES.

Parameters:
TARGET The project to which the folders will be created.
SOURCES The list of files to derive folder names from.
    # Put helloworld.cpp and .h in the top-level project folder.
    # Put filename.cpp and .h in a project folder caled platform\\directory (in SourceGroup syntax).
    SRCS =
            helloworld.cpp
            helloworld.h
            platform/directory/filename.cpp
            platform/directory/filename.h
    ;

    AutoSourceGroup MyProject : $(SRCS) ;

rule Clean TARGETS : FILES

When executing actions for TARGETS, the specified list of FILES are removed from the disk, and any empty directories resulting from the file deletions are removed, too.

Parameters:
TARGETS A list of one or more targets. Generally, the target name is clean or clean:SOMETARGET.
FILES A list of files to be deleted.
    Clean clean : <mytarget>myfile.txt $(TEMP)/anotherfile.txt ;

rule FGristDirectories DIRECTORIES

Given a list of DIRECTORIES, a gristed version of each is returned. Currently, this means the directories are returned in the form: <!dir!>directory/name

Parameters:
DIRECTORIES The directories to grist.
Returns:
Returns the gristed version of each directory.
    Echo [ FGristDirectories $(TEMP)/stuff ] ;

rule GroupByVar TARGETLIST_VARIABLE_NAME : COMPARISON_SETTINGS_NAME [ : MAX_PER_GROUP ] ;

Returns a list of targets with identical settings as specified by VARIABLE_NAME using the first target specified in TARGETS_VARIABLE.

Example: The C/C++ compilation puts a variety of compilation flags in a variable declared per target called MFLAGS. For compilers that support batching of files using the same build flags, GroupByVar returns each set of matching files one after another to send to the compiler.

Parameters:
TARGETS_VARIABLE The variable containing the targets to return matching groups from. The first target in the variable is used as the target to match against. TARGETS_VARIABLE is updated with the remaining list of targets after the current found group has been identified.
VARIABLE_NAME The settings variable used to obtain matches from.
MAX_PER_GROUP The maximum number of files to return in the group. If not specified, there is no upper limit.
Returns:
Returns a list of 1 or more TARGETS matching the string list in VARIABLE_NAME.
    # Prints:
    #
    # Together - targeta targetc targete targetf
    # Together - targetb
    # Together - targetd
    # (2 max) - targeta targetc
    # (2 max) - targetb
    # (2 max) - targetd
    # (2 max) - targete targetf
    files = targeta targetb targetc targetd targete targetf ;
    FLAGS on targeta = a b c ;
    FLAGS on targetb = a b c d ;
    FLAGS on targetc = a b c ;
    FLAGS on targetd = a b c e ;
    FLAGS on targete = a b c ;
    FLAGS on targetf = a b c ;

    while $(files) {
        local together = [ GroupByVar files : FLAGS ] ;
        Echo Together - $(together) ;
    }


    files = targeta targetb targetc targetd targete targetf ;
    while $(files) {
        local together = [ GroupByVar files : FLAGS : 2 ] ;
        Echo (2 max) - $(together) ;
    }

rule IncludeModule MODULE_NAME

Loads a Jam module. It searches in the following manner:

When IncludeModule is specified more than once for the same MODULE_NAME, the module is only loaded once.

Parameters:
MODULE_NAME The name of the module, which is the filename without path and extension.
    # Make the C.UseDirectX rule available.
    IncludeModule c/directx ;

rule MakeLocate TARGETS : DIRECTORY

Creates DIRECTORY and causes TARGETS to be built into the directory. It does so by setting the special Jam variable LOCATE on each of the TARGETS and then arranges with rule MkDir DIRECTORY to create the target directory.

Parameters:
TARGETS The targets to set the output directory on.
DIRECTORY The output directory to build the targets into.
    # Set the output location of the given target to be the TEMP directory.
    MakeLocate junkfile.txt : $(TEMP) ;

rule MkDir DIRECTORY

Creates DIRECTORY and its parent directories.

If using MkDir separately from rule MakeLocate TARGETS : DIRECTORY, it is necessary to set dependencies using the properly gristed directory name obtained through rule FGristDirectories DIRECTORIES.

Parameters:
DIRECTORY The output directory to create.
    # Create a directory in the TEMP directory called stuff/.
    MkDir $(TEMP)/stuff ;

    # Link it into the dependency graph.
    Depends sometarget : [ FGristDirectories $(TEMP)/stuff ] ;

rule NoWorkspace WORKSPACE_NAME

Workspaces are automatically generated for any executable processed while reading in the Jamfiles. To prevent a workspace from automatically exporting, this rule is used.

Parameters:
WORKSPACE_NAME The name of the new workspace to suppress the export of.
        NoWorkspace lua ;

rule Project PROJECT_NAME : SOURCES

When generating a workspace, projects are automatically made of each executable or library processed while reading in the Jamfiles. When a project isn't an executable or library, such as one containing data files, the Project rule can be used to generate a project containing those files.

Parameters:
PROJECT_NAME The name of the new project to generate.
SOURCES The list of files representing the contents of the new project.
    Project Data : $(DATA_FILES) ;

rule ProjectGroup TARGET : FOLDERNAME : PROJECTS

For workspaces that support grouping of projects into folders, the ProjectGroup rule is used to tell JamToWorkspace which projects go into which folders.

Parameters:
TARGET The workspace to which the project folders will be created.
FOLDERNAME The backslash separated folder name to which PROJECTS will be inserted into.
PROJECTS The list of projects to put into the folder.
    ProjectGroup MyApp : "Plugins\\Data Generators" : DataGeneratorA DataGeneratorB ;

rule RmTemps TARGETS : SOURCES

Marks SOURCES as temporary with the Temporary rule and deletes SOURCES once TARGETS are built. RmTemps must be the last rule invoked on TARGETS. Used internally.


rule SearchSource SOURCES

Applies $(SEARCH_SOURCE) to all SOURCES that do not already have a SEARCH applied. Generally, SEARCH_SOURCE is applied through rules just as Application or Library.

Parameters:
SOURCES The list of sources to apply $(SEARCH_SOURCE) to.
        SearchSource $(SRCS) ;

rule SourceGroup TARGET : FOLDERNAME : SOURCES

For workspace projects that support grouping of files into folders, the SourceGroup rule is used to tell JamToWorkspace which files are to be placed into which folders within a project.

Parameters:
TARGET The project to which the folders will be created.
FOLDERNAME The backslash separated folder name to which SOURCES will be inserted.
SOURCES The list of files to put into the folder.
        SourceGroup Misc : "zlib" : $(ZLIB_SRCS) ;
        SourceGroup Misc : "string\\trio" : $(TRIO_SRCS) ;

rule Split STRINGS : SPLIT_CHARACTERS

Splits each of the STRINGS at SPLIT_CHARACTERS. All splits are returned as a string list.

Parameters:
STRINGS The list of strings to split at the points specified by SPLIT_CHARACTERS.
SPLIT_CHARACTERS One or more characters to split the list of STRINGS at.
Returns:
Returns a list of strings split at the points specified by SPLIT_CHARACTERS.
    # Prints:
    #
    # **I** **like** **peas.**
    # No splits here
    local list = [ Split I like peas. : " " ] ;
    Echo **$(list)** ;

    Echo [ Split No splits here : "|" ] ;

rule SubDir TOP d1...dn : SUBNAME

Sets up housekeeping for the source files located in /d1/.../dn:

TOP is the name of a variable; d1 thru dn are elements of a directory path.


rule SubInclude VAR d1...dn : FILETITLE

Reads the Jamfile in /d1/.../dn/. Assumes a default Jamfile name of Jamfile.jam. If FILETITLE is specified, .jam is read instead of Jamfile.jam.

A given Jamfile is only ever read in once, even if multiple SubInclude calls are made with the same arguments.

Parameters:
VAR A previously specified TOP variable created with rule SubDir TOP d1...dn : SUBNAME.
d1...dn Additional directory components from making up the total path of /d1/.../dn/.
FILETITLE (optional) If specified, a Jamfile called .jam is read instead of the default Jamfile.jam.

rule Workspace WORKSPACE_NAME : TARGETS

Workspaces are automatically generated for any executable processed while reading in the Jamfiles. To create additional workspaces, such as one that combines all executables into one workspace, the Workspace rule is used.

Parameters:
WORKSPACE_NAME The name of the new workspace to generate.
TARGETS The list of targets representing the projects of the new workspace.
        Workspace Project-all : AppA AppB AppC ;