mirror of
https://github.com/Ryujinx/Opentk.git
synced 2024-12-23 13:25:27 +00:00
Added Build.Tasks project that contains custom MSBuild tasks for the compilation process:
- DateStamp, which generates a version number based on the current date. - DelTree which mimics RemoveDir but can delete non-empty directories on xbuild 2.6.x (which only supports empty directories). - Run which mimics Exec but also captures stderr/stdout.
This commit is contained in:
parent
1f4b5be7d0
commit
16009bf9f3
78
Source/Build.Tasks/Build.Tasks.csproj
Normal file
78
Source/Build.Tasks/Build.Tasks.csproj
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProductVersion>8.0.30703</ProductVersion>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
<ProjectGuid>{CCE26215-7591-4CC3-8E39-9A08F8BF35E2}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>Build.Tasks</RootNamespace>
|
||||||
|
<AssemblyName>Build.Tasks</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>..\..\Binaries\OpenTK\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Documentation|AnyCPU'">
|
||||||
|
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Nsis|AnyCPU'">
|
||||||
|
<OutputPath>..\..\Binaries\OpenTK\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<CodeAnalysisLogFile>..\..\Binaries\OpenTK\Release\Build.Tasks.dll.CodeAnalysisLog.xml</CodeAnalysisLogFile>
|
||||||
|
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
|
||||||
|
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<CodeAnalysisRuleSetDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\\Rule Sets</CodeAnalysisRuleSetDirectories>
|
||||||
|
<CodeAnalysisRuleDirectories>;C:\Program Files\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
|
||||||
|
<CodeAnalysisIgnoreBuiltInRules>false</CodeAnalysisIgnoreBuiltInRules>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="Microsoft.Build.Framework" />
|
||||||
|
<Reference Include="Microsoft.Build.Utilities" />
|
||||||
|
<Reference Include="System" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Run.cs" />
|
||||||
|
<Compile Include="DateStamp.cs" />
|
||||||
|
<Compile Include="DelTree.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Common.xml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
14
Source/Build.Tasks/Common.xml
Normal file
14
Source/Build.Tasks/Common.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' != 'Debug' ">Release</Configuration>
|
||||||
|
<BuildTasksPath Condition="'$(BuildTasksPath)' == ''">..\..\Binaries\OpenTK\Release</BuildTasksPath>
|
||||||
|
<BuildTasksLib>$(BuildTasksPath)\Build.Tasks.dll</BuildTasksLib>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<UsingTask AssemblyFile="$(BuildTasksLib)" TaskName="DateStamp" Condition="'$(Target)' != 'Clean'" />
|
||||||
|
<UsingTask AssemblyFile="$(BuildTasksLib)" TaskName="DelTree" Condition="'$(Target)' != 'Clean'" />
|
||||||
|
<UsingTask AssemblyFile="$(BuildTasksLib)" TaskName="Run" Condition="'$(Target)' != 'Clean'" />
|
||||||
|
|
||||||
|
</Project>
|
39
Source/Build.Tasks/DateStamp.cs
Normal file
39
Source/Build.Tasks/DateStamp.cs
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
|
||||||
|
namespace Build.Tasks
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a date stamp in the form yyMMdd.
|
||||||
|
/// </summary>
|
||||||
|
public class DateStamp : Task
|
||||||
|
{
|
||||||
|
string date;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a <see cref="System.String"/> represting the date stamp.
|
||||||
|
/// </summary>
|
||||||
|
[Output]
|
||||||
|
public string Date
|
||||||
|
{
|
||||||
|
get { return date; }
|
||||||
|
private set { date = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Date = DateTime.Now.ToString("yyMMdd", CultureInfo.InvariantCulture);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.LogErrorFromException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
50
Source/Build.Tasks/DelTree.cs
Normal file
50
Source/Build.Tasks/DelTree.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
|
||||||
|
namespace Build.Tasks
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes directory and all of its contents.
|
||||||
|
/// Replaces RemoveDir task which exhibits different behavior
|
||||||
|
/// on xbuild compared to msbuild: the first requires an empty
|
||||||
|
/// directory, while the latter does not.
|
||||||
|
/// </summary>
|
||||||
|
public class DelTree : Task
|
||||||
|
{
|
||||||
|
string path;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The filesystem path to delete.
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string Path
|
||||||
|
{
|
||||||
|
get { return path; }
|
||||||
|
set { path = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (String.IsNullOrEmpty(Path) ||
|
||||||
|
System.IO.Directory.Exists(Path))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.IO.Directory.Delete(Path, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.LogErrorFromException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
36
Source/Build.Tasks/Properties/AssemblyInfo.cs
Normal file
36
Source/Build.Tasks/Properties/AssemblyInfo.cs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("Build.Time")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("Build.Time")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2010")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("f1d4ac4c-e931-44f4-ac34-966f3ec505e3")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
94
Source/Build.Tasks/Run.cs
Normal file
94
Source/Build.Tasks/Run.cs
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using Microsoft.Build.Framework;
|
||||||
|
using Microsoft.Build.Utilities;
|
||||||
|
|
||||||
|
namespace Build.Tasks
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Executes specified process, capturing its stdout/stderr output.
|
||||||
|
/// Replaces Exec task which does not capture output.
|
||||||
|
/// </summary>
|
||||||
|
public class Run : Task
|
||||||
|
{
|
||||||
|
string command, args, wdir;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The command to execute.
|
||||||
|
/// </summary>
|
||||||
|
[Required]
|
||||||
|
public string Command
|
||||||
|
{
|
||||||
|
get { return command; }
|
||||||
|
set { command = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The working directory for the command.
|
||||||
|
/// </summary>
|
||||||
|
public string WorkingDirectory
|
||||||
|
{
|
||||||
|
get { return wdir; }
|
||||||
|
set { wdir = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Execute()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (String.IsNullOrEmpty(command))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split arguments from command:
|
||||||
|
int arg_end = command.IndexOf(' ');
|
||||||
|
ProcessStartInfo psi = null;
|
||||||
|
if (arg_end > 0)
|
||||||
|
{
|
||||||
|
psi = new ProcessStartInfo(command.Substring(0, arg_end), command.Substring(arg_end + 1));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
psi = new ProcessStartInfo(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
psi.UseShellExecute = false;
|
||||||
|
if (!String.IsNullOrEmpty(wdir))
|
||||||
|
{
|
||||||
|
psi.WorkingDirectory = wdir;
|
||||||
|
}
|
||||||
|
|
||||||
|
Process p = new Process();
|
||||||
|
p.ErrorDataReceived += LogErrors;
|
||||||
|
p.OutputDataReceived += LogOutput;
|
||||||
|
p.StartInfo = psi;
|
||||||
|
|
||||||
|
Log.LogMessage("Running {0} {1} on directory {2}",
|
||||||
|
psi.FileName,
|
||||||
|
psi.Arguments,
|
||||||
|
String.IsNullOrEmpty(psi.WorkingDirectory) ?
|
||||||
|
Environment.CurrentDirectory : psi.WorkingDirectory);
|
||||||
|
|
||||||
|
if (p.Start())
|
||||||
|
p.WaitForExit();
|
||||||
|
return p.ExitCode == 0;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log.LogErrorFromException(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogErrors(object sender, DataReceivedEventArgs e)
|
||||||
|
{
|
||||||
|
Log.LogError(e.Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogOutput(object sender, DataReceivedEventArgs e)
|
||||||
|
{
|
||||||
|
Log.LogMessage(e.Data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue