Each of the following variables is available for use in any GENie script.
Name of the action to be performed on this execution run.
$ genie vs2005
produces
_ACTION: "vs2005"
Any arguments to the current action.
$ genie vs2015 alpha beta
produces
_ARGS[0]: "alpha"
_ARGS[1]: "beta"
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.
Full path to the GENie (Premake) executable.
GENie (Premake) version.
Full path to the currently executing script.
Current working directory.
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++.
action - the action to be performed. One of:
Embed all PNGs into the target binary
configuration "**.png"
buildaction "Embed"
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 filesoptions - list of compiler flags
Add some GCC-specific options
configuration {"linux", "gmake"}
buildoptions {"-ansi", "-pedantic"}
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.
keywords - list of identifiers to compare to the current runtime environment
Possible values:
You may also use "*" and "**" wildcards, as well as "not" and "or".
Current configuration object with the following fields:
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 {}
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 an AND
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 as
not
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.
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
names - list of configuration names
When called with no arguments - list of current configuration names
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()
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
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
custombuildtask {
{ ROOT_DIR .. "version.txt" , GEN_DIR .. "src/version.inc", { ROOT_DIR .. "version.py" }, {"@echo Generating version.inc file...", "python $(1) $(<) > $(@)" }},
}
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
cmd - the command to execute when starting with the debugger
configuration 'TestConfig'
debugcmd 'D:\\Apps\\Test.exe'
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
args - list of arguments to pass to the executable while debugging
configuration "Debug"
debugargs { "--append", "somefile.txt" }
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
path - path to the working directory, relative to the currently-executing script file
configuration "Debug"
debugdir "bin/debug"
Adds preprocessor or compiler symbols to the project. Multiple calls are concatenated.
Scope: solutions, projects, configurations
symbols - list of symbols
Define two new symbols
defines { "DEBUG", "TRACE" }
Assign a symbol value
defines { "CALLSPEC=__dllexport" }
GMAKE specific. Adds dependency between source file and any other file.
Scope: solutions, projects, configurations
main_file - name of source file that depends of other file
depending_of - name of dependency file
dependency { { ROOT_DIR .. "src/test.c", ROOT_DIR .. "verion.txt" } }
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
options - list of arguments
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
files - List of files to exclude. Paths should be relative to the currently-executing script file and may contain wildcards.
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" }
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
files - List of files to include. Paths should be relative to the currently-executing script file and may contain wildcards.
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" }
Specifies build flags to modify the compiling or linking process. Multiple calls are concatenated.
Scope: solutions, projects, configurations
flags - List of flag names from list below. Names are case-insensitive and ignored if not supported on a platform.
Project Properties > Debugging > Merge Environment
to false
)Project Properties > Debugging > Environment > Edit > Inherit from parent of project defaults
to true
)DeploymentContent
flag in the project file. (For C++ Win Store apps) (#139)char
s to be unsigned
by default.__FILE__
.Note: When not set, options will default to the tool default.
Additional tool-specific arguments can be passed with buildoptions
or linkoptions
Enable debugging symbols in the Debug configuration and optimize the Release configuration
configuration "Debug"
flags { "Symbols" }
configuration "Release"
flags { "OptimizeSpeed", "No64BitChecks" }
Specifies a .NET framework version.
Note: Currently only applied to Visual Studio 2005+ and GNU Makefiles using Mono.
Scope: solutions, projects
version - one of the following:
Use the .NET 3.0 framework
framework "3.0"
Creates a solution folder for Visual Studio solutions.
Scope: solutions
name - the name of the solution folder
solution "MySolution"
group "MyGroup1"
project "Project1"
-- ...
project "Project2"
-- ...
group "MyGroup2"
project "Project3"
-- ...
Passes arguments directly to the image tool command line without translation. Multiple calls are concatenated.
Scope: solutions, project, configurations
options - list of image tools flags and options
Sets the file name of the deployment image produced by the build
Scope: solutions, projects, configurations
path - the full path for the image file, relative to the currently-executing script
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
path - the output directory for the library, relative to the currently-executing script file
implibdir "../Libraries"
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
extension - the extension, including the leading dot
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
name - new base file name
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
prefix - new file name prefix
implibprefix "plugin"
The prefix may also be set to an empty string for no prefix
implibprefix ""
Specifies the file name suffix for the import library base file name. Import libraries are generated for Windows DLL projects.
Scope: solutions, projects, configurations
suffix - the new filename suffix
-- Add "-d" to debug versions of files
configuration "Debug"
implibsuffix "-d"
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.
directory - path to the included directory, relative to the currently-executing script file.
Any values returned by the script are passed through to the caller
-- runs "src/MyApplication/premake4.lua"
include "src/MyApplication"
-- runs "src/MyLibrary/premake4.lua"
include "src/MyLibrary"
Specifies include file search paths. Multiple calls are concatenated.
Scope: solutions, projects, configurations
paths - list of include file search directories, relative to the currently-executing script file.
Define two include file search paths
includedirs { "../lua/include", "../zlib" }
You can also use wildcards to match multiple directories.
includedirs { "../includes/**" }
Sets the kind of binary object being created by the project, such as a console or windowed application.
Scope: solutions, projects, configurations
kind - project kind identifier. One of:
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"
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
lang - language identifier string ("C", "C++", "C#" or "Vala"). Case insensitive.
language "C++"
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
paths - list of library search directories, relative to the currently-executing script file
libdirs { "../lua/libs", "../zlib" }
You can also use wildcards to match multiple directories.
libdirs { "../libs/**" }
Passes arguments to the linker command line. Multiple calls are concatenated.
Scope: solutions, projects, configurations
options - list of flags and options to pass
Use pkg-config
-style configuration when building on Linux with GCC.
configuration { "linux", "gmake" }
linkoptions { "`wx-config --libs`"}
Specifies a list of libraries and projects to link against. Multiple calls are concatenated.
Scope: solutions, projects, configurations
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.
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"
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
path - directory into which files should be generated, relative to the currently-executing script file.
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)
Skips certain messages in ninja and Makefile generated projects.
Scope: solutions
options - one or several of "SkipCreatingMessage", "SkipBuildingMessage", "SkipCleaningMessage"
messageskip { "SkipCreatingMessage", "SkipBuildingMessage", "SkipCleaningMessage" }
Registers a new command-line action argument.
description - a table describing the new action with the following fields:
newaction {
trigger = "install",
description = "Install the software",
execute = function()
os.copyfile("bin/debug/myprogram", "/usr/local/bin/myprogram")
end
}
Registers a new command-line option argument.
Scope: solutions, projects, configurations
description - a table describing the new option with the following fields:
newoption {
trigger = "gfxapi",
value = "API",
description = "Choose a particular 3D API for rendering",
allowed = {
{ "opengl", "OpenGL" },
{ "direct3d", "Direct3D (Windows only)"},
{ "software", "Software Renderer" }
}
}
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
files - List of files to not use the precompiled header. Paths should be relative to the currently-executing script file and may contain wildcards.
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" }
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
path - directory where the object and intermediate files should be stored, relative to the currently-executing script file.
project "MyProject"
objdir "objects"
Set object directories per configuration
configuration "Debug"
objdir "../obj_debug"
configuration "Release"
objdir "../obj_release"
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
options - List of option names from list below. Names are case-insensitive and ignored if not supported on a platform.
Sets the main header file for precompiled header support.
Scope: projects
file - name of the header file, as it is specified in your #include
statements
pchheader "afxwin.h"
pchsource "afxwin.cpp"
Sets the main source file for precompiled header support. Only used by Visual Studio.
Scope: projects
file - name of the source file, relative to the currently-executing script file
pchheader "afxwin.h"
pchsource "afxwin.cpp"
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
identifiers - list of hardware platform specifiers from this list:
Current list of target platforms for the active solution
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"
Specifies shell commands to run after build is finished
Scope: solutions, projects, configurations
commands - one or more shell commands
configuration "windows"
postbuildcommands { "copy default.config bin\\project.config" }
configuration "not windows"
postbuildcommands { "cp default.config bin/project.config" }
Specifies shell commands to run after compile of file is finished (GMAKE specific)
Scope: solutions, projects, configurations
commands - one or more shell commands
postcompiletasks { "rm $(@:%.o=%.d)" }
Specifies shell commands to run before each build
Scope: solutions, projects, configurations
commands - one or more shell commands
configuration "windows"
prebuildcommands { "copy default.config bin\\project.config" }
configuration "not windows"
prebuildcommands { "cp default.config bin/project.config" }
Specifies shell commands to run after source files have been compiled, but before the link step
Scope: solutions, projects, configurations
commands - one or more shell commands
configuration "windows"
prelinkcommands { "copy default.config bin\\project.config" }
configuration "not windows"
prelinkcommands { "cp default.config bin/project.config" }
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.
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.
The active project object.
project
ObjectEvery 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.
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
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
files - list of files to remove.
Removes flags from the flag list.
Scope: solutions, projects, configurations
flags - list of flags to remove from the flag list. They must be valid flags.
Removes flags from the flag list.
Scope: solutions, projects, configurations
references - list of libraries and project names to remove from the links list.
Removes platforms from the platform list.
Scope: solutions, projects, configurations
platforms - list of platforms to remove from the platforms list.
Specifies preprocessor symbols for the resource compiler. Multiple calls are concatenated.
Scope: solutions, projects, configurations
symbols - list of symbols to be defined
resdefines { "DEBUG", "TRACE" }
resdefines { "CALLSPEC=__dllexport" }
Specifies the include file search paths for the resource compiler. Multiple calls are concatenated.
Scope: solutions, projects, configurations
paths - list of include file search directories, relative to the currently executing script file
resincludedirs { "../lua/include", "../zlib" }
May use wildcards
resincludedirs { "../includes/**" }
Passes arguments directly to the resource compiler. Multiple calls are concatenated.
Scope: solutions, projects, configurations
options - list of resource compiler flags and options
configuration { "linux", "gmake" }
resoptions { "`wx-config --cxxflags`", "-ansi", "-pedantic" }
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.
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.
The active solution
object.
solution
ObjectRepresented 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.
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
Sets the start (default) project for the solution. Works for VS, QBS and Xcode.
Scope: solutions
name - name of the project to set as the start project.
solution "MySolution"
startproject "MyProjectFoo"
-- [...]
project "MyProjectFoo"
-- [...]
project "MyProjectBar"
-- [...]
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
paths - list of system include file search directories, relative to the currently-executing script file.
Define two include file search paths
systemincludedirs { "../lua/include", "../zlib" }
You can also use wildcards to match multiple directories.
systemincludedirs { "../includes/**" }
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
path - file system path to the directory where the compiled target file should be stored, relative to the currently executing script file.
project "MyProject"
configuration "Debug"
targetdir "bin/debug"
configuration "Release"
targetdir "bin/release"
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
ext - new file extension, including leading dot
targetextension ".zmf"
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
name - new base file name
targetname "mytarget"
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
prefix - new file name prefix
targetprefix "plugin"
The prefix may also be set to an empty string for no prefix
targetprefix ""
Sets a subdirectory inside the target directory for the compiled binary target.
Scope: solutions, projects, configurations
path - name of the subdirectory.
Specifies a file name suffix for the compiled binary target.
Scope: solutions, projects, configurations
suffix - new filename suffix
--- Add "-d" to debug versions of files
configuration "Debug"
targetsuffix "-d"
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
projectuuid - UUID for the current project
Current project UUID or nil
if no UUID has been set
uuid "XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXX"
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
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
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"
}
Sets XCode project options in the generated project files. List of options.
key - Name of the option to set value - Value to set it to
xcodeprojectopts {
ENABLE_BITCODE = "NO",
GCC_ENABLE_TRIGRAPHS = "YES",
}
Sets XCode target options in the generated project files. List of options.
key - Name of the option to set value - Value to set it to
xcodetargetopts {
ALWAYS_SEARCH_USER_PATHS = "YES",
}
Adds a script phase to the generated XCode project file.
One tag can contain several commands with different inputpaths.
cmd - The actual command to run. (This can be a shell script file or direct shell code).
inputpaths - The paths passed to the command
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")}
},
}
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
Adds a 'Copy Files' phase to the generated XCode project file.
One tag can contain several target paths with different input files.
targetpath - The target path relative to the Resource folder in the resulting .app
structure.
inputfiles - The input files to be copied.
xcodecopyresources {
{ ".", {
"GameResources", -- a folder
}},
{ "shaders", {
os.matchfiles("**.shader"), -- sparse files
}},
}
xcodecopyresources
can only be set per project, not per configuration.Adds a 'Copy Files' phase to the generated XCode project file that will copy and sign the provided frameworks.
inputframeworks - A list of frameworks to be copied to the .app
structure, with the SignOnCopy
flag set.
links { -- frameworks have to be linked with the .app first
"GTLR.framework",
"BGFX.framework",
}
xcodecopyframeworks {
"GTLR.framework",
"BGFX.framework",
}
links {}
.xcodecopyframeworks
can only be set per project, not per configuration.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
references - list of library and project names
project "static_lib"
kind "StaticLib"
project "console_app"
kind "ConsoleApp"
links { "static_lib" }
wholearchive { "static_lib" }
Implements an immediate if
clause, returning one of two possible values.
condition - logical condition to test
trueval - value to return if condition evaluates to true
falseval - value to return if condition evaluates to false
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")
Changes the working directory
path - path to the new working directory
true
if successful, otherwise nil
and an error message
Copies a file from one location to another.
source - file system path to the file to be copied destination - path to the copy location
true
if successful, otherwise nil
and an error message
Scans the well-known system locations looking for a binary file.
libname - name of the library to locate. May be specified with (libX11.so) or without (X11) system-specified decorations.
The path containing the library file, if found. Otherwise, nil
.
Identifies the currently-targeted operating system.
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.
if os.get() == "windows" then
-- do something windows-specific
end
Gets the current working directory.
The current working directory
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.
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 |
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)"
Checks the current operating system identifier against a particular value
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.
true
if the supplied id matches the current operating system identifier, false
otherwise.
Determines if the host is using a 64-bit processor.
true
if the host system has a 64-bit processor
false
otherwise
if os.is64bit() then
print("This is a 64-bit system")
else
print("This is NOT a 64-bit system")
end
Checks for the existence of a directory.
path - the file system path to check
true
if a matching directory is found
false
if there is no such file system path, or if the path points to a file
Checks for the existence of a file.
path - the file system path to check
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
Performs a wildcard match to locate one or more directories.
pattern - file system path to search. May wildcard patterns.
List of directories which match the specified pattern. May be empty.
matches = os.matchdirs("src/*") -- non-recursive match
matches = os.matchdirs("src/**") -- recursive match
matches = os.matchdirs("src/test*") -- may also match partial name
Performs a wildcard match to locate one or more directories.
pattern - file system path to search. May contain wildcard patterns.
List of files which match the specified pattern. May be empty.
matches = os.matchfiles("src/*.c") -- non-recursive match
matches = os.matchfiles("src/**.c") -- recursive match
Creates a new directory.
path - path to be created
true
if successful
nil
and an error message otherwise
Runs a shell command and returns the output.
command - shell command to run
The output of the command
-- Get the ID for the host processor architecture
local proc = os.outputof("uname -p")
description
Scope: solutions, projects, configurations
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
Path to the directory which contains the file, if found
nil
otherwise
local p = os.pathsearch("mysystem.config", "./config:/usr/local/etc:/etc")
Removes an existing directory as well as any files or subdirectories it contains.
path - file system path to be removed
true
if successful
nil
and an error message otherwise
Retrieves information about a file.
path - path to file for which to retrieve information
Table of values:
Key | Value |
---|---|
mtime | Last modified timestamp |
size | File size in bytes |
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
paths - list of user include file search directories, relative to the currently-executing script file.
Define two include file search paths
userincludedirs { "../lua/include", "../zlib" }
You can also use wildcards to match multiple directories.
userincludedirs { "../includes/**" }
Returns a Universally Unique Identifier
name - (optional) string to be hashed
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
Converts relative path to absolute path
path - the relative path to be converted
New absolute path, calculated from the current working directory
Extracts base file portion of a path, with the directory and extension removed.
path - path to be split
Base name portion of the path
Extracts directory portion of a path, with file name removed
path - path to be split
Directory portion of the path
Returns drive letter portion of a path
path - path to be split
Drive letter portion of the path, or nil
Returns file extension portion of a path
path - path to be split
File extension portion of the path, or an empty string
Returns file name and extension, removes directory information.
path - path to be split
File name and extension without directory information
Computes relative path from one directory to another.
src - originating directory
dest - target directory
Relative path from src to dest
Returns whether or not a path is absolute.
path - path to check
true
if path is absolute
false
otherwise
Determines whether file is a C source code file, based on extension.
path - path to check
true
if path uses a C file extension
false
otherwise
Determines whether a file is a C++ source code file, based on extension.
path - path to check
true
if path uses a C++ file extension
false
otherwise
Determines whether a path represends a Windows resource file, based on extension.
path - path to check
true
if path uses a well-known Windows resource file extension
false
otherwise
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.
leading - beginning portion of the path
trailing - ending portion of the path
Merged path
-- 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)")
Takes a relative path and makes it relative to a different location.
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
Rebased path
Converts the separators in a path.
path - path to modify
newsep - new path separator. Defaults to current environment default.
Modified path
Prints a formatted string
format - formatting string, containing C printf()
formatting codes
args - arguments to be substituted into the format string
Checks if the given haystack string ends with needle.
haystack - string to search within
needle - string to check ending of haystack against
true
- haystack ends with needle
false
- haystack does not end with needle
Breaks a string into an array of strings, formed by splitting str on pattern.
str - string to be split
pattern - separator pattern at which to split; may use Lua's pattern matching syntax
List of substrings
Finds the last instance of a pattern within a string.
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)
The matching pattern, if found, or nil
Checks if the given haystack starts with needle.
haystack - string to search within
needle - string to check start of haystack against
true
- haystack starts with needle
false
- haystack does not start with needle
Determines if a array contains value.
array - table to test for value
value - value being tested for
true
- array contains value
false
- array does not contain value
Merges an array of items into a single formatted string.
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
Formatted string
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