_preload.lua 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. --
  2. -- Name: d/_preload.lua
  3. -- Purpose: Define the D language API's.
  4. -- Author: Manu Evans
  5. -- Created: 2013/10/28
  6. -- Copyright: (c) 2013-2015 Manu Evans and the Premake project
  7. --
  8. -- TODO:
  9. -- MonoDevelop/Xamarin Studio has 'workspaces', which correspond to collections
  10. -- of Premake workspaces. If premake supports multiple workspaces, we should
  11. -- write out a workspace file...
  12. local p = premake
  13. local api = p.api
  14. --
  15. -- Register the D extension
  16. --
  17. p.D = "D"
  18. api.addAllowed("language", p.D)
  19. api.addAllowed("floatingpoint", "None")
  20. api.addAllowed("flags", {
  21. "CodeCoverage",
  22. "Color",
  23. "Documentation",
  24. "GenerateHeader",
  25. "GenerateJSON",
  26. "GenerateMap",
  27. "LowMem",
  28. "Profile",
  29. "Quiet",
  30. "RetainPaths",
  31. "SymbolsLikeC",
  32. "UnitTest",
  33. -- These are used by C++/D mixed $todo move them somewhere else? "flags2" "Dflags"?
  34. -- [Code Generation Flags]
  35. "UseLDC",
  36. "ProfileGC",
  37. "StackFrame",
  38. "StackStomp",
  39. "AllInstantiate",
  40. "BetterC",
  41. "Main",
  42. "PerformSyntaxCheckOnly",
  43. -- [Messages Flags]
  44. "ShowCommandLine",
  45. "Verbose",
  46. "ShowTLS",
  47. "ShowGC",
  48. "IgnorePragma",
  49. "ShowDependencies",
  50. })
  51. api.addAllowed("toolset", {
  52. "dmd",
  53. "gdc",
  54. "ldc",
  55. })
  56. --
  57. -- Register some D specific properties
  58. --
  59. api.register {
  60. name = "boundscheck",
  61. scope = "config",
  62. kind = "string",
  63. allowed = {
  64. "Default",
  65. "Off",
  66. "On",
  67. "SafeOnly",
  68. },
  69. }
  70. api.register {
  71. name = "compilationmodel",
  72. scope = "config",
  73. kind = "string",
  74. allowed = {
  75. "Default",
  76. "File",
  77. "Package", -- TODO: this doesn't work with gmake!!
  78. "Project",
  79. },
  80. }
  81. api.register {
  82. name = "checkaction",
  83. scope = "config",
  84. kind = "string",
  85. allowed = {
  86. "Default",
  87. "D",
  88. "C",
  89. "Halt",
  90. "Context",
  91. },
  92. }
  93. api.register {
  94. name = "computetargets",
  95. scope = "config",
  96. kind = "list:string",
  97. }
  98. -- api.register {
  99. -- name = "debugcode",
  100. -- scope = "config",
  101. -- kind = "string",
  102. -- }
  103. api.register {
  104. name = "debugconstants",
  105. scope = "config",
  106. kind = "list:string",
  107. tokens = true,
  108. }
  109. api.register {
  110. name = "debuglevel",
  111. scope = "config",
  112. kind = "integer",
  113. }
  114. api.register {
  115. name = "dependenciesfile",
  116. scope = "config",
  117. kind = "path",
  118. tokens = true,
  119. }
  120. api.register {
  121. name = "deprecatedfeatures",
  122. scope = "config",
  123. kind = "string",
  124. allowed = {
  125. "Default",
  126. "Allow",
  127. "Warn",
  128. "Error",
  129. },
  130. }
  131. api.register {
  132. name = "docdir",
  133. scope = "config",
  134. kind = "path",
  135. tokens = true,
  136. }
  137. api.register {
  138. name = "docname",
  139. scope = "config",
  140. kind = "string",
  141. tokens = true,
  142. }
  143. api.register {
  144. name = "headerdir",
  145. scope = "config",
  146. kind = "path",
  147. tokens = true,
  148. }
  149. api.register {
  150. name = "headername",
  151. scope = "config",
  152. kind = "string",
  153. tokens = true,
  154. }
  155. api.register {
  156. name = "jsonfile",
  157. scope = "config",
  158. kind = "path",
  159. tokens = true,
  160. }
  161. api.register {
  162. name = "importdirs",
  163. scope = "config",
  164. kind = "list:path",
  165. tokens = true,
  166. }
  167. api.register {
  168. name = "preview",
  169. scope = "config",
  170. kind = "list:string",
  171. allowed = {
  172. "dip25",
  173. "dip1000",
  174. "dip1008",
  175. "fieldwise",
  176. "markdown",
  177. "fixAliasThis",
  178. "intpromote",
  179. "dtorfields",
  180. },
  181. }
  182. api.register {
  183. name = "revert",
  184. scope = "config",
  185. kind = "list:string",
  186. allowed = {
  187. "dip25",
  188. "import",
  189. },
  190. }
  191. api.register {
  192. name = "stringimportdirs",
  193. scope = "config",
  194. kind = "list:path",
  195. tokens = true,
  196. }
  197. api.register {
  198. name = "transition",
  199. scope = "config",
  200. kind = "list:string",
  201. allowed = {
  202. "field",
  203. "checkimports",
  204. "complex",
  205. "tls",
  206. "vmarkdown",
  207. },
  208. }
  209. api.register {
  210. name = "versionconstants",
  211. scope = "config",
  212. kind = "list:string",
  213. tokens = true,
  214. }
  215. api.register {
  216. name = "versionlevel",
  217. scope = "config",
  218. kind = "integer",
  219. }
  220. --
  221. -- Provide information for the help output
  222. --
  223. newoption
  224. {
  225. category = "compilers",
  226. trigger = "dc",
  227. value = "VALUE",
  228. description = "Choose a D compiler",
  229. allowed = {
  230. { "dmd", "Digital Mars (dmd)" },
  231. { "gdc", "GNU GDC (gdc)" },
  232. { "ldc", "LLVM LDC (ldc2)" },
  233. }
  234. }
  235. --
  236. -- Decide when to load the full module
  237. --
  238. return function (cfg)
  239. return (cfg.language == p.D or cfg.language == "C" or cfg.language == "C++")
  240. end