From 6f01ad7f95cccde256d8b473a4259262de03e58b Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Fri, 16 Nov 2012 10:17:20 -0800 Subject: [PATCH] Add project to fetch and update most of Aegisub's external deps --- .gitignore | 4 + aegisub/build/BuildTasks/BuildTasks.fsproj | 122 ++++++++-------- .../build/BuildTasks/DependencyFetchers.fs | 132 ++++++++++++++++++ aegisub/build/BuildTasks/packages.config | 4 + aegisub/build/deps/deps.vcxproj | 67 +++++++++ 5 files changed, 271 insertions(+), 58 deletions(-) create mode 100644 aegisub/build/BuildTasks/DependencyFetchers.fs create mode 100644 aegisub/build/BuildTasks/packages.config create mode 100644 aegisub/build/deps/deps.vcxproj diff --git a/.gitignore b/.gitignore index 768f17312..f0dba3433 100644 --- a/.gitignore +++ b/.gitignore @@ -71,3 +71,7 @@ git_version.h aegisub/tests/data aegisub/tests/run aegisub/tests/*.json + +/packages +/deps +.nuget diff --git a/aegisub/build/BuildTasks/BuildTasks.fsproj b/aegisub/build/BuildTasks/BuildTasks.fsproj index 36561c33f..8163a4eee 100644 --- a/aegisub/build/BuildTasks/BuildTasks.fsproj +++ b/aegisub/build/BuildTasks/BuildTasks.fsproj @@ -1,59 +1,65 @@ - - - - - Debug - AnyCPU - 2.0 - 15c79e75-f5f6-451d-b870-94ed02af257e - Library - BuildTakss - BuildTasks - v4.5 - BuildTasks - BuildTasks - - - - $(AegisubBinaryDir) - $(AegisubObjectDir) - - - true - full - false - false - DEBUG;TRACE - 3 - Program - C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe - Z:\src\temp\aegisub\aegisub - /p:BuildProjectReferences=false build\fribidi\fribidi.vcxproj - - - pdbonly - true - true - TRACE - 3 - - - - - - - - - - - - - - - - - - 11 - - + + + + + Debug + AnyCPU + 2.0 + 15c79e75-f5f6-451d-b870-94ed02af257e + Library + BuildTakss + BuildTasks + v4.5 + BuildTasks + BuildTasks + + + + $(AegisubBinaryDir) + $(AegisubObjectDir) + + + true + full + false + false + DEBUG;TRACE + 3 + Program + C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe + Z:\src\temp\aegisub\aegisub + /p:BuildProjectReferences=false build\deps\deps.vcxproj + + + pdbonly + true + true + TRACE + 3 + + + 11 + + + + + + + + + + ..\..\..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll + + + + + + + + + + + + + \ No newline at end of file diff --git a/aegisub/build/BuildTasks/DependencyFetchers.fs b/aegisub/build/BuildTasks/DependencyFetchers.fs new file mode 100644 index 000000000..1cadfe83f --- /dev/null +++ b/aegisub/build/BuildTasks/DependencyFetchers.fs @@ -0,0 +1,132 @@ +// Copyright (c) 2012, Thomas Goyne +// +// 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 diff --git a/aegisub/build/BuildTasks/packages.config b/aegisub/build/BuildTasks/packages.config new file mode 100644 index 000000000..6caeef935 --- /dev/null +++ b/aegisub/build/BuildTasks/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/aegisub/build/deps/deps.vcxproj b/aegisub/build/deps/deps.vcxproj new file mode 100644 index 000000000..0729970f7 --- /dev/null +++ b/aegisub/build/deps/deps.vcxproj @@ -0,0 +1,67 @@ + + + + + + Debug + Win32 + + + + {472212DF-99E8-4B73-9736-8500616D8A80} + ! Update Dependencies + + + + + + + + + trunk + + + msvc + + + msvc + + + + + + 3.3.2 + http://www.fftw.org/fftw-3.3.2.tar.gz + + + + + + + + + + + + +