A new version is available!

Premake 4.0 is now available at our new website.

This page describes Premake 3.7, the last release in the 3.x series.

Functions and Variables

Premake adds a number of functions and variables to the standard Lua runtime environment.

Functions

addoption(option, desc) Document a supported command-line option. See Options and Commands
dopackage(path) Calls an external package script.
matchdirs(pattern, ...) Returns a list of directories that match the provided set of patterns.
matchfiles(pattern, ...) Returns a list of files that match the provided set of patterns.
matchrecursive(pattern, ...) Like matchfiles(), but recurses into subdirectories.
newpackage() Creates a new, empty package.
os.appendfile(src, dest) Append one file to another.
os.chdir(path) Change the current working directory.
os.copyfile(src, dest) Copy a file.
os.direxists(filename) Checks for the existence of a directory.
os.fileexists(filename) Checks for the existence of a file.
os.findlib(library) Searches for a library file on the system. If found, returns the path to the library.
os.getcwd() Returns the current working directory.
os.mkdir(path) Creates a new directory on the disk.
os.rmdir(path) Removes a directory from the disk.
path.getbasename(path) Gets the filename from a path, with no fileextension.
path.getdir(path) Gets the directory name from a full path.
path.getextension(path) Gets the file extension.
path.getname(path) Gets the filename from a full path.

Variables

bsd Set to true if running on a BSD system
linux Set to true if running on a Linux system.
macosx Set to true if running on a MacOS X system
options A list of the options encountered on the command-line. See Options and Commands, above.
OS A string representing the current operating system. Values include “windows”, “linux”, “freebsd”, “netbsd”, “openbsd”, and “macosx”.
target The current target toolset, as set with the --target command-line flag.
windows Set to true if running on a MS Windows system.