Add support for IL tests.
authorPat Gavlin <pagavlin@microsoft.com>
Tue, 9 Jun 2015 19:40:18 +0000 (12:40 -0700)
committerPat Gavlin <pagavlin@microsoft.com>
Tue, 9 Jun 2015 19:50:25 +0000 (12:50 -0700)
This change is comprised of two parts:
- A new property in dir.targets, ProjectLanguage, that allows test
  projects to specify the language in which they are written. If unset,
  this property is inferred from the extension, defaulting to C# if all
  else fails. The only lanugages currently supported are C# and IL, but
  it should be easy to support others (e.g. Visual Basic) if necessary.
- A copy of IL.targets from Microsoft.DotNet.BuildTools. This should be
  removed once CoreCLR has been moved to a version of the build tools
  package that contains IL.targets; this work is tracked by
  https://github.com/dotnet/coreclr/issues/1122.

This work is necessary to support a large number of JIT tests that are
written in IL and have yet to be ported.

tests/src/IL.targets [new file with mode: 0644]
tests/src/dir.targets

diff --git a/tests/src/IL.targets b/tests/src/IL.targets
new file mode 100644 (file)
index 0000000..0096377
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+
+  <!-- Required by Microsoft.Common.targets -->
+  <Target Name="CreateManifestResourceNames" Condition="'@(EmbeddedResource)' != ''" />
+
+  <Target Name="CoreCompile"
+          Inputs="$(MSBuildAllProjects);
+                  @(Compile)"
+          Outputs="@(IntermediateAssembly);"
+          Returns=""
+          DependsOnTargets="$(CoreCompileDependsOn)">
+    <PropertyGroup>
+      <_OutputTypeArgument Condition="'$(OutputType)' == 'Library'">/DLL</_OutputTypeArgument>
+      <_OutputTypeArgument Condition="'$(OutputType)' == 'Exe'">/EXE</_OutputTypeArgument>
+
+      <_KeyFileArgument Condition="'$(KeyOriginatorFile)' != ''">/KEY=$(KeyOriginatorFile)</_KeyFileArgument>
+    </PropertyGroup>
+
+    <Exec Command="ilasm /QUIET $(_OutputTypeArgument) /OUTPUT=@(IntermediateAssembly) $(_KeyFileArgument) @(Compile)">
+      <Output TaskParameter="ExitCode" PropertyName="_ILAsmExitCode" />
+    </Exec>
+    <Error Text="ILAsm failed" Condition="'$(_ILAsmExitCode)' != '0'" />
+  </Target>
+
+  <Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
+
+</Project>
index 0c38331..8335ec4 100644 (file)
     </ItemGroup>
   </Target>
 
-  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <!-- Project language -->
+  <PropertyGroup Condition="'$(ProjectLanguage)' == ''">
+    <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.ilproj' OR '$(Language)' == 'IL'">IL</ProjectLanguage>
+    <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.csproj' OR '$(Language)' == 'C#' OR '$(ProjectLanguage)'==''">CSharp</ProjectLanguage>
+  </PropertyGroup>
+
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" Condition="'$(ProjectLanguage)' == 'CSharp'" />
+
+  <!-- TODO (#1122): import this from the ToolsDir once it becomes available -->
+  <Import Project="$(ProjectDir)IL.targets" Condition="'$(ProjectLanguage)' == 'IL'" />
 
   <Import Project="$(ToolsDir)packageresolve.targets" Condition="Exists('$(ToolsDir)packageresolve.targets')" />