74 KiB
Vendored
Scripting Reference
Table of Contents
- Predefined variables
- Build script functions
- buildaction
- buildoptions
- configuration
- configurations
- custombuildtask
- debugcmd
- debugargs
- debugdir
- defines
- dependency
- deploymentoptions
- excludes
- files
- flags
- framework
- group
- imageoptions
- imagepath
- implibdir
- implibextension
- implibname
- implibprefix
- implibsuffix
- include
- includedirs
- kind
- language
- libdirs
- linkoptions
- links
- location
- messageskip
- newaction
- newoption
- nopch
- objdir
- options
- pchheader
- pchsource
- platforms
- postbuildcommands
- postcompiletasks
- prebuildcommands
- prelinkcommands
- project
- removefiles
- removeflags
- removelinks
- removeplatforms
- resdefines
- resincludedirs
- resoptions
- solution
- startproject
- systemincludedirs
- targetdir
- targetextension
- targetname
- targetprefix
- targetsubdir
- targetsuffix
- userincludedirs
- uuid
- vpaths
- xcodeprojectopts
- xcodetargetopts
- xcodescriptphases
- xcodecopyresources
- xcodecopyframeworks
- wholearchive
- Utility functions
- iif
- os.chdir
- os.copyfile
- os.findlib
- os.get
- os.getcwd
- os.getversion
- os.is
- os.is64bit
- os.isdir
- os.isfile
- os.matchdirs
- os.matchfiles
- os.mkdir
- os.outputof
- os.pathsearch
- os.rmdir
- os.stat
- os.uuid
- path.getabsolute
- path.getbasename
- path.getdirectory
- path.getdrive
- path.getextension
- path.getname
- path.getrelative
- path.isabsolute
- path.iscfile
- path.isSourceFile
- path.isresourcefile
- path.join
- path.rebase
- path.translate
- printf
- string.endswith
- string.explode
- string.findlast
- string.startswith
- table.contains
- table.implode
- Additional information
Predefined Variables
Each of the following variables is available for use in any GENie script.
_ACTION
Name of the action to be performed on this execution run.
$ genie vs2005
produces
_ACTION: "vs2005"
_ARGS
Any arguments to the current action.
$ genie vs2015 alpha beta
produces
_ARGS[0]: "alpha"
_ARGS[1]: "beta"
_OPTIONS
Current set of command line options and their values, if any.
$ genie vs2015 --gfxapi=directx
produces
_OPTIONS['gfxapi']: "directx"
Note: Options may be registered with newoption to fully integrate them into the CLI.
_PREMAKE_COMMAND
Full path to the GENie (Premake) executable.
_PREMAKE_VERSION
GENie (Premake) version.
_SCRIPT
Full path to the currently executing script.
_WORKING_DIR
Current working directory.
Build script functions
buildaction(action)
Specifies what action should be performed on a set of files during compilation. Usually paired with a configuration filter to select a file set. If no build action is specified for a file, a default action will be used (chosen based on the file's extension).
Scope: solutions, projects, configurations
Note: only supported for .NET projects, and not for C or C++.
Arguments
action - the action to be performed. One of:
- "Compile" - treat the file as source code: compile and run it
- "Embed" - embed the file into the target binary as a resource
- "Copy" - copy the file to the target directory
- "None" - do nothing with this file
Examples
Embed all PNGs into the target binary
configuration "**.png"
buildaction "Embed"
buildoptions({options...})
Passes arguments direction to the compiler command line. Multiple calls in a project will be concatenated in order.
Scope: solutions, projects, configurations
You may also use one of these functions to configure buildoptions for each individual file extension:
buildoptions_asm
for .asm filesbuildoptions_c
for .c filesbuildoptions_cpp
for .cpp filesbuildoptions_objc
for .m filesbuildoptions_objcpp
for .mm filesbuildoptions_swift
for .swift filesbuildoptions_vala
for .vala files
Arguments
options - list of compiler flags
Examples
Add some GCC-specific options
configuration {"linux", "gmake"}
buildoptions {"-ansi", "-pedantic"}
configuration({keywords...})
Limits subsequent build settings to a particular environment. Acts as a filter, only applying settings that appear after this function if the environment matches the keywords.
Arguments
keywords - list of identifiers to compare to the current runtime environment
Possible values:
- Configuration names - configuration names passed to configurations
- Action names - "vs2015", "gmake", etc.
- Operating system names - "windows", "macosx", etc.
- Platform names - "ps3", "xbox360", etc.
- Command-line options - either built-in or custom
- File names - very limited, but some settings can be applied to specific files
You may also use "*" and "**" wildcards, as well as "not" and "or".
Return
Current configuration object with the following fields:
- buildaction - build action.
- buildoptions - list of compiler options.
- defines - list of compiler symbols.
- excludes - list of excluded files.
- files - list of files.
- flags - list of build flags.
- implibdir - import library directory.
- implibextension - import library file extension.
- implibname - import library base file name.
- implibprefix - import library file name prefix.
- implibsuffix - import library file name suffix.
- includedirs - list of include file search directories.
- keywords - list of keywords associated with the block.
- kind - target kind.
- libdirs - list of library search directories.
- linkoptions - list of linker options.
- links - list of libraries or assemblies to link against.
- objdir - objects and intermediate files directory.
- pchheader - target file name for precompiled header support.
- pchsource - target source file name for precompiled header support.
- prebuildcommands - list of pre-build commands.
- prelinkcommands - list of pre-link commands.
- postbuildcommands - list of post-build commands.
- resdefines - list of symbols for the resource compiler.
- resincludedirs - list of include file search paths for the resource compiler.
- resoptions - list of resource compiler options.
- targetdir - target output directory.
- targetextension - target file extension.
- targetname - target base file name.
- targetprefix - target file name prefix.
- targetsuffix - target file name suffix.
- terms - filter terms passed to the configuration function to create the block (i.e. "Debug").
Examples
Define debug symbol for debug configurations
configuration "Debug"
defines { "DEBUG" }
Define a symbol based on a wildcard
configuration "vs*"
defines { "VISUAL_STUDIO_2005" }
Define a symbol based on an "or"
configuration "linux or macosx"
defines { "LINUX_OR_MACOSX" }
Define a symbol based on a "not"
configuration "not windows"
defines { "NOT_WINDOWS" }
Define a symbol based on custom command line option
newoption {
trigger = "gfxapi",
description = "Choose a particular 3D API for rendering",
allowed = { { "opengl", "OpenGL Renderer" } }
}
configuration "opengl"
defines { "OPENGL" }
Reset the configuration filter
configuration {}
Caveats
-
Argument chaining:
configuration
can take multiple arguments, e.g.,configuration {"StaticLib", "xcode*", "osx or ios*"}
These arguments will be combined as an
AND
clause, i.e. if one of the keywords does not match the actual configuration terms, the following settings will not be applied. -
Condition evaluation:
The arguments are not evaluated as Lua. They are merely regex-matched against the configuration terms. The implications of this are that parentheses have no effect outside of regular expression groups. A condition like"not (osx or ios*)"
will not be equivalent to{"not osx", "not ios*}"
. Furthermore, a condition like"not osx or ios*"
will be evaluated as the negation of"osx or ios*"
. -
and
is not a valid keyword for configuration combinations.
However, several keywords will be combined as anAND
clause. -
Limits of Lua's regular expressions:
Each passed keyword is matched against each configuration terms from the project/solution type being built using Lua's regular expression mechanism. This means that keyword matching is subject to the same limits as regular Lua regex matching. This implies that regexes like"(osx|ios)"
do not work. -
Wildcard expansion:
Wildcards will get expanded following the same rules as paths. Similarly, special characters such as()
will get escaped (i.e. converted to%(%)
) before being matched. This means that"not (osx or ios*)"
will in fact get expanded to"not %(osx or ios[^/]*)"
and then checked asnot
result of"%(osx or ios[^/]*)"
, which in turn gets broken down to"%(osx"
and"ios[^/]*)"
. -
"win*"
matchings:
Intuitively, the configuration keyword to match "Windows" ("Win32", "Win64" or "WinCE") configuration would be"win*"
. However"win*"
also matches "WindowedApp". Prefer using the term"vs*"
to check for configurations targeting Windows.
configurations({names...})
Defines a set of build configurations, such as "Debug" and "Release". Must be specified before any projects are defined, so can't be called after a project has been defined.
Scope: solutions
Arguments
names - list of configuration names
Return Value
When called with no arguments - list of current configuration names
Examples
Specify configurations for a solution
solution "MySolution"
configurations { "Debug", "Release" }
Add additional configurations
configurations{ "Debug", "Release", "DebugDLL", "ReleaseDLL" }
Retrieve current list of configurations
local cfgs = configurations()
custombuildtask({input_file, output_file, {dependency, ...}, {command, ...}}, ...)
Defines custom build task for specific input file, that generates output file, there can be additional dependencies, and for rule listed commands are executed.
Scope: solutions, projects, configurations
Arguments
input_file - source file that should be "compiled" with custom task
output_file - generated file name
dependency - additional dependencies, that can be used as parameters to commands
command - command list, special functions in commands are :
$(<) - input file
$(@) - output file
$(1) - $(9) - additional dependencies
Examples
custombuildtask {
{ ROOT_DIR .. "version.txt" , GEN_DIR .. "src/version.inc", { ROOT_DIR .. "version.py" }, {"@echo Generating version.inc file...", "python $(1) $(<) > $(@)" }},
}
debugcmd(cmd)
Specifies a command to execute when running under the debugger instead of the build target.
Note: In Visual Studio, this can be overridden by a per-user config file (e.g. ProjectName.vcxproj.MYDOMAIN-MYUSERNAME.user).
Scope: solutions, projects, configurations
Arguments
cmd - the command to execute when starting with the debugger
Examples
configuration 'TestConfig'
debugcmd 'D:\\Apps\\Test.exe'
debugargs({args...})
Specifies a list of arguments to pas to the application when run under the debugger.
Note: In Visual Studio, this can be overridden by a per-user config file (e.g. ProjectName.vcxproj.MYDOMAIN-MYUSERNAME.user).
Scope: solutions, projects, configurations
Arguments
args - list of arguments to pass to the executable while debugging
Examples
configuration "Debug"
debugargs { "--append", "somefile.txt" }
debugdir(path)
Sets the working directory for the integrated debugger.
Note: In Visual Studio, this can be overridden by a per-user config file (e.g. ProjectName.vcxproj.MYDOMAIN-MYUSERNAME.user).
Scope: solutions, projects, configurations
Arguments
path - path to the working directory, relative to the currently-executing script file
Examples
configuration "Debug"
debugdir "bin/debug"
defines({symbols...})
Adds preprocessor or compiler symbols to the project. Multiple calls are concatenated.
Scope: solutions, projects, configurations
Arguments
symbols - list of symbols
Examples
Define two new symbols
defines { "DEBUG", "TRACE" }
Assign a symbol value
defines { "CALLSPEC=__dllexport" }
dependency({main_file, depending_of} ...)
GMAKE specific. Adds dependency between source file and any other file.
Scope: solutions, projects, configurations
Arguments
main_file - name of source file that depends of other file
depending_of - name of dependency file
Examples
dependency { { ROOT_DIR .. "src/test.c", ROOT_DIR .. "verion.txt" } }
deploymentoptions({options...})
Passes arguments directly to the deployment tool command line. Multiple calls are concatenated.
Note: Currently only supported for Xbox 360 targets.
Scope: solutions, projects, configurations
Arguments
options - list of arguments
excludes({files...})
Excludes files from the project. This is different from removefiles in that it may keep them in the project (Visual Studio) while still excluding them from the build. Multiple calls are concatenated.
Note: May be set on the solution, project, or configuration, but only project-level file lists are currently supported.
Scope: solutions, projects, configurations
Arguments
files - List of files to exclude. Paths should be relative to the currently-executing script file and may contain wildcards.
Examples
Add all c files in a directory, then exclude a specific file
files { "*.c" }
excludes { "a_file.c" }
Add an entire directory of C files, then exclude one directory
files { "*.c" }
excludes { "tests/*.c" }
files({files...})
Adds files to a project. Multiple calls are concatenated.
Note: May be set on the solution, project, or configuration, but only project-level file lists are currently supported.
Scope: solutions, projects, configurations
Arguments
files - List of files to include. Paths should be relative to the currently-executing script file and may contain wildcards.
Examples
Add two files to the current project
files { "hello.cpp", "goodbye.cpp" }
Add all C++ files from the "src/" directory to the project
files { "src/*.cpp" }
Add all C++ files from the "src/" directory and any subdirectories
files { "src/**.cpp" }
flags({flags...})
Specifies build flags to modify the compiling or linking process. Multiple calls are concatenated.
Scope: solutions, projects, configurations
Arguments
flags - List of flag names from list below. Names are case-insensitive and ignored if not supported on a platform.
- AntBuildDebuggable - Enables Visual Studio projects targetting Android to be debugged using the NVIDIA Nsight Tegra tools. (#321)
- C7DebugInfo - Enables C7 compatible debug info for MSVC builds.
- Cpp11 - Enable usage of C++11 features.
- Cpp14 - Enable usage of C++14 features.
- Cpp17 - Enable usage of C++17 features.
- CppLatest - Enable usage of latest C++ features.
- DebugEnvsDontMerge - Cause Visual Studio projects to not merge debug environment with the one inherited from the parent process. (i.e. sets
Project Properties > Debugging > Merge Environment
tofalse
) - DebugEnvsInherit - Cause Visual Studio projects to inherit debug environment. (i.e. sets in
Project Properties > Debugging > Environment > Edit > Inherit from parent of project defaults
totrue
) - DeploymentContent - Mark files with
DeploymentContent
flag in the project file. (For C++ Win Store apps) (#139) - EnableMinimalRebuild - Enable Visual Studio's minimal rebuild feature.
- EnableSSE, EnableSSE2, EnableAVX, EnableAVX2 - Enable SSE/AVX instruction sets
- ExtraWarnings - Sets compiler's max warning level.
- FatalWarnings - Treat warnings as errors.
- FloatFast - Enable floating point optimizations at the expense of accuracy.
- FloatStrict - Improve floating point consistency at the expense of performance.
- FullSymbols - Use together with Symbols to generate full debug symbols with Visual Studio.
- GenerateMapFiles - Enable .map file outputs from the Visual Studio linker.
- LinkSupportCircularDependencies - Enables the linker to iterate over provided libs in order to resolve circular dependencies (make and ninja only).
- Managed - Enable Managed C++ (.NET).
- MinimumWarnings - - Sets compiler's minimum warning level (Visual Studio only).
- NativeWChar, NoNativeWChar - Toggle support for the wchar data type.
- No64BitChecks - Disable 64-bit portability warnings.
- NoBufferSecurityCheck - Turns off Visual Studio 'Security Check' option. Can give up to 10% performance improvement.
- NoEditAndContinue - Disable support for Visual Studio's Edit-and-Continue feature.
- NoExceptions - Disable C++ exception support.
- NoFramePointer - Disable the generation of stack frame pointers.
- NoImportLib - Prevent the generation of an import library for a Windows DLL.
- NoIncrementalLink - Disable support for Visual Studio's incremental linking feature.
- NoJMC - Disable Visual Studio's 'Just my Code' feature.
- NoManifest - Prevent the generation of a manifest for Windows executables and shared libraries.
- NoMultiProcessorCompilation - Disables Visual Studio's and FastBuild's multiprocessor compilation.
- NoPCH - Disable precompiled headers.
- NoRTTI - Disable C++ runtime type information.
- NoRuntimeChecks - Disable Visual Studio's Basic Runtime Checks in Debug builds.
- NoWinMD - Disables Generation of Windows Metadata.
- NoWinRT - Disables Windows RunTime Extension for project.
- ObjcARC - Enable automatic reference counting for Object-C and Objective-C++.
- Optimize - Perform a balanced set of optimizations.
- OptimizeSize - Optimize for the smallest file size.
- OptimizeSpeed - Optimize for the best performance.
- PedanticWarnings - Enables the pedantic warning flags.
- SEH - Enable structured exception handling.
- SingleOutputDir - Allow source files in the same project to have the same name.
- StaticRuntime - Perform a static link against the standard runtime libraries.
- Symbols - Generate debugging information.
- Unicode - Enable Unicode strings. If not specified, the default toolset behavior is used.
- Unsafe - Enable the use of unsafe code in .NET applications.
- UnsignedChar - Force
char
s to beunsigned
by default. - UseFullPaths - Enable absolute paths for
__FILE__
. - UseLDResponseFile - Enable use of response file (aka @file) for linking lib dependencies (make and ninja).
- UseObjectResponseFile - Enable use of response file (aka @file) for linking objects (make and ninja).
- WinMain - Use WinMain() as the entry point for Windows applications, rather than main().
Note: When not set, options will default to the tool default.
Additional tool-specific arguments can be passed with buildoptions
or linkoptions
Examples
Enable debugging symbols in the Debug configuration and optimize the Release configuration
configuration "Debug"
flags { "Symbols" }
configuration "Release"
flags { "OptimizeSpeed", "No64BitChecks" }
framework(version)
Specifies a .NET framework version.
Note: Currently only applied to Visual Studio 2005+ and GNU Makefiles using Mono.
Scope: solutions, projects
Arguments
version - one of the following:
- 1.0
- 1.1
- 2.0
- 3.0
- 3.5
- 4.0
Examples
Use the .NET 3.0 framework
framework "3.0"
group(name)
Creates a solution folder for Visual Studio solutions.
Scope: solutions
Arguments
name - the name of the solution folder
Examples
solution "MySolution"
group "MyGroup1"
project "Project1"
-- ...
project "Project2"
-- ...
group "MyGroup2"
project "Project3"
-- ...
imageoptions({options...})
Passes arguments directly to the image tool command line without translation. Multiple calls are concatenated.
Scope: solutions, project, configurations
Arguments
options - list of image tools flags and options
imagepath(path)
Sets the file name of the deployment image produced by the build
Scope: solutions, projects, configurations
Arguments
path - the full path for the image file, relative to the currently-executing script
implibdir(path)
Specifies the import library output directory. Import libraries are generated for Windows DLL projects. By default, the generated files will place the import library in the same directory as the compiled binary.
Scope: solutions, projects, configurations
Arguments
path - the output directory for the library, relative to the currently-executing script file
Examples
implibdir "../Libraries"
implibextension(extension)
Specifies the import library file extension. Import libraries are generated for Windows DLL projects. By default, the toolset static library file extension will be used (.lib
with Windows tools, .a
with GNU tools).
Scope: solutions, projects, configurations
Arguments
extension - the extension, including the leading dot
implibname(name)
Specifies the import library base file name. Import libraries are generated for Windows DLL projects. By default the target name will be used as the import library file name.
Scope: solutions, projects, configurations
Arguments
name - new base file name
implibprefix(prefix)
Specifies the import library file name prefix. Import libraries are generated for Windows DLL projects. By default the system naming convention will be used (no prefix on Windows, lib
prefix on other systems).
Scope: solutions, projects, configurations
Arguments
prefix - new file name prefix
Examples
implibprefix "plugin"
The prefix may also be set to an empty string for no prefix
implibprefix ""
implibsuffix(suffix)
Specifies the file name suffix for the import library base file name. Import libraries are generated for Windows DLL projects.
Scope: solutions, projects, configurations
Arguments
suffix - the new filename suffix
Examples
-- Add "-d" to debug versions of files
configuration "Debug"
implibsuffix "-d"
include(directory)
Includes a file named premake4.lua
from the specified directory. This allows you to specify each project in its own file, and easily include them into a solution.
Arguments
directory - path to the included directory, relative to the currently-executing script file.
Return Value
Any values returned by the script are passed through to the caller
Examples
-- runs "src/MyApplication/premake4.lua"
include "src/MyApplication"
-- runs "src/MyLibrary/premake4.lua"
include "src/MyLibrary"
includedirs({paths...})
Specifies include file search paths. Multiple calls are concatenated.
Scope: solutions, projects, configurations
Arguments
paths - list of include file search directories, relative to the currently-executing script file.
Examples
Define two include file search paths
includedirs { "../lua/include", "../zlib" }
You can also use wildcards to match multiple directories.
includedirs { "../includes/**" }
kind(kind)
Sets the kind of binary object being created by the project, such as a console or windowed application.
Scope: solutions, projects, configurations
Arguments
kind - project kind identifier. One of:
- ConsoleApp - console executable
- WindowedApp - application that runs in a window (Windows, Android, MacOS and iOS). Does not apply on Linux.
- StaticLib - static library
- SharedLib - shared library or DLL
- Bundle - Xcode: Cocoa Bundle, everywhere else: alias to SharedLib
Examples
kind "ConsoleApp"
You can also set different kinds for each configuration. Not supported by XCode.
solution "MySolution"
configurations { "DebugLib", "ReleaseLib", "DebugDLL", "ReleaseDLL" }
project "MyProject"
configuration "*Lib"
kind "StaticLib"
configuration "*DLL"
kind "SharedLib"
language(lang)
Sets the programming language used by a project. GENie currently supports C, C++, C# and Vala. Not all languages are supported by all of the generators. For instance, SharpDevelop does not currently support C or C++ development, and Code::Blocks does not support the .NET languages (C#, managed C++).
Scope: solutions, projects
Arguments
lang - language identifier string ("C", "C++", "C#" or "Vala"). Case insensitive.
Examples
language "C++"
libdirs({paths...})
Specifies the library search paths. Library search directories are not well supported by the .NET tools. Visual Studio will change relative paths to absolute, making it difficult to share the generated project. MonoDevelop and SharpDevelop do not support search directories at all, using only the GAC. In general, it is better to include the full (relative) path to the assembly in links instead. C/C++ projects do not have this limitation.
Multiple calls are concatenated.
Scope: solutions, projects, configurations
Arguments
paths - list of library search directories, relative to the currently-executing script file
Examples
libdirs { "../lua/libs", "../zlib" }
You can also use wildcards to match multiple directories.
libdirs { "../libs/**" }
linkoptions({options...})
Passes arguments to the linker command line. Multiple calls are concatenated.
Scope: solutions, projects, configurations
Arguments
options - list of flags and options to pass
Examples
Use pkg-config
-style configuration when building on Linux with GCC.
configuration { "linux", "gmake" }
linkoptions { "`wx-config --libs`"}
links({references...})
Specifies a list of libraries and projects to link against. Multiple calls are concatenated.
Scope: solutions, projects, configurations
Arguments
references - list of library and project names
When linking against another project in the same solution, specify the project name here, rather than the library name. GENie will figure out the correct library to link against for the current configuration and will also create a dependency between the projects to ensure proper build order.
When linking against system libraries, do not include any prefix or file extension. GENie will use the appropriate naming conventions for the current platform.
Examples
Link against some system libraries
configuration "windows"
links { "user32", "gdi32" }
configuration "linux"
links { "m", "png" }
configuration "macosx"
--- OS X frameworks need the extension to be handled properly
links { "Cocoa.framework", "png" }
In a solution with two projects, link the library into the executable. Note that the project name is used to specify the link. GENie will automatically figure out the correct library file name and directory and create a project dependency.
solution "MySolution"
configurations { "Debug", "Release" }
language "C++"
project "MyExecutable"
kind "ConsoleApp"
files "**.cpp"
links { "MyLibrary" }
project "MyLibrary"
kind "SharedLib"
files "**.cpp"
You may also create links between non-library projects. In this case, GENie will generate a build dependency (the linked project will build first) but not an actual link. In this example, MyProject uses a build dependency to ensure that MyTool gets built first. It then uses MyTool as part of its build process
solution "MySolution"
configurations { "Debug", "Release" }
language "C++"
project "MyProject"
kind "ConsoleApp"
files "**.cpp"
links { "MyTool" }
prebuildcommands { "MyTool --dosomething" }
project "MyTool"
kind "ConsoleApp"
files "**.cpp"
location(path)
Sets the destination directory for a generated solution or project file. By default, project files are generated into the same directory as the script that defines them.
Note: Does not automatically propagate to the contained projects. Projects will use their default location unless explicitly overridden.
Scope: solutions, projects
Arguments
path - directory into which files should be generated, relative to the currently-executing script file.
Examples
solution "MySolution"
location "../build"
If you plan to build with multiple tools from the same source tree, you might want to split up the project files by toolset. The _ACTION global variable contains the current toolset identifier, as specified on the command line. Note that Lua syntax requires parentheses around the function parameters in this case.
location ("../build/" .. _ACTION)
messageskip(options)
Skips certain messages in ninja and Makefile generated projects.
Scope: solutions
Arguments
options - one or several of "SkipCreatingMessage", "SkipBuildingMessage", "SkipCleaningMessage"
Examples
messageskip { "SkipCreatingMessage", "SkipBuildingMessage", "SkipCleaningMessage" }
newaction(description)
Registers a new command-line action argument.
Arguments
description - a table describing the new action with the following fields:
- trigger - string identifier of the action; what the user would type on the command line
- description - short description of the action, to be displayed in the help text
- execute - Function to be executed when the action is fired
Examples
newaction {
trigger = "install",
description = "Install the software",
execute = function()
os.copyfile("bin/debug/myprogram", "/usr/local/bin/myprogram")
end
}
newoption(description)
Registers a new command-line option argument.
Scope: solutions, projects, configurations
Arguments
description - a table describing the new option with the following fields:
- trigger - string identifier of the option; what the user would type on the command line
- description - short description of the option, to be displayed in the help text
- value - (optional) provides a hint to the user as to what type of data is expected
- allowed - (optional) list of key-value pairs listing the allowed values for the option
Examples
newoption {
trigger = "gfxapi",
value = "API",
description = "Choose a particular 3D API for rendering",
allowed = {
{ "opengl", "OpenGL" },
{ "direct3d", "Direct3D (Windows only)"},
{ "software", "Software Renderer" }
}
}
nopch({files...})
Sets sources files added with the files
function, to not use the precompiled header. Multiple calls are concatenated.
Note: May be set on the solution, project, or configuration, but only project-level file lists are currently supported.
Scope: solutions, projects, configurations
Arguments
files - List of files to not use the precompiled header. Paths should be relative to the currently-executing script file and may contain wildcards.
Examples
Add all c files in a directory, then set a specific file to not use precompiled headers.
files { "*.c" }
nopch { "a_file.c" }
Add an entire directory of C files, then set one directory to not use precompiled headers
files { "*.c" }
nopch { "tests/*.c" }
objdir(path)
Sets an object and intermediate file directory for a project. By default, object and intermediate files are stored in a directory named "obj" in the same directory as the project.
Scope: solutions, projects, configurations
Arguments
path - directory where the object and intermediate files should be stored, relative to the currently-executing script file.
Examples
project "MyProject"
objdir "objects"
Set object directories per configuration
configuration "Debug"
objdir "../obj_debug"
configuration "Release"
objdir "../obj_release"
options({options...})
Specifies build flags to modify the compiling or linking process. This differs from flags
in
that these are set per project rather than per configuration.
Scope: solutions, projects
Arguments
options - List of option names from list below. Names are case-insensitive and ignored if not supported on a platform.
- ArchiveSplit - Split arguments to the gmake archiver across multiple invocations, if there are too many of them.
- ForceCPP - Force compiling source as C++ despite the file extension suggesting otherwise.
- SkipBundling - Disable generating bundles for Apple platforms.
- XcodeLibrarySchemes - Generate XCode schemes for libraries too. (By default schemes are only created for runnable apps.)
- XcodeSchemeNoConfigs - Generate a single scheme per project, rather than one per project config.
pchheader(file)
Sets the main header file for precompiled header support.
Scope: projects
Arguments
file - name of the header file, as it is specified in your #include
statements
Examples
pchheader "afxwin.h"
pchsource "afxwin.cpp"
pchsource(file)
Sets the main source file for precompiled header support. Only used by Visual Studio.
Scope: projects
Arguments
file - name of the source file, relative to the currently-executing script file
Examples
pchheader "afxwin.h"
pchsource "afxwin.cpp"
platforms({identifiers...})
Specifies a set of target hardware platforms for a solution.
Platform support is a new, experimental feature. The syntax and behavior described here might change as we sort out the details
Scope: solutions
Arguments
identifiers - list of hardware platform specifiers from this list:
- Native - general build not targeting any particular platform. If your project can be built in a generic fashion, you should include this as the first platform option
- x32 - 32-bit environment
- x64 - 64-bit environment
- Universal - OS X universal binary, target both 32- and 64-bit versions of x86 and PPC. Automated dependency generation must be turned off, and always do a clean build. Not supported by Visual Studio.
- Universal32 - like Universal above, but targeting only 32-bit platforms
- Universal64 - like Universal above, but targeting only 64-bit platforms
- PS3 - Playstation 3
- WiiDev - Wii
- Xbox360 - Xbox 360 compiler and linker under Visual Studio
- PowerPC - PowerPC processors
- ARM - ARM-based processors
- ARM64 - ARM64-based processors
- Orbis - Playstation 4
- Durango - Xbox One
- NX32 - Nintendo Switch 32-bit
- NX64 - Nintendo Switch 64-bit
Return Value
Current list of target platforms for the active solution
Examples
Generic build, as well as OS X Universal build
solution "MySolution"
configurations { "Debug", "Release" }
platforms { "native", "universal" }
Prove 32- and 64-bit specific build targets. No generic build is provided so one of these two platforms must always be used. Do this only if your software requires knowledge of the underlying architecture at build time; otherwise, include native to provide a generic build.
solution "MySolution"
configurations { "Debug", "Release" }
platforms { "x32", "x64" }
You can retrieve the current list of platforms by calling the function with no parameters
local p = platforms()
Once you have defined a list of platforms, you may use those identifiers to set up configuration filters and apply platform-specific settings.
configuration "x64"
defines "IS_64BIT"
-- You can also mix platforms with other configuration selectors
configuration { "Debug", "x64" }
defines "IS_64BIT_DEBUG"
postbuildcommands({commands...})
Specifies shell commands to run after build is finished
Scope: solutions, projects, configurations
Arguments
commands - one or more shell commands
Examples
configuration "windows"
postbuildcommands { "copy default.config bin\\project.config" }
configuration "not windows"
postbuildcommands { "cp default.config bin/project.config" }
postcompiletasks({commands...})
Specifies shell commands to run after compile of file is finished (GMAKE specific)
Scope: solutions, projects, configurations
Arguments
commands - one or more shell commands
Examples
postcompiletasks { "rm $(@:%.o=%.d)" }
prebuildcommands({commands...})
Specifies shell commands to run before each build
Scope: solutions, projects, configurations
Arguments
commands - one or more shell commands
Examples
configuration "windows"
prebuildcommands { "copy default.config bin\\project.config" }
configuration "not windows"
prebuildcommands { "cp default.config bin/project.config" }
prelinkcommands({commands...})
Specifies shell commands to run after source files have been compiled, but before the link step
Scope: solutions, projects, configurations
Arguments
commands - one or more shell commands
Examples
configuration "windows"
prelinkcommands { "copy default.config bin\\project.config" }
configuration "not windows"
prelinkcommands { "cp default.config bin/project.config" }
project(name)
Creates a new project and makes it active. Projects contain all of the settings necessary to build a single binary target, and are synonymous with a Visual Studio Project. These settings include the list of source code files, the programming language used by those files, compiler flags, include directories, and which libraries to link against.
Every project belongs to a solution.
Arguments
name - a unique name for the project. If a project with the given name already exists, it is made active and returned. The project name will be used as the file name of the generated solution file.
Return Value
The active project object.
The project
Object
Every project is represented in Lua as a table of key-value pairs. You should treat this object as read-only and use the GENie API to make any changes.
- basedir - directory where the project was originally defined. Root for relative paths.
- blocks - list of configuration blocks
- language - project language, if set
- location - output directory for generated project file
- name - name of the project
- solution - solution which contains the project
- uuid - unique identifier
Examples
Create a new project named "MyProject". Note that a solution must exist to contain the project. The indentation is for readability and is optional.
solution "MySolution"
configurations { "Debug", "Release" }
project "MyProject"
You can retrieve the currently active project by calling project
with no parameters.
local prj = project()
You can retrieve the list of projects associated with a solution using the projects
field of the solution object, which may then be iterated over.
local prjs = solution().projects
for i, prj in ipairs(prjs) do
print(prj.name)
end
removefiles({files...})
Removes files from the project. This is different from excludes in that it completely removes them from the project, not only from the build. Multiple calls are concatenated.
Scope: solutions, projects, configurations
Arguments
files - list of files to remove.
removeflags({flags...})
Removes flags from the flag list.
Scope: solutions, projects, configurations
Arguments
flags - list of flags to remove from the flag list. They must be valid flags.
removelinks({references...})
Removes flags from the flag list.
Scope: solutions, projects, configurations
Arguments
references - list of libraries and project names to remove from the links list.
removeplatforms({platforms...})
Removes platforms from the platform list.
Scope: solutions, projects, configurations
Arguments
platforms - list of platforms to remove from the platforms list.
resdefines({symbols...})
Specifies preprocessor symbols for the resource compiler. Multiple calls are concatenated.
Scope: solutions, projects, configurations
Arguments
symbols - list of symbols to be defined
Examples
resdefines { "DEBUG", "TRACE" }
resdefines { "CALLSPEC=__dllexport" }
resincludedirs({paths...})
Specifies the include file search paths for the resource compiler. Multiple calls are concatenated.
Scope: solutions, projects, configurations
Arguments
paths - list of include file search directories, relative to the currently executing script file
Examples
resincludedirs { "../lua/include", "../zlib" }
May use wildcards
resincludedirs { "../includes/**" }
resoptions({options...})
Passes arguments directly to the resource compiler. Multiple calls are concatenated.
Scope: solutions, projects, configurations
Arguments
options - list of resource compiler flags and options
Examples
configuration { "linux", "gmake" }
resoptions { "`wx-config --cxxflags`", "-ansi", "-pedantic" }
solution(name)
Creates a new solution and makes it active. Solutions are the top-level objects in a GENie build script, and are synonymous with a Visual Studio solution. Each solution contains one or more projects, which in turn contain the settings to generate a single binary target.
Arguments
name - unique name for the solution. If a solution with the given name already exists, it is made active and returned. This value will be used as the file name of the generated solution file.
Return Value
The active solution
object.
The solution
Object
Represented as a Lua table key-value pairs, containing the following values. You should treat this object as read-only and use the GENie API to make any changes.
- basedir - directory where the original project was defined; acts as a root for relative paths
- configurations - list of valid configuration names
- blocks - list of configuration blocks
- language - solution language, if set
- location - output directory for the generated solution file
- name - name of the solution
- platforms - list of target platforms
- projects - list of projects contained by the solution
Examples
solution "MySolution"
You can retrieve the currently active solution object by calling solution
with no parameters.
local sln = solution()
You can use the global variable _SOLUTIONS
to list out all of the currently defined solutions.
for i, sln in ipairs(_SOLUTIONS) do
print(sln.name)
end
startproject(name)
Sets the start (default) project for the solution. Works for VS, QBS and Xcode.
Scope: solutions
Arguments
name - name of the project to set as the start project.
Examples
solution "MySolution"
startproject "MyProjectFoo"
-- [...]
project "MyProjectFoo"
-- [...]
project "MyProjectBar"
-- [...]
systemincludedirs({paths...})
Specifies the system include file search paths. Multiple calls are concatenated.
For clang/gcc, it maps to setting the include directory using the -isystem
option.
On the other build systems, it behaves like includedirs, but is always searched after directories specified using includedirs.
Scope: solutions, projects, configurations
Arguments
paths - list of system include file search directories, relative to the currently-executing script file.
Examples
Define two include file search paths
systemincludedirs { "../lua/include", "../zlib" }
You can also use wildcards to match multiple directories.
systemincludedirs { "../includes/**" }
targetdir(path)
Sets the destination directory for the compiled binary target. By default, generated project files will place their compiled output in the same directory as the script.
Scope: solutions, projects, configurations
Arguments
path - file system path to the directory where the compiled target file should be stored, relative to the currently executing script file.
Examples
project "MyProject"
configuration "Debug"
targetdir "bin/debug"
configuration "Release"
targetdir "bin/release"
targetextension(ext)
Specifies the file extension for the compiled binary target. By default, the project will use the system's normal naming conventions: ".exe" for Windows executables, ".so" for Linux shared libraries, etc.
Scope: solutions, projects, configurations
Arguments
ext - new file extension, including leading dot
Examples
targetextension ".zmf"
targetname(name)
Specifies the base file name for the compiled binary target. By default, the project name will be used as the file name of the compiled binary target.
Scope: solutions, projects, configurations
Arguments
name - new base file name
Examples
targetname "mytarget"
targetprefix(prefix)
Specifies the file name prefix for the compiled binary target. By default, system naming conventions will be used: "lib" for POSIX libraries (e.g. "libMyProject.so") and no prefix elsewhere.
Scope: solutions, projects, configurations
Arguments
prefix - new file name prefix
Examples
targetprefix "plugin"
The prefix may also be set to an empty string for no prefix
targetprefix ""
targetsubdir(path)
Sets a subdirectory inside the target directory for the compiled binary target.
Scope: solutions, projects, configurations
Arguments
path - name of the subdirectory.
targetsuffix(suffix)
Specifies a file name suffix for the compiled binary target.
Scope: solutions, projects, configurations
Arguments
suffix - new filename suffix
Examples
--- Add "-d" to debug versions of files
configuration "Debug"
targetsuffix "-d"
uuid(projectuuid)
Sets the UUID for a project. GENie automatically assigns a UUID to each project, which is used by the Visual Studio generators to identify the project within a solution. This UUID is essentially random and will change each time the project file is generated. If you are storing the generated Visual Studio project files in a version control system, this will create a lot of unnecessary deltas. Using the uuid
function, you can assign a fixed UUID to each project which never changes.
Scope: projects
Arguments
projectuuid - UUID for the current project
Return Value
Current project UUID or nil
if no UUID has been set
Examples
uuid "XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXX"
vpaths({[group] = {pattern...}})
Places files into groups for "virtual paths", rather than mirroring the filesystem. This allows you to, for instance, put all header files in a group called "Headers", no matter where they appeared in the source tree.
Note: May be set on the solution, project, or configuration, but only project-level file lists are currently supported.
Scope: solutions, projects, configurations
Arguments
Table of values, where keys (groups) are strings and values (pattern) are lists of file system patterns.
group - name for the new group
pattern - file system pattern for matching file names
Examples
Place all header files into a virtual path called "Headers". Any directory information is removed, "src/lua/lua.h" will appear in the IDE as "Headers/lua.h"
vpaths { ["Headers"] = "**.h" }
You may specify multiple file patterns using table syntax
vpaths {
["Headers"] = { "**.h", "**.hxx", "**.hpp" }
}
It is also possible to include the file's path in the virtual group. Using this rule, "src/lua/lua.h" will appear in the IDE as "Headers/src/lua/lua.h".
vpaths { ["Headers/*"] = "**.h" }
Any directory information explicitly provided in the pattern will be removed from the replacement. Using this rule, "src/lua/lua.h" will appear in the IDE as "Headers/lua/lua.h".
vpaths { ["Headers/*"] = "src/**.h" }
You can also use virtual paths to remove extra directories from the IDE. Using this rule, "src/lua/lua.h" will appear in the IDE as "lua/lua.h".
vpaths { ["*"] = "src" }
You may specify more than one rule at a time
vpaths {
["Headers"] = "**.h",
["Sources/*"] = {"**.c", "**.cpp"},
["Docs"] = "**.txt"
}
xcodeprojectopts({[key] = value, ...})
XCode only
Sets XCode project options in the generated project files. List of options.
Arguments
key - Name of the option to set value - Value to set it to
Examples
xcodeprojectopts {
ENABLE_BITCODE = "NO",
GCC_ENABLE_TRIGRAPHS = "YES",
}
xcodetargetopts({[key] = value, ...})
XCode only
Sets XCode target options in the generated project files. List of options.
Arguments
key - Name of the option to set value - Value to set it to
Examples
xcodetargetopts {
ALWAYS_SEARCH_USER_PATHS = "YES",
}
xcodescriptphases({{cmd, {inputpaths, ...}}})
XCode only
Adds a script phase to the generated XCode project file.
One tag can contain several commands with different inputpaths.
Arguments
cmd - The actual command to run. (This can be a shell script file or direct shell code).
inputpaths - The paths passed to the command
Examples
Building shader files
xcodescriptphases {
{"shaderc_xcode.sh", {
os.matchfiles("**.shader")}
},
}
Copying, trimming and signing frameworks by relying on carthage
xcodescriptphases {
{"carthage copy-frameworks", {
os.matchdirs("**.frameworks")}
},
}
Caveats
- Script phases are added in their order of declaration inside the project, and in their order of declaration inside the tag.
- The input paths are used as passed to the tag.
If relative paths are required, you have to rebase them beforehand using
path.getrelative()
. - For commands/scripts: You can iterate over the input paths using the following XCode variables:
${SCRIPT_INPUT_FILE_COUNT}
: The number of input paths provided to the script${SCRIPT_INPUT_FILE_0}
...: The input paths at index 0 and so on. NOTE: You can construct the indexed variable as in the example below:
for (( i = 0; i < ${SCRIPT_INPUT_FILE_COUNT}; ++i )); do
varname=SCRIPT_INPUT_FILE_$i
echo ${!varname}
done
xcodecopyresources({{targetpath, {inputfiles, ...}}})
XCode only
Adds a 'Copy Files' phase to the generated XCode project file.
One tag can contain several target paths with different input files.
Arguments
targetpath - The target path relative to the Resource folder in the resulting .app
structure.
inputfiles - The input files to be copied.
Examples
xcodecopyresources {
{ ".", {
"GameResources", -- a folder
}},
{ "shaders", {
os.matchfiles("**.shader"), -- sparse files
}},
}
Caveats
- The target path is only handled as relative to the Resource folder. No other folder can be indicated at the moment. If you need support for other targets, please file an issue on Github.
xcodecopyresources
can only be set per project, not per configuration.
xcodecopyframeworks({inputframeworks, ...})
XCode only
Adds a 'Copy Files' phase to the generated XCode project file that will copy and sign the provided frameworks.
Arguments
inputframeworks - A list of frameworks to be copied to the .app
structure, with the SignOnCopy
flag set.
Examples
links { -- frameworks have to be linked with the .app first
"GTLR.framework",
"BGFX.framework",
}
xcodecopyframeworks {
"GTLR.framework",
"BGFX.framework",
}
Caveats
- Frameworks must be known to the project to be copyable: set the link dependency accordingly using
links {}
. xcodecopyframeworks
can only be set per project, not per configuration.
wholearchive({references...})
Specifies a list of libraries to link without stripping unreferenced object files. The libraries must have already been added using links
, and the same identifier must be specified.
Scope: solutions, projects, configurations
Arguments
references - list of library and project names
Examples
project "static_lib"
kind "StaticLib"
project "console_app"
kind "ConsoleApp"
links { "static_lib" }
wholearchive { "static_lib" }
References
Utility functions
iif(condition, trueval, falseval)
Implements an immediate if
clause, returning one of two possible values.
Arguments
condition - logical condition to test
trueval - value to return if condition evaluates to true
falseval - value to return if condition evaluates to false
Examples
result = iif(os.is("windows"), "is windows", "is not windows")
Note that all expressions are evaluated before the condition is checked. The following expression cannot be implemented with an iif
because it may try to concatenate a string value.
result = iif(x -= nil, "x is " .. x, "x is nil")
os.chdir(path)
Changes the working directory
Arguments
path - path to the new working directory
Return Value
true
if successful, otherwise nil
and an error message
os.copyfile(source, destination)
Copies a file from one location to another.
Arguments
source - file system path to the file to be copied destination - path to the copy location
Return Value
true
if successful, otherwise nil
and an error message
os.findlib(libname)
Scans the well-known system locations looking for a binary file.
Arguments
libname - name of the library to locate. May be specified with (libX11.so) or without (X11) system-specified decorations.
Return Value
The path containing the library file, if found. Otherwise, nil
.
os.get()
Identifies the currently-targeted operating system.
Return Value
One of "bsd", "linux", "macosx", "solaris", or "windows"
Note: This function returns the OS being targeted, which is not necessarily the same as the OS on which GENie is being run.
Example
if os.get() == "windows" then
-- do something windows-specific
end
os.getcwd()
Gets the current working directory.
Return Value
The current working directory
os.getversion()
Retrieves version information for the host operating system
Note: Not implemented for all platforms. On unimplemented platforms, will return 0
for all version numbers, and the platform name as the description.
Return Value
Table containing the following key-value pairs:
Key | Value |
---|---|
majorversion | major version number |
minorversion | minor version number |
revision | bug fix release or service pack number |
description | human-readable description of the OS version |
Examples
local ver = os.getversion()
print(string.format(" %d.%d.%d (%s)",
ver.majorversion, ver.minorversion, ver.revision,
ver.description))
-- On Windows XP: "5.1.3 (Windows XP)"
-- On OSX: "10.6.6 (Mac OS X Snow Leopard)"
os.is(id)
Checks the current operating system identifier against a particular value
Arguments
id - one of "bsd", "linux", "macosx", "solaris", or "windows"
Note: This function returns the OS being targeted, which is not necessarily the same as the OS on which GENie is being run.
Return Value
true
if the supplied id matches the current operating system identifier, false
otherwise.
os.is64bit()
Determines if the host is using a 64-bit processor.
Return Value
true
if the host system has a 64-bit processor
false
otherwise
Examples
if os.is64bit() then
print("This is a 64-bit system")
else
print("This is NOT a 64-bit system")
end
os.isdir(path)
Checks for the existence of a directory.
Arguments
path - the file system path to check
Return Value
true
if a matching directory is found
false
if there is no such file system path, or if the path points to a file
os.isfile(path)
Checks for the existence of a file.
Arguments
path - the file system path to check
Return Value
true
if a matching file is found
false
if there is no such file system path or if the path points to a directory instead of a file
os.matchdirs(pattern)
Performs a wildcard match to locate one or more directories.
Arguments
pattern - file system path to search. May wildcard patterns.
Return Value
List of directories which match the specified pattern. May be empty.
Examples
matches = os.matchdirs("src/*") -- non-recursive match
matches = os.matchdirs("src/**") -- recursive match
matches = os.matchdirs("src/test*") -- may also match partial name
os.matchfiles(patterns)
Performs a wildcard match to locate one or more directories.
Arguments
pattern - file system path to search. May contain wildcard patterns.
Return Value
List of files which match the specified pattern. May be empty.
Examples
matches = os.matchfiles("src/*.c") -- non-recursive match
matches = os.matchfiles("src/**.c") -- recursive match
os.mkdir(path)
Creates a new directory.
Arguments
path - path to be created
Return Value
true
if successful
nil
and an error message otherwise
os.outputof(command)
Runs a shell command and returns the output.
Arguments
command - shell command to run
Return Value
The output of the command
Examples
-- Get the ID for the host processor architecture
local proc = os.outputof("uname -p")
os.pathsearch(fname, paths...)
description
Scope: solutions, projects, configurations
Arguments
fname - name of the file being searched, followed by one or more path sets to be searched
paths - the match format of the PATH environment variable: a colon-delimited list of path. On Windows, you may use a semicolon-delimited list if drive letters might be included
Return Value
Path to the directory which contains the file, if found
nil
otherwise
Examples
local p = os.pathsearch("mysystem.config", "./config:/usr/local/etc:/etc")
os.rmdir(path)
Removes an existing directory as well as any files or subdirectories it contains.
Arguments
path - file system path to be removed
Return Value
true
if successful
nil
and an error message otherwise
os.stat(path)
Retrieves information about a file.
Arguments
path - path to file for which to retrieve information
Return Value
Table of values:
Key | Value |
---|---|
mtime | Last modified timestamp |
size | File size in bytes |
userincludedirs({paths...})
Specifies the user include file search paths. Multiple calls are concatenated.
For XCode, it maps to setting the USER INCLUDE SEARCH PATH.
For clang/gcc, it maps to setting the include directory using the iquote option.
On the other build systems, it behaves like includedirs.
Scope: solutions, projects, configurations
Arguments
paths - list of user include file search directories, relative to the currently-executing script file.
Examples
Define two include file search paths
userincludedirs { "../lua/include", "../zlib" }
You can also use wildcards to match multiple directories.
userincludedirs { "../includes/**" }
os.uuid(name)
Returns a Universally Unique Identifier
Arguments
name - (optional) string to be hashed
Return Value
A new UUID, a string value with the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
, generated from name if it is provided, otherwise generated from random data
path.getabsolute(path)
Converts relative path to absolute path
Arguments
path - the relative path to be converted
Return Value
New absolute path, calculated from the current working directory
path.getbasename(path)
Extracts base file portion of a path, with the directory and extension removed.
Arguments
path - path to be split
Return Value
Base name portion of the path
path.getdirectory(path)
Extracts directory portion of a path, with file name removed
Arguments
path - path to be split
Return Value
Directory portion of the path
path.getdrive(path)
Returns drive letter portion of a path
Arguments
path - path to be split
Return Value
Drive letter portion of the path, or nil
path.getextension(path)
Returns file extension portion of a path
Arguments
path - path to be split
Return Value
File extension portion of the path, or an empty string
path.getname(path)
Returns file name and extension, removes directory information.
Arguments
path - path to be split
Return Value
File name and extension without directory information
path.getrelative(src, dest)
Computes relative path from one directory to another.
Arguments
src - originating directory
dest - target directory
Return Value
Relative path from src to dest
path.isabsolute(path)
Returns whether or not a path is absolute.
Arguments
path - path to check
Return Value
true
if path is absolute
false
otherwise
path.iscfile(path)
Determines whether file is a C source code file, based on extension.
Arguments
path - path to check
Return Value
true
if path uses a C file extension
false
otherwise
path.isSourceFile(path)
Determines whether a file is a C++ source code file, based on extension.
Arguments
path - path to check
Return Value
true
if path uses a C++ file extension
false
otherwise
path.isresourcefile(path)
Determines whether a path represends a Windows resource file, based on extension.
Arguments
path - path to check
Return Value
true
if path uses a well-known Windows resource file extension
false
otherwise
path.join(leading, trailing)
Joins two path portions together into a single path.
Note: if trailing is an absolute path, then leading is ignored and the absolute path is returned.
Arguments
leading - beginning portion of the path
trailing - ending portion of the path
Return Value
Merged path
Examples
-- returns "MySolution/MyProject"
p = path.join("MySolution", "MyProject")
-- returns "/usr/bin", because the trailing path is absolute
p = path.join("MySolution", "/usr/bin")
-- tokens are assumed to be absolute. This returns `${ProjectDir}`
p = path.join("MySolution", "$(ProjectDir)")
path.rebase(path, oldbase, newbase)
Takes a relative path and makes it relative to a different location.
Arguments
path - path to be modified
oldbase - original base directory, from which path is relative
newbase - the new base directory, from where the resulting path should be relative
Return Value
Rebased path
path.translate(path, newsep)
Converts the separators in a path.
Arguments
path - path to modify
newsep - new path separator. Defaults to current environment default.
Return Value
Modified path
Back to top
printf(format, args...)
Prints a formatted string
Arguments
format - formatting string, containing C printf()
formatting codes
args - arguments to be substituted into the format string
string.endswith(haystack, needle)
Checks if the given haystack string ends with needle.
Arguments
haystack - string to search within
needle - string to check ending of haystack against
Return Value
true
- haystack ends with needle
false
- haystack does not end with needle
string.explode(str, pattern)
Breaks a string into an array of strings, formed by splitting str on pattern.
Arguments
str - string to be split
pattern - separator pattern at which to split; may use Lua's pattern matching syntax
Return Value
List of substrings
string.findlast(str, pattern, plain)
Finds the last instance of a pattern within a string.
Arguments
str - string to be searched
pattern - pattern to search for; may use Lua's pattern matching syntax
plain - whether or not plain string comparison should be used (rather than pattern-matching)
Return Value
The matching pattern, if found, or nil
string.startswith(haystack, needle)
Checks if the given haystack starts with needle.
Arguments
haystack - string to search within
needle - string to check start of haystack against
Return Value
true
- haystack starts with needle
false
- haystack does not start with needle
table.contains(array, value)
Determines if a array contains value.
Arguments
array - table to test for value
value - value being tested for
Return Value
true
- array contains value
false
- array does not contain value
table.implode(array, before, after, between)
Merges an array of items into a single formatted string.
Arguments
array - table to be converted into a string
before - string to be inserted before each item
after - string to be inserted after each item
between - string to be inserted between each item
Return Value
Formatted string
Additional information
Wildcards
In some places, wildcards may be used in string values passed to a function. Usually, these strings represent paths. There are two types of wildcards:
*
- matches files within a single directory**
- matches files recursively in any child directory