vs2013_vcxitems.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. --
  2. -- vs2013_vcxitems.lua
  3. -- Generate a Visual Studio 201x C/C++ shared items project.
  4. -- Copyright (c) Jason Perkins and the Premake project
  5. --
  6. local p = premake
  7. p.vstudio.vc2013 = {}
  8. local vstudio = p.vstudio
  9. local project = p.project
  10. local config = p.config
  11. local fileconfig = p.fileconfig
  12. local tree = p.tree
  13. local m = p.vstudio.vc2013
  14. local vc2010 = p.vstudio.vc2010
  15. ---
  16. -- Add namespace for element definition lists for p.callArray()
  17. ---
  18. m.elements = {}
  19. m.conditionalElements = {}
  20. --
  21. -- Generate a Visual Studio 201x C++ project, with support for the new platforms API.
  22. --
  23. m.elements.project = function(prj)
  24. return {
  25. vc2010.xmlDeclaration,
  26. m.project,
  27. m.globals,
  28. m.itemDefinitionGroup,
  29. m.itemGroup,
  30. vc2010.files,
  31. }
  32. end
  33. function m.generate(prj)
  34. p.utf8()
  35. p.callArray(m.elements.project, prj)
  36. p.out('</Project>')
  37. end
  38. --
  39. -- Output the XML declaration and opening <Project> tag.
  40. --
  41. function m.project(prj)
  42. p.push('<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">')
  43. end
  44. --
  45. -- Write out the Globals property group.
  46. --
  47. m.elements.globals = function(prj)
  48. return {
  49. m.msbuildAllProjects,
  50. m.hasSharedItems,
  51. m.itemsProjectGuid,
  52. m.itemsProjectName,
  53. }
  54. end
  55. function m.globals(prj)
  56. vc2010.propertyGroup(nil, "Globals")
  57. p.callArray(m.elements.globals, prj)
  58. p.pop('</PropertyGroup>')
  59. end
  60. function m.msbuildAllProjects(prj)
  61. vc2010.element("MSBuildAllProjects", nil, "$(MSBuildAllProjects);$(MSBuildThisFileFullPath)")
  62. end
  63. function m.hasSharedItems(prj)
  64. vc2010.element("HasSharedItems", nil, "true")
  65. end
  66. function m.itemsProjectGuid(prj)
  67. vc2010.element("ItemsProjectGuid", nil, "{%s}", prj.uuid)
  68. end
  69. function m.itemsProjectName(prj)
  70. if prj.name ~= prj.filename then
  71. vc2010.element("ItemsProjectName", nil, "%s", prj.name)
  72. end
  73. end
  74. --
  75. -- Write an item definition group, which contains all of the shared compile settings.
  76. --
  77. m.elements.itemDefinitionGroup = function(prj)
  78. return {
  79. m.clCompile,
  80. }
  81. end
  82. function m.itemDefinitionGroup(prj)
  83. p.push('<ItemDefinitionGroup>')
  84. p.callArray(m.elements.itemDefinitionGroup, prj)
  85. p.pop('</ItemDefinitionGroup>')
  86. end
  87. m.elements.clCompile = function(prj)
  88. return {
  89. m.additionalIncludeDirectories,
  90. }
  91. end
  92. function m.clCompile(prj)
  93. p.push('<ClCompile>')
  94. p.callArray(m.elements.clCompile, prj)
  95. p.pop('</ClCompile>')
  96. end
  97. function m.additionalIncludeDirectories(prj)
  98. vc2010.element("AdditionalIncludeDirectories", nil, '%s', '%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)')
  99. end
  100. --
  101. -- Write an item group, which contains the project capability
  102. --
  103. m.elements.itemGroup = function(prj)
  104. return {
  105. m.projectCapability,
  106. }
  107. end
  108. function m.itemGroup(prj)
  109. p.push('<ItemGroup>')
  110. p.callArray(m.elements.itemGroup, prj)
  111. p.pop('</ItemGroup>')
  112. end
  113. function m.projectCapability(prj)
  114. p.w('<ProjectCapability Include="SourceItemsFromImports" />')
  115. end