1# Scripting Reference 2 3## Table of Contents 4 5* Predefined variables 6 * [_ACTION](#_action) 7 * [_ARGS](#_args) 8 * [_OPTIONS](#_options) 9 * [_PREMAKE_COMMAND](#_premake_command) 10 * [_PREMAKE_VERSION](#_premake_version) 11 * [_SCRIPT](#_script) 12 * [_WORKING_DIR](#_working_dir) 13* Build script functions 14 * [buildaction](#buildactionaction) 15 * [buildoptions](#buildoptionsoptions) 16 * [configuration](#configurationkeywords) 17 * [configurations](#configurationsnames) 18 * [custombuildtask](#custombuildtasktask) 19 * [debugcmd](#debugcmdcmd) 20 * [debugargs](#debugargsargs) 21 * [debugdir](#debugdirpath) 22 * [defines](#definessymbols) 23 * [dependency](#dependencyfiles) 24 * [deploymentoptions](#deploymentoptionsoptions) 25 * [excludes](#excludesfiles) 26 * [files](#filesfiles) 27 * [flags](#flagsflags) 28 * [framework](#frameworkversion) 29 * [group](#groupname) 30 * [imageoptions](#imageoptionsoptions) 31 * [imagepath](#imagepathpath) 32 * [implibdir](#implibdir) 33 * [implibextension](#implibextensionextension) 34 * [implibname](#implibnamename) 35 * [implibprefix](#implibprefixprefix) 36 * [implibsuffix](#implibsuffixsuffix) 37 * [include](#includedirectory) 38 * [includedirs](#includedirspaths) 39 * [kind](#kindkind) 40 * [language](#languagelang) 41 * [libdirs](#libdirspaths) 42 * [linkoptions](#linkoptionsoptions) 43 * [links](#linksreferences) 44 * [location](#locationpath) 45 * [messageskip](#messageskipoptions) 46 * [newaction](#newactiondescription) 47 * [newoption](#newoptionsdescription) 48 * [nopch](#nopch) 49 * [objdir](#objdirpath) 50 * [options](#optionsoptions) 51 * [pchheader](#pchheaderfile) 52 * [pchsource](#pchsourcefile) 53 * [platforms](#platformsidentifiers) 54 * [postbuildcommands](#postbuildcommandscommands) 55 * [postcompiletasks](#postcompiletaskstasks) 56 * [prebuildcommands](#prebuildcommandscommands) 57 * [prelinkcommands](#prelinkcommandscommands) 58 * [project](#projectname) 59 * [removefiles](#removefilesfiles) 60 * [removeflags](#removeflagsflags) 61 * [removelinks](#removelinkslinks) 62 * [removeplatforms](#removeplatformsplatforms) 63 * [resdefines](#resdefinessymbols) 64 * [resincludedirs](#resincludedirspaths) 65 * [resoptions](#resoptionsoptions) 66 * [solution](#solutionname) 67 * [startproject](#startprojectname) 68 * [systemincludedirs](#systemincludedirspaths) 69 * [targetdir](#targetdirpath) 70 * [targetextension](#targetextensionext) 71 * [targetname](#targetnamename) 72 * [targetprefix](#targetprefixprefix) 73 * [targetsubdir](#targetsubdirpath) 74 * [targetsuffix](#targetsuffixsuffix) 75 * [userincludedirs](#userincludedirspaths) 76 * [uuid](#uuidprojectuuid) 77 * [vpaths](#vpathsgroup--pattern) 78 * [xcodeprojectopts](#xcodeprojectoptskey--value-) 79 * [xcodetargetopts](#xcodetargetoptskey--value-) 80 * [xcodescriptphases](#xcodescriptphasescmd-inputpaths-) 81 * [xcodecopyresources](#xcodecopyresourcestargetpath-inputfiles-) 82 * [xcodecopyframeworks](#xcodecopyframeworksinputframeworks-) 83 * [wholearchive](#wholearchivereferences) 84* Utility functions 85 * [iif](#iifcondition-trueval-falseval) 86 * [os.chdir](#oschdirpath) 87 * [os.copyfile](#oscopyfilesource-destination) 88 * [os.findlib](#osfindliblibname) 89 * [os.get](#osget) 90 * [os.getcwd](#osgetcwd) 91 * [os.getversion](#osgetversion) 92 * [os.is](#osisid) 93 * [os.is64bit](#osis64bit) 94 * [os.isdir](#osisdirpath) 95 * [os.isfile](#osisfilepath) 96 * [os.matchdirs](#osmatchdirspattern) 97 * [os.matchfiles](#osmatchfilespatterns) 98 * [os.mkdir](#osmkdirpath) 99 * [os.outputof](#osoutputofcommand) 100 * [os.pathsearch](#ospathsearchfname-paths) 101 * [os.rmdir](#osrmdirpath) 102 * [os.stat](#osstatpath) 103 * [os.uuid](#osuuidname) 104 * [path.getabsolute](#pathgetabsolutepath) 105 * [path.getbasename](#pathgetbasenamepath) 106 * [path.getdirectory](#pathgetdirectorypath) 107 * [path.getdrive](#pathgetdrivepath) 108 * [path.getextension](#pathgetextension) 109 * [path.getname](#pathgetnamepath) 110 * [path.getrelative](#pathgetrelativesrc-dest) 111 * [path.isabsolute](#pathisabsolutepath) 112 * [path.iscfile](#pathiscfilepath) 113 * [path.isSourceFile](#pathiscppfilepath) 114 * [path.isresourcefile](#pathisresourcefilepath) 115 * [path.join](#pathjoinleading-trailing) 116 * [path.rebase](#pathrebasepath-oldbase-newbase) 117 * [path.translate](#pathtranslatepath-newsep) 118 * [printf](#printfformat-args) 119 * [string.endswith](#stringendswithhaystack-needle) 120 * [string.explode](#stringexplodestr-pattern) 121 * [string.findlast](#stringfindlaststr-pattern-plain) 122 * [string.startswith](#stringstartswithhaystack-needle) 123 * [table.contains](#tablecontainsarray-value) 124 * [table.implode](#tableimplodearray-before-after-between) 125* Additional information 126 * [Wildcards](#wildcards) 127 128--- 129 130## Predefined Variables 131 132Each of the following variables is available for use in any GENie script. 133 134### _ACTION 135 136Name of the action to be performed on this execution run. 137 138`$ genie vs2005` 139 140produces 141 142`_ACTION: "vs2005"` 143 144[Back to top](#table-of-contents) 145 146--- 147### _ARGS 148 149Any arguments to the current action. 150 151`$ genie vs2015 alpha beta` 152 153produces 154 155`_ARGS[0]: "alpha"` 156`_ARGS[1]: "beta"` 157 158[Back to top](#table-of-contents) 159 160--- 161### _OPTIONS 162 163Current set of command line options and their values, if any. 164 165`$ genie vs2015 --gfxapi=directx` 166 167produces 168 169`_OPTIONS['gfxapi']: "directx"` 170 171**Note:** Options may be registered with [newoption](#newoption) to fully integrate them into the CLI. 172 173[Back to top](#table-of-contents) 174 175--- 176### _PREMAKE_COMMAND 177 178Full path to the GENie (Premake) executable. 179 180[Back to top](#table-of-contents) 181 182--- 183### _PREMAKE_VERSION 184 185GENie (Premake) version. 186 187[Back to top](#table-of-contents) 188 189--- 190### _SCRIPT 191 192Full path to the currently executing script. 193 194[Back to top](#table-of-contents) 195 196--- 197### _WORKING_DIR 198 199Current working directory. 200 201[Back to top](#table-of-contents) 202 203--- 204 205## Build script functions 206 207### buildaction(_action_) 208Specifies 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). 209 210**Scope:** solutions, projects, configurations 211 212**Note:** only supported for .NET projects, and not for C or C++. 213 214#### Arguments 215_action_ - the action to be performed. One of: 216 217* "Compile" - treat the file as source code: compile and run it 218* "Embed" - embed the file into the target binary as a resource 219* "Copy" - copy the file to the target directory 220* "None" - do nothing with this file 221 222#### Examples 223Embed all PNGs into the target binary 224 225```lua 226configuration "**.png" 227 buildaction "Embed" 228``` 229 230[Back to top](#table-of-contents) 231 232--- 233### buildoptions({_options_...}) 234Passes arguments direction to the compiler command line. Multiple calls in a project will be concatenated in order. 235 236**Scope:** solutions, projects, configurations 237 238You may also use one of these functions to configure buildoptions for each individual file extension: 239 240* `buildoptions_asm` for .asm files 241* `buildoptions_c` for .c files 242* `buildoptions_cpp` for .cpp files 243* `buildoptions_objc` for .m files 244* `buildoptions_objcpp` for .mm files 245* `buildoptions_swift` for .swift files 246* `buildoptions_vala` for .vala files 247 248#### Arguments 249_options_ - list of compiler flags 250 251#### Examples 252Add some GCC-specific options 253 254```lua 255configuration {"linux", "gmake"} 256 buildoptions {"-ansi", "-pedantic"} 257``` 258 259[Back to top](#table-of-contents) 260 261--- 262### configuration({_keywords_...}) 263Limits 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. 264 265#### Arguments 266_keywords_ - list of identifiers to compare to the current runtime environment 267 268Possible values: 269 270* Configuration names - configuration names passed to [configurations](#configurations) 271* Action names - "vs2015", "gmake", etc. 272* Operating system names - "windows", "macosx", etc. 273* Platform names - "ps3", "xbox360", etc. 274* Command-line options - either built-in or custom 275* File names - very limited, but some settings can be applied to specific files 276 277You may also use "*" and "**" wildcards, as well as "not" and "or". 278 279#### Return 280Current configuration object with the following fields: 281 282* _buildaction_ - build action. 283* _buildoptions_ - list of compiler options. 284* _defines_ - list of compiler symbols. 285* _excludes_ - list of excluded files. 286* _files_ - list of files. 287* _flags_ - list of build flags. 288* _implibdir_ - import library directory. 289* _implibextension_ - import library file extension. 290* _implibname_ - import library base file name. 291* _implibprefix_ - import library file name prefix. 292* _implibsuffix_ - import library file name suffix. 293* _includedirs_ - list of include file search directories. 294* _keywords_ - list of keywords associated with the block. 295* _kind_ - target kind. 296* _libdirs_ - list of library search directories. 297* _linkoptions_ - list of linker options. 298* _links_ - list of libraries or assemblies to link against. 299* _objdir_ - objects and intermediate files directory. 300* _pchheader_ - target file name for precompiled header support. 301* _pchsource_ - target source file name for precompiled header support. 302* _prebuildcommands_ - list of pre-build commands. 303* _prelinkcommands_ - list of pre-link commands. 304* _postbuildcommands_ - list of post-build commands. 305* _resdefines_ - list of symbols for the resource compiler. 306* _resincludedirs_ - list of include file search paths for the resource compiler. 307* _resoptions_ - list of resource compiler options. 308* _targetdir_ - target output directory. 309* _targetextension_ - target file extension. 310* _targetname_ - target base file name. 311* _targetprefix_ - target file name prefix. 312* _targetsuffix_ - target file name suffix. 313* _terms_ - filter terms passed to the configuration function to create the block (i.e. "Debug"). 314 315#### Examples 316Define debug symbol for debug configurations 317 318```lua 319configuration "Debug" 320 defines { "DEBUG" } 321``` 322 323Define a symbol based on a wildcard 324 325```lua 326configuration "vs*" 327 defines { "VISUAL_STUDIO_2005" } 328``` 329 330Define a symbol based on an "or" 331 332```lua 333configuration "linux or macosx" 334 defines { "LINUX_OR_MACOSX" } 335``` 336 337Define a symbol based on a "not" 338 339```lua 340configuration "not windows" 341 defines { "NOT_WINDOWS" } 342``` 343 344Reset the configuration filter 345 346```lua 347configuration {} 348``` 349 350#### Caveats 351 352- Argument chaining: 353 `configuration` can take multiple arguments, e.g., 354 ```lua 355 configuration {"StaticLib", "xcode*", "osx or ios*"} 356 ``` 357 These arguments will be combined as an `AND` clause, 358 i.e. if one of the keywords does _not_ match the actual configuration terms, 359 the following settings will not be applied. 360 361- Condition evaluation: 362 The arguments are **not** evaluated as Lua. They are merely regex-matched against the configuration terms. 363 The implications of this are that parentheses have no effect outside of regular expression groups. 364 A condition like `"not (osx or ios*)"` will not be equivalent to `{"not osx", "not ios*}"`. 365 Furthermore, a condition like `"not osx or ios*"` will be evaluated as the negation of `"osx or ios*"`. 366 367- `and` is **not** a valid keyword for configuration combinations. 368 However, several keywords will be combined as an `AND` clause. 369 370- Limits of Lua's regular expressions: 371 Each passed keyword is matched against each configuration terms from the project/solution type being built 372 using [Lua's regular expression mechanism](https://www.lua.org/manual/5.3/manual.html#6.4). 373 This means that keyword matching is subject to the same limits as regular Lua regex matching. 374 This implies that regexes like `"(osx|ios)"` do not work. 375 376- Wildcard expansion: 377 Wildcards will get expanded following the same rules as paths. 378 Similarly, special characters such as `()` will get escaped (i.e. converted to `%(%)`) before being matched. 379 This means that `"not (osx or ios*)"` will in fact get expanded to `"not %(osx or ios[^/]*)"` and then checked as 380 `not` _result of_ `"%(osx or ios[^/]*)"`, which in turn gets broken down to `"%(osx"` and `"ios[^/]*)"`. 381 382- `"win*"` matchings: 383 Intuitively, the configuration keyword to match "Windows" ("Win32", "Win64" or "WinCE") configuration would be 384 `"win*"`. However **`"win*"` also matches "WindowedApp"**. Prefer using the term `"vs*"` to check for configurations 385 targeting Windows. 386 387[Back to top](#table-of-contents) 388 389--- 390### configurations({_names_...}) 391Defines 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. 392 393**Scope:** solutions 394 395#### Arguments 396_names_ - list of configuration names 397 398#### Return Value 399When called with no arguments - list of current configuration names 400 401#### Examples 402Specify configurations for a solution 403 404```lua 405solution "MySolution" 406 configurations { "Debug", "Release" } 407``` 408 409Add additional configurations 410 411```lua 412configurations{ "Debug", "Release", "DebugDLL", "ReleaseDLL" } 413``` 414 415Retrieve current list of configurations 416 417```lua 418local cfgs = configurations() 419``` 420 421[Back to top](#table-of-contents) 422 423--- 424### custombuildtask({*input_file*, *output_file*, {*dependency*, ...}, {*command*, ...}}, ...) 425Defines custom build task for specific input file, that generates output file, there can be additional dependencies, and 426for rule listed commands are executed. 427 428**Scope:** solutions, projects, configurations 429 430#### Arguments 431*input_file* - source file that should be "compiled" with custom task 432*output_file* - generated file name 433*dependency* - additional dependencies, that can be used as parameters to commands 434*command* - command list, special functions in commands are : 435 $(<) - input file 436 $(@) - output file 437 $(1) - $(9) - additional dependencies 438 439#### Examples 440 441```lua 442custombuildtask { 443 { ROOT_DIR .. "version.txt" , GEN_DIR .. "src/version.inc", { ROOT_DIR .. "version.py" }, {"@echo Generating version.inc file...", "python $(1) $(<) > $(@)" }}, 444 } 445``` 446 447[Back to top](#table-of-contents) 448 449--- 450### debugcmd(cmd) 451Specifies a command to execute when running under the debugger instead of the build target. 452 453**Note:** In Visual Studio, this can be overridden by a per-user config file (e.g. ProjectName.vcxproj.MYDOMAIN-MYUSERNAME.user). 454 455**Scope:** solutions, projects, configurations 456 457#### Arguments 458_cmd_ - the command to execute when starting with the debugger 459 460#### Examples 461 462```lua 463configuration 'TestConfig' 464 debugcmd 'D:\\Apps\\Test.exe' 465``` 466 467[Back to top](#table-of-contents) 468 469--- 470### debugargs({_args_...}) 471Specifies a list of arguments to pas to the application when run under the debugger. 472 473**Note:** In Visual Studio, this can be overridden by a per-user config file (e.g. ProjectName.vcxproj.MYDOMAIN-MYUSERNAME.user). 474 475**Scope:** solutions, projects, configurations 476 477#### Arguments 478_args_ - list of arguments to pass to the executable while debugging 479 480#### Examples 481 482```lua 483configuration "Debug" 484 debugargs { "--append", "somefile.txt" } 485``` 486 487[Back to top](#table-of-contents) 488 489--- 490### debugdir(_path_) 491Sets the working directory for the integrated debugger. 492 493**Note:** In Visual Studio, this can be overridden by a per-user config file (e.g. ProjectName.vcxproj.MYDOMAIN-MYUSERNAME.user). 494 495**Scope:** solutions, projects, configurations 496 497#### Arguments 498_path_ - path to the working directory, relative to the currently-executing script file 499 500#### Examples 501 502```lua 503configuration "Debug" 504 debugdir "bin/debug" 505``` 506 507[Back to top](#table-of-contents) 508 509--- 510### defines({_symbols_...}) 511Adds preprocessor or compiler symbols to the project. Multiple calls are concatenated. 512 513**Scope:** solutions, projects, configurations 514 515#### Arguments 516_symbols_ - list of symbols 517 518#### Examples 519Define two new symbols 520 521```lua 522defines { "DEBUG", "TRACE" } 523``` 524 525Assign a symbol value 526 527```lua 528defines { "CALLSPEC=__dllexport" } 529``` 530 531[Back to top](#table-of-contents) 532 533--- 534### dependency({*main_file*, *depending_of*} ...) 535GMAKE specific. Adds dependency between source file and any other file. 536 537**Scope:** solutions, projects, configurations 538 539#### Arguments 540*main_file* - name of source file that depends of other file 541*depending_of* - name of dependency file 542 543#### Examples 544 545```lua 546dependency { { ROOT_DIR .. "src/test.c", ROOT_DIR .. "verion.txt" } } 547``` 548 549[Back to top](#table-of-contents) 550 551--- 552### deploymentoptions({_options_...}) 553Passes arguments directly to the deployment tool command line. Multiple calls are concatenated. 554 555**Note:** Currently only supported for Xbox 360 targets. 556 557**Scope:** solutions, projects, configurations 558 559#### Arguments 560_options_ - list of arguments 561 562[Back to top](#table-of-contents) 563 564--- 565### excludes({_files_...}) 566Excludes files from the project. This is different from [removefiles](#removefilesfiles) in that it may keep them in the project (Visual Studio) while still excluding them from the build. Multiple calls are concatenated. 567 568**Note:** May be set on the solution, project, or configuration, but only project-level file lists are currently supported. 569 570**Scope:** solutions, projects, configurations 571 572#### Arguments 573_files_ - List of files to exclude. Paths should be relative to the currently-executing script file and may contain [wildcards](#wildcards). 574 575#### Examples 576Add all c files in a directory, then exclude a specific file 577 578```lua 579files { "*.c" } 580excludes { "a_file.c" } 581``` 582 583Add an entire directory of C files, then exclude one directory 584 585```lua 586files { "*.c" } 587excludes { "tests/*.c" } 588``` 589 590[Back to top](#table-of-contents) 591 592--- 593### files({_files_...}) 594Adds files to a project. Multiple calls are concatenated. 595 596**Note:** May be set on the solution, project, or configuration, but only project-level file lists are currently supported. 597 598**Scope:** solutions, projects, configurations 599 600#### Arguments 601_files_ - List of files to include. Paths should be relative to the currently-executing script file and may contain [wildcards](#wildcards). 602 603#### Examples 604Add two files to the current project 605 606```lua 607files { "hello.cpp", "goodbye.cpp" } 608``` 609 610Add all C++ files from the "src/" directory to the project 611 612```lua 613files { "src/*.cpp" } 614``` 615 616Add all C++ files from the "src/" directory and any subdirectories 617 618```lua 619files { "src/**.cpp" } 620``` 621 622[Back to top](#table-of-contents) 623 624--- 625### flags({_flags_...}) 626Specifies build flags to modify the compiling or linking process. Multiple calls are concatenated. 627 628**Scope:** solutions, projects, configurations 629 630#### Arguments 631_flags_ - List of flag names from list below. Names are case-insensitive and ignored if not supported on a platform. 632 633* _C7DebugInfo_ - Enables C7 compatible debug info for MSVC builds. 634* _EnableMinimalRebuild_ - Enable Visual Studio's minimal rebuild feature. 635* _EnableSSE, EnableSSE2, EnableAVX, EnableAVX2_ - Enable SSE/AVX instruction sets 636* _ExtraWarnings_ - Sets compiler's max warning level. 637* _FatalWarnings_ - Treat warnings as errors. 638* _FloatFast_ - Enable floating point optimizations at the expense of accuracy. 639* _FloatStrict_ - Improve floating point consistency at the expense of performance. 640* _FullSymbols_ - Use together with _Symbols_ to generate full debug symbols with Visual Studio. 641* _GenerateMapFiles_ - Enable .map file outputs from the Visual Studio linker. 642* _LinkSupportCircularDependencies_ - Enables the linker to iterate over provided libs in order to resolve circular dependencies (make and ninja only). 643* _Managed_ - Enable Managed C++ (.NET). 644* _MFC_ - Enable support for Microsoft Foundation Classes. 645* _MinimumWarnings_ - - Sets compiler's minimum warning level (Visual Studio only). 646* _NativeWChar, NoNativeWChar_ - Toggle support for the wchar data type. 647* _No64BitChecks_ - Disable 64-bit portability warnings. 648* _NoBufferSecurityCheck_ - Turns off Visual Studio 'Security Check' option. Can give up to 10% performance improvement. 649* _NoEditAndContinue_ - Disable support for Visual Studio's Edit-and-Continue feature. 650* _NoExceptions_ - Disable C++ exception support. 651* _NoFramePointer_ - Disable the generation of stack frame pointers. 652* _NoImportLib_ - Prevent the generation of an import library for a Windows DLL. 653* _NoIncrementalLink_ - Disable support for Visual Studio's incremental linking feature. 654* _NoManifest_ - Prevent the generation of a manifest for Windows executables and shared libraries. 655* _NoMultiProcessorCompilation_ - Disables Visual Studio's and FastBuild's multiprocessor compilation. 656* _NoPCH_ - Disable precompiled headers. 657* _NoRTTI_ - Disable C++ runtime type information. 658* _NoRuntimeChecks_ - Disable Visual Studio's Basic Runtime Checks in Debug builds. 659* _NoWinMD_ - Disables Generation of Windows Metadata. 660* _NoWinRT_ - Disables Windows RunTime Extension for project. 661* _ObjcARC_ - Enable automatic reference counting for Object-C and Objective-C++. 662* _Optimize_ - Perform a balanced set of optimizations. 663* _OptimizeSize_ - Optimize for the smallest file size. 664* _OptimizeSpeed_ - Optimize for the best performance. 665* _PedanticWarnings_ - Enables the pedantic warning flags. 666* _SEH_ - Enable structured exception handling. 667* _SingleOutputDir_ - Allow source files in the same project to have the same name. 668* _StaticRuntime_ - Perform a static link against the standard runtime libraries. 669* _Symbols_ - Generate debugging information. 670* _Unicode_ - Enable Unicode strings. If not specified, the default toolset behavior is used. 671* _Unsafe_ - Enable the use of unsafe code in .NET applications. 672* _UnsignedChar_ - Force `char`s to be `unsigned` by default. 673* _UseFullPaths_ - Enable absolute paths for `__FILE__`. 674* _UseLDResponseFile_ - Enable use of response file (aka @file) for linking lib dependencies (make only). 675* _UseObjectResponseFile_ - Enable use of response file (aka @file) for linking objects (make only). 676* _WinMain_ - Use WinMain() as the entry point for Windows applications, rather than main(). 677 678**Note:** When not set, options will default to the tool default. 679 680Additional tool-specific arguments can be passed with [`buildoptions`](#buildoptions) or [`linkoptions`](#linkoptions) 681 682#### Examples 683Enable debugging symbols in the Debug configuration and optimize the Release configuration 684 685```lua 686configuration "Debug" 687 flags { "Symbols" } 688 689configuration "Release" 690 flags { "OptimizeSpeed", "No64BitChecks" } 691``` 692 693[Back to top](#table-of-contents) 694 695--- 696### framework(_version_) 697Specifies a .NET framework version. 698 699**Note:** Currently only applied to Visual Studio 2005+ and GNU Makefiles using Mono. 700 701**Scope:** solutions, projects 702 703#### Arguments 704_version_ - one of the following: 705 706* 1.0 707* 1.1 708* 2.0 709* 3.0 710* 3.5 711* 4.0 712 713#### Examples 714Use the .NET 3.0 framework 715 716```lua 717framework "3.0" 718``` 719 720[Back to top](#table-of-contents) 721 722--- 723### group(_name_) 724Creates a solution folder for Visual Studio solutions. 725 726**Scope:** solutions 727 728#### Arguments 729_name_ - the name of the solution folder 730 731#### Examples 732 733```lua 734solution "MySolution" 735 group "MyGroup1" 736 project "Project1" 737 -- ... 738 project "Project2" 739 -- ... 740 group "MyGroup2" 741 project "Project3" 742 -- ... 743``` 744 745[Back to top](#table-of-contents) 746 747--- 748### imageoptions({_options_...}) 749Passes arguments directly to the image tool command line without translation. Multiple calls are concatenated. 750 751**Scope:** solutions, project, configurations 752 753#### Arguments 754_options_ - list of image tools flags and options 755 756[Back to top](#table-of-contents) 757 758--- 759### imagepath(_path_) 760Sets the file name of the deployment image produced by the build 761 762**Scope:** solutions, projects, configurations 763 764#### Arguments 765_path_ - the full path for the image file, relative to the currently-executing script 766 767[Back to top](#table-of-contents) 768 769--- 770### implibdir(_path_) 771Specifies 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. 772 773**Scope:** solutions, projects, configurations 774 775#### Arguments 776_path_ - the output directory for the library, relative to the currently-executing script file 777 778#### Examples 779 780```lua 781implibdir "../Libraries" 782``` 783 784[Back to top](#table-of-contents) 785 786--- 787### implibextension(_extension_) 788Specifies 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). 789 790**Scope:** solutions, projects, configurations 791 792#### Arguments 793_extension_ - the extension, including the leading dot 794 795[Back to top](#table-of-contents) 796 797--- 798### implibname(_name_) 799Specifies 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. 800 801**Scope:** solutions, projects, configurations 802 803#### Arguments 804_name_ - new base file name 805 806[Back to top](#table-of-contents) 807 808--- 809### implibprefix(_prefix_) 810Specifies 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). 811 812**Scope:** solutions, projects, configurations 813 814#### Arguments 815_prefix_ - new file name prefix 816 817#### Examples 818 819```lua 820implibprefix "plugin" 821``` 822 823The prefix may also be set to an empty string for no prefix 824 825```lua 826implibprefix "" 827``` 828 829[Back to top](#table-of-contents) 830 831--- 832### implibsuffix(_suffix_) 833Specifies the file name suffix for the import library base file name. Import libraries are generated for Windows DLL projects. 834 835**Scope:** solutions, projects, configurations 836 837#### Arguments 838_suffix_ - the new filename suffix 839 840#### Examples 841 842```lua 843-- Add "-d" to debug versions of files 844configuration "Debug" 845 implibsuffix "-d" 846``` 847 848[Back to top](#table-of-contents) 849 850--- 851### include(_directory_) 852Includes 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. 853 854#### Arguments 855_directory_ - path to the included directory, relative to the currently-executing script file. 856 857#### Return Value 858Any values returned by the script are passed through to the caller 859 860#### Examples 861 862```lua 863-- runs "src/MyApplication/premake4.lua" 864include "src/MyApplication" 865 866-- runs "src/MyLibrary/premake4.lua" 867include "src/MyLibrary" 868``` 869 870[Back to top](#table-of-contents) 871 872--- 873### includedirs({_paths_...}) 874Specifies include file search paths. Multiple calls are concatenated. 875 876**Scope:** solutions, projects, configurations 877 878#### Arguments 879_paths_ - list of include file search directories, relative to the currently-executing script file. 880 881#### Examples 882Define two include file search paths 883 884```lua 885includedirs { "../lua/include", "../zlib" } 886``` 887 888You can also use [wildcards](#wildcards) to match multiple directories. 889 890```lua 891includedirs { "../includes/**" } 892``` 893 894[Back to top](#table-of-contents) 895 896--- 897### kind(_kind_) 898Sets the kind of binary object being created by the project, such as a console or windowed application. 899 900**Scope:** solutions, projects, configurations 901 902#### Arguments 903_kind_ - project kind identifier. One of: 904 905* _ConsoleApp_ - console executable 906* _WindowedApp_ - application that runs in a desktop window. Does not apply on Linux. 907* _StaticLib_ - static library 908* _SharedLib_ - shared library or DLL 909* _Bundle_ - Xcode: Cocoa Bundle, everywhere else: alias to _SharedLib_ 910 911#### Examples 912 913```lua 914kind "ConsoleApp" 915``` 916 917You can also set different kinds for each configuration. **Not supported by XCode.** 918 919```lua 920solution "MySolution" 921 configurations { "DebugLib", "ReleaseLib", "DebugDLL", "ReleaseDLL" } 922 923project "MyProject" 924 configuration "*Lib" 925 kind "StaticLib" 926 927 configuration "*DLL" 928 kind "SharedLib" 929``` 930 931[Back to top](#table-of-contents) 932 933--- 934### language(_lang_) 935Sets 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++). 936 937**Scope:** solutions, projects 938 939#### Arguments 940_lang_ - language identifier string ("C", "C++", "C#" or "Vala"). Case insensitive. 941 942#### Examples 943 944```lua 945language "C++" 946``` 947 948[Back to top](#table-of-contents) 949 950--- 951### libdirs({_paths_...}) 952Specifies 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. 953 954Multiple calls are concatenated. 955 956**Scope:** solutions, projects, configurations 957 958#### Arguments 959_paths_ - list of library search directories, relative to the currently-executing script file 960 961#### Examples 962 963```lua 964libdirs { "../lua/libs", "../zlib" } 965``` 966 967You can also use [wildcards](#wildcards) to match multiple directories. 968 969```lua 970libdirs { "../libs/**" } 971``` 972 973[Back to top](#table-of-contents) 974 975--- 976### linkoptions({_options_...}) 977Passes arguments to the linker command line. Multiple calls are concatenated. 978 979**Scope:** solutions, projects, configurations 980 981#### Arguments 982_options_ - list of flags and options to pass 983 984#### Examples 985Use `pkg-config`-style configuration when building on Linux with GCC. 986 987```lua 988configuration { "linux", "gmake" } 989 linkoptions { "`wx-config --libs`"} 990``` 991 992[Back to top](#table-of-contents) 993 994--- 995### links({_references_...}) 996Specifies a list of libraries and projects to link against. Multiple calls are concatenated. 997 998**Scope:** solutions, projects, configurations 999 1000#### Arguments 1001_references_ - list of library and project names 1002 1003When 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. 1004 1005When linking against system libraries, do not include any prefix or file extension. GENie will use the appropriate naming conventions for the current platform. 1006 1007#### Examples 1008Link against some system libraries 1009 1010```lua 1011configuration "windows" 1012 links { "user32", "gdi32" } 1013 1014configuration "linux" 1015 links { "m", "png" } 1016 1017configuration "macosx" 1018--- OS X frameworks need the extension to be handled properly 1019 links { "Cocoa.framework", "png" } 1020``` 1021 1022In 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. 1023 1024```lua 1025solution "MySolution" 1026 configurations { "Debug", "Release" } 1027 language "C++" 1028 1029 project "MyExecutable" 1030 kind "ConsoleApp" 1031 files "**.cpp" 1032 links { "MyLibrary" } 1033 1034 project "MyLibrary" 1035 kind "SharedLib" 1036 files "**.cpp" 1037``` 1038 1039You 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 1040 1041```lua 1042solution "MySolution" 1043 configurations { "Debug", "Release" } 1044 language "C++" 1045 1046 project "MyProject" 1047 kind "ConsoleApp" 1048 files "**.cpp" 1049 links { "MyTool" } 1050 prebuildcommands { "MyTool --dosomething" } 1051 1052 project "MyTool" 1053 kind "ConsoleApp" 1054 files "**.cpp" 1055``` 1056 1057[Back to top](#table-of-contents) 1058 1059--- 1060### location(_path_) 1061Sets 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. 1062 1063**Note:** Does not automatically propagate to the contained projects. Projects will use their default location unless explicitly overridden. 1064 1065**Scope:** solutions, projects 1066 1067#### Arguments 1068_path_ - directory into which files should be generated, relative to the currently-executing script file. 1069 1070#### Examples 1071 1072```lua 1073solution "MySolution" 1074 location "../build" 1075``` 1076 1077If 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. 1078 1079```lua 1080location ("../build/" .. _ACTION) 1081``` 1082 1083[Back to top](#table-of-contents) 1084 1085--- 1086### messageskip(_options_) 1087Skips certain messages in ninja and Makefile generated projects. 1088 1089**Scope:** solutions 1090 1091#### Arguments 1092_options_ - one or several of "SkipCreatingMessage", "SkipBuildingMessage", "SkipCleaningMessage" 1093 1094#### Examples 1095 1096```lua 1097messageskip { "SkipCreatingMessage", "SkipBuildingMessage", "SkipCleaningMessage" } 1098``` 1099 1100[Back to top](#table-of-contents) 1101 1102--- 1103### newaction(_description_) 1104Registers a new command-line action argument. 1105 1106#### Arguments 1107_description_ - a table describing the new action with the following fields: 1108 1109* _trigger_ - string identifier of the action; what the user would type on the command line 1110* _description_ - short description of the action, to be displayed in the help text 1111* _execute_ - Function to be executed when the action is fired 1112 1113#### Examples 1114 1115```lua 1116newaction { 1117 trigger = "install", 1118 description = "Install the software", 1119 execute = function() 1120 os.copyfile("bin/debug/myprogram", "/usr/local/bin/myprogram") 1121 end 1122} 1123``` 1124 1125[Back to top](#table-of-contents) 1126 1127--- 1128### newoption(_description_) 1129Registers a new command-line option argument. 1130 1131**Scope:** solutions, projects, configurations 1132 1133#### Arguments 1134_description_ - a table describing the new option with the following fields: 1135 1136* _trigger_ - string identifier of the option; what the user would type on the command line 1137* _description_ - short description of the option, to be displayed in the help text 1138* _value_ - (optional) provides a hint to the user as to what type of data is expected 1139* _allowed_ - (optional) list of key-value pairs listing the allowed values for the option 1140 1141#### Examples 1142 1143```lua 1144newoption { 1145 trigger = "gfxapi", 1146 value = "API", 1147 description = "Choose a particular 3D API for rendering", 1148 allowed = { 1149 { "opengl", "OpenGL" }, 1150 { "direct3d", "Direct3D (Windows only)"}, 1151 { "software", "Software Renderer" } 1152 } 1153} 1154``` 1155 1156[Back to top](#table-of-contents) 1157 1158--- 1159### nopch({_files_...}) 1160Sets sources files added with the [`files`](#files) function, to not use the precompiled header. Multiple calls are concatenated. 1161 1162**Note:** May be set on the solution, project, or configuration, but only project-level file lists are currently supported. 1163 1164**Scope:** solutions, projects, configurations 1165 1166#### Arguments 1167_files_ - List of files to not use the precompiled header. Paths should be relative to the currently-executing script file and may contain [wildcards](#wildcards). 1168 1169#### Examples 1170Add all c files in a directory, then set a specific file to not use precompiled headers. 1171 1172```lua 1173files { "*.c" } 1174nopch { "a_file.c" } 1175``` 1176 1177Add an entire directory of C files, then set one directory to not use precompiled headers 1178 1179```lua 1180files { "*.c" } 1181nopch { "tests/*.c" } 1182``` 1183 1184[Back to top](#table-of-contents) 1185 1186--- 1187### objdir(_path_) 1188Sets 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. 1189 1190**Scope:** solutions, projects, configurations 1191 1192#### Arguments 1193_path_ - directory where the object and intermediate files should be stored, relative to the currently-executing script file. 1194 1195#### Examples 1196 1197```lua 1198project "MyProject" 1199 objdir "objects" 1200``` 1201 1202Set object directories per configuration 1203 1204```lua 1205configuration "Debug" 1206 objdir "../obj_debug" 1207 1208configuration "Release" 1209 objdir "../obj_release" 1210``` 1211 1212[Back to top](#table-of-contents) 1213 1214--- 1215### options({_options_...}) 1216Specifies build flags to modify the compiling or linking process. This differs from `flags` in 1217that these are set per project rather than per configuration. 1218 1219**Scope:** solutions, projects 1220 1221#### Arguments 1222_options_ - List of option names from list below. Names are case-insensitive and ignored if not supported on a platform. 1223 1224* _ArchiveSplit_ - Split arguments to the gmake archiver across multiple invocations, if there are too many of them. 1225* _ForceCPP_ - Force compiling source as C++ despite the file extension suggesting otherwise. 1226* _SkipBundling_ - Disable generating bundles for Apple platforms. 1227* _XcodeLibrarySchemes_ - Generate XCode schemes for libraries too. (By default schemes are only created for runnable apps.) 1228* _XcodeSchemeNoConfigs_ - Generate a single scheme per project, rather than one per project config. 1229 1230[Back to top](#table-of-contents) 1231 1232--- 1233### pchheader(_file_) 1234Sets the main header file for precompiled header support. 1235 1236**Scope:** projects 1237 1238#### Arguments 1239_file_ - name of the header file, as it is specified in your `#include` statements 1240 1241#### Examples 1242 1243```lua 1244pchheader "afxwin.h" 1245pchsource "afxwin.cpp" 1246``` 1247 1248[Back to top](#table-of-contents) 1249 1250--- 1251### pchsource(_file_) 1252Sets the main source file for precompiled header support. Only used by Visual Studio. 1253 1254**Scope:** projects 1255 1256#### Arguments 1257_file_ - name of the source file, relative to the currently-executing script file 1258 1259#### Examples 1260 1261```lua 1262pchheader "afxwin.h" 1263pchsource "afxwin.cpp" 1264``` 1265 1266[Back to top](#table-of-contents) 1267 1268--- 1269### platforms({_identifiers_...}) 1270Specifies a set of target hardware platforms for a solution. 1271 1272_Platform support is a new, experimental feature. The syntax and behavior described here might change as we sort out the details_ 1273 1274**Scope:** solutions 1275 1276#### Arguments 1277_identifiers_ - list of hardware platform specifiers from this list: 1278 1279* _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 1280* _x32_ - 32-bit environment 1281* _x64_ - 64-bit environment 1282* _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. 1283* _Universal32_ - like _Universal_ above, but targeting only 32-bit platforms 1284* _Universal64_ - like _Universal_ above, but targeting only 64-bit platforms 1285* _PS3_ - Playstation 3 1286* _WiiDev_ - Wii 1287* _Xbox360_ - Xbox 360 compiler and linker under Visual Studio 1288* _PowerPC_ - PowerPC processors 1289* _ARM_ - ARM-based processors 1290* _Orbis_ - Playstation 4 1291* _Durango_ - Xbox One 1292 1293#### Return Value 1294Current list of target platforms for the active solution 1295 1296#### Examples 1297Generic build, as well as OS X Universal build 1298 1299```lua 1300solution "MySolution" 1301 configurations { "Debug", "Release" } 1302 platforms { "native", "universal" } 1303``` 1304 1305Prove 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. 1306 1307```lua 1308solution "MySolution" 1309 configurations { "Debug", "Release" } 1310 platforms { "x32", "x64" } 1311``` 1312 1313You can retrieve the current list of platforms by calling the function with no parameters 1314 1315```lua 1316local p = platforms() 1317``` 1318 1319Once you have defined a list of platforms, you may use those identifiers to set up configuration filters and apply platform-specific settings. 1320 1321```lua 1322configuration "x64" 1323 defines "IS_64BIT" 1324 1325-- You can also mix platforms with other configuration selectors 1326configuration { "Debug", "x64" } 1327 defines "IS_64BIT_DEBUG" 1328``` 1329 1330[Back to top](#table-of-contents) 1331 1332--- 1333### postbuildcommands({_commands_...}) 1334Specifies shell commands to run after build is finished 1335 1336**Scope:** solutions, projects, configurations 1337 1338#### Arguments 1339_commands_ - one or more shell commands 1340 1341#### Examples 1342 1343```lua 1344configuration "windows" 1345 postbuildcommands { "copy default.config bin\\project.config" } 1346 1347configuration "not windows" 1348 postbuildcommands { "cp default.config bin/project.config" } 1349``` 1350 1351[Back to top](#table-of-contents) 1352 1353--- 1354### postcompiletasks({_commands_...}) 1355Specifies shell commands to run after compile of file is finished 1356(GMAKE specific) 1357 1358**Scope:** solutions, projects, configurations 1359 1360#### Arguments 1361_commands_ - one or more shell commands 1362 1363#### Examples 1364 1365```lua 1366 postcompiletasks { "rm $(@:%.o=%.d)" } 1367``` 1368 1369[Back to top](#table-of-contents) 1370 1371--- 1372### prebuildcommands({_commands_...}) 1373Specifies shell commands to run before each build 1374 1375**Scope:** solutions, projects, configurations 1376 1377#### Arguments 1378_commands_ - one or more shell commands 1379 1380#### Examples 1381 1382```lua 1383configuration "windows" 1384 prebuildcommands { "copy default.config bin\\project.config" } 1385 1386configuration "not windows" 1387 prebuildcommands { "cp default.config bin/project.config" } 1388``` 1389 1390[Back to top](#table-of-contents) 1391 1392--- 1393### prelinkcommands({_commands_...}) 1394Specifies shell commands to run after source files have been compiled, but before the link step 1395 1396**Scope:** solutions, projects, configurations 1397 1398#### Arguments 1399_commands_ - one or more shell commands 1400 1401#### Examples 1402 1403```lua 1404configuration "windows" 1405 prelinkcommands { "copy default.config bin\\project.config" } 1406 1407configuration "not windows" 1408 prelinkcommands { "cp default.config bin/project.config" } 1409``` 1410 1411[Back to top](#table-of-contents) 1412 1413 1414--- 1415### project(_name_) 1416Creates 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. 1417 1418Every project belongs to a solution. 1419 1420#### Arguments 1421_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. 1422 1423#### Return Value 1424The active project object. 1425 1426#### The `project` Object 1427Every 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. 1428 1429* _basedir_ - directory where the project was originally defined. Root for relative paths. 1430* _blocks_ - list of configuration blocks 1431* _language_ - project language, if set 1432* _location_ - output directory for generated project file 1433* _name_ - name of the project 1434* _solution_ - solution which contains the project 1435* _uuid_ - unique identifier 1436 1437#### Examples 1438Create a new project named "MyProject". Note that a solution must exist to contain the project. The indentation is for readability and is optional. 1439 1440```lua 1441solution "MySolution" 1442 configurations { "Debug", "Release" } 1443 1444 project "MyProject" 1445``` 1446 1447You can retrieve the currently active project by calling `project` with no parameters. 1448 1449```lua 1450local prj = project() 1451``` 1452 1453You can retrieve the list of projects associated with a solution using the `projects` field of the solution object, which may then be iterated over. 1454 1455```lua 1456local prjs = solution().projects 1457for i, prj in ipairs(prjs) do 1458 print(prj.name) 1459end 1460``` 1461 1462[Back to top](#table-of-contents) 1463 1464--- 1465### removefiles({_files_...}) 1466Removes files from the project. This is different from [excludes](#excludesfiles) in that it completely removes them from the project, not only from the build. Multiple calls are concatenated. 1467 1468**Scope:** solutions, projects, configurations 1469 1470#### Arguments 1471_files_ - list of files to remove. 1472 1473[Back to top](#table-of-contents) 1474 1475--- 1476### removeflags({_flags_...}) 1477Removes flags from the flag list. 1478 1479**Scope:** solutions, projects, configurations 1480 1481#### Arguments 1482_flags_ - list of flags to remove from the flag list. They must be valid flags. 1483 1484[Back to top](#table-of-contents) 1485 1486--- 1487### removelinks({_references_...}) 1488 1489Removes flags from the flag list. 1490 1491**Scope:** solutions, projects, configurations 1492 1493#### Arguments 1494_references_ - list of libraries and project names to remove from the links list. 1495 1496[Back to top](#table-of-contents) 1497 1498--- 1499### removeplatforms({_platforms_...}) 1500 1501Removes platforms from the platform list. 1502 1503**Scope:** solutions, projects, configurations 1504 1505#### Arguments 1506_platforms_ - list of platforms to remove from the platforms list. 1507 1508[Back to top](#table-of-contents) 1509 1510--- 1511### resdefines({_symbols_...}) 1512Specifies preprocessor symbols for the resource compiler. Multiple calls are concatenated. 1513 1514**Scope:** solutions, projects, configurations 1515 1516#### Arguments 1517_symbols_ - list of symbols to be defined 1518 1519#### Examples 1520 1521```lua 1522resdefines { "DEBUG", "TRACE" } 1523``` 1524 1525```lua 1526resdefines { "CALLSPEC=__dllexport" } 1527``` 1528 1529[Back to top](#table-of-contents) 1530 1531--- 1532### resincludedirs({_paths_...}) 1533Specifies the include file search paths for the resource compiler. Multiple calls are concatenated. 1534 1535**Scope:** solutions, projects, configurations 1536 1537#### Arguments 1538_paths_ - list of include file search directories, relative to the currently executing script file 1539 1540#### Examples 1541 1542```lua 1543resincludedirs { "../lua/include", "../zlib" } 1544``` 1545 1546May use wildcards 1547 1548```lua 1549resincludedirs { "../includes/**" } 1550``` 1551 1552[Back to top](#table-of-contents) 1553 1554--- 1555### resoptions({_options_...}) 1556Passes arguments directly to the resource compiler. Multiple calls are concatenated. 1557 1558**Scope:** solutions, projects, configurations 1559 1560#### Arguments 1561_options_ - list of resource compiler flags and options 1562 1563#### Examples 1564 1565```lua 1566configuration { "linux", "gmake" } 1567 resoptions { "`wx-config --cxxflags`", "-ansi", "-pedantic" } 1568``` 1569 1570[Back to top](#table-of-contents) 1571 1572--- 1573### solution(_name_) 1574Creates 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. 1575 1576#### Arguments 1577_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. 1578 1579#### Return Value 1580The active `solution` object. 1581 1582#### The `solution` Object 1583Represented 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. 1584 1585* _basedir_ - directory where the original project was defined; acts as a root for relative paths 1586* _configurations_ - list of valid configuration names 1587* _blocks_ - list of configuration blocks 1588* _language_ - solution language, if set 1589* _location_ - output directory for the generated solution file 1590* _name_ - name of the solution 1591* _platforms_ - list of target platforms 1592* _projects_ - list of projects contained by the solution 1593 1594#### Examples 1595 1596```lua 1597solution "MySolution" 1598``` 1599 1600You can retrieve the currently active solution object by calling `solution` with no parameters. 1601 1602```lua 1603local sln = solution() 1604``` 1605 1606You can use the global variable `_SOLUTIONS` to list out all of the currently defined solutions. 1607 1608```lua 1609for i, sln in ipairs(_SOLUTIONS) do 1610 print(sln.name) 1611end 1612``` 1613 1614[Back to top](#table-of-contents) 1615 1616--- 1617### startproject(_name_) 1618Sets the start (default) project for the solution. Works for VS, QBS and Xcode. 1619 1620**Scope:** solutions 1621 1622#### Arguments 1623_name_ - name of the project to set as the start project. 1624 1625### Examples 1626 1627```lua 1628solution "MySolution" 1629 startproject "MyProjectFoo" 1630 -- [...] 1631 1632project "MyProjectFoo" 1633-- [...] 1634 1635project "MyProjectBar" 1636-- [...] 1637``` 1638 1639[Back to top](#table-of-contents) 1640 1641--- 1642### systemincludedirs({_paths_...}) 1643Specifies the system include file search paths. Multiple calls are concatenated. 1644 1645For clang/gcc, it maps to setting the include directory using the `-isystem` option. 1646 1647On the other build systems, it behaves like [includedirs](#includedirspaths), 1648but is always searched after directories specified using includedirs. 1649 1650**Scope:** solutions, projects, configurations 1651 1652#### Arguments 1653_paths_ - list of system include file search directories, relative to the currently-executing script file. 1654 1655#### Examples 1656Define two include file search paths 1657 1658```lua 1659systemincludedirs { "../lua/include", "../zlib" } 1660``` 1661 1662You can also use [wildcards](#wildcards) to match multiple directories. 1663 1664```lua 1665systemincludedirs { "../includes/**" } 1666``` 1667 1668[Back to top](#table-of-contents) 1669 1670--- 1671### targetdir(_path_) 1672Sets 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. 1673 1674**Scope:** solutions, projects, configurations 1675 1676#### Arguments 1677_path_ - file system path to the directory where the compiled target file should be stored, relative to the currently executing script file. 1678 1679#### Examples 1680 1681```lua 1682project "MyProject" 1683 1684 configuration "Debug" 1685 targetdir "bin/debug" 1686 1687 configuration "Release" 1688 targetdir "bin/release" 1689``` 1690 1691[Back to top](#table-of-contents) 1692 1693--- 1694### targetextension(_ext_) 1695Specifies 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. 1696 1697**Scope:** solutions, projects, configurations 1698 1699#### Arguments 1700_ext_ - new file extension, including leading dot 1701 1702#### Examples 1703 1704```lua 1705targetextension ".zmf" 1706``` 1707 1708[Back to top](#table-of-contents) 1709 1710--- 1711### targetname(_name_) 1712Specifies 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. 1713 1714**Scope:** solutions, projects, configurations 1715 1716#### Arguments 1717_name_ - new base file name 1718 1719#### Examples 1720 1721```lua 1722targetname "mytarget" 1723``` 1724 1725[Back to top](#table-of-contents) 1726 1727--- 1728### targetprefix(_prefix_) 1729Specifies 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. 1730 1731**Scope:** solutions, projects, configurations 1732 1733#### Arguments 1734_prefix_ - new file name prefix 1735 1736#### Examples 1737 1738```lua 1739targetprefix "plugin" 1740``` 1741 1742The prefix may also be set to an empty string for no prefix 1743 1744```lua 1745targetprefix "" 1746``` 1747 1748[Back to top](#table-of-contents) 1749 1750--- 1751### targetsubdir(_path_) 1752Sets a subdirectory inside the target directory for the compiled binary target. 1753 1754**Scope:** solutions, projects, configurations 1755 1756#### Arguments 1757_path_ - name of the subdirectory. 1758 1759[Back to top](#table-of-contents) 1760 1761--- 1762### targetsuffix(_suffix_) 1763Specifies a file name suffix for the compiled binary target. 1764 1765**Scope:** solutions, projects, configurations 1766 1767#### Arguments 1768_suffix_ - new filename suffix 1769 1770#### Examples 1771 1772```lua 1773--- Add "-d" to debug versions of files 1774configuration "Debug" 1775 targetsuffix "-d" 1776``` 1777 1778[Back to top](#table-of-contents) 1779 1780--- 1781### uuid(_projectuuid_) 1782Sets 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. 1783 1784**Scope:** projects 1785 1786#### Arguments 1787_projectuuid_ - UUID for the current project 1788 1789### Return Value 1790Current project UUID or `nil` if no UUID has been set 1791 1792#### Examples 1793 1794```lua 1795uuid "XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXX" 1796``` 1797 1798[Back to top](#table-of-contents) 1799 1800--- 1801### vpaths({[_group_] = {_pattern_...}}) 1802Places 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. 1803 1804**Note:** May be set on the solution, project, or configuration, but only project-level file lists are currently supported. 1805 1806**Scope:** solutions, projects, configurations 1807 1808#### Arguments 1809Table of values, where keys (_groups_) are strings and values (_pattern_) are lists of file system patterns. 1810 1811_group_ - name for the new group 1812_pattern_ - file system pattern for matching file names 1813 1814#### Examples 1815 1816Place 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" 1817 1818```lua 1819vpaths { ["Headers"] = "**.h" } 1820``` 1821 1822You may specify multiple file patterns using table syntax 1823 1824```lua 1825vpaths { 1826 ["Headers"] = { "**.h", "**.hxx", "**.hpp" } 1827} 1828``` 1829 1830It 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". 1831 1832```lua 1833vpaths { ["Headers/*"] = "**.h" } 1834``` 1835 1836Any 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". 1837 1838```lua 1839vpaths { ["Headers/*"] = "src/**.h" } 1840``` 1841 1842You 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". 1843 1844```lua 1845vpaths { ["*"] = "src" } 1846``` 1847 1848You may specify more than one rule at a time 1849 1850```lua 1851vpaths { 1852 ["Headers"] = "**.h", 1853 ["Sources/*"] = {"**.c", "**.cpp"}, 1854 ["Docs"] = "**.txt" 1855} 1856``` 1857 1858[Back to top](#table-of-contents) 1859 1860--- 1861### xcodeprojectopts({[_key_] = _value_, ...}) 1862#### XCode only 1863Sets XCode project options in the generated project files. [List of options.](https://gist.github.com/tkersey/39b4fe69e14b859889ffadccb009e397) 1864 1865#### Arguments 1866_key_ - Name of the option to set 1867_value_ - Value to set it to 1868 1869#### Examples 1870 1871```lua 1872xcodeprojectopts { 1873 ENABLE_BITCODE = "NO", 1874 GCC_ENABLE_TRIGRAPHS = "YES", 1875} 1876``` 1877 1878[Back to top](#table-of-contents) 1879 1880--- 1881### xcodetargetopts({[_key_] = _value_, ...}) 1882#### XCode only 1883Sets XCode target options in the generated project files. [List of options.](https://gist.github.com/tkersey/39b4fe69e14b859889ffadccb009e397) 1884 1885#### Arguments 1886_key_ - Name of the option to set 1887_value_ - Value to set it to 1888 1889#### Examples 1890 1891```lua 1892xcodetargetopts { 1893 ALWAYS_SEARCH_USER_PATHS = "YES", 1894} 1895``` 1896 1897[Back to top](#table-of-contents) 1898 1899--- 1900### xcodescriptphases({{_cmd_, {_inputpaths_, ...}}}) 1901#### XCode only 1902Adds a script phase to the generated XCode project file. 1903One tag can contain several commands with different inputpaths. 1904 1905#### Arguments 1906_cmd_ - The actual command to run. (This can be a shell script file or direct shell code). 1907_inputpaths_ - The paths passed to the command 1908 1909#### Examples 1910_Building shader files_ 1911 1912```lua 1913xcodescriptphases { 1914 {"shaderc_xcode.sh", { 1915 os.matchfiles("**.shader")} 1916 }, 1917} 1918``` 1919 1920_Copying, trimming and signing frameworks by relying on [carthage](https://github.com/Carthage/Carthage)_ 1921 1922```lua 1923xcodescriptphases { 1924 {"carthage copy-frameworks", { 1925 os.matchdirs("**.frameworks")} 1926 }, 1927} 1928``` 1929 1930#### Caveats 1931- Script phases are added in their order of declaration inside the project, 1932 and in their order of declaration inside the tag. 1933- The input paths are used as passed to the tag. 1934 If relative paths are required, you have to rebase them beforehand using `path.getrelative()`. 1935- For commands/scripts: You can iterate over the input paths using the following XCode variables: 1936 `${SCRIPT_INPUT_FILE_COUNT}`: The number of input paths provided to the script 1937 `${SCRIPT_INPUT_FILE_0}` ...: The input paths at index 0 and so on. 1938 **NOTE**: You can construct the indexed variable as in the example below: 1939```bash 1940for (( i = 0; i < ${SCRIPT_INPUT_FILE_COUNT}; ++i )); do 1941 varname=SCRIPT_INPUT_FILE_$i 1942 echo ${!varname} 1943done 1944``` 1945 1946[Back to top](#table-of-contents) 1947 1948--- 1949### xcodecopyresources({{_targetpath_, {_inputfiles_, ...}}}) 1950#### XCode only 1951Adds a 'Copy Files' phase to the generated XCode project file. 1952One tag can contain several target paths with different input files. 1953 1954#### Arguments 1955_targetpath_ - The target path relative to the _Resource_ folder in the resulting `.app` structure. 1956_inputfiles_ - The input files to be copied. 1957 1958#### Examples 1959 1960```lua 1961xcodecopyresources { 1962 { ".", { 1963 "GameResources", -- a folder 1964 }}, 1965 { "shaders", { 1966 os.matchfiles("**.shader"), -- sparse files 1967 }}, 1968} 1969``` 1970 1971#### Caveats 1972- The target path is only handled as relative to the _Resource_ folder. No other folder can be indicated at the moment. 1973 If you need support for other targets, please file an issue on Github. 1974- `xcodecopyresources` can only be set _per project_, not _per configuration_. 1975 1976 1977[Back to top](#table-of-contents) 1978 1979--- 1980### xcodecopyframeworks({_inputframeworks_, ...}) 1981#### XCode only 1982Adds a 'Copy Files' phase to the generated XCode project file that will copy and sign the provided frameworks. 1983 1984#### Arguments 1985_inputframeworks_ - A list of frameworks to be copied to the `.app` structure, with the `SignOnCopy` flag set. 1986 1987#### Examples 1988 1989```lua 1990links { -- frameworks have to be linked with the .app first 1991 "GTLR.framework", 1992 "BGFX.framework", 1993} 1994xcodecopyframeworks { 1995 "GTLR.framework", 1996 "BGFX.framework", 1997} 1998``` 1999 2000#### Caveats 2001- Frameworks must be known to the project to be copyable: set the link dependency accordingly using `links {}`. 2002- `xcodecopyframeworks` can only be set _per project_, not _per configuration_. 2003 2004[Back to top](#table-of-contents) 2005 2006--- 2007 2008--- 2009### wholearchive({_references_...}) 2010Specifies 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. 2011 2012**Scope:** solutions, projects, configurations 2013 2014#### Arguments 2015_references_ - list of library and project names 2016 2017#### Examples 2018 2019```lua 2020project "static_lib" 2021 kind "StaticLib" 2022 2023project "console_app" 2024 kind "ConsoleApp" 2025 links { "static_lib" } 2026 wholearchive { "static_lib" } 2027``` 2028 2029#### References 2030* [Clang documentation](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang2-force-load) 2031* [GNU documentation](https://ftp.gnu.org/old-gnu/Manuals/ld-2.9.1/html_node/ld_3.html#IDX183) 2032* [Microsoft documentation](https://docs.microsoft.com/en-us/cpp/build/reference/wholearchive-include-all-library-object-files?view=vs-2017) 2033 2034[Back to top](#table-of-contents) 2035 2036 2037--- 2038## Utility functions 2039 2040### iif(_condition_, _trueval_, _falseval_) 2041Implements an immediate `if` clause, returning one of two possible values. 2042 2043#### Arguments 2044_condition_ - logical condition to test 2045_trueval_ - value to return if _condition_ evaluates to `true` 2046_falseval_ - value to return if _condition_ evaluates to `false` 2047 2048#### Examples 2049 2050```lua 2051result = iif(os.is("windows"), "is windows", "is not windows") 2052``` 2053 2054Note 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. 2055 2056```lua 2057result = iif(x -= nil, "x is " .. x, "x is nil") 2058``` 2059 2060[Back to top](#table-of-contents) 2061 2062--- 2063### os.chdir(_path_) 2064Changes the working directory 2065 2066#### Arguments 2067_path_ - path to the new working directory 2068 2069#### Return Value 2070`true` if successful, otherwise `nil` and an error message 2071 2072[Back to top](#table-of-contents) 2073 2074--- 2075### os.copyfile(_source_, _destination_) 2076Copies a file from one location to another. 2077 2078#### Arguments 2079_source_ - file system path to the file to be copied 2080_destination_ - path to the copy location 2081 2082#### Return Value 2083`true` if successful, otherwise `nil` and an error message 2084 2085[Back to top](#table-of-contents) 2086 2087--- 2088### os.findlib(_libname_) 2089Scans the well-known system locations looking for a binary file. 2090 2091#### Arguments 2092_libname_ - name of the library to locate. May be specified with (libX11.so) or without (X11) system-specified decorations. 2093 2094#### Return Value 2095The path containing the library file, if found. Otherwise, `nil`. 2096 2097[Back to top](#table-of-contents) 2098 2099--- 2100### os.get() 2101Identifies the currently-targeted operating system. 2102 2103#### Return Value 2104One of "bsd", "linux", "macosx", "solaris", or "windows" 2105 2106**Note:** This function returns the OS being targeted, which is not necessarily the same as the OS on which GENie is being run. 2107 2108#### Example 2109 2110```lua 2111if os.get() == "windows" then 2112 -- do something windows-specific 2113end 2114``` 2115 2116[Back to top](#table-of-contents) 2117 2118--- 2119### os.getcwd() 2120Gets the current working directory. 2121 2122#### Return Value 2123The current working directory 2124 2125[Back to top](#table-of-contents) 2126 2127--- 2128### os.getversion() 2129Retrieves version information for the host operating system 2130 2131**Note:** Not implemented for all platforms. On unimplemented platforms, will return `0` for all version numbers, and the platform name as the description. 2132 2133#### Return Value 2134Table containing the following key-value pairs: 2135 2136| Key | Value | 2137| ------------ | -------------------------------------------- | 2138| majorversion | major version number | 2139| minorversion | minor version number | 2140| revision | bug fix release or service pack number | 2141| description | human-readable description of the OS version | 2142 2143 2144#### Examples 2145 2146```lua 2147local ver = os.getversion() 2148print(string.format(" %d.%d.%d (%s)", 2149 ver.majorversion, ver.minorversion, ver.revision, 2150 ver.description)) 2151 2152-- On Windows XP: "5.1.3 (Windows XP)" 2153-- On OSX: "10.6.6 (Mac OS X Snow Leopard)" 2154``` 2155 2156[Back to top](#table-of-contents) 2157 2158--- 2159### os.is(_id_) 2160Checks the current operating system identifier against a particular value 2161 2162#### Arguments 2163_id_ - one of "bsd", "linux", "macosx", "solaris", or "windows" 2164 2165**Note:** This function returns the OS being targeted, which is not necessarily the same as the OS on which GENie is being run. 2166 2167#### Return Value 2168`true` if the supplied _id_ matches the current operating system identifier, `false` otherwise. 2169 2170[Back to top](#table-of-contents) 2171 2172--- 2173### os.is64bit() 2174Determines if the host is using a 64-bit processor. 2175 2176#### Return Value 2177`true` if the host system has a 64-bit processor 2178`false` otherwise 2179 2180#### Examples 2181 2182```lua 2183if os.is64bit() then 2184 print("This is a 64-bit system") 2185else 2186 print("This is NOT a 64-bit system") 2187end 2188``` 2189 2190[Back to top](#table-of-contents) 2191 2192--- 2193### os.isdir(_path_) 2194Checks for the existence of a directory. 2195 2196#### Arguments 2197_path_ - the file system path to check 2198 2199#### Return Value 2200`true` if a matching directory is found 2201`false` if there is no such file system path, or if the path points to a file 2202 2203[Back to top](#table-of-contents) 2204 2205--- 2206### os.isfile(_path_) 2207Checks for the existence of a file. 2208 2209#### Arguments 2210_path_ - the file system path to check 2211 2212#### Return Value 2213`true` if a matching file is found 2214`false` if there is no such file system path or if the path points to a directory instead of a file 2215 2216[Back to top](#table-of-contents) 2217 2218--- 2219### os.matchdirs(_pattern_) 2220Performs a wildcard match to locate one or more directories. 2221 2222#### Arguments 2223_pattern_ - file system path to search. May [wildcard](#wildcard) patterns. 2224 2225#### Return Value 2226List of directories which match the specified pattern. May be empty. 2227 2228#### Examples 2229 2230```lua 2231matches = os.matchdirs("src/*") -- non-recursive match 2232matches = os.matchdirs("src/**") -- recursive match 2233matches = os.matchdirs("src/test*") -- may also match partial name 2234``` 2235 2236[Back to top](#table-of-contents) 2237 2238--- 2239### os.matchfiles(_patterns_) 2240Performs a wildcard match to locate one or more directories. 2241 2242#### Arguments 2243_pattern_ - file system path to search. May contain [wildcard](#wildcard) patterns. 2244 2245#### Return Value 2246List of files which match the specified pattern. May be empty. 2247 2248#### Examples 2249 2250```lua 2251matches = os.matchfiles("src/*.c") -- non-recursive match 2252matches = os.matchfiles("src/**.c") -- recursive match 2253``` 2254 2255[Back to top](#table-of-contents) 2256 2257--- 2258### os.mkdir(_path_) 2259Creates a new directory. 2260 2261#### Arguments 2262_path_ - path to be created 2263 2264#### Return Value 2265`true` if successful 2266`nil` and an error message otherwise 2267 2268[Back to top](#table-of-contents) 2269 2270--- 2271### os.outputof(_command_) 2272Runs a shell command and returns the output. 2273 2274#### Arguments 2275_command_ - shell command to run 2276 2277#### Return Value 2278The output of the command 2279 2280#### Examples 2281 2282```lua 2283-- Get the ID for the host processor architecture 2284local proc = os.outputof("uname -p") 2285``` 2286 2287[Back to top](#table-of-contents) 2288 2289--- 2290### os.pathsearch(_fname_, _paths..._) 2291description 2292 2293**Scope:** solutions, projects, configurations 2294 2295#### Arguments 2296_fname_ - name of the file being searched, followed by one or more path sets to be searched 2297_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 2298 2299#### Return Value 2300Path to the directory which contains the file, if found 2301`nil` otherwise 2302 2303#### Examples 2304 2305```lua 2306local p = os.pathsearch("mysystem.config", "./config:/usr/local/etc:/etc") 2307``` 2308 2309[Back to top](#table-of-contents) 2310 2311--- 2312### os.rmdir(_path_) 2313Removes an existing directory as well as any files or subdirectories it contains. 2314 2315#### Arguments 2316_path_ - file system path to be removed 2317 2318#### Return Value 2319`true` if successful 2320`nil` and an error message otherwise 2321 2322[Back to top](#table-of-contents) 2323 2324--- 2325### os.stat(_path_) 2326Retrieves information about a file. 2327 2328#### Arguments 2329_path_ - path to file for which to retrieve information 2330 2331#### Return Value 2332Table of values: 2333 2334| Key | Value | 2335| ----- | ----------------------- | 2336| mtime | Last modified timestamp | 2337| size | File size in bytes | 2338 2339[Back to top](#table-of-contents) 2340 2341--- 2342### userincludedirs({_paths_...}) 2343Specifies the user include file search paths. Multiple calls are concatenated. 2344 2345For XCode, it maps to setting the USER INCLUDE SEARCH PATH. 2346 2347For clang/gcc, it maps to setting the include directory using the iquote option. 2348 2349On the other build systems, it behaves like [includedirs](#includedirspaths). 2350 2351**Scope:** solutions, projects, configurations 2352 2353#### Arguments 2354_paths_ - list of user include file search directories, relative to the currently-executing script file. 2355 2356#### Examples 2357Define two include file search paths 2358 2359```lua 2360userincludedirs { "../lua/include", "../zlib" } 2361``` 2362 2363You can also use [wildcards](#wildcards) to match multiple directories. 2364 2365```lua 2366userincludedirs { "../includes/**" } 2367``` 2368 2369[Back to top](#table-of-contents) 2370 2371--- 2372### os.uuid(_name_) 2373Returns a Universally Unique Identifier 2374 2375#### Arguments 2376_name_ - (optional) string to be hashed 2377 2378#### Return Value 2379A 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 2380 2381[Back to top](#table-of-contents) 2382 2383--- 2384### path.getabsolute(_path_) 2385Converts relative path to absolute path 2386 2387#### Arguments 2388_path_ - the relative path to be converted 2389 2390#### Return Value 2391New absolute path, calculated from the current working directory 2392 2393[Back to top](#table-of-contents) 2394 2395--- 2396### path.getbasename(_path_) 2397Extracts base file portion of a path, with the directory and extension removed. 2398 2399#### Arguments 2400_path_ - path to be split 2401 2402#### Return Value 2403Base name portion of the path 2404 2405[Back to top](#table-of-contents) 2406 2407--- 2408### path.getdirectory(_path_) 2409Extracts directory portion of a path, with file name removed 2410 2411#### Arguments 2412_path_ - path to be split 2413 2414#### Return Value 2415Directory portion of the path 2416 2417[Back to top](#table-of-contents) 2418 2419--- 2420### path.getdrive(_path_) 2421Returns drive letter portion of a path 2422 2423#### Arguments 2424_path_ - path to be split 2425 2426#### Return Value 2427Drive letter portion of the path, or `nil` 2428 2429[Back to top](#table-of-contents) 2430 2431--- 2432### path.getextension(_path_) 2433Returns file extension portion of a path 2434 2435#### Arguments 2436_path_ - path to be split 2437 2438#### Return Value 2439File extension portion of the path, or an empty string 2440 2441[Back to top](#table-of-contents) 2442 2443--- 2444### path.getname(_path_) 2445Returns file name and extension, removes directory information. 2446 2447#### Arguments 2448_path_ - path to be split 2449 2450#### Return Value 2451File name and extension without directory information 2452 2453[Back to top](#table-of-contents) 2454 2455--- 2456### path.getrelative(_src_, _dest_) 2457Computes relative path from one directory to another. 2458 2459#### Arguments 2460_src_ - originating directory 2461_dest_ - target directory 2462 2463#### Return Value 2464Relative path from _src_ to _dest_ 2465 2466[Back to top](#table-of-contents) 2467 2468--- 2469### path.isabsolute(_path_) 2470Returns whether or not a path is absolute. 2471 2472#### Arguments 2473_path_ - path to check 2474 2475#### Return Value 2476`true` if path is absolute 2477`false` otherwise 2478 2479[Back to top](#table-of-contents) 2480 2481--- 2482### path.iscfile(_path_) 2483Determines whether file is a C source code file, based on extension. 2484 2485#### Arguments 2486_path_ - path to check 2487 2488#### Return Value 2489`true` if path uses a C file extension 2490`false` otherwise 2491 2492[Back to top](#table-of-contents) 2493 2494--- 2495### path.isSourceFile(_path_) 2496Determines whether a file is a C++ source code file, based on extension. 2497 2498#### Arguments 2499_path_ - path to check 2500 2501#### Return Value 2502`true` if path uses a C++ file extension 2503`false` otherwise 2504 2505[Back to top](#table-of-contents) 2506 2507--- 2508### path.isresourcefile(_path_) 2509Determines whether a path represends a Windows resource file, based on extension. 2510 2511#### Arguments 2512_path_ - path to check 2513 2514#### Return Value 2515`true` if path uses a well-known Windows resource file extension 2516`false` otherwise 2517 2518[Back to top](#table-of-contents) 2519 2520--- 2521### path.join(_leading_, _trailing_) 2522Joins two path portions together into a single path. 2523 2524**Note:** if _trailing_ is an absolute path, then _leading_ is ignored and the absolute path is returned. 2525 2526#### Arguments 2527_leading_ - beginning portion of the path 2528_trailing_ - ending portion of the path 2529 2530#### Return Value 2531Merged path 2532 2533#### Examples 2534 2535```lua 2536-- returns "MySolution/MyProject" 2537p = path.join("MySolution", "MyProject") 2538 2539-- returns "/usr/bin", because the trailing path is absolute 2540p = path.join("MySolution", "/usr/bin") 2541 2542-- tokens are assumed to be absolute. This returns `${ProjectDir}` 2543p = path.join("MySolution", "$(ProjectDir)") 2544``` 2545 2546[Back to top](#table-of-contents) 2547 2548--- 2549### path.rebase(_path_, _oldbase_, _newbase_) 2550Takes a relative path and makes it relative to a different location. 2551 2552#### Arguments 2553_path_ - path to be modified 2554_oldbase_ - original base directory, from which _path_ is relative 2555_newbase_ - the new base directory, from where the resulting path should be relative 2556 2557#### Return Value 2558Rebased path 2559 2560[Back to top](#table-of-contents) 2561 2562--- 2563### path.translate(_path_, _newsep_) 2564Converts the separators in a path. 2565 2566#### Arguments 2567_path_ - path to modify 2568_newsep_ - new path separator. Defaults to current environment default. 2569 2570#### Return Value 2571Modified path 2572 2573[Back to top](#table-of-contents) 2574--- 2575 2576### printf(_format_, _args_...) 2577Prints a formatted string 2578 2579#### Arguments 2580_format_ - formatting string, containing C `printf()` formatting codes 2581_args_ - arguments to be substituted into the format string 2582 2583[Back to top](#table-of-contents) 2584 2585--- 2586### string.endswith(_haystack_, _needle_) 2587Checks if the given _haystack_ string ends with _needle_. 2588 2589#### Arguments 2590_haystack_ - string to search within 2591_needle_ - string to check ending of _haystack_ against 2592 2593#### Return Value 2594`true` - _haystack_ ends with _needle_ 2595`false` - _haystack_ does not end with _needle_ 2596 2597[Back to top](#table-of-contents) 2598 2599--- 2600### string.explode(_str_, _pattern_) 2601Breaks a string into an array of strings, formed by splitting _str_ on _pattern_. 2602 2603#### Arguments 2604_str_ - string to be split 2605_pattern_ - separator pattern at which to split; may use Lua's pattern matching syntax 2606 2607#### Return Value 2608List of substrings 2609 2610[Back to top](#table-of-contents) 2611 2612--- 2613### string.findlast(_str_, _pattern_, _plain_) 2614Finds the last instance of a pattern within a string. 2615 2616#### Arguments 2617_str_ - string to be searched 2618_pattern_ - pattern to search for; may use Lua's pattern matching syntax 2619_plain_ - whether or not plain string comparison should be used (rather than pattern-matching) 2620 2621#### Return Value 2622The matching pattern, if found, or `nil` 2623 2624[Back to top](#table-of-contents) 2625 2626--- 2627### string.startswith(_haystack_, _needle_) 2628Checks if the given _haystack_ starts with _needle_. 2629 2630#### Arguments 2631_haystack_ - string to search within 2632_needle_ - string to check start of _haystack_ against 2633 2634#### Return Value 2635`true` - _haystack_ starts with _needle_ 2636`false` - _haystack_ does not start with _needle_ 2637 2638[Back to top](#table-of-contents) 2639 2640--- 2641### table.contains(_array_, _value_) 2642Determines if a _array_ contains _value_. 2643 2644#### Arguments 2645_array_ - table to test for _value_ 2646_value_ - _value_ being tested for 2647 2648#### Return Value 2649`true` - _array_ contains _value_ 2650`false` - _array_ does not contain _value_ 2651 2652[Back to top](#table-of-contents) 2653 2654--- 2655### table.implode(_array_, _before_, _after_, _between_) 2656Merges an array of items into a single formatted string. 2657 2658#### Arguments 2659_array_ - table to be converted into a string 2660_before_ - string to be inserted before each item 2661_after_ - string to be inserted after each item 2662_between_ - string to be inserted between each item 2663 2664#### Return Value 2665Formatted string 2666 2667[Back to top](#table-of-contents) 2668 2669--- 2670 2671## Additional information 2672 2673### Wildcards 2674 2675In some places, wildcards may be used in string values passed to a function. Usually, these strings represent paths. There are two types of wildcards: 2676 2677* `*` - matches files within a single directory 2678* `**` - matches files recursively in any child directory 2679