PageRenderTime 44ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/tutorial/build/premake4.lua

https://bitbucket.org/orx/orx
Lua | 335 lines | 187 code | 96 blank | 52 comment | 10 complexity | 011f81cfa874a113a705af9116d9670f MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0, BSD-3-Clause
  1. -- This premake script should be used with orx-customized version of premake4.
  2. -- Its Hg repository can be found at https://bitbucket.org/orx/premake-stable.
  3. -- A copy, including binaries, can also be found in the extern/premake folder.
  4. --
  5. -- Globals
  6. --
  7. function islinux64 ()
  8. local pipe = io.popen ("uname -m")
  9. local content = pipe:read ('*a')
  10. pipe:close ()
  11. local t64 =
  12. {
  13. 'x86_64',
  14. 'ia64',
  15. 'amd64',
  16. 'powerpc64',
  17. 'sparc64'
  18. }
  19. for i, v in ipairs (t64) do
  20. if content:find (v) then
  21. return true
  22. end
  23. end
  24. return false
  25. end
  26. function initconfigurations ()
  27. return
  28. {
  29. "Debug",
  30. "Profile",
  31. "Release"
  32. }
  33. end
  34. function initplatforms ()
  35. if os.is ("windows") then
  36. return
  37. {
  38. "Native"
  39. }
  40. elseif os.is ("linux") then
  41. if islinux64 () then
  42. return
  43. {
  44. "x64",
  45. "x32"
  46. }
  47. else
  48. return
  49. {
  50. "x32",
  51. "x64"
  52. }
  53. end
  54. elseif os.is ("macosx") then
  55. return
  56. {
  57. "x64",
  58. "x32"
  59. }
  60. end
  61. end
  62. function defaultaction (name, action)
  63. if os.is (name) then
  64. _ACTION = _ACTION or action
  65. end
  66. end
  67. defaultaction ("windows", "vs2010")
  68. defaultaction ("linux", "gmake")
  69. defaultaction ("macosx", "gmake")
  70. newoption
  71. {
  72. trigger = "to",
  73. value = "path",
  74. description = "Set the output location for the generated files"
  75. }
  76. if os.is ("macosx") then
  77. osname = "mac"
  78. else
  79. osname = os.get()
  80. end
  81. destination = _OPTIONS["to"] or "./" .. osname .. "/" .. _ACTION
  82. copybase = path.rebase ("..", os.getcwd (), os.getcwd () .. "/" .. destination)
  83. --
  84. -- Solution: orx
  85. --
  86. solution "Tutorial"
  87. language ("C")
  88. location (destination)
  89. kind ("ConsoleApp")
  90. configurations
  91. {
  92. initconfigurations ()
  93. }
  94. platforms
  95. {
  96. initplatforms ()
  97. }
  98. includedirs
  99. {
  100. "../include",
  101. "../../code/include"
  102. }
  103. libdirs
  104. {
  105. "../lib",
  106. "../../code/lib/dynamic"
  107. }
  108. targetdir ("../bin")
  109. flags
  110. {
  111. "NoPCH",
  112. "NoManifest",
  113. "EnableSSE2",
  114. "FloatFast",
  115. "NoNativeWChar",
  116. "NoExceptions",
  117. "Symbols",
  118. "StaticRuntime"
  119. }
  120. configuration {"not windows"}
  121. flags {"Unicode"}
  122. configuration {"*Debug*"}
  123. defines {"__orxDEBUG__"}
  124. links {"orxd"}
  125. configuration {"*Profile*"}
  126. defines {"__orxPROFILER__"}
  127. flags {"Optimize", "NoRTTI"}
  128. links {"orxp"}
  129. configuration {"*Release*"}
  130. flags {"Optimize", "NoRTTI"}
  131. links {"orx"}
  132. -- Linux
  133. configuration {"linux"}
  134. linkoptions {"-Wl,-rpath ./", "-Wl,--export-dynamic"}
  135. links
  136. {
  137. "dl",
  138. "m",
  139. "rt"
  140. }
  141. -- This prevents an optimization bug from happening with some versions of gcc on linux
  142. configuration {"linux", "not *Debug*"}
  143. buildoptions {"-fschedule-insns"}
  144. -- Mac OS X
  145. configuration {"macosx"}
  146. buildoptions
  147. {
  148. "-isysroot /Developer/SDKs/MacOSX10.6.sdk",
  149. "-mmacosx-version-min=10.6",
  150. "-gdwarf-2",
  151. "-Wno-write-strings"
  152. }
  153. links
  154. {
  155. "Foundation.framework",
  156. "AppKit.framework"
  157. }
  158. linkoptions
  159. {
  160. "-isysroot /Developer/SDKs/MacOSX10.6.sdk",
  161. "-mmacosx-version-min=10.6",
  162. "-dead_strip"
  163. }
  164. configuration {"macosx", "x32"}
  165. buildoptions
  166. {
  167. "-mfix-and-continue"
  168. }
  169. -- Windows
  170. --
  171. -- Project: 01_Object
  172. --
  173. project "01_Object"
  174. files {"../src/01_Object.c"}
  175. -- Linux
  176. configuration {"linux"}
  177. postbuildcommands {"$(shell [ -f " .. copybase .. "/../code/lib/dynamic/liborx.so ] && cp -f " .. copybase .. "/../code/lib/dynamic/liborx*.so " .. copybase .. "/bin)"}
  178. -- Mac OS X
  179. configuration {"macosx"}
  180. postbuildcommands {"$(shell [ -f " .. copybase .. "/../code/lib/dynamic/liborx.dylib ] && cp -f " .. copybase .. "/../code/lib/dynamic/liborx*.dylib " .. copybase .. "/bin)"}
  181. -- Windows
  182. configuration {"windows"}
  183. postbuildcommands {"cmd /c if exist " .. path.translate(copybase, "\\") .. "\\..\\code\\lib\\dynamic\\orx.dll copy /Y " .. path.translate(copybase, "\\") .. "\\..\\code\\lib\\dynamic\\orx*.dll " .. path.translate(copybase, "\\") .. "\\bin"}
  184. --
  185. -- Project: 02_Clock
  186. --
  187. project "02_Clock"
  188. files {"../src/02_Clock.c"}
  189. --
  190. -- Project: 03_Frame
  191. --
  192. project "03_Frame"
  193. files {"../src/03_Frame.c"}
  194. --
  195. -- Project: 04_Anim
  196. --
  197. project "04_Anim"
  198. files {"../src/04_Anim.c"}
  199. --
  200. -- Project: 05_Viewport
  201. --
  202. project "05_Viewport"
  203. files {"../src/05_Viewport.c"}
  204. --
  205. -- Project: 06_Sound
  206. --
  207. project "06_Sound"
  208. files {"../src/06_Sound.c"}
  209. --
  210. -- Project: 07_FX
  211. --
  212. project "07_FX"
  213. files {"../src/07_FX.c"}
  214. --
  215. -- Project: 08_Physics
  216. --
  217. project "08_Physics"
  218. files {"../src/08_Physics.c"}
  219. --
  220. -- Project: 09_Scrolling
  221. --
  222. project "09_Scrolling"
  223. files {"../src/09_Scrolling.c"}
  224. --
  225. -- Project: 10_Locale
  226. --
  227. project "10_Locale"
  228. language ("C++")
  229. files {"../src/10_Locale.cpp"}
  230. --
  231. -- Project: 11_Spawner
  232. --
  233. project "11_Spawner"
  234. files {"../src/11_Spawner.c"}
  235. --
  236. -- Project: 12_Lighting
  237. --
  238. project "12_Lighting"
  239. files {"../src/12_Lighting.c"}