Skip to main content

newaction

Registers a new command-line action argument. For more information, see Command Line Arguments.

newaction { description }

Parameters

description is a table describing the new action. It may contain the following fields:

FieldDescription
triggerWhat the user would type on the command line to select the action, e.g. "vs2013".
shortnameA short summary for the help text, e.g. "Visual Studio 2013".
descriptionA description of the action's result, e.g. "Generate Visual Studio 2013 project files".
executeA function to be executed when the action is fired.
targetosIf the toolset targets a specific OS, the identifier for that OS.
valid_kindsThe list of project kinds supported by the action.
valid_languagesThe list of languages supported by the action.
valid_toolsThe list of tools supported by the action.
toolsetDefault tools.
onStartA callback marking the start of action processing.
onWorkspaceA callback for each workspace specified in the user script.
onProjectA callback for each project specified in the user script.
onRuleA callback for each rule specified in the user script.
onEndA callback marking the end of action processing.
onCleanWorkspaceA callback for each workspace, when the clean action is selected.
onCleanProjectA callback for each project, when the clean action is selected.
onCleanTargetA callback for each target, when the clean action is selected.
pathVarsA map of Premake tokens to toolset specific identifiers.
aliasesA list of action names to alias to this action.
deprecatedaliasesA table containing a mapping of aliases to callbacks to invoke on action invocation and filters containing the deprecated alias. Each value in the deprecatedaliases table is a table optionally containing an "action" and "filter" key. The values in this table are functions taking zero arguments. See the example below.

The callbacks will fire in this order:

  1. onStart() 2a. onWorkspace() for each workspace 2b. onProject() for each project in each workspace
  2. onRule() for each rule
  3. execute()
  4. onEnd()
caution

The following fields have been deprecated:

FieldDescription
osDeprecated, use targetos instead.
onSolutionDeprecated, use onWorkspace instead.

Availability

Premake 5.0 and later.

Examples

Register a new action to install the software project.

newaction {
trigger = "install",
description = "Install the software",
execute = function ()
os.copyfile("bin/debug/myprogram", "/usr/local/bin/myprogram")
end
}

Register a new action with aliases and deprecations.

newaction {
trigger = "myaction",
description = "Custom action",
aliases = { "myalias", "deprecatedalias" },
deprecatedaliases = {
["deprecatedalias" ] = {
[ "action" ] = function()
p.warn("Use myaction instead of deprecatedalias.")
end,
[ "filter" ] = function()
p.warn("deprecatedalias has been deprecated. Filter on myaction instead.")
end
}
}
}

See Also