vs2005.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. --
  2. -- vs2005.lua
  3. -- Add support for the Visual Studio 2005 project formats.
  4. -- Copyright (c) Jason Perkins and the Premake project
  5. --
  6. local p = premake
  7. p.vstudio.vs2005 = {}
  8. local vs2005 = p.vstudio.vs2005
  9. local vstudio = p.vstudio
  10. ---
  11. -- Register a command-line action for Visual Studio 2006.
  12. ---
  13. function vs2005.generateSolution(wks)
  14. p.indent("\t")
  15. p.eol("\r\n")
  16. p.escaper(vs2005.esc)
  17. p.generate(wks, ".sln", vstudio.sln2005.generate)
  18. end
  19. function vs2005.generateProject(prj)
  20. p.indent(" ")
  21. p.eol("\r\n")
  22. p.escaper(vs2005.esc)
  23. if p.project.iscsharp(prj) then
  24. p.generate(prj, ".csproj", vstudio.cs2005.generate)
  25. -- Skip generation of empty user files
  26. local user = p.capture(function() vstudio.cs2005.generateUser(prj) end)
  27. if #user > 0 then
  28. p.generate(prj, ".csproj.user", function() p.outln(user) end)
  29. end
  30. elseif p.project.isfsharp(prj) then
  31. p.generate(prj, ".fsproj", vstudio.fs2005.generate)
  32. -- Skip generation of empty user files
  33. local user = p.capture(function() vstudio.fs2005.generateUser(prj) end)
  34. if #user > 0 then
  35. p.generate(prj, ".fsproj.user", function() p.outln(user) end)
  36. end
  37. else
  38. p.generate(prj, ".vcproj", vstudio.vc200x.generate)
  39. -- Skip generation of empty user files
  40. local user = p.capture(function() vstudio.vc200x.generateUser(prj) end)
  41. if #user > 0 then
  42. p.generate(prj, ".vcproj.user", function() p.outln(user) end)
  43. end
  44. end
  45. end
  46. ---
  47. -- Apply XML escaping on a value to be included in an
  48. -- exported project file.
  49. ---
  50. function vs2005.esc(value)
  51. value = string.gsub(value, '&', "&")
  52. value = value:gsub('"', """)
  53. value = value:gsub("'", "'")
  54. value = value:gsub('<', "&lt;")
  55. value = value:gsub('>', "&gt;")
  56. value = value:gsub('\r', "&#x0D;")
  57. value = value:gsub('\n', "&#x0A;")
  58. return value
  59. end
  60. ---
  61. -- Define the Visual Studio 2005 export action.
  62. ---
  63. newaction {
  64. -- Metadata for the command line and help system
  65. trigger = "vs2005",
  66. shortname = "Visual Studio 2005",
  67. description = "Generate Visual Studio 2005 project files",
  68. -- Visual Studio always uses Windows path and naming conventions
  69. targetos = "windows",
  70. toolset = "msc-v80",
  71. -- The capabilities of this action
  72. valid_kinds = { "ConsoleApp", "WindowedApp", "StaticLib", "SharedLib", "Makefile", "None" },
  73. valid_languages = { "C", "C++", "C#", "F#" },
  74. valid_tools = {
  75. cc = { "msc" },
  76. dotnet = { "msnet" },
  77. },
  78. -- Workspace and project generation logic
  79. onWorkspace = vstudio.vs2005.generateSolution,
  80. onProject = vstudio.vs2005.generateProject,
  81. onCleanWorkspace = vstudio.cleanSolution,
  82. onCleanProject = vstudio.cleanProject,
  83. onCleanTarget = vstudio.cleanTarget,
  84. -- This stuff is specific to the Visual Studio exporters
  85. vstudio = {
  86. csprojSchemaVersion = "2.0",
  87. productVersion = "8.0.50727",
  88. solutionVersion = "9",
  89. versionName = "2005",
  90. }
  91. }