JamPlus manual
|
The C module provides rules to build C, C++, Objective C, and Objective C++ applications, shared libraries, and static libraries.
When first loaded, it attempts to detect the compiler on the machine. On Windows, it can successfully detect and run Visual Studio 2015/2013/2012/2010/2008/2005/2003 and Visual C++ 6. MinGW can also be specified. On other OSes, it attempts to detect GCC.
Support for more than one toolchain used during the same Jam execution is provided via the C Module Multiple Toolchain Support.
Changes the active target to TARGET
. All rules taking an optional TARGET
parameter will default to the active target if empty.
TARGET | The target to become active. |
Makes a new C/C++ source extensions available to the compiler. This rule requires some additional setup, described below.
TODO: Finish me.
TYPE
identifies a category of files and is a short identifier, usually all caps. It is used to access compiler flags variables during a file's compilation. If TYPE
were specified as CC
, then the compiler flags in the variables called preCCFLAGS
, CCFLAGS
, SUBDIRCCFLAGS
, and PCHCCFLAGS
would be used.
For the given project TARGET
, add the compilation FLAGS
for the current toolchain.
TARGET | The target to add the FLAGS to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the flags are made available globally. |
FLAGS | The list of flags to add. |
Compiles SOURCES
and links them into TARGET
. Platform specific .o
files or, on Visual C++ compilers, .res
files are passed straight through to the linker. Any file excluded from the build via rule C.ExcludeFromBuild TARGET : SOURCES is ignored.
TARGET | The target to link SOURCES into. The target name is given without extension. A platform specific extension will be generated, often reflecting a configuration type. TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of .cpp , .cxx , and .c (and possibly others) files to link into the application. Object and compiled Windows resource files may also be passed with this list. |
OPTIONS | The following options are available. All options are optional. |
windows
- Forces a GUI application. On Windows, the application must have aWinMain
function. For Visual C++, the executable is linked with/SUBSYSTEM:WINDOWS
.console
(default) - Builds a console application. For Visual C++, the executable is linked with/SUBSYSTEM:CONSOLE
.
For the given project TARGET
, only allow SIZE
files to be batch compiled in a given compiler execution.
TARGET | The target to assign the SIZE information to. TARGET is optional if rule ActiveTarget TARGET has been specified. |
SIZE | (optional) The maximum number of files to allow to compile on a given compiler execution. If not specified, there is no limit to the number of batch compiled files. |
For the given project TARGET
, assign the FLAGS
to the appropriate configuration and platform.
TARGET | The target to assign the FLAGS to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the flags are made available globally. |
FLAGS | The list of flags to apply. |
Add FILES
to the clean
target for TARGET
.
TARGET | The target to add FILES to for cleaning. TARGET is optional if rule ActiveTarget TARGET has been specified. |
FILES | The files to clean. |
For the given project TARGET
, turn on/off C++ exception support within the current toolchain.
TARGET | The target to assign the FLAGS to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the flags are made available globally. |
TYPE | true to turn on exceptions, false (default) to turn off exceptions. |
For the given project TARGET
, assign the C++ FLAGS
for the current toolchain.
TARGET | The target to assign the FLAGS to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the flags are made available globally. |
FLAGS | The list of flags to apply. |
Sets options that affect how the compiler builds.
OPTIONS | The following options are available. |
outputastree
- Set this if you want object files to be put in subdirectories matching the directory hierarchy of the source files...
directory entries are changed to__
so the object files stay within the build hierarchy. The default is to put all object files in one flat directory per project.
For the given TARGET
, run the file specified through SOURCE
through a CMake-like configure mechanism and output the file to DESTINATION
.
TARGET | The target to do the processing within. TARGET is optional if rule ActiveTarget TARGET has been specified. |
DESTINATION | The destination filename to output the configured file to. The default output directory is $(LOCATE_SOURCE) . |
SOURCE | The source filename to configure. The default search directory is $(SEARCH_SOURCE) . |
OPTIONS | Either addinclude to add the DESTINATION $(LOCATE) directory to the private include paths or addpublicinclude to add it to the public include paths for inheritance. |
tests/configurefile/
.When linking the given TARGET
, link the .def
file(s) specified in SOURCES
.
TARGET | The target to link the def file to. TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | One or more .def files. .def files are searched for in . |
Assign the DEFINES
to the given project TARGET
.
TARGET | The target to assign the DEFINES to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the defines are made available globally. |
DEFINES | The list of defines to apply. |
OPTIONS | If public is specified, the defines specified by DEFINES are made available to a project using C.Inherits . |
For the given project TARGET
, exclude the SOURCES
from the build. When using
jam --workspace
for project generation, sources must be excluded and not simply removed from the list. Otherwise, they will not show in the generated projects.
TARGET | The target to exclude the SOURCES from. TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of sources to exclude. |
For the given project TARGET
, exclude the SOURCES
from the projects generated by
jam --workspace
.
TARGET | The target to exclude the SOURCES from. TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of sources to exclude. |
For the given project TARGET
, exclude the files matching regular express PATTERNS
from the build. When using
jam --workspace
for project generation, sources must be excluded and not simply removed from the list. Otherwise, they will not show in the generated projects.
TARGET | The target to exclude the files matching PATTERNS from. TARGET is optional if rule ActiveTarget TARGET has been specified. |
PATTERNS | The list of patterns used to match files to exclude from the project. |
Assign the compilation FLAGS
to the project TARGET
. TYPE
can be any known source compilation type, such as CC
for C-style files, C++
for C++-style files, and on certain compilers, M
for Objective C files, or MM
for Objective C++ files.
TYPE | A source compilation type added through C.AddBuildExtensions. If more than one is specified, the flags are applied to all types. |
TARGET | The target to assign the FLAGS to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the flags are made available globally. |
FLAGS | The list of flags to apply. |
Force the FILE_TYPE
of the provided SOURCES
attached to TARGET
.
TARGET | The target to use when forcing the file type of SOURCES . TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of files to affect the compilation type of. |
FILE_TYPE | A known extension, such as .c , .cpp , .m , or .mm , to force the SOURCES to be interpreted as. |
For the given project TARGET
, assign the INCLUDES
for the current toolchain causing that project's compilation to force the inclusion of the header before anything else.
TARGET | The target to assign the INCLUDES to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the defines are made available globally. |
INCLUDES | The list of header files to force include. |
Force the rule C.Inherits TARGET : INHERITS_TARGETS [ : OPTIONS ] public inheritance pattern for TARGET
. This will treat TARGET
as if one of the flag setting functions, such as rule C.Defines TARGET : DEFINES [ : OPTIONS ] or rule C.IncludeDirectories TARGET : INCLUDEPATHS [ : OPTIONS ], had been called with public
OPTIONS
.
C.ForcePublic
is usually used in situations where rule C.Inherits TARGET : INHERITS_TARGETS [ : OPTIONS ] is called with TARGET
to inherit from, but TARGET
has no public defines or include directories or other flags. C.Inherits
will abort as a precautionary measure assuming that Jam has not yet defined TARGET
yet.
TARGET | The target to force to public. |
Retrieves the C.ARCHITECTURE
assigned to the specified toolchain.
TOOLCHAIN_SPEC | A toolchain spec. Defaults to the current toolchain. |
The rule C.Application TARGET : SOURCES [ : OPTIONS ] and rule C.Library TARGET : SOURCES [ : OPTIONS ] rules return the target name of the executable or library being built. The properly gristed target name is unique within the dependency graph and takes into account the currently active toolchain.
When it is not possible to save off the result when calling the C.Application
or C.Library
rules, the C.GetLinkTargets
rule can retrieve the properly gristed target later.
TARGET | The target to retrieve the link targets from. |
TOOLCHAIN_SPEC | A tool specification such as win32/debug or $(PLATFORM)/$(CONFIG)/spu . |
Grists the passed in FILES
against TARGET
and returns them to the user in the form: <win32/debug:TARGET>FILES
TARGET | The target to grist. May be * . |
FILES | The list of files to apply the target grist to. |
FILES
.Grists the passed in TARGET
and returns it to the user in the form: <win32/debug>TARGET
TARGET | The target to grist. May be * . |
TARGET
.Add the INCLUDEPATHS
to the given project TARGET
.
TARGET | The target to assign the INCLUDEPATHS to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the defines are made available globally. |
INCLUDEPATHS | The list of include paths to apply. |
OPTIONS | The following options are available: |
prepend
- Instead of appending the paths specified byINCLUDEPATHS
to the include directories list, the paths will be prepended instead.public
- Ifpublic
is specified, the paths specified byINCLUDEPATHS
are made available to a project usingC.Inherits
.
For the given project TARGET
, re-include the SOURCES
into the build.
TARGET | The target to include the SOURCES from. TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of source files to force include |
Inherits the settings from INHERITS_TARGETS
and apply them to TARGET
.
C.IncludeDirectories
are inherited. If OPTIONS
contains public
, the include directories are made available for any C.Inherits
utilizing this TARGET
as an INHERITS_TARGET
. C.LinkPrebuiltLibraries
are inherited and passed up the C.Inherits
chain regardless of OPTIONS
containing public
. C.LinkLibraries
are inherited and passed up the C.Inherits
chain regardless of OPTIONS
containing public
. If one of the targets specified in INHERITS_TARGETS
has no public entries, then an error is generated.
TARGET | The target to inherit settings from INHERITS_TARGETS into. |
INHERITS_TARGETS | The list of targets to inherit public settings from. |
OPTIONS | May be empty or may contain public . Behavior for public is described above. |
On platforms with Unix-like shared libraries, C.InstallNamePath
allows adjustment of the directory in which the shared library is allowed to run from.
TARGET | The target to modify the install name path on. TARGET is optional if rule ActiveTarget TARGET has been specified. |
INSTALL_NAME_PATH | A valid path for shared libraries, such as @rpath . |
For the given project TARGET
, assign the lib FLAGS
to the current toolchain to be used when archiving object files into library files.
TARGET | The target to assign the link FLAGS to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the flags are made available globally. |
FLAGS | The list of lib flags to apply. |
Compiles SOURCES
and archives them into a library called TARGET
. Filenames with an .obj
or .res
are passed straight through to the linker. Any file excluded from the build via rule C.ExcludeFromBuild TARGET : SOURCES is ignored.
TARGET | The targets to archive SOURCES into. The target name is given without extension; a platform specific extension will be generated. TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of .cpp , .cxx , and .c to link into the application. Object and compiled Windows resource files may also be passed with this list. |
OPTIONS | (optional) The following options are available: |
shared
- Instead of building a static library (the default), a shared library (DLL) is built.
Ifshared
is specified forOPTIONS
, the following additional options are available:
console
(default) - Builds a console application. For Visual C++, the DLL is linked with/SUBSYSTEM:CONSOLE
.nodefaults
- Avoid adding /SUBSYSTEM to the link flags.noexportlib
- Don't write out an export library.nomanifest
- Don't embed a manifest.regserver
- On Windows, regsvr32 is run during the build to automatically register the DLL with the system. When cleaning, regsvr32 /u is run.windows
- Forces a GUI application. For Visual C++, the DLL is linked with/SUBSYSTEM:WINDOWS
.
Assign the linker search DIRECTORIES
for the given project TARGET
.
TARGET | The target to assign the link DIRECTORIES to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the defines are made available globally. |
DIRECTORIES | The list of link directories to apply. Absolute paths are used directly. Relative paths are local to $(SUBDIR) . That is, they are relative to the subdirectory specified via SubDir. |
OPTIONS | If public is specified, the directories specified by DIRECTORIES are made available to a project using C.Inherits . |
Assign extra link FLAGS
to the given project TARGET
.
TARGET | The target to assign the link FLAGS to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the flags are made available globally. |
FLAGS | The list of link flags to apply. |
Makes TARGET
depend on Jam generated LIBRARIES
and includes them during linking.
TARGET | The target to link LIBRARIES to. TARGET is optional if rule ActiveTarget TARGET has been specified. |
LIBRARIES | The list of libraries to apply. These libraries are those generated from the rule C.Library TARGET : SOURCES [ : OPTIONS ] rule. They do not include prebuilt libraries. To link prebuilt libraries, use the rule C.LinkPrebuiltLibraries TARGET : LIBRARIES [ : OPTIONS ] rule. |
OPTIONS | If public is specified, the libraries specified by LIBRARIES are made available to a project using C.Inherits . |
Makes TARGET
depend on LIBRARIES
and includes them during linking.
TARGET | The target to link LIBRARIES to. TARGET is optional if rule ActiveTarget TARGET has been specified. |
LIBRARIES | The list of libraries to apply. These libraries are prebuilt libraries, such as kernel32.lib, and are specified without an extension. For those libraries generated from the rule C.Library TARGET : SOURCES [ : OPTIONS ] rule, use the rule C.LinkLibraries TARGET : LIBRARIES [ : OPTIONS ] rule. |
OPTIONS | If public is specified, the libraries specified by LIBRARIES are made available to a project using C.Inherits . |
Generates a small file containing an #include
amalgamation of files passed into the rule.
The name of the generated lump file is $(LOCATE_SOURCE)/!$(LUMP_NAME)!.$(LUMP_NAME:S)
. If LUMP_NAME
does not have an extension, then the extension from $(PCH_FILENAMES[1]:S) is used. If that doesn't exist, then the default is .cpp
.
The lump file has the following contents:
PCH_FILENAMES
, a #include "\$(PCH_FILENAMES[1])"
line is added to the lump file. SOURCES_VARIABLE_NAME
that is not excluded from the build via rule C.ExcludeFromBuild TARGET : SOURCES, a #include "filename"
is added to the lump file. Lumping may be turned off globally by setting the global variable LUMP
to be 0
.
PARENT | The parent target to which the lump file belongs. PARENT is optional if rule ActiveTarget TARGET has been specified. |
SOURCES_VARIABLE_NAME | The variable name listing the source files to be added to the lump. This is not an expanded version through $(SRCS) but rather, it is the actual name of the variable, SRCS . On return from the Lump rule, SOURCES_VARIABLE_NAME will be populated with the gristed name of the lump file. It will not contain the original file list anymore. It may include the precompiled header source filename $(PCH_FILENAMES[1]) if $(PCH_FILENAMES[3]) is set. |
PCH_FILENAMES | (optional) PCH_FILENAMES [1] is the filename of the precompiled header source file (generally, the .cpp). PCH_FILENAMES [2] is the filename of the precompiled header's header file. If PCH_FILENAMES [2] is not specified, then $(PCH_FILENAMES[1]:S=.h) is used. Finally, if PCH_FILENAMES [3] is set to 1 , the precompiled header's source file (set through PCH_FILENAMES [1]) is added to the SOURCES_VARIABLE_NAME list. |
EXTRA_INCLUDE_PATHS | If additional include paths are needed for this lump file, specify them here. |
Creates a precompiled header and uses it on the specified FILES
.
TARGET | The target to which the precompiled header belongs. This is needed to properly grist the precompiled header filenames. If not specified, TARGET defaults to the active target set via ActiveTarget. |
FILES | The list of files to turn off precompiled header support for. |
For the given SOURCES
, add the compilation FLAGS
.
TARGET | The target containing the SOURCES . TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of sources to add the FLAGS to. |
FLAGS | The list of flags to add. |
For the given SOURCES
matching *.c
, assign the passed in FLAGS
.
TARGET | The target containing the SOURCES . TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of sources to assign the FLAGS to. |
FLAGS | The list of flags to apply. |
For the given SOURCES
matching *.cpp or *.cxx, assign the passed in FLAGS
.
TARGET | The target containing the SOURCES . TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of sources to assign the FLAGS to. |
FLAGS | The list of flags to apply. |
For the given SOURCES
, assign the passed in DEFINES
.
TARGET | The target containing the SOURCES . TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of sources to assign the DEFINES to. |
DEFINES | The list of defines to apply. |
For the given SOURCES
, assign the INCLUDES
to the TARGET
, causing that project's compilation to force the inclusion of the header before anything else.
TARGET | The target containing the SOURCES . TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of sources to assign the force include flag to. |
INCLUDES | The list of header files to force include. |
For the given SOURCES
, assign the INCLUDEPATHS
as part of the TARGET
compilation of the SOURCES
.
TARGET | The target containing the SOURCES . TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of sources to assign the include paths to. |
INCLUDEPATHS | The list of include paths to apply. |
OPTIONS | The following options are available: |
prepend
- Instead of appending the paths specified byINCLUDEPATHS
to the include directories list, the paths will be prepended instead.
For the given SOURCES
, remove the compilation FLAGS
.
TARGET | The target containing the SOURCES . TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of sources to remove the FLAGS from. |
FLAGS | The list of flags to remove. |
By default, the name of a generated executable or library is determined by the name of the TARGET
. OutputName
is used to override the name of the executable or library.
TARGET | The target to affect the output name change on. TARGET is optional if rule ActiveTarget TARGET has been specified. |
NAME | The new name of the output target. |
By default, the output location of a generated executable or library is at LOCATE_TARGET
. OutputPath
is used to override the output location of the executable or library.
TARGET | The target to affect the output path change on. TARGET is optional if rule ActiveTarget TARGET has been specified. |
OUTPUTPATH | The new output location of the generated target. |
The output postfix is appended to the end of the generated target name. By default, the output postfix is empty. This means the resultant filename is $(OUTPUTNAME).$(EXT).
If there is no assigned output postfix for TARGET
, then the global target *
is checked for a postfix.
TARGET | The target to affect the output path change on. TARGET is optional if rule ActiveTarget TARGET has been specified. |
POSTFIX | The new output postfix of the generated target. |
Clear the output postfix.
TARGET | The target to affect the output path change on. TARGET is optional if rule ActiveTarget TARGET has been specified. |
The output suffix is the file extension of the generated target. By default, the output suffix is appropriate for an executable or library.
TARGET | The target to affect the output suffix change on. TARGET is optional if rule ActiveTarget TARGET has been specified. |
SUFFIX | The new output suffix of the generated target. |
Advanced functionality used when setting up overlay toolchains.
TOOLCHAIN_SPEC_OPTIONS | TBD |
OPTIONS | TBD |
Creates a precompiled header based around NAME
and uses it on the specified FILES
.
Under Visual C++, NAME.cpp
is expected to exist as part of the build. If NAME.cpp
is not provided by the user, JamPlus will create an empty one automatically tied to the .cpp
extension. If another extension is desired, the first parameter to NAME
should be the alternate filename.
Under GCC-based compilers, the precompiled header name is automatic based on the flags and file extensions going into the build.
TARGET | The target to which the precompiled header belongs. This is needed to properly grist the precompiled header filenames. |
NAME | This parameter is made up of either one or two filenames. The first filename is the .cpp file used to create the precompiled header. If it does not contain an extension, .cpp is added. If the second filename is not specified, the default is to use the first filename with its suffix modified to .h . If the second filename is specified, it will represent the header file used for the precompilation. |
FILES | The list of files to apply the precompiled header to. |
For the given project TARGET
, remove the compilation FLAGS
from the current toolchain.
TARGET | The target to remove the FLAGS from. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the flags are made available globally. |
FLAGS | The list of flags to remove. |
For the given project TARGET
, alter the build to use either a statically linked C runtime or a dynamically linked C runtime.
TARGET | The target to assign the new C runtime to. TARGET is optional if rule ActiveTarget TARGET has been specified. If TARGET is * , the C runtime is changed globally. |
TYPE | May be set to either static or dynamic . Use static to select a statically linked C runtime. Use dynamic to dynamically link against the C runtime. |
THE_PLATFORM | (optional) If not specified, the default is the current platform. |
For the given project TARGET
, apply SEARCH_PATHS
to each of the SOURCES
that do not already have a SEARCH
applied.
TARGET | The target to work against. TARGET is optional if rule ActiveTarget TARGET has been specified. |
SOURCES | The list of sources to apply SEARCH_PATH to. |
SEARCH_PATH | The paths to search for. If none are specified, SEARCH_SOURCE is used. Any relative paths are rooted against SEARCH_SOURCE . |
Activate the toolchain specified by TOOLCHAIN_SPEC
.
TOOLCHAIN_SPEC | The toolchain to activate. |
Helper function to set LOCATE_SOURCE
on TARGET
to DIRECTORY
and to override the current global LOCATE_SOURCE
provided from rule SubDir TOP d1...dn : SUBNAME.
TARGET | The target to do the processing within. TARGET is optional if rule ActiveTarget TARGET has been specified. |
DIRECTORY | The directory to use as the override. |
Helper function to set LOCATE_TARGET
on TARGET
to DIRECTORY
and to override the current global LOCATE_TARGET
provided from rule SubDir TOP d1...dn : SUBNAME.
TARGET | The target to do the processing within. TARGET is optional if rule ActiveTarget TARGET has been specified. |
DIRECTORY | The directory to use as the override. |