2008-03-05 09:52:00 -05:00
|
|
|
<!--
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Microsoft Research Singularity
|
|
|
|
#
|
|
|
|
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
#
|
|
|
|
# File: Targets\InterfaceAssembly.targets
|
|
|
|
|
|
|
|
This file contains the build logic for interface assemblies. Interface assemblies
|
|
|
|
contain MSIL metadata, but do not contain method bodies. Interface assemblies allow
|
|
|
|
cyclic dependencies (e.g. kernel.exe also IoSystem.dll both refer to each other),
|
|
|
|
and also allow one assembly to be replaced with another at runtime (or at ngen).
|
|
|
|
|
|
|
|
Projects that import this file can set the following properties:
|
|
|
|
|
|
|
|
AssemblyName Name of assembly, excluding file extension
|
|
|
|
OutputType 'Exe' or 'Library'
|
|
|
|
AllowUnsafeBlocks 'true' to allow unverifiable code
|
|
|
|
NoStrongName 'true' to turn off assembly strong name signing
|
|
|
|
InterfaceAssemblyIsKey 'true' to pass /key to csic.exe
|
|
|
|
CSIC Overrides the default compiler tool, $(BUILDDIR)\csic.exe
|
2008-11-17 18:29:00 -05:00
|
|
|
OutputPath Specifies output path for the assembly. Default is $(APPILLSDIR).
|
2008-03-05 09:52:00 -05:00
|
|
|
NoStdLib 'true' to pass /nostdlib to csic.exe
|
|
|
|
|
|
|
|
Projects can declare the following items:
|
|
|
|
|
|
|
|
Compile Source file (.cs or .sg, etc.)
|
|
|
|
ProjectReference A reference to another interface project. The project can
|
|
|
|
also declare the optional 'Alias' metadata tag. This will
|
|
|
|
add the "=<aliasvalue>" suffix to the /r: reference arg.
|
|
|
|
|
|
|
|
-->
|
|
|
|
|
|
|
|
<Project DefaultTarget="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
|
|
|
|
<!-- Supply defaults. -->
|
|
|
|
<PropertyGroup>
|
|
|
|
<NoStdlib Condition="'$(NoStdlib)'==''">false</NoStdlib>
|
|
|
|
<AllowUnsafeBlocks Condition="'$(AllowUnsafeBlocks)'==''">false</AllowUnsafeBlocks>
|
|
|
|
<NoStrongName Condition="'$(NoStrongName)'==''">false</NoStrongName>
|
|
|
|
<InterfaceAssemblyIsKey Condition="'$(InterfaceAssemblyIsKey)'==''">false</InterfaceAssemblyIsKey>
|
2008-11-17 18:29:00 -05:00
|
|
|
<CSIC Condition="'$(CSIC)'==''">"$(BUILDDIR)\csic.exe"</CSIC>
|
2008-03-05 09:52:00 -05:00
|
|
|
</PropertyGroup>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Build the command line for the csic compiler. -->
|
|
|
|
<PropertyGroup>
|
|
|
|
<CompilerFlags></CompilerFlags>
|
|
|
|
</PropertyGroup>
|
|
|
|
|
|
|
|
<Choose>
|
|
|
|
<When Condition="'$(OutputType)'=='Exe'">
|
|
|
|
<PropertyGroup>
|
|
|
|
<AssemblyExt>.exe</AssemblyExt>
|
|
|
|
</PropertyGroup>
|
|
|
|
</When>
|
|
|
|
<When Condition="'$(OutputType)'=='Library'">
|
|
|
|
<PropertyGroup>
|
|
|
|
<AssemblyExt>.ill</AssemblyExt>
|
|
|
|
</PropertyGroup>
|
|
|
|
</When>
|
|
|
|
<Otherwise>
|
|
|
|
<ItemGroup>
|
|
|
|
<Error Include="The value '$(OutputType)' is not valid for the 'OutputType' property."/>
|
|
|
|
</ItemGroup>
|
|
|
|
</Otherwise>
|
|
|
|
</Choose>
|
|
|
|
|
|
|
|
|
|
|
|
<PropertyGroup>
|
|
|
|
<AssemblyFileName>$(AssemblyName)$(AssemblyExt)</AssemblyFileName>
|
|
|
|
<OutputAssemblyPath>$(OutputPath)\$(AssemblyFileName)</OutputAssemblyPath>
|
|
|
|
</PropertyGroup>
|
|
|
|
|
|
|
|
|
|
|
|
<Choose>
|
|
|
|
<When Condition="'$(NoStdlib)'=='false'"/>
|
|
|
|
|
|
|
|
<When Condition="'$(NoStdlib)'=='true'">
|
|
|
|
<PropertyGroup>
|
|
|
|
<CompilerFlags>$(CompilerFlags) /nostdlib</CompilerFlags>
|
|
|
|
</PropertyGroup>
|
|
|
|
</When>
|
|
|
|
|
|
|
|
<Otherwise>
|
|
|
|
<ItemGroup>
|
|
|
|
<Error Include="The value '$(NoStdlib)' is not a valid choice for the 'NoStdlib' property."/>
|
|
|
|
</ItemGroup>
|
|
|
|
</Otherwise>
|
|
|
|
</Choose>
|
|
|
|
|
|
|
|
<Choose>
|
|
|
|
<When Condition="'$(AllowUnsafeBlocks)'=='true'">
|
|
|
|
<PropertyGroup>
|
|
|
|
<CompilerFlags>$(CompilerFlags) /unsafe</CompilerFlags>
|
|
|
|
</PropertyGroup>
|
|
|
|
</When>
|
|
|
|
<When Condition="'$(AllowUnsafeBlocks)'=='false'">
|
|
|
|
</When>
|
|
|
|
<Otherwise>
|
|
|
|
<PropertyGroup>
|
|
|
|
<ERROR>The value '$(AllowUnsafeBlocks)' is not a valid choice for the 'AllowUnsafeBlocks' property.</ERROR>
|
|
|
|
</PropertyGroup>
|
|
|
|
</Otherwise>
|
|
|
|
</Choose>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Choose>
|
|
|
|
<When Condition="'$(NoStrongName)'=='false'">
|
|
|
|
|
|
|
|
<ItemGroup>
|
|
|
|
<DependentProject Include="$(SINGULARITY_ROOT)\Build\BuildKey.proj"/>
|
|
|
|
<Dependency Include="$(StrongNameKeyFile)"/>
|
|
|
|
</ItemGroup>
|
|
|
|
|
|
|
|
</When>
|
|
|
|
</Choose>
|
|
|
|
|
|
|
|
<Choose>
|
|
|
|
<When Condition="'$(InterfaceAssemblyIsKey)'=='true'">
|
|
|
|
<PropertyGroup>
|
|
|
|
<CompilerFlags>$(CompilerFlags) /key</CompilerFlags>
|
|
|
|
</PropertyGroup>
|
|
|
|
</When>
|
|
|
|
</Choose>
|
|
|
|
|
|
|
|
<!-- TARGETS -->
|
|
|
|
|
|
|
|
<Target Name="CheckErrors">
|
|
|
|
<Error Condition="'@(Error)'!=''" Text="%(Error.Identity)"/>
|
|
|
|
<Error Condition="'$(AssemblyName)'==''" Text="The 'AssemblyName' property is required."/>
|
|
|
|
<Error Condition="'$(OutputPath)'==''" Text="The 'OutputPath' property is required."/>
|
|
|
|
<Error Condition="'$(OutputType)'==''" Text="The 'OutputType' property is required."/>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
<Target Name="ShowDebugInfo" DependsOnTargets="CheckErrors">
|
|
|
|
<Message Text="Projects: @(ProjectReference,' ')"/>
|
|
|
|
<Message Text="Dependent project: %(ProjectReference.Identity)"/>
|
|
|
|
<Message Text="_aliased_refs: %(_aliased_refs.Identity)"/>
|
|
|
|
<Message Text="Reference: %(Reference.Identity) alias %(Reference.Alias)"/>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
<Target Name="BuildDependentProjects" DependsOnTargets="CheckErrors">
|
2008-11-17 18:29:00 -05:00
|
|
|
<MSBuild Projects="@(ProjectReference);@(DependentProject)"
|
|
|
|
Targets="Build"
|
|
|
|
StopOnFirstFailure="$(StopOnFirstFailure)"
|
|
|
|
Condition="'$(BuildInParallel)'!='true'">
|
|
|
|
<Output TaskParameter="TargetOutputs" ItemName="__built_items" />
|
|
|
|
</MSBuild>
|
|
|
|
<MSBuild Projects="@(ProjectReference);@(DependentProject)"
|
|
|
|
Targets="Build"
|
|
|
|
StopOnFirstFailure="$(StopOnFirstFailure)"
|
|
|
|
Condition="'$(BuildInParallel)'=='true'"
|
|
|
|
BuildInParallel="true">
|
2008-03-05 09:52:00 -05:00
|
|
|
<Output TaskParameter="TargetOutputs" ItemName="__built_items" />
|
|
|
|
</MSBuild>
|
|
|
|
|
|
|
|
<!-- i hate this. -->
|
|
|
|
<CreateItem Include="@(ProjectReference->'$(OutputPath)\%(filename).ill')" AdditionalMetadata="Alias=%(ProjectReference.Alias)">
|
|
|
|
<Output TaskParameter="Include" ItemName="Reference"/>
|
|
|
|
</CreateItem>
|
|
|
|
|
|
|
|
<!-- now create "_aliased_refs" set -->
|
|
|
|
<CreateItem Include="@(Reference)">
|
|
|
|
<Output TaskParameter="Include" Condition="'%(Reference.Alias)'==''" ItemName="_aliased_refs" />
|
|
|
|
</CreateItem>
|
2008-11-17 18:29:00 -05:00
|
|
|
<Error Condition="'%(Reference.Alias)'=='' and '%(Reference.Identity)'!=''" Text="Missing Alias $(AssemblyName) for %(Reference.Identity)"/>
|
2008-03-05 09:52:00 -05:00
|
|
|
<CreateItem Include="%(Reference.Identity)=%(Reference.Alias)">
|
|
|
|
<Output TaskParameter="Include" Condition="'%(Reference.Alias)'!=''" ItemName="_aliased_refs" />
|
|
|
|
</CreateItem>
|
2008-11-17 18:29:00 -05:00
|
|
|
|
2008-03-05 09:52:00 -05:00
|
|
|
</Target>
|
2008-11-17 18:29:00 -05:00
|
|
|
|
|
|
|
<!--
|
|
|
|
It is necessary to invoke Build\BuildKey.proj, rather than directly invoking sn.exe, in order
|
|
|
|
to avoid a race condition during parallel builds. If you have enough processors, then more than
|
|
|
|
one project can race this sequence: check to see if key file exists, execute sn.exe to create file,
|
|
|
|
one sn.exe opens file for write, another sn.exe attempts to open file for write, but fails because
|
|
|
|
the file is locked. The solution is to use a single MSBuild project as a dependency of all of
|
|
|
|
these projects; that project is Build\BuildKey.proj.
|
|
|
|
|
|
|
|
This points out a general principal: No two projects should ever produce or modify the same file.
|
|
|
|
-->
|
2008-03-05 09:52:00 -05:00
|
|
|
<Target Name="BuildStrongName" DependsOnTargets="CheckErrors"
|
2008-11-17 18:29:00 -05:00
|
|
|
Condition="'$(NoStrongName)'!='true'">
|
|
|
|
<MSBuild Projects="$(SINGULARITY_ROOT)\Build\BuildKey.proj" StopOnFirstFailure="$(StopOnFirstFailure)"/>
|
2008-03-05 09:52:00 -05:00
|
|
|
</Target>
|
2008-11-17 18:29:00 -05:00
|
|
|
|
|
|
|
<PropertyGroup>
|
|
|
|
<ResponseFileName>$(OutputPath)\$(AssemblyName).csic.rsp</ResponseFileName>
|
|
|
|
</PropertyGroup>
|
|
|
|
|
2008-03-05 09:52:00 -05:00
|
|
|
|
|
|
|
<Target Name="BuildAssembly"
|
|
|
|
Inputs="@(Compile);@(Reference);@(Dependency);$(MSBuildProjectFullPath)"
|
|
|
|
Outputs="$(OutputAssemblyPath)"
|
2008-11-17 18:29:00 -05:00
|
|
|
DependsOnTargets="CheckErrors;BuildStrongName;BuildDependentProjects">
|
2008-03-05 09:52:00 -05:00
|
|
|
|
|
|
|
<MakeDir Directories="$(OutputPath)"/>
|
2008-11-17 18:29:00 -05:00
|
|
|
|
|
|
|
<Message Text="Writing response file - $(ResponseFileName)"/>
|
|
|
|
<WriteLinesToFile File="$(ResponseFileName)"
|
|
|
|
Overwrite="true"
|
|
|
|
Lines="
|
|
|
|
@(_aliased_refs->'/r:%(Identity)');
|
|
|
|
@(Compile->'%(FullPath)');
|
|
|
|
"/>
|
|
|
|
|
|
|
|
<Exec Command="$(CSIC) -ilasm:$(ILASM) -out:"$(OutputAssemblyPath)" -outdir:"$(OutputPath)" $(CompilerFlags) -t:library @"$(ResponseFileName)" || (
|
|
|
|
echo Deleting corrupted output - "$(OutputAssemblyPath)" & del "$(OutputAssemblyPath)" /q & exit 1)"/>
|
2008-03-05 09:52:00 -05:00
|
|
|
</Target>
|
|
|
|
|
|
|
|
<Target Name="Build"
|
|
|
|
Outputs="$(OutputAssemblyPath)"
|
|
|
|
DependsOnTargets="BuildAssembly">
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
<Target Name="Clean" DependsOnTargets="$(CleanDependsOn)">
|
|
|
|
<Delete Files="$(OutputAssemblyPath)"/>
|
|
|
|
<Delete Files="$(OutputPath)\$(AssemblyName).pdb"/>
|
|
|
|
<Delete Files="$(OutputPath)\$(AssemblyName).il"/>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
<Target Name="ShowCommands">
|
|
|
|
<MSBuild Projects="@(ProjectReference);@(DependentProject)" Targets="ShowCommands"/>
|
2008-11-17 18:29:00 -05:00
|
|
|
<Message Text="$(CSIC) -ilasm:$(ILASM) -out:"$(OutputAssemblyPath)" -outdir:"$(OutputPath)" $(CompilerFlags) @(_aliased_refs->'/r:%(Identity)',' ') -t:library @(Compile->'"%(Identity)",' ')"/>
|
2008-03-05 09:52:00 -05:00
|
|
|
</Target>
|
|
|
|
|
|
|
|
</Project>
|
|
|
|
|