zeroc.icebuilder.msbuild.cpp.targets 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- Copyright (c) 2009-2018 ZeroC, Inc. All rights reserved. -->
  3. <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  4. <!-- Import our custom MSbuild tasks used to build Ice for C++ projects -->
  5. <UsingTask TaskName="IceBuilder.MSBuild.Slice2CppTask"
  6. AssemblyFile="$(MSBuildThisFileDirectory)..\tools\net45\zeroc.icebuilder.msbuild.dll"/>
  7. <UsingTask TaskName="IceBuilder.MSBuild.Slice2CppDependTask"
  8. AssemblyFile="$(MSBuildThisFileDirectory)..\tools\net45\zeroc.icebuilder.msbuild.dll"/>
  9. <!-- Import common settings -->
  10. <Import Project="$(MSBuildThisFileDirectory)\zeroc.icebuilder.msbuild.common.props"/>
  11. <!-- Import Ice.cpp.props file provided by Ice 3.6 binary distribution -->
  12. <Import Project="$(IceHome)\config\Ice.Cpp.props"
  13. Condition="'$(IceNugetPackageVersion)' == '' and Exists('$(IceHome)\config\Ice.Cpp.props')"/>
  14. <!-- With Ice 3.6.0 the C++ props were not part of the Ice distribution. They are included with
  15. Ice Builder for MSBuild for backwards compatibility -->
  16. <Import Project="$(MSBuildThisFileDirectory)\Ice.3.6.0.Cpp.props"
  17. Condition="'$(IceVersion)' == '3.6.0' and Exists('$(MSBuildThisFileDirectory)\Ice.3.6.0.Cpp.props')"/>
  18. <!-- With Ice 3.6 the LocalDebuggerEviroment settings are not set in the targets file we add IceBin
  19. to the PATH here -->
  20. <PropertyGroup Condition="'$(IceIntVersion)' != '' and ('$(IceIntVersion)' &lt; '30700' or '$(IceVersion)' == '3.6.0')">
  21. <LocalDebuggerEnvironment>PATH=$(IceBin)</LocalDebuggerEnvironment>
  22. </PropertyGroup>
  23. <ItemGroup>
  24. <PropertyPageSchema Include="$(MSBuildThisFileDirectory)ProjectItemsSchema.xaml" />
  25. <PropertyPageSchema Include="$(MSBuildThisFileDirectory)SliceCompile.Cpp.xaml">
  26. <Context>Project</Context>
  27. </PropertyPageSchema>
  28. <PropertyPageSchema Include="$(MSBuildThisFileDirectory)SliceCompile.Cpp.File.xaml">
  29. <Context>File</Context>
  30. </PropertyPageSchema>
  31. <AvailableItemName Include="SliceCompile"/>
  32. </ItemGroup>
  33. <ItemDefinitionGroup Condition="'$(IceCppMapping)' == 'cpp11' and '$(IceIntVersion)' != '' and '$(IceIntVersion)' &gt;= '30700' and '$(VisualStudioVersion)' &gt;= '14.0'">
  34. <ClCompile>
  35. <PreprocessorDefinitions>ICE_CPP11_MAPPING;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  36. </ClCompile>
  37. </ItemDefinitionGroup>
  38. <Target Name="SliceCompile" BeforeTargets="CLCompile"
  39. Condition="@(SliceCompile) != ''">
  40. <Error Text="Ice Installation invalid or not detected. Invalid IceHome setting `$(IceHome)'"
  41. Condition="!Exists('$(IceHome)')" />
  42. <Error Text="Ice Installation invalid or not detected. Invalid IceToolsPath setting `$(IceToolsPath)'"
  43. Condition="!Exists('$(IceToolsPath)')" />
  44. <Error Text="The Ice Builder requires Ice Version 3.6 or later. Invalid IceHome setting `$(IceHome)'"
  45. Condition="'$(IceIntVersion)' == '' Or '$(IceIntVersion)' &lt; '30600'" />
  46. <Warning Text="The C++11 mapping is only available for Ice 3.7 with Visual Studio 2015 or later"
  47. Condition="'$(IceCppMapping)' == 'cpp11' and ('$(IceIntVersion)' &lt; '30700' or '$(VisualStudioVersion)' &lt; '14.0')"/>
  48. <!--
  49. Create the output directories
  50. -->
  51. <MakeDir Directories="%(SliceCompile.OutputDir)" Condition="!Exists('%(SliceCompile.OutputDir)')"/>
  52. <MakeDir Directories="%(SliceCompile.HeaderOutputDir)" Condition="!Exists('%(SliceCompile.HeaderOutputDir)')"/>
  53. <!-- First we check dependencies to compute which Slice files need to be recompiled -->
  54. <Slice2CppDependTask
  55. IceHome = "$(IceHome)"
  56. IceToolsPath = "$(IceToolsPath)"
  57. WorkingDirectory = "$(MSBuildProjectDirectory)"
  58. Sources = "@(SliceCompile)">
  59. <Output
  60. ItemName = "_SliceCompile"
  61. TaskParameter = "ComputedSources"/>
  62. <Output
  63. PropertyName = "_SliceCompileGeneratedPaths"
  64. TaskParameter = "GeneratedCompiledPaths"/>
  65. </Slice2CppDependTask>
  66. <!-- Compile the Slice files -->
  67. <Slice2CppTask
  68. IceHome = "$(IceHome)"
  69. IceToolsPath = "$(IceToolsPath)"
  70. WorkingDirectory = "$(MSBuildProjectDirectory)"
  71. OutputDir = "%(_SliceCompile.OutputDir)"
  72. HeaderOutputDir = "%(_SliceCompile.HeaderOutputDir)"
  73. IncludeDirectories = "%(_SliceCompile.IncludeDirectories)"
  74. AdditionalOptions = "%(_SliceCompile.AdditionalOptions)"
  75. BaseDirectoryForGeneratedInclude = "%(_SliceCompile.BaseDirectoryForGeneratedInclude)"
  76. HeaderExt = "%(_SliceCompile.HeaderExt)"
  77. SourceExt = "%(_SliceCompile.SourceExt)"
  78. Sources = "@(_SliceCompile)"
  79. Condition = "'%(_SliceCompile.BuildRequired)' == 'True'">
  80. <Output
  81. ItemName = "_SliceCompileTLogItem"
  82. TaskParameter = "ComputedSources"/>
  83. </Slice2CppTask>
  84. <!--
  85. Include all C++ generated source items that have not been manually included. We want to delay this until we are
  86. running the SliceCompile target so that the Visual Studio extension has a chance to add the items to the project in
  87. a persistent way. If the extension is not enabled or we are building from the command line we just add the
  88. missing items in a transient way.
  89. The builder's depend task has an output property named GeneratedPaths that contains the paths of all generated items.
  90. -->
  91. <ItemGroup>
  92. <ClCompile Include="$(_SliceCompileGeneratedPaths)"
  93. Exclude="@(ClCompile->'%(FullPath)');@(ClCompile->'%(Identity)')" />
  94. </ItemGroup>
  95. <!--
  96. TLog files are used by Visual Studio's up to date check to figure out if a project file
  97. needs to be rebuilt.
  98. -->
  99. <!-- Write TLog files -->
  100. <MakeDir Directories="$(TLogLocation)" Condition="!Exists('$(TLogLocation)')"/>
  101. <WriteLinesToFile File = "$(TLogLocation)\slice2cpp.write.1u.tlog"
  102. Encoding = "Unicode"
  103. Overwrite = "true"
  104. Lines = ""/>
  105. <WriteLinesToFile File = "$(TLogLocation)\slice2cpp.write.1u.tlog"
  106. Encoding = "Unicode"
  107. Lines = "^%(_SliceCompile.FullPath);%(_SliceCompile.Outputs)"
  108. Condition = "'%(_SliceCompile.Outputs)' != ''"/>
  109. <WriteLinesToFile File = "$(TLogLocation)\slice2cpp.write.1u.tlog"
  110. Encoding = "Unicode"
  111. Lines = "^%(_SliceCompileTLogItem.FullPath);%(_SliceCompileTLogItem.Outputs)"
  112. Condition = "'%(_SliceCompileTLogItem.Outputs)' != ''"/>
  113. <!-- Read TLog files -->
  114. <WriteLinesToFile File = "$(TLogLocation)\slice2cpp.read.1u.tlog"
  115. Encoding = "Unicode"
  116. Overwrite = "true"
  117. Lines = ""/>
  118. <WriteLinesToFile File = "$(TLogLocation)\slice2cpp.read.1u.tlog"
  119. Encoding = "Unicode"
  120. Lines = "^%(_SliceCompile.FullPath);%(_SliceCompile.Inputs)"
  121. Condition = "'%(_SliceCompile.Inputs)' != ''"/>
  122. <WriteLinesToFile File = "$(TLogLocation)\slice2cpp.read.1u.tlog"
  123. Encoding = "Unicode"
  124. Lines = "^%(_SliceCompileTLogItem.FullPath);%(_SliceCompileTLogItem.Inputs)"
  125. Condition = "'%(_SliceCompileTLogItem.Inputs)' != ''"/>
  126. </Target>
  127. <Target Name="SliceCompileClean" BeforeTargets="Clean">
  128. <Delete Files="@(SliceCompile->'%(OutputDir)\%(Filename).%(SourceExt)')"/>
  129. <Delete Files="@(SliceCompile->'%(OutputDir)\%(Filename).%(HeaderExt)')"/>
  130. <Delete Files="@(SliceCompile->'%(OutputDir)\SliceCompile.%(Filename).d')"/>
  131. </Target>
  132. </Project>