Add project to fetch and update most of Aegisub's external deps

This commit is contained in:
Thomas Goyne 2012-11-16 10:17:20 -08:00
parent b055abae44
commit 6f01ad7f95
5 changed files with 271 additions and 58 deletions

4
.gitignore vendored
View file

@ -71,3 +71,7 @@ git_version.h
aegisub/tests/data aegisub/tests/data
aegisub/tests/run aegisub/tests/run
aegisub/tests/*.json aegisub/tests/*.json
/packages
/deps
.nuget

View file

@ -1,59 +1,65 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition="'$(Configuration)'==''">Debug</Configuration> <Configuration Condition="'$(Configuration)'==''">Debug</Configuration>
<Platform>AnyCPU</Platform> <Platform>AnyCPU</Platform>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>15c79e75-f5f6-451d-b870-94ed02af257e</ProjectGuid> <ProjectGuid>15c79e75-f5f6-451d-b870-94ed02af257e</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>BuildTakss</RootNamespace> <RootNamespace>BuildTakss</RootNamespace>
<AssemblyName>BuildTasks</AssemblyName> <AssemblyName>BuildTasks</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<Name>BuildTasks</Name> <Name>BuildTasks</Name>
<ProjectName>BuildTasks</ProjectName> <ProjectName>BuildTasks</ProjectName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)..\paths.props" /> <Import Project="$(MSBuildThisFileDirectory)..\paths.props" />
<PropertyGroup> <PropertyGroup>
<OutputPath>$(AegisubBinaryDir)</OutputPath> <OutputPath>$(AegisubBinaryDir)</OutputPath>
<IntermediateOutputPath>$(AegisubObjectDir)</IntermediateOutputPath> <IntermediateOutputPath>$(AegisubObjectDir)</IntermediateOutputPath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<Tailcalls>false</Tailcalls> <Tailcalls>false</Tailcalls>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<WarningLevel>3</WarningLevel> <WarningLevel>3</WarningLevel>
<StartAction>Program</StartAction> <StartAction>Program</StartAction>
<StartProgram>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</StartProgram> <StartProgram>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</StartProgram>
<StartWorkingDirectory>Z:\src\temp\aegisub\aegisub</StartWorkingDirectory> <StartWorkingDirectory>Z:\src\temp\aegisub\aegisub</StartWorkingDirectory>
<StartArguments>/p:BuildProjectReferences=false build\fribidi\fribidi.vcxproj</StartArguments> <StartArguments>/p:BuildProjectReferences=false build\deps\deps.vcxproj</StartArguments>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<Tailcalls>true</Tailcalls> <Tailcalls>true</Tailcalls>
<DefineConstants>TRACE</DefineConstants> <DefineConstants>TRACE</DefineConstants>
<WarningLevel>3</WarningLevel> <WarningLevel>3</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <PropertyGroup>
<Reference Include="Microsoft.Build" /> <MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
<Reference Include="Microsoft.Build.Engine" /> </PropertyGroup>
<Reference Include="Microsoft.Build.Framework" /> <Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')" />
<Reference Include="Microsoft.Build.Utilities.v4.0" /> <ItemGroup>
<Reference Include="mscorlib" /> <Compile Include="BuildTasks.fs" />
<Reference Include="FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> <Compile Include="DependencyFetchers.fs" />
<Reference Include="System" /> <None Include="packages.config" />
<Reference Include="System.Core" /> </ItemGroup>
<Reference Include="System.Numerics" /> <ItemGroup>
<Reference Include="System.Xml" /> <Reference Include="ICSharpCode.SharpZipLib">
</ItemGroup> <HintPath>..\..\..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
<ItemGroup> </Reference>
<Compile Include="BuildTasks.fs" /> <Reference Include="Microsoft.Build" />
</ItemGroup> <Reference Include="Microsoft.Build.Engine" />
<PropertyGroup> <Reference Include="Microsoft.Build.Framework" />
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion> <Reference Include="Microsoft.Build.Utilities.v4.0" />
</PropertyGroup> <Reference Include="mscorlib" />
<Import Project="$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets" Condition=" Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')" /> <Reference Include="FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Net" />
<Reference Include="System.Numerics" />
<Reference Include="System.Xml" />
</ItemGroup>
</Project> </Project>

View file

@ -0,0 +1,132 @@
// Copyright (c) 2012, Thomas Goyne <plorkyeran@aegisub.org>
//
// Permission to use, copy, modify, and distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
//
// Aegisub Project http://www.aegisub.org/
module DependencyFetchers
open System
open System.Diagnostics
open System.Linq
open Microsoft.Build.Evaluation
open Microsoft.Build.Framework
open Microsoft.Build.Utilities
type GitWrapper(path : String) =
inherit ToolTask()
member val Arguments = "" with get, set
member val WorkingDirectory = "" with get, set
// ToolTask overrides
override val ToolName = "git.exe" with get
override this.GenerateFullPathToTool() = path
override this.GenerateCommandLineCommands() = this.Arguments
override this.GetWorkingDirectory() = this.WorkingDirectory
override this.Execute() =
if this.GenerateFullPathToTool() |> IO.File.Exists |> not then
failwith "git.exe not found. Make sure the MSYS root is set to a correct location."
this.UseCommandProcessor <- false
this.StandardOutputImportance <- "High"
base.Execute()
type GitProject() =
inherit Task()
member val Projects : ITaskItem[] = null with get, set
member val Root = "" with get, set
member val GitPath = "" with get, set
override this.Execute() =
let callGit dir args =
let gw = GitWrapper(this.GitPath,
BuildEngine = this.BuildEngine,
HostObject = this.HostObject,
Arguments = args,
WorkingDirectory = dir)
if not <| gw.Execute() then failwith "git failed"
let update (projectName : String) directory url =
this.Log.LogMessage ("Updating {0}", projectName)
callGit directory "pull --rebase"
callGit directory "clean -xfd"
let fetch (projectName : String) root (url : ITaskItem) =
this.Log.LogMessage ("Fetching {0}", projectName)
ignore <| IO.Directory.CreateDirectory root
callGit root (sprintf "clone %s" url.ItemSpec)
let branch = url.GetMetadata("Branch")
if branch.Length > 0
then callGit (sprintf "%s\\%s" root projectName) (sprintf "checkout %s" branch)
let updateGit (url : ITaskItem) =
let projectName = Uri(url.ItemSpec).Segments.Last().Replace(".git", "")
let directory = sprintf "%s\\%s" this.Root projectName
if IO.Directory.Exists directory
then update projectName directory url
else fetch projectName this.Root url
this.Log.LogMessage ("Using git at {0}", this.GitPath)
try
this.Projects |> Array.map updateGit |> ignore
true
with e ->
this.Log.LogErrorFromException e
false
type TarballProject() =
inherit Task()
member val Projects : ITaskItem[] = null with get, set
member val Root = "" with get, set
override this.Execute() =
let needsUpdate directory version =
try
not <| String.Equals(sprintf "%s\\version.aegisub" directory |> IO.File.ReadAllText, version)
with | :? IO.IOException -> true
let update directory (project : ITaskItem) version =
try IO.Directory.Delete(directory, true) with | :? IO.IOException -> ()
this.Log.LogMessage ("Downloading {0} {1} from {2}", project.ItemSpec, version, project.GetMetadata "Url")
use wc = new Net.WebClient()
use downloadStream = project.GetMetadata "Url" |> wc.OpenRead
use gzStream = new ICSharpCode.SharpZipLib.GZip.GZipInputStream(downloadStream)
use tarStream = new ICSharpCode.SharpZipLib.Tar.TarInputStream(gzStream)
use tarArchive = ICSharpCode.SharpZipLib.Tar.TarArchive.CreateInputTarArchive tarStream
sprintf @"%s\.." directory |> tarArchive.ExtractContents
IO.Directory.Move(sprintf @"%s\..\%s-%s" directory project.ItemSpec version, directory)
IO.File.WriteAllText(sprintf @"%s\version.aegisub" directory, version)
let check (project : ITaskItem) =
let directory = sprintf "%s\\%s" this.Root project.ItemSpec
let version = project.GetMetadata "Version"
if needsUpdate directory <| version
then update directory project version
else this.Log.LogMessage <| sprintf "%s is up to date" project.ItemSpec
try
this.Projects |> Array.map check |> ignore
true
with e ->
this.Log.LogErrorFromException e
false

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="SharpZipLib" version="0.86.0" targetFramework="net45" />
</packages>

View file

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (c) 2012, Thomas Goyne <plorkyeran@aegisub.org>
Permission to use, copy, modify, and distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
Aegisub Project http://www.aegisub.org/
-->
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{472212DF-99E8-4B73-9736-8500616D8A80}</ProjectGuid>
<ProjectName>! Update Dependencies</ProjectName>
</PropertyGroup>
<ItemGroup Label="git">
<GitProject Include="git://anongit.freedesktop.org/fribidi/fribidi" />
<GitProject Include="git://git.sv.nongnu.org/freetype/freetype2.git" />
<GitProject Include="git://github.com/madler/zlib.git" />
<GitProject Include="git://source.ffmpeg.org/ffmpeg.git" />
<GitProject Include="git://github.com/tgoyne/ffms2.git">
<Branch>trunk</Branch>
</GitProject>
<GitProject Include="git://github.com/tgoyne/fontconfig.git">
<Branch>msvc</Branch>
</GitProject>
<GitProject Include="git://github.com/tgoyne/libass.git">
<Branch>msvc</Branch>
</GitProject>
</ItemGroup>
<ItemGroup Label="tarball">
<TarballProject Include="fftw">
<Version>3.3.2</Version>
<Url>http://www.fftw.org/fftw-3.3.2.tar.gz</Url>
</TarballProject>
</ItemGroup>
<Import Project="$(MSBuildThisFileDirectory)\..\aegisub.props" />
<UsingTask TaskName="GitProject" AssemblyFile="$(AegisubBinaryDir)BuildTasks.dll" />
<UsingTask TaskName="TarballProject" AssemblyFile="$(AegisubBinaryDir)BuildTasks.dll" />
<Target Name="Build">
<GitProject
Projects="@(GitProject)"
Root="$(MSBuildThisFileDirectory)\..\..\..\deps"
GitPath="$(MsysBasePath)\bin\git.exe"
/>
<TarballProject Projects="@(TarballProject)" Root="$(MSBuildThisFileDirectory)..\..\..\deps" />
</Target>
</Project>