test_targets.lua 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. --
  2. -- tests/test_targets.lua
  3. -- Automated test suite for premake.gettarget()
  4. -- Copyright (c) 2008, 2009 Jason Perkins and the Premake project
  5. --
  6. T.targets = { }
  7. local cfg
  8. function T.targets.setup()
  9. cfg = { }
  10. cfg.basedir = "."
  11. cfg.location = "."
  12. cfg.targetdir = "../bin"
  13. cfg.language = "C++"
  14. cfg.project = { name = "MyProject" }
  15. cfg.flags = { }
  16. cfg.objectsdir = "obj"
  17. cfg.platform = "Native"
  18. end
  19. --
  20. -- Path Style Name Style Example Environment
  21. -- ---------- ---------- -------------------
  22. -- windows windows VStudio with MSC
  23. -- posix posix GMake with GCC
  24. -- windows posix VStudio for PS3
  25. -- posix windows GMake for .NET
  26. --
  27. --
  28. -- ConsoleApp tests
  29. --
  30. function T.targets.ConsoleApp_Build_WindowsNames()
  31. cfg.kind = "ConsoleApp"
  32. result = premake.gettarget(cfg, "build", "posix", "windows", "macosx")
  33. test.isequal([[../bin/MyProject.exe]], result.fullpath)
  34. end
  35. function T.targets.ConsoleApp_Build_PosixNames_OnWindows()
  36. cfg.kind = "ConsoleApp"
  37. result = premake.gettarget(cfg, "build", "posix", "posix", "windows")
  38. test.isequal([[../bin/MyProject.exe]], result.fullpath)
  39. end
  40. function T.targets.ConsoleApp_Build_PosixNames_OnLinux()
  41. cfg.kind = "ConsoleApp"
  42. result = premake.gettarget(cfg, "build", "posix", "posix", "linux")
  43. test.isequal([[../bin/MyProject]], result.fullpath)
  44. end
  45. function T.targets.ConsoleApp_Build_PosixNames_OnMacOSX()
  46. cfg.kind = "ConsoleApp"
  47. result = premake.gettarget(cfg, "build", "posix", "posix", "macosx")
  48. test.isequal([[../bin/MyProject]], result.fullpath)
  49. end
  50. function T.targets.ConsoleApp_Build_PS3Names()
  51. cfg.kind = "ConsoleApp"
  52. result = premake.gettarget(cfg, "build", "posix", "PS3", "macosx")
  53. test.isequal([[../bin/MyProject.elf]], result.fullpath)
  54. end
  55. --
  56. -- WindowedApp tests
  57. --
  58. function T.targets.WindowedApp_Build_WindowsNames()
  59. cfg.kind = "WindowedApp"
  60. result = premake.gettarget(cfg, "build", "posix", "windows", "macosx")
  61. test.isequal([[../bin/MyProject.exe]], result.fullpath)
  62. end
  63. function T.targets.WindowedApp_Build_PosixNames_OnWindows()
  64. cfg.kind = "WindowedApp"
  65. result = premake.gettarget(cfg, "build", "posix", "posix", "windows")
  66. test.isequal([[../bin/MyProject.exe]], result.fullpath)
  67. end
  68. function T.targets.WindowedApp_Build_PosixNames_OnLinux()
  69. cfg.kind = "WindowedApp"
  70. result = premake.gettarget(cfg, "build", "posix", "posix", "linux")
  71. test.isequal([[../bin/MyProject]], result.fullpath)
  72. end
  73. function T.targets.WindowedApp_Build_PosixNames_OnMacOSX()
  74. cfg.kind = "WindowedApp"
  75. result = premake.gettarget(cfg, "build", "posix", "posix", "macosx")
  76. test.isequal([[../bin/MyProject.app/Contents/MacOS/MyProject]], result.fullpath)
  77. end
  78. function T.targets.WindowedApp_Build_PS3Names()
  79. cfg.kind = "WindowedApp"
  80. result = premake.gettarget(cfg, "build", "posix", "PS3", "macosx")
  81. test.isequal([[../bin/MyProject.elf]], result.fullpath)
  82. end
  83. --
  84. -- SharedLib tests
  85. --
  86. function T.targets.SharedLib_Build_WindowsNames()
  87. cfg.kind = "SharedLib"
  88. result = premake.gettarget(cfg, "build", "posix", "windows", "macosx")
  89. test.isequal([[../bin/MyProject.dll]], result.fullpath)
  90. end
  91. function T.targets.SharedLib_Link_WindowsNames()
  92. cfg.kind = "SharedLib"
  93. result = premake.gettarget(cfg, "link", "posix", "windows", "macosx")
  94. test.isequal([[../bin/MyProject.lib]], result.fullpath)
  95. end
  96. function T.targets.SharedLib_Build_PosixNames_OnWindows()
  97. cfg.kind = "SharedLib"
  98. result = premake.gettarget(cfg, "build", "posix", "posix", "windows")
  99. test.isequal([[../bin/MyProject.dll]], result.fullpath)
  100. end
  101. function T.targets.SharedLib_Link_PosixNames_OnWindows()
  102. cfg.kind = "SharedLib"
  103. result = premake.gettarget(cfg, "link", "posix", "posix", "windows")
  104. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  105. end
  106. function T.targets.SharedLib_Build_PosixNames_OnLinux()
  107. cfg.kind = "SharedLib"
  108. result = premake.gettarget(cfg, "build", "posix", "posix", "linux")
  109. test.isequal([[../bin/libMyProject.so]], result.fullpath)
  110. end
  111. function T.targets.SharedLib_Link_PosixNames_OnLinux()
  112. cfg.kind = "SharedLib"
  113. result = premake.gettarget(cfg, "link", "posix", "posix", "linux")
  114. test.isequal([[../bin/libMyProject.so]], result.fullpath)
  115. end
  116. function T.targets.SharedLib_Build_PosixNames_OnMacOSX()
  117. cfg.kind = "SharedLib"
  118. result = premake.gettarget(cfg, "build", "posix", "posix", "macosx")
  119. test.isequal([[../bin/libMyProject.dylib]], result.fullpath)
  120. end
  121. function T.targets.SharedLib_Link_PosixNames_OnMacOSX()
  122. cfg.kind = "SharedLib"
  123. result = premake.gettarget(cfg, "link", "posix", "posix", "macosx")
  124. test.isequal([[../bin/libMyProject.dylib]], result.fullpath)
  125. end
  126. --
  127. -- Bundle tests
  128. --
  129. function T.targets.Bundle_Build_WindowsNames()
  130. cfg.kind = "Bundle"
  131. result = premake.gettarget(cfg, "build", "posix", "windows", "macosx")
  132. test.isequal([[../bin/MyProject.dll]], result.fullpath)
  133. end
  134. function T.targets.Bundle_Link_WindowsNames()
  135. cfg.kind = "Bundle"
  136. result = premake.gettarget(cfg, "link", "posix", "windows", "macosx")
  137. test.isequal([[../bin/MyProject.lib]], result.fullpath)
  138. end
  139. function T.targets.Bundle_Build_PosixNames_OnWindows()
  140. cfg.kind = "Bundle"
  141. result = premake.gettarget(cfg, "build", "posix", "posix", "windows")
  142. test.isequal([[../bin/MyProject.dll]], result.fullpath)
  143. end
  144. function T.targets.Bundle_Link_PosixNames_OnWindows()
  145. cfg.kind = "Bundle"
  146. result = premake.gettarget(cfg, "link", "posix", "posix", "windows")
  147. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  148. end
  149. function T.targets.Bundle_Build_PosixNames_OnLinux()
  150. cfg.kind = "Bundle"
  151. result = premake.gettarget(cfg, "build", "posix", "posix", "linux")
  152. test.isequal([[../bin/libMyProject.so]], result.fullpath)
  153. end
  154. function T.targets.Bundle_Link_PosixNames_OnLinux()
  155. cfg.kind = "Bundle"
  156. result = premake.gettarget(cfg, "link", "posix", "posix", "linux")
  157. test.isequal([[../bin/libMyProject.so]], result.fullpath)
  158. end
  159. function T.targets.Bundle_Build_PosixNames_OnMacOSX()
  160. cfg.kind = "Bundle"
  161. result = premake.gettarget(cfg, "build", "posix", "posix", "macosx")
  162. test.isequal([[../bin/MyProject.bundle]], result.fullpath)
  163. end
  164. function T.targets.Bundle_Link_PosixNames_OnMacOSX()
  165. cfg.kind = "Bundle"
  166. result = premake.gettarget(cfg, "link", "posix", "posix", "macosx")
  167. test.isequal([[../bin/MyProject.bundle]], result.fullpath)
  168. end
  169. --
  170. -- StaticLib tests
  171. --
  172. function T.targets.StaticLib_Build_WindowsNames()
  173. cfg.kind = "StaticLib"
  174. result = premake.gettarget(cfg, "build", "posix", "windows", "macosx")
  175. test.isequal([[../bin/MyProject.lib]], result.fullpath)
  176. end
  177. function T.targets.StaticLib_Link_WindowsNames()
  178. cfg.kind = "StaticLib"
  179. result = premake.gettarget(cfg, "link", "posix", "windows", "macosx")
  180. test.isequal([[../bin/MyProject.lib]], result.fullpath)
  181. end
  182. function T.targets.StaticLib_Build_PosixNames_OnWindows()
  183. cfg.kind = "StaticLib"
  184. result = premake.gettarget(cfg, "build", "posix", "posix", "windows")
  185. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  186. end
  187. function T.targets.StaticLib_Link_PosixNames_OnWindows()
  188. cfg.kind = "StaticLib"
  189. result = premake.gettarget(cfg, "link", "posix", "posix", "windows")
  190. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  191. end
  192. function T.targets.StaticLib_Build_PosixNames_OnLinux()
  193. cfg.kind = "StaticLib"
  194. result = premake.gettarget(cfg, "build", "posix", "posix", "linux")
  195. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  196. end
  197. function T.targets.StaticLib_Link_PosixNames_OnLinux()
  198. cfg.kind = "StaticLib"
  199. result = premake.gettarget(cfg, "link", "posix", "posix", "linux")
  200. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  201. end
  202. function T.targets.StaticLib_Build_PosixNames_OnMacOSX()
  203. cfg.kind = "StaticLib"
  204. result = premake.gettarget(cfg, "build", "posix", "posix", "macosx")
  205. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  206. end
  207. function T.targets.StaticLib_Link_PosixNames_OnMacOSX()
  208. cfg.kind = "StaticLib"
  209. result = premake.gettarget(cfg, "link", "posix", "posix", "macosx")
  210. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  211. end
  212. function T.targets.StaticLib_Build_PosixNames_OnPS3()
  213. cfg.kind = "StaticLib"
  214. result = premake.gettarget(cfg, "build", "posix", "PS3", "macosx")
  215. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  216. end
  217. function T.targets.StaticLib_Link_PosixNames_OnPS3()
  218. cfg.kind = "StaticLib"
  219. result = premake.gettarget(cfg, "link", "posix", "PS3", "macosx")
  220. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  221. end
  222. function T.targets.StaticLib_Link_IgnoresImpLib()
  223. cfg.kind = "StaticLib"
  224. cfg.implibdir = "../lib"
  225. result = premake.gettarget(cfg, "link", "posix", "posix", "macosx")
  226. test.isequal([[../bin/libMyProject.a]], result.fullpath)
  227. end
  228. --
  229. -- Windows path tests
  230. --
  231. function T.targets.WindowsPaths()
  232. cfg.kind = "ConsoleApp"
  233. result = premake.gettarget(cfg, "build", "windows", "windows", "linux")
  234. test.isequal([[..\bin]], result.directory)
  235. test.isequal([[..\bin\MyProject.exe]], result.fullpath)
  236. end