A Sample Script

Premake is built on Lua, a powerful, fast, light-weight scripting language. Premake scripts are really Lua programs, so anything you can do in Lua can also be done in a Premake script. To this, Premake adds functions for defining solutions, projects, and configurations as well as support for common build configuration tasks. Premake also provides conventions for defining and handling command line options and actions, allowing you to build sophisticated configuration scripts.

Because of the descriptive nature of the Lua language, your build scripts will often look more like static configuration files than mini-programs. Here is an example of a fairly typical Premake script for a C++ executable. See the Premake Cookbook for more examples of common configuration tasks.

-- A solution contains projects, and defines the available configurations
solution "MyApplication"
   configurations { "Debug", "Release" }
 
   -- A project defines one build target
   project "MyApplication"
      kind "ConsoleApp"
      language "C++"
      files { "**.h", "**.cpp" }
 
      configuration "Debug"
         defines { "DEBUG" }
         flags { "Symbols" }
 
      configuration "Release"
         defines { "NDEBUG" }
         flags { "Optimize" }    

The indentation in this sample is arbitrary, this is the way I happen to like it.

The following sections of this guide will walk you through all of the features of Premake in a somewhat logical fashion. It isn't rocket science, and you probably already have the gist of it from the example above, so feel free to skip around. You can also refer to the Reference section or the Lua Reference Manual for information on a particular function or variable.

Right here, you need to say what file this actually goes into. In fact, I've read about 10 pages and not once do you mention the file anything goes in. It's just all disconnected blobs of lua floating on a web page.

Good point, @Anonymous. I'll take a pass over it and see if I can tie it together.

Why did you say that "The indentation in this sample is arbitrary"? IMHO, it's not at all.

It would be nice to mention that this file is probably called "premake4.lua". (Right?)

Anonymous is right. I had to run premake4 --help to know which file is loaded by default.

Why did you say that "The indentation in this sample is arbitrary"? IMHO, it's not at all.

It's Lua. Lua ignores indentation. The indentation is purely for readability, it doesn't mean anything to the computer.

This is NOT Python.