Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 328 lines (320 sloc) 16.042 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327
<Project DefaultTargets="DevBuild2Stage" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <UsingTask TaskName="MSBuild.Community.Tasks.FileUpdate" AssemblyFile="$(MSBuildProjectDirectory)\ExternalDependences\MSBuild.Community.Tasks.dll" />
  <PropertyGroup Condition=" '$(NTargetName)' == '' ">
    <NTargetName>Rebuild</NTargetName>
  </PropertyGroup>
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <!--Path to root directory of Nemerle sources.-->
    <NRoot>$(MSBuildProjectDirectory)</NRoot>
    <NVer Condition="'$(TargetFrameworkVersion)' == '' Or '$(TargetFrameworkVersion)' == 'v2.0' Or '$(TargetFrameworkVersion)' == 'v3.0' Or '$(TargetFrameworkVersion)' == 'v3.5'">mono-3.5</NVer>
    <NVer Condition="'$(TargetFrameworkVersion)' == 'v4.0'">mono-4.0</NVer>
    <!-- Original boot -->
    <NRootBoot Condition="'$(TargetFrameworkVersion)' == '' Or '$(TargetFrameworkVersion)' == 'v2.0' Or '$(TargetFrameworkVersion)' == 'v3.0' Or '$(TargetFrameworkVersion)' == 'v3.5'">$(NRoot)\boot\</NRootBoot>
    <NRootBoot Condition="'$(TargetFrameworkVersion)' == 'v4.0'">$(NRoot)\boot-4.0\</NRootBoot>
    <!--Path to stages output directory (including current configuration subfolder).-->
    <NBin>$(NRoot)\bin\$(Configuration)\$(NVer)\</NBin>
    <NObj>$(NRoot)\obj\$(Configuration)\$(NVer)\</NObj>
    <!--Path to boot compiler.-->
    <NBoot>$(NBin)\boot\</NBoot>
    <!-- Project Constants -->
    <NProjectConstants Condition="'$(TargetFrameworkVersion)' == '' Or '$(TargetFrameworkVersion)' == 'v2.0' Or '$(TargetFrameworkVersion)' == 'v3.0' Or '$(TargetFrameworkVersion)' == 'v3.5'">RUNTIME_MONO</NProjectConstants>
    <NProjectConstants Condition="'$(TargetFrameworkVersion)' == 'v4.0'">RUNTIME_MONO;NET_4_0</NProjectConstants>
    <NProjectConstants Condition="'$(Configuration)' == 'Debug'">$(NProjectConstants);DEBUG</NProjectConstants>
    <NDefineProjectConstants>DefineConstants=$(NProjectConstants)</NDefineProjectConstants>
  </PropertyGroup>
  <!--Project required to build any Nemerle project (.nproj)-->
  <ItemGroup>
    <NTasksProject Include="$(NRoot)\Nemerle.XBuild.Tasks.csproj" />
  </ItemGroup>
  <!--Projects related only to compiler.-->
  <ItemGroup>
    <NCompilerProject Include="$(NRoot)\Nemerle.nproj" />
    <NCompilerProject Include="$(NRoot)\Nemerle.Compiler.nproj" />
    <NCompilerProject Include="$(NRoot)\Nemerle.Macros.nproj" />
    <NCompilerProject Include="$(NRoot)\ncc.nproj" />
  </ItemGroup>
  <!--Projects related to PowerPack-->
  <ItemGroup>
    <NPowerPack Include="$(NRoot)\snippets\peg-parser\Nemerle.Peg\Nemerle.Peg.nproj" />
    <NPowerPack Include="$(NRoot)\snippets\peg-parser\Nemerle.Peg.Macros\Nemerle.Peg.Macros.nproj" />
    <NPowerPack Include="$(NRoot)\snippets\csharp-parser\CSharpParser\CSharpParser.nproj" />
    <NPowerPack Include="$(NRoot)\snippets\csharp-parser\CSharpToNemerle\CSharpToNemerle.nproj" />
    <NPowerPack Include="$(NRoot)\snippets\Nemerle.WPF\Nemerle.WPF\Nemerle.WPF.nproj" />
    <NPowerPack Include="$(NRoot)\snippets\ComputationExpressions\ComputationExpressions\ComputationExpressions.nproj" />
    <NPowerPack Include="$(NRoot)\snippets\ComputationExpressions\ComputationExpressions.Macros\ComputationExpressions.Macros.nproj" />
    <NPowerPack Include="$(NRoot)\snippets\ObjectExpressions\NewObjectMacro\NewObjectMacro.nproj" />
    <NPowerPack Include="$(NRoot)\snippets\aop\DevMacros.nproj" />
    <!-- for Nemerle.Aop build -->
    <NPowerPack Include="$(NRoot)\snippets\aop\Nemerle.Aop.nproj" />
  </ItemGroup>
  <!--Initialize FX and SDK tools locations-->
  <Target Name="InitTools">
    <GetFrameworkPath>
      <Output TaskParameter="Path" PropertyName="FW20" />
    </GetFrameworkPath>
    <GetFrameworkSdkPath>
      <Output TaskParameter="Path" PropertyName="SDK" />
    </GetFrameworkSdkPath>
    <!--
    <PropertyGroup>
      <GacUtil>"$(SDK)\bin\gacutil.exe"</GacUtil>
      <Ildasm>"$(SDK)\bin\ildasm.exe"</Ildasm>
      <PEVerify>"$(SDK)\bin\peverify.exe"</PEVerify>
      <NGen>"$(FW20)\ngen.exe"</NGen>
      <MSBuild>$(MSBuildBinPath)\msbuild.exe</MSBuild>
      <Junction>$(NRoot)\ExternalDependences\junction.exe</Junction>
    </PropertyGroup>
    -->
    <CreateProperty Value="$(SDK)\..\..\..\bin\gacutil">
      <Output
          TaskParameter="Value"
          PropertyName="GacUtil" />
    </CreateProperty>
    <CreateProperty Value="$(SDK)\..\..\..\bin\ildasm">
      <Output
          TaskParameter="Value"
          PropertyName="Ildasm" />
    </CreateProperty>
    <CreateProperty Value="$(SDK)\..\..\..\bin\peverify">
      <Output
          TaskParameter="Value"
          PropertyName="PEVerify" />
    </CreateProperty>
    <CreateProperty Value="$(FW20)\..\..\..\bin\ngen">
      <Output
          TaskParameter="Value"
          PropertyName="NGen" />
    </CreateProperty>
    <CreateProperty Value="$(MSBuildBinPath)\..\..\..\bin\xbuild">
      <Output
          TaskParameter="Value"
          PropertyName="XBuild" />
    </CreateProperty>

    <Message Text="Framework tools found at:" Importance="high" />
    <Message Text=" XBuild - $(XBuild)" Importance="high" />
    <Message Text=" NGen - $(NGen)" Importance="high" />
    <Message Text="SDK tools found at:" Importance="high" />
    <Message Text=" GacUtil - $(GacUtil)" Importance="high" />
    <Message Text=" Ildasm - $(Ildasm)" Importance="high" />
    <Message Text=" PEVerify - $(PEVerify)" Importance="high" />
  </Target>
  <!--Builds and deploy tasks dll into boot directory-->
  <Target Name="NTasks" DependsOnTargets="InitTools">
    <MSBuild Projects="@(NTasksProject)" Properties="OutputPath=$(NBoot); IntermediateOutputPath=$(NObj)\Tasks\; NKeysDir=$(NBin)\keys" Targets="$(NTargetName)" />
    <CreateItem Include="$(NBoot)\Nemerle.XBuild.Tasks.dll">
      <Output ItemName="NTasksFiles" TaskParameter="Include" />
    </CreateItem>
    <CreateItem Include="$(NBoot)\Nemerle.MSBuild.targets">
      <Output ItemName="NTasksFiles" TaskParameter="Include" />
    </CreateItem>
    <CreateItem Include="$(NBoot)\ncc.bat">
      <Output ItemName="NTasksFiles" TaskParameter="Include" />
    </CreateItem>
    <CreateItem Include="$(NBoot)\ncc">
      <Output ItemName="NTasksFiles" TaskParameter="Include" />
    </CreateItem>
  </Target>
  <!--Prepare boot-->
  <Target Name="NPrepareBoot">
    <CreateItem Include="$(NRootBoot)\*.exe">
      <Output ItemName="NBootFiles" TaskParameter="Include" />
    </CreateItem>
    <CreateItem Include="$(NRootBoot)\*.dll">
      <Output ItemName="NBootFiles" TaskParameter="Include" />
    </CreateItem>
    <Copy SourceFiles="@(NBootFiles)" DestinationFolder="$(NBoot)" />
  </Target>
  <!--Keys-->
  <Target Name="NPrepareKeys">
    <CreateItem Include="$(NRoot)\misc\keys\*.snk">
      <Output ItemName="NKeyFiles" TaskParameter="Include"/>
    </CreateItem>
    <Copy SourceFiles="@(NKeyFiles)" DestinationFolder="$(NBin)\keys" />
  </Target>
  <!--Builds compiler using boot-->
  <Target Name="Stage1" DependsOnTargets="NPrepareKeys;NPrepareBoot;NTasks">
    <!--
    <PropertyGroup>
      <NPrevBin>$(NBoot)</NPrevBin>
      <NCurBin>$(NBin)\Stage1\</NCurBin>
      <NCurObj>$(NObj)\Stage1\</NCurObj>
    </PropertyGroup>
  -->
    <CreateProperty Value="$(NBoot)">
      <Output
          TaskParameter="Value"
          PropertyName="NPrevBin" />
    </CreateProperty>
    <CreateProperty Value="$(NBin)\Stage1\">
      <Output
          TaskParameter="Value"
          PropertyName="NCurBin" />
    </CreateProperty>
    <CreateProperty Value="$(NObj)\Stage1\">
      <Output
          TaskParameter="Value"
          PropertyName="NCurObj" />
    </CreateProperty>
    <MSBuild Projects="@(NCompilerProject)" Properties="OutputPath=$(NCurBin); IntermediateOutputPath=$(NCurObj); Nemerle=$(NPrevBin); NKeysDir=$(NBin)\keys; DefineConstants=RUNTIME_MONO" Targets="$(NTargetName)" />
    <Copy SourceFiles="@(NTasksFiles)" DestinationFolder="$(NCurBin)" />
  </Target>
  <!--Builds compiler using Stage1-->
  <Target Name="Stage2" DependsOnTargets="Stage1">
    <!--
    <PropertyGroup>
      <NPrevBin>$(NBin)\Stage1\</NPrevBin>
      <NCurBin>$(NBin)\Stage2\</NCurBin>
      <NCurObj>$(NObj)\Stage2\</NCurObj>
    </PropertyGroup>
  -->
    <CreateProperty Value="$(NBin)\Stage1\">
      <Output
          TaskParameter="Value"
          PropertyName="NPrevBin" />
    </CreateProperty>
    <CreateProperty Value="$(NBin)\Stage2\">
      <Output
          TaskParameter="Value"
          PropertyName="NCurBin" />
    </CreateProperty>
    <CreateProperty Value="$(NObj)\Stage2\">
      <Output
          TaskParameter="Value"
          PropertyName="NCurObj" />
    </CreateProperty>
    <MSBuild Projects="@(NCompilerProject)" Properties="OutputPath=$(NCurBin); IntermediateOutputPath=$(NCurObj); Nemerle=$(NPrevBin); NKeysDir=$(NBin)\keys; DefineConstants=RUNTIME_MONO" Targets="$(NTargetName)" />
    <Copy SourceFiles="@(NTasksFiles)" DestinationFolder="$(NCurBin)" />
  </Target>
  <!--Builds compiler using Stage2-->
  <Target Name="Stage3" DependsOnTargets="Stage2">
    <!--
    <PropertyGroup>
      <NPrevBin>$(NBin)\Stage2\</NPrevBin>
      <NCurBin>$(NBin)\Stage3\</NCurBin>
      <NCurObj>$(NObj)\Stage3\</NCurObj>
    </PropertyGroup>
  -->
    <CreateProperty Value="$(NBin)\Stage2\">
      <Output
          TaskParameter="Value"
          PropertyName="NPrevBin" />
    </CreateProperty>
    <CreateProperty Value="$(NBin)\Stage3\">
      <Output
          TaskParameter="Value"
          PropertyName="NCurBin" />
    </CreateProperty>
    <CreateProperty Value="$(NObj)\Stage3\">
      <Output
          TaskParameter="Value"
          PropertyName="NCurObj" />
    </CreateProperty>
    <MSBuild Projects="@(NCompilerProject)" Properties="OutputPath=$(NCurBin); IntermediateOutputPath=$(NCurObj); Nemerle=$(NPrevBin); NKeysDir=$(NBin)\keys; DefineConstants=RUNTIME_MONO" Targets="$(NTargetName)" />
    <Copy SourceFiles="@(NTasksFiles)" DestinationFolder="$(NCurBin)" />
  </Target>
  <!--Builds compiler using Stage3-->
  <Target Name="Stage4" DependsOnTargets="Stage3">
    <!--
    <PropertyGroup>
      <NPrevBin>$(NBin)\Stage3\</NPrevBin>
      <NCurBin>$(NBin)\Stage4\</NCurBin>
      <NCurObj>$(NObj)\Stage4\</NCurObj>
    </PropertyGroup>
  -->
    <CreateProperty Value="$(NBin)\Stage3\">
      <Output
          TaskParameter="Value"
          PropertyName="NPrevBin" />
    </CreateProperty>
    <CreateProperty Value="$(NBin)\Stage4\">
      <Output
          TaskParameter="Value"
          PropertyName="NCurBin" />
    </CreateProperty>
    <CreateProperty Value="$(NObj)\Stage4\">
      <Output
          TaskParameter="Value"
          PropertyName="NCurObj" />
    </CreateProperty>
    <MSBuild Projects="@(NCompilerProject)" Properties="OutputPath=$(NCurBin); IntermediateOutputPath=$(NCurObj); Nemerle=$(NPrevBin); NKeysDir=$(NBin)\keys; DefineConstants=RUNTIME_MONO" Targets="$(NTargetName)" />
    <Copy SourceFiles="@(NTasksFiles)" DestinationFolder="$(NCurBin)" />
  </Target>

  <!--Builds only PowerPack using Stage1 compiler.-->
  <Target Name="PowerPack" DependsOnTargets="Stage1; _PowerPack" />

  <!--Compare last two stages on IL level-->
  <Target Name="Validate" DependsOnTargets="InitTools">
    <!--
    <ItemGroup>
      <Asm2 Include="$(NPrevBin)\*.dll" />
      <Asm2 Include="$(NPrevBin)\*.exe" />
      <Asm3 Include="$(NCurBin)\*.dll" />
      <Asm3 Include="$(NCurBin)\*.exe" />
    </ItemGroup>
    -->
    <CreateItem Include="$(NPrevBin)\*.dll">
      <Output TaskParameter="Include" ItemName="Asm2" />
    </CreateItem>
    <CreateItem Include="$(NPrevBin)\*.exe">
      <Output TaskParameter="Include" ItemName="Asm2" />
    </CreateItem>
    <CreateItem Include="$(NCurBin)\*.dll">
      <Output TaskParameter="Include" ItemName="Asm3" />
    </CreateItem>
    <CreateItem Include="$(NCurBin)\*.exe">
      <Output TaskParameter="Include" ItemName="Asm3" />
    </CreateItem>
    <Exec Command="$(Ildasm) %(Asm2.FullPath) /output:%(Asm2.FullPath).il /nobar" WorkingDirectory="$(NPrevBin)" />
    <Exec Command="$(Ildasm) %(Asm3.FullPath) /output:%(Asm3.FullPath).il /nobar" WorkingDirectory="$(NCurBin)" />
    <!--
    <ItemGroup>
      <IL_PREV Include="$(NPrevBin)\*.il" />
      <IL_LAST Include="$(NCurBin)\*.il" />
    </ItemGroup>
    -->
    <CreateItem Include="$(NPrevBin)\*.il">
      <Output TaskParameter="Include" ItemName="IL_PREV" />
    </CreateItem>
    <CreateItem Include="$(NCurBin)\*.il">
      <Output TaskParameter="Include" ItemName="IL_LAST" />
    </CreateItem>
    <MSBuild.Community.Tasks.FileUpdate Files="@(IL_PREV)" Regex="^(//.*)(?=\r)" ReplacementText="// REPLACED" Multiline="True" />
    <MSBuild.Community.Tasks.FileUpdate Files="@(IL_LAST)" Regex="^(//.*)(?=\r)" ReplacementText="// REPLACED" Multiline="True" />
    <Exec Command="fc $(NPrevBin)\*.il $(NCurBin)\*.il" Condition=" '$(OS)' == 'Windows_NT' "/>
    <Exec Command="diff --from-file=$(NPrevBin) $(NCurBin)\*.il" Condition=" '$(OS)' != 'Windows_NT' "/>
    <Exec Command="$(PEVerify) %(Asm3.FullPath)" ContinueOnError="True" />
    <Delete Files="@(IL_PREV)" />
    <Delete Files="@(IL_LAST)" />
  </Target>

  <!--Runs compiler tests.-->
  <Target Name="CompilerTests">
    <!--Build tester positive-->
    <MSBuild Projects="$(NRoot)\Tests.nproj" Properties="Nemerle=$(NCurBin); Configuration=$(Configuration); IntermediateOutputPath=$(NObj)\Tests\positive\; NTestOutPath=$(NBin)\Tests\positive\" />
    <!--Build tester negative-->
    <MSBuild Projects="$(NRoot)\Tests.nproj" Properties="Nemerle=$(NCurBin); Configuration=$(Configuration); IntermediateOutputPath=$(NObj)\Tests\negative\; NTestOutPath=$(NBin)\Tests\negative\" />
    <!--Delete all temporary files in old testing directory-->
    <CreateItem Include="$(NRoot)\ncc\testsuite\*.exe;$(NRoot)\ncc\testsuite\*.dll;$(NRoot)\ncc\testsuite\*.pdb">
      <Output ItemName="NTestSuiteTempFiles" TaskParameter="Include"/>
    </CreateItem>
    <Delete Files="@(NTestSuiteTempFiles)" />
    <!--Copy test files to the testing directory-->
    <CreateItem Include="$(NRoot)\ncc\testsuite\*.*">
      <Output ItemName="NTestSuiteFiles" TaskParameter="Include" />
    </CreateItem>
    <Copy SourceFiles="@(NTestSuiteFiles)" DestinationFolder="$(NBin)\Tests\positive" />
    <Copy SourceFiles="@(NTestSuiteFiles)" DestinationFolder="$(NBin)\Tests\negative" />
    <!--Run positive tests-->
    <Exec Command="mono $(NBin)\Tests\positive\Tests.exe -d:$(NRoot)\ncc\testsuite\positive -p &quot;-nowarn:10003 -def:$(NProjectConstants)&quot; -s" WorkingDirectory="$(NBin)\Tests\positive" />
    <!--Run negative tests-->
    <Exec Command="mono $(NBin)\Tests\negative\Tests.exe -d:$(NRoot)\ncc\testsuite\negative -p &quot;-nowarn:10003 -def:$(NProjectConstants)&quot; -s" WorkingDirectory="$(NBin)\Tests\negative" />
  </Target>

  <!--Helper target to build power pack-->
  <Target Name="_PowerPack">
    <MSBuild Projects="@(NPowerPack)" Properties="OutputPath=$(NBin)\PowerPack; IntermediateOutputPath=$(NObj)\PowerPack\; Nemerle=$(NCurBin); Configuration=$(Configuration); DefineConstants=RUNTIME_MONO" Targets="$(NTargetName)" />
  </Target>

  <Target Name="DevBuildQuick" DependsOnTargets="Stage1;" />
  <Target Name="DevBuildQuickWithTests" DependsOnTargets="Stage1; CompilerTests" />
  <Target Name="DevBuild2Stage" DependsOnTargets="Stage2;" />
  <Target Name="DevBuild2StageWithTests" DependsOnTargets="Stage2; CompilerTests" />
  <Target Name="DevBuildFull" DependsOnTargets="Stage4; Validate; CompilerTests; _PowerPack" />

</Project>
Something went wrong with that request. Please try again.