1
0

test_helpers.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. ---
  2. -- test_helpers.lua
  3. --
  4. -- Helper functions for setting up workspaces and projects, etc.
  5. --
  6. -- Author Jason Perkins
  7. -- Copyright (c) 2008-2016 Jason Perkins and the Premake project.
  8. ---
  9. local p = premake
  10. local m = p.modules.self_test
  11. function m.createWorkspace()
  12. local wks = workspace("MyWorkspace")
  13. configurations { "Debug", "Release" }
  14. local prj = m.createProject(wks)
  15. return wks, prj
  16. end
  17. -- Eventually we'll want to deprecate this one and move everyone
  18. -- over to createWorkspace() instead (4 Sep 2015).
  19. function m.createsolution()
  20. local wks = workspace("MySolution")
  21. configurations { "Debug", "Release" }
  22. local prj = m.createproject(wks)
  23. return wks, prj
  24. end
  25. function m.createProject(wks)
  26. local n = #wks.projects + 1
  27. if n == 1 then n = "" end
  28. local prj = project ("MyProject" .. n)
  29. language "C++"
  30. kind "ConsoleApp"
  31. return prj
  32. end
  33. function m.createGroup(wks)
  34. local prj = group ("MyGroup" .. (#wks.groups + 1))
  35. return prj
  36. end
  37. function m.getWorkspace(wks)
  38. p.oven.bake()
  39. return p.global.getWorkspace(wks.name)
  40. end
  41. function m.getRule(name)
  42. p.oven.bake()
  43. return p.global.getRule(name)
  44. end
  45. function m.getProject(wks, i)
  46. wks = m.getWorkspace(wks)
  47. return p.workspace.getproject(wks, i or 1)
  48. end
  49. function m.getConfig(prj, buildcfg, platform)
  50. local wks = m.getWorkspace(prj.workspace)
  51. prj = p.workspace.getproject(wks, prj.name)
  52. return p.project.getconfig(prj, buildcfg, platform)
  53. end
  54. m.print = print
  55. p.alias(m, "createProject", "createproject")
  56. p.alias(m, "getConfig", "getconfig")
  57. p.alias(m, "getProject", "getproject")
  58. p.alias(m, "getWorkspace", "getsolution")