_preload.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. --
  2. -- Name: gmake2/_preload.lua
  3. -- Purpose: Define the gmake2 action.
  4. -- Author: Blizzard Entertainment (Tom van Dijck)
  5. -- Modified by: Aleksi Juvani
  6. -- Vlad Ivanov
  7. -- Created: 2016/01/01
  8. -- Copyright: (c) 2016-2017 Jason Perkins, Blizzard Entertainment and the Premake project
  9. --
  10. local p = premake
  11. local project = p.project
  12. newaction {
  13. trigger = "gmake2",
  14. shortname = "Alternative GNU Make",
  15. description = "Generate GNU makefiles for POSIX, MinGW, and Cygwin",
  16. toolset = "gcc",
  17. valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Utility", "Makefile" },
  18. valid_languages = { "C", "C++", "C#" },
  19. valid_tools = {
  20. cc = { "clang", "gcc" },
  21. dotnet = { "mono", "msnet", "pnet" }
  22. },
  23. onInitialize = function()
  24. require("gmake2")
  25. p.modules.gmake2.cpp.initialize()
  26. end,
  27. onWorkspace = function(wks)
  28. p.escaper(p.modules.gmake2.esc)
  29. p.generate(wks, p.modules.gmake2.getmakefilename(wks, false), p.modules.gmake2.generate_workspace)
  30. end,
  31. onProject = function(prj)
  32. p.escaper(p.modules.gmake2.esc)
  33. local makefile = p.modules.gmake2.getmakefilename(prj, true)
  34. if prj.kind == p.UTILITY then
  35. p.generate(prj, makefile, p.modules.gmake2.utility.generate)
  36. elseif prj.kind == p.MAKEFILE then
  37. p.generate(prj, makefile, p.modules.gmake2.makefile.generate)
  38. else
  39. if project.isdotnet(prj) then
  40. p.generate(prj, makefile, p.modules.gmake2.cs.generate)
  41. elseif project.isc(prj) or project.iscpp(prj) then
  42. p.generate(prj, makefile, p.modules.gmake2.cpp.generate)
  43. end
  44. end
  45. end,
  46. onCleanWorkspace = function(wks)
  47. p.clean.file(wks, p.modules.gmake2.getmakefilename(wks, false))
  48. end,
  49. onCleanProject = function(prj)
  50. p.clean.file(prj, p.modules.gmake2.getmakefilename(prj, true))
  51. end
  52. }
  53. --
  54. -- Decide when the full module should be loaded.
  55. --
  56. return function(cfg)
  57. return (_ACTION == "gmake2")
  58. end