174 lines
7.2 KiB
XML
174 lines
7.2 KiB
XML
<!--
|
|
This file is an awful hack to create a nmake-like builder for tundra that
|
|
doesn't just kill the tool when you cancel the build.
|
|
-->
|
|
|
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<UsingTask TaskName="VCMessage" AssemblyName="Microsoft.Build.CppTasks.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
|
|
|
<UsingTask TaskName="SofterExec" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
|
<ParameterGroup>
|
|
<Command Required="true" />
|
|
</ParameterGroup>
|
|
<Task>
|
|
<Reference Include="Microsoft.Build.Utilities.v4.0" />
|
|
<Reference Include="Microsoft.Build.Tasks.v4.0" />
|
|
<Code Type="Class" Language="cs">
|
|
<![CDATA[
|
|
using System;
|
|
using Microsoft.Build.Utilities;
|
|
using Microsoft.Build.Framework;
|
|
using System.Diagnostics;
|
|
using System.Runtime.InteropServices;
|
|
public class SofterExec : Task, ICancelableTask
|
|
{
|
|
[DllImport("kernel32.dll", SetLastError=true)]
|
|
static extern bool GenerateConsoleCtrlEvent(ConsoleCtrlEvent sigevent, int dwProcessGroupId);
|
|
public enum ConsoleCtrlEvent
|
|
{
|
|
CTRL_C = 0,
|
|
CTRL_BREAK = 1,
|
|
CTRL_CLOSE = 2,
|
|
CTRL_LOGOFF = 5,
|
|
CTRL_SHUTDOWN = 6
|
|
}
|
|
|
|
public string Command { get; set; }
|
|
|
|
private volatile bool m_Cancel = false;
|
|
|
|
public SofterExec()
|
|
{
|
|
}
|
|
|
|
public void Cancel()
|
|
{
|
|
m_Cancel = true;
|
|
}
|
|
|
|
public override bool Execute()
|
|
{
|
|
try
|
|
{
|
|
using (Process p = new Process())
|
|
{
|
|
p.StartInfo.FileName = "cmd";
|
|
p.StartInfo.Arguments = "/c \"" + Command + "\"";
|
|
p.StartInfo.UseShellExecute = false;
|
|
p.StartInfo.RedirectStandardOutput = true;
|
|
p.StartInfo.RedirectStandardError = true;
|
|
p.OutputDataReceived += (object sender, DataReceivedEventArgs line) => {
|
|
if (line.Data != null)
|
|
Log.LogMessageFromText(line.Data, MessageImportance.High);
|
|
};
|
|
p.ErrorDataReceived += (object sender, DataReceivedEventArgs line) => {
|
|
if (line.Data != null)
|
|
Log.LogMessageFromText(line.Data, MessageImportance.High);
|
|
};
|
|
p.Start();
|
|
p.BeginOutputReadLine();
|
|
p.BeginErrorReadLine();
|
|
|
|
while (!p.WaitForExit(100))
|
|
{
|
|
if (m_Cancel)
|
|
{
|
|
// Keep sending CTRL+C events - sometimes it takes more than one..
|
|
GenerateConsoleCtrlEvent(ConsoleCtrlEvent.CTRL_C, 0);
|
|
}
|
|
}
|
|
|
|
p.WaitForExit();
|
|
return m_Cancel ? false : p.ExitCode == 0;
|
|
}
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
Console.WriteLine(e);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
]]>
|
|
</Code>
|
|
</Task>
|
|
</UsingTask>
|
|
|
|
<Target Name="CoreClean">
|
|
<VCMessage Code="MSB8005" Type="Warning" Arguments="NMakeCleanCommandLine" Condition="'$(NMakeCleanCommandLine)'==''"/>
|
|
<SofterExec Command="$(NMakeCleanCommandLine)" Condition="'$(NMakeCleanCommandLine)'!=''"/>
|
|
</Target>
|
|
|
|
<Target Name="Build" DependsOnTargets="PrepareForNMakeBuild;ResolveReferences;GetTargetPath" Returns="$(NMakeManagedOutput)">
|
|
<VCMessage Code="MSB8005" Type="Warning" Arguments="NMakeBuildCommandLine" Condition="'$(NMakeBuildCommandLine)'==''"/>
|
|
<SofterExec Command="$(NMakeBuildCommandLine)" Condition="'$(NMakeBuildCommandLine)'!=''"/>
|
|
</Target>
|
|
|
|
<Target Name="Rebuild" DependsOnTargets="PrepareForNMakeBuild;Clean;ResolveReferences;GetTargetPath" Returns="$(NMakeManagedOutput)">
|
|
<VCMessage Code="MSB8005" Type="Warning" Arguments="NMakeReBuildCommandLine" Condition="'$(NMakeReBuildCommandLine)'==''"/>
|
|
<SofterExec Command="$(NMakeReBuildCommandLine)" Condition="'$(NMakeReBuildCommandLine)'!=''"/>
|
|
</Target>
|
|
|
|
<!-- *******************************************************************************************
|
|
GetResolved Native Targets
|
|
Since Makefile doesn't import Microsoft.common.targets or microsoft.cppbuild.targets,
|
|
it needs to have its own set of project to project reference targets.
|
|
******************************************************************************************* -->
|
|
|
|
<Target Name="GetResolvedLinkObjs" DependsOnTargets="GetNativeTargetPath" Returns="@(NMakeNativeOutput)" />
|
|
<Target Name="GetResolvedLinkLibs" DependsOnTargets="GetNativeTargetPath" Returns="@(NMakeNativeOutput)" />
|
|
<Target Name="GetResolvedXDCMake" DependsOnTargets="GetNativeTargetPath" Returns="@(NMakeNativeOutput)" />
|
|
<Target Name="GetCopyToOutputDirectoryItems" />
|
|
|
|
<Target Name="SetToGetNativeTargetPath" >
|
|
<ItemGroup>
|
|
<ProjectReference>
|
|
<Targets Condition="'%(Extension)' == '.vcxproj'">GetNativeTargetPath;%(Targets)</Targets>
|
|
</ProjectReference>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<Target Name="GetNativeTargetPath" Returns="@(NMakeNativeOutput)">
|
|
<ItemGroup>
|
|
<NMakeNativeOutput Condition="'$(CLRSupport)' == '' or '$(CLRSupport)' == 'false'" Include="$(TargetPath)" />
|
|
</ItemGroup>
|
|
<ItemGroup>
|
|
<NMakeNativeOutput Condition="'@(NMakeNativeOutput)' != ''" >
|
|
<FileType Condition="'%(NMakeNativeOutput.Extension)' == '.obj'">obj</FileType>
|
|
<FileType Condition="'%(NMakeNativeOutput.Extension)' == '.lib'">lib</FileType>
|
|
<FileType Condition="'%(NMakeNativeOutput.Extension)' == '.dll'">dll</FileType>
|
|
<FileType Condition="'%(NMakeNativeOutput.Extension)' == '.xdc'">xdc</FileType>
|
|
</NMakeNativeOutput>
|
|
</ItemGroup>
|
|
</Target>
|
|
|
|
<Target Name="GetTargetPath" Returns="$(NMakeManagedOutput)">
|
|
<PropertyGroup>
|
|
<NMakeManagedOutput Condition="'$(CLRSupport)' != '' and '$(CLRSupport)' != 'false'">$(TargetPath)</NMakeManagedOutput>
|
|
</PropertyGroup>
|
|
</Target>
|
|
<Target Name="GetNativeManifest" />
|
|
|
|
<!-- *******************************************************************************************
|
|
Property pages
|
|
******************************************************************************************* -->
|
|
<ItemGroup Condition="'$(UseDefaultPropertyPageSchemas)' != 'false'">
|
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\ProjectItemsSchema.xml" />
|
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\directories.xml" />
|
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\debugger_*.xml" />
|
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\nmake.xml" />
|
|
|
|
<!-- project only rules -->
|
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\general_makefile.xml">
|
|
<Context>Project</Context>
|
|
</PropertyPageSchema>
|
|
|
|
<!-- Property sheet only rules -->
|
|
<PropertyPageSchema Include="$(VCTargetsPath)$(LangID)\general_makefile_ps.xml;$(VCTargetsPath)$(LangID)\usermacros.xml">
|
|
<Context>PropertySheet</Context>
|
|
</PropertyPageSchema>
|
|
</ItemGroup>
|
|
|
|
</Project>
|