Search code examples
premake

Why isn't an action being added in premake4?


I'm trying to add an action named "dummy", using premake4.

Here's my premake4 lua script:

-- For reference, please refer to the premake wiki:
-- https://github.com/premake/premake-core/wiki

-- Demonstrates creating new actions:
-- dummy

--#!lua

-- A solution contains projects,
-- and defines the available configurations
solution "hello-world"
   configurations { "Debug", "Release" }

   -- A project defines one build target
   project "hello-world"
      kind "ConsoleApp"
      language "C++"
      files { "**.h", "**.cpp" }

      configuration "Debug"
         defines { "DEBUG" }
         flags { "Symbols" }

      configuration "Release"
         defines { "NDEBUG" }
         flags { "Optimize" }


premake.dummy = {}

-- Register the "runmakefile" action.
newaction
{
   trigger = "dummy",
   description = "dummy",
   execute = function()
     print("** dummy")
   end
}


I have generated the makefile, but it doesn't contain any action named "dummy".

What am I doing wrong and what should I really be doing?


Solution

  • newaction adds an action to Premake, not the generated project files. You would execute your action by running this at a command prompt:

    premake4 dummy
    

    Premake4 does not provide a way to add custom targets to the generated Makefiles. Premake5 provides makesettings to add arbitrary rules to a makefile.