mirror of https://github.com/odrling/Aegisub
Add fribidi project
This commit is contained in:
parent
3cf2a39884
commit
ffcd455713
|
@ -47,7 +47,7 @@
|
||||||
<!-- Update git_version.h -->
|
<!-- Update git_version.h -->
|
||||||
<UsingTask TaskName="ExecShellScript" AssemblyFile="$(AegisubBinaryDir)\BuildTasks.dll" />
|
<UsingTask TaskName="ExecShellScript" AssemblyFile="$(AegisubBinaryDir)\BuildTasks.dll" />
|
||||||
<Target Name="UpdateVersion" BeforeTargets="ClCompile">
|
<Target Name="UpdateVersion" BeforeTargets="ClCompile">
|
||||||
<ExecShellScript Command="build/version.sh .." />
|
<ExecShellScript Script="../../build/version.sh" Arguments=".." />
|
||||||
</Target>
|
</Target>
|
||||||
<!-- Project References -->
|
<!-- Project References -->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -22,8 +22,8 @@ open Microsoft.Build.Evaluation
|
||||||
open Microsoft.Build.Framework
|
open Microsoft.Build.Framework
|
||||||
open Microsoft.Build.Utilities
|
open Microsoft.Build.Utilities
|
||||||
|
|
||||||
exception ShellException of string
|
/// Search the executable path for the directory containing the given file and
|
||||||
|
/// return it or empty string if not found
|
||||||
let searchPath file =
|
let searchPath file =
|
||||||
Environment.GetEnvironmentVariable("path").Split ';'
|
Environment.GetEnvironmentVariable("path").Split ';'
|
||||||
|> Seq.map (fun p -> IO.Path.Combine(p, file))
|
|> Seq.map (fun p -> IO.Path.Combine(p, file))
|
||||||
|
@ -31,6 +31,8 @@ let searchPath file =
|
||||||
|> Seq.append [""]
|
|> Seq.append [""]
|
||||||
|> Seq.nth 1
|
|> Seq.nth 1
|
||||||
|
|
||||||
|
/// Read all of the defined properties from the calling project file and stuff
|
||||||
|
/// them in a Map
|
||||||
let propertyMap (be : IBuildEngine) =
|
let propertyMap (be : IBuildEngine) =
|
||||||
use reader = Xml.XmlReader.Create(be.ProjectFileOfTaskNode)
|
use reader = Xml.XmlReader.Create(be.ProjectFileOfTaskNode)
|
||||||
let project = new Project(reader)
|
let project = new Project(reader)
|
||||||
|
@ -41,44 +43,106 @@ let propertyMap (be : IBuildEngine) =
|
||||||
|> Seq.map (fun x -> (x.Name, x.EvaluatedValue))
|
|> Seq.map (fun x -> (x.Name, x.EvaluatedValue))
|
||||||
|> Map.ofSeq
|
|> Map.ofSeq
|
||||||
|
|
||||||
|
/// Convert a windows path possibly relative to the Aegisub project file to an
|
||||||
|
/// absolute msys path
|
||||||
|
let mungePath projectDir path =
|
||||||
|
let matchre pat str =
|
||||||
|
let m = System.Text.RegularExpressions.Regex.Match(str, pat)
|
||||||
|
if m.Success
|
||||||
|
then List.tail [ for g in m.Groups -> g.Value ]
|
||||||
|
else []
|
||||||
|
match IO.Path.Combine(projectDir, path) |> matchre "([A-Za-z]):\\\\(.*)" with
|
||||||
|
| drive :: path :: [] -> sprintf "/%s/%s" drive (path.Replace('\\', '/'))
|
||||||
|
| _ -> failwith <| sprintf "Bad path: '%s' '%s'" projectDir path
|
||||||
|
|
||||||
type ShellWrapper(props : Map<String, String>) =
|
type ShellWrapper(props : Map<String, String>) =
|
||||||
|
let setPath msysRoot =
|
||||||
|
Environment.SetEnvironmentVariable("path", msysRoot + "\\bin;" + props.["NativeExecutablePath"])
|
||||||
|
Environment.SetEnvironmentVariable("CC", "cl")
|
||||||
|
Environment.SetEnvironmentVariable("INCLUDE", props.["IncludePath"])
|
||||||
|
Environment.SetEnvironmentVariable("LIB", props.["LibraryPath"])
|
||||||
|
|
||||||
let sh =
|
let sh =
|
||||||
match props.TryFind "MsysBasePath" with
|
match props.TryFind "MsysBasePath" with
|
||||||
| None | Some "" -> searchPath "sh.exe"
|
| None | Some "" -> searchPath "sh.exe"
|
||||||
| Some path -> sprintf "%s\\bin\\sh.exe" path
|
| Some path -> setPath path; sprintf "%s\\bin\\sh.exe" path
|
||||||
|
|
||||||
let cwd = function
|
let cwd = function
|
||||||
| null | "" -> props.["AegisubSourceBase"]
|
| null | "" -> props.["AegisubSourceBase"]
|
||||||
| x -> x
|
| x -> if not <| IO.Directory.Exists x then ignore <| IO.Directory.CreateDirectory(x)
|
||||||
|
x
|
||||||
|
|
||||||
member this.call scriptName workingDir =
|
member this.call args workingDir =
|
||||||
if not <| IO.File.Exists sh then
|
if not <| IO.File.Exists sh then
|
||||||
raise <| ShellException "sh.exe not found. Make sure the MSYS root is set to a correct location."
|
failwith "sh.exe not found. Make sure the MSYS root is set to a correct location."
|
||||||
|
|
||||||
let info = new ProcessStartInfo(FileName = sh
|
let info = new ProcessStartInfo(FileName = sh
|
||||||
, Arguments = scriptName
|
, Arguments = args
|
||||||
, WorkingDirectory = cwd workingDir
|
, WorkingDirectory = cwd workingDir
|
||||||
, RedirectStandardOutput = true
|
, RedirectStandardOutput = true
|
||||||
, UseShellExecute = false)
|
, UseShellExecute = false)
|
||||||
|
|
||||||
use p = new Process(StartInfo = info)
|
use p = new Process(StartInfo = info)
|
||||||
ignore(p.Start())
|
ignore(p.Start())
|
||||||
|
let output = p.StandardOutput.ReadToEnd()
|
||||||
p.WaitForExit()
|
p.WaitForExit()
|
||||||
if p.ExitCode <> 0 then
|
if p.ExitCode <> 0 then
|
||||||
raise <| ShellException(p.StandardOutput.ReadToEnd())
|
failwith output
|
||||||
|
|
||||||
|
member this.callScript scriptName args workingDir =
|
||||||
|
this.call (sprintf "%s %s" (mungePath props.["ProjectDir"] scriptName) args) workingDir
|
||||||
|
|
||||||
type ExecShellScript() =
|
type ExecShellScript() =
|
||||||
inherit Task()
|
inherit Task()
|
||||||
|
|
||||||
member val WorkingDirectory = "" with get, set
|
member val WorkingDirectory = "" with get, set
|
||||||
member val Command = "" with get, set
|
member val Command = "" with get, set
|
||||||
|
member val Script = "" with get, set
|
||||||
|
member val Arguments = "" with get, set
|
||||||
|
|
||||||
override this.Execute() =
|
override this.Execute() =
|
||||||
try
|
try
|
||||||
let sw = ShellWrapper (propertyMap this.BuildEngine)
|
let sw = ShellWrapper (propertyMap this.BuildEngine)
|
||||||
this.Log.LogMessage("Calling '{0}'", this.Command);
|
if this.Script.Length > 0
|
||||||
sw.call this.Command this.WorkingDirectory
|
then this.Log.LogMessage("Calling '{0}' {1}", this.Script, this.Arguments);
|
||||||
|
sw.callScript this.Script this.Arguments this.WorkingDirectory
|
||||||
|
else this.Log.LogMessage("Calling '{0}' {1}", this.Command, this.Arguments);
|
||||||
|
sw.call (sprintf "-c '%s %s'" this.Command this.Arguments) this.WorkingDirectory
|
||||||
true
|
true
|
||||||
with ShellException(e) ->
|
with Failure(e) ->
|
||||||
this.Log.LogError(e)
|
this.Log.LogError(e)
|
||||||
false
|
false
|
||||||
|
|
||||||
|
type MsysPath() =
|
||||||
|
inherit Task()
|
||||||
|
|
||||||
|
member val ProjectDir = "" with get, set
|
||||||
|
member val Path = "" with get, set
|
||||||
|
|
||||||
|
[<Output>]
|
||||||
|
member val Result = "" with get, set
|
||||||
|
|
||||||
|
override this.Execute() =
|
||||||
|
try
|
||||||
|
this.Result <- mungePath this.ProjectDir this.Path
|
||||||
|
true
|
||||||
|
with Failure(e) ->
|
||||||
|
this.Log.LogError(e)
|
||||||
|
false
|
||||||
|
|
||||||
|
type UpdateFile() =
|
||||||
|
inherit Task()
|
||||||
|
|
||||||
|
member val File = "" with get, set
|
||||||
|
member val Find = "" with get, set
|
||||||
|
member val Replacement = "" with get, set
|
||||||
|
|
||||||
|
override this.Execute() =
|
||||||
|
try
|
||||||
|
this.Log.LogMessage("Replacing '{0}' with '{1}' in '{2}'", this.Find, this.Replacement, this.File)
|
||||||
|
let text = IO.File.ReadAllText(this.File).Replace(this.Find, this.Replacement)
|
||||||
|
IO.File.WriteAllText(this.File, text)
|
||||||
|
true
|
||||||
|
with e ->
|
||||||
|
this.Log.LogErrorFromException e
|
||||||
|
false
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?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>
|
||||||
|
@ -25,6 +25,10 @@
|
||||||
<Tailcalls>false</Tailcalls>
|
<Tailcalls>false</Tailcalls>
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
<WarningLevel>3</WarningLevel>
|
<WarningLevel>3</WarningLevel>
|
||||||
|
<StartAction>Program</StartAction>
|
||||||
|
<StartProgram>C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</StartProgram>
|
||||||
|
<StartWorkingDirectory>Z:\src\temp\aegisub\aegisub</StartWorkingDirectory>
|
||||||
|
<StartArguments>/p:BuildProjectReferences=false build\fribidi\fribidi.vcxproj</StartArguments>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<DebugType>pdbonly</DebugType>
|
<DebugType>pdbonly</DebugType>
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<!-- VC boilerplate -->
|
||||||
|
<ItemGroup Label="ProjectConfigurations">
|
||||||
|
<ProjectConfiguration Include="Debug|Win32">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Debug|x64">
|
||||||
|
<Configuration>Debug</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|Win32">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>Win32</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
<ProjectConfiguration Include="Release|x64">
|
||||||
|
<Configuration>Release</Configuration>
|
||||||
|
<Platform>x64</Platform>
|
||||||
|
</ProjectConfiguration>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>{FB8E8D19-A4D6-4181-943C-282075F49B41}</ProjectGuid>
|
||||||
|
<Keyword>MakeFileProj</Keyword>
|
||||||
|
<ConfigurationType>Makefile</ConfigurationType>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<!-- Aegisub project configuration -->
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Project="$(MSBuildThisFileDirectory)..\aegisub.props" />
|
||||||
|
</ImportGroup>
|
||||||
|
|
||||||
|
<UsingTask TaskName="ExecShellScript" AssemblyFile="$(AegisubBinaryDir)BuildTasks.dll" />
|
||||||
|
<UsingTask TaskName="MsysPath" AssemblyFile="$(AegisubBinaryDir)BuildTasks.dll" />
|
||||||
|
<UsingTask TaskName="UpdateFile" AssemblyFile="$(AegisubBinaryDir)BuildTasks.dll" />
|
||||||
|
|
||||||
|
<PropertyGroup Label="ConfigArgs">
|
||||||
|
<CfgEnableDebug Condition="'$(Configuration)' == 'Debug'">--enable-debug</CfgEnableDebug>
|
||||||
|
<CfgEnableDebug Condition="'$(Configuration)' == 'Release'">--disable-debug</CfgEnableDebug>
|
||||||
|
<CfgArgs>--enable-static --disable-shared --disable-dependency-tracking --without-glib $(CfgEnableDebug)</CfgArgs>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<Target Name="Configure">
|
||||||
|
<MsysPath ProjectDir="$(MSBuildThisFileDirectory)" Path="$(AegisubObjectDir)\temp">
|
||||||
|
<Output TaskParameter="Result" PropertyName="CfgPrefix" />
|
||||||
|
</MsysPath>
|
||||||
|
|
||||||
|
<MsysPath ProjectDir="$(MSBuildThisFileDirectory)" Path="../../include">
|
||||||
|
<Output TaskParameter="Result" PropertyName="CfgIncludePrefix" />
|
||||||
|
</MsysPath>
|
||||||
|
|
||||||
|
<MsysPath ProjectDir="$(MSBuildThisFileDirectory)" Path="../../lib/$(Platform)/$(Configuration)">
|
||||||
|
<Output TaskParameter="Result" PropertyName="CfgLibPrefix" />
|
||||||
|
</MsysPath>
|
||||||
|
|
||||||
|
<ExecShellScript
|
||||||
|
Script="$(FribidiSrcDir)\configure"
|
||||||
|
Arguments="$(CfgArgs) --prefix=$(CfgPrefix) --libdir=$(CfgLibPrefix) --includedir=$(CfgIncludePrefix)"
|
||||||
|
WorkingDirectory="$(AegisubObjectDir)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- fribidi defines the symbols to export twice, which causes errors -->
|
||||||
|
<UpdateFile File="$(AegisubObjectDir)lib\Makefile" Find=" %24(am__append_1)" Replacement="" />
|
||||||
|
<!-- We only want the library and the docs want c2man, so remove
|
||||||
|
unused stuff from SUBDIRS -->
|
||||||
|
<UpdateFile File="$(AegisubObjectDir)Makefile" Find=" bin doc test" Replacement="" />
|
||||||
|
</Target>
|
||||||
|
|
||||||
|
<Target Name="Build">
|
||||||
|
<Error Condition="!Exists('$(FribidiSrcDir)')" Text="Fribidi source not found at '$(FribidiSrcDir)'" />
|
||||||
|
|
||||||
|
<ExecShellScript
|
||||||
|
Condition="!Exists('$(FribidiSrcDir)\configure')"
|
||||||
|
Script="$(FribidiSrcDir)\bootstrap"
|
||||||
|
WorkingDirectory="$(FribidiSrcDir)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<CallTarget Targets="Configure" Condition="!Exists('$(AegisubObjectDir)\Makefile')" />
|
||||||
|
|
||||||
|
<ExecShellScript
|
||||||
|
Command="make"
|
||||||
|
Arguments="-j$(NUMBER_OF_PROCESSORS)"
|
||||||
|
WorkingDirectory="$(AegisubObjectDir)"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<ExecShellScript
|
||||||
|
Command="make install"
|
||||||
|
WorkingDirectory="$(AegisubObjectDir)"
|
||||||
|
/>
|
||||||
|
</Target>
|
||||||
|
</Project>
|
|
@ -0,0 +1,2 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
|
Loading…
Reference in New Issue