premake/website/docs/buildcommands.md
2021-03-12 22:10:24 +01:00

1.5 KiB

Specifies one or more shell commands to be executed to build a project or file.

buildcommands { "commands" }

Parameters

commands specifies a list of one or more shell commands to be executed. The commands may use tokens.

Applies To

Makefile projects and per-file custom build commands.

Availability

Premake 5.0 or later.

Examples

Use per-file custom build commands to compile all Lua files in a project to C:

filter 'files:**.lua'
   -- A message to display while this build step is running (optional)
   buildmessage 'Compiling %{file.relpath}'

   -- One or more commands to run (required)
   buildcommands {
      'luac -o "%{cfg.objdir}/%{file.basename}.out" "%{file.relpath}"'
   }

   -- One or more outputs resulting from the build (required)
   buildoutputs { '%{cfg.objdir}/%{file.basename}.c' }

Use a Makefile project to execute an external makefile.

workspace "Workspace"
   configurations { "Debug", "Release" }

project "MyProject"
   kind "Makefile"

   buildcommands {
      "make %{cfg.buildcfg}"
   }

   cleancommands {
      "make clean %{cfg.buildcfg}"
   }

See Also