-
-
Notifications
You must be signed in to change notification settings - Fork 640
Tokens
Tokens provide the ability to substitute computed values into a configuration setting. Using tokens, you can specify a single value that automatically adjusts itself to different platforms and configurations.
Tokens come in two varieties: value tokens, and command tokens.
Value tokens are expressions wrapped in a %{} sequence. Tokens have access to one or more context objects, depending on their scope within the project: wks, prj, cfg, and file. You can access all of the fields of these context objects within the token.
%{wks.name}
%{prj.location}
%{cfg.targetdir}The contents of the %{} are run through loadstring() and executed at token-replacement time, so more complex replacements can be used. You can access any global value.
%{wks.name:gsub(' ', '_')}You can use wks, prj, cfg, and file to represent the current workspace, project, configuration, and file configuration respectively. Note that these values must be in scope for the type of value you are trying to substitute or the object will be nil. You'll have to hunt around for the available fields until I have a chance to document them, but in general they follow the API names (includedirs, location, flags, etc.).
Some known tokens (feel free to add more as you use them):
wks.name
wks.location
prj.name
prj.language
cfg.architecture
cfg.buildcfg
cfg.buildtarget -- (see "targets", below)
cfg.kind
cfg.linktarget -- (see "targets", below)
cfg.longname
cfg.objdir
cfg.platform
cfg.shortname
cfg.system
file.abspath
file.basename
file.name
file.relpath
-- These values are available on build and link targets
-- Replace "target" with one of "cfg.buildtarget" or "cfg.linktarget"
target.abspath
target.basename
target.bundlename
target.bundlepath
target.directory
target.extension
target.name
target.prefix
target.relpath
target.suffixCommand tokens represent a system level command in a platform-neutral way.
postbuildcommands {
"{COPY} file1.txt file2.txt"
}You can use command tokens anywhere you specify a command line, including:
- buildcommands
- cleancommands
- os.execute
- os.executef
- postbuildcommands
- prebuildcommands
- prelinkcommands
- rebuildcommands
Command tokens are replaced with an appropriate command for the target platform. For Windows, path separators in the commmand arguments are converted to backslashes.
The available tokens, and their replacements:
| Token | DOS | Posix |
|---|---|---|
| {CHDIR} | chdir {args} | cd {args} |
| {COPY} | xcopy /Q /E /Y /I {args} | cp -rf {args} |
| {DELETE} | del {args} | rm -rf {args} |
| {ECHO} | echo {args} | echo {args} |
| {MKDIR} | mkdir {args} | mkdir -p {args} |
| {MOVE} | move /Y {args} | mv -f {args} |
| {RMDIR} | rmdir /S /Q {args} | rm -rf {args} |
| {TOUCH} | type nul >> {arg} && copy /b {arg}+,, {arg} | touch {args} |