Obey the platform/configuration set in the UI for ffmpeg and fribidi

This commit is contained in:
Thomas Goyne 2012-11-15 12:36:23 -08:00
parent eaf66ea329
commit 0be698965a
7 changed files with 95 additions and 82 deletions

View File

@ -45,9 +45,12 @@
</ClCompile>
</ItemDefinitionGroup>
<!-- Update git_version.h -->
<UsingTask TaskName="ExecShellScript" AssemblyFile="$(AegisubBinaryDir)\BuildTasks.dll" />
<Target Name="UpdateVersion" BeforeTargets="ClCompile">
<ExecShellScript Script="../../build/version.sh" Arguments=".." />
<ExecShellScript
Command="$(MSBuildThisFileDirectory)..\version.sh"
WorkingDirectory="$(AegisubSourceBase)"
Configuration="@(ExecShellScript)"
Arguments=".." />
</Target>
<!-- Project References -->
<ItemGroup>

View File

@ -34,36 +34,26 @@ let propertyMap (be : IBuildEngine) =
|> Seq.map (fun x -> (x.Name, x.EvaluatedValue))
|> Map.ofSeq
/// Convert a windows path possibly relative to the Aegisub project file to an
/// absolute msys path
let mungePath projectDir path =
/// Convert an absolute windows path to an msys path
let mungePath 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
match matchre "([A-Za-z]):\\\\(.*)" path with
| drive :: path :: [] -> sprintf "/%s/%s" drive (path.Replace('\\', '/'))
| _ -> failwith <| sprintf "Bad path: '%s' '%s'" projectDir path
| _ -> path
type ShellWrapper(props : Map<String, String>) =
type ShellWrapper(conf : ITaskItem) =
inherit ToolTask()
let cwd = function
| null | "" -> props.["AegisubSourceBase"]
| x -> if not <| IO.Directory.Exists x then ignore <| IO.Directory.CreateDirectory(x)
x
member val Arguments = "" with get, set
member val WorkingDirectory = "" with get, set
member this.callScript scriptName args =
this.Arguments <- sprintf "%s %s" (mungePath props.["ProjectDir"] scriptName) args
this.Execute()
// ToolTask overrides
override val ToolName = "sh.exe" with get
override this.GenerateFullPathToTool() = sprintf "%s\\bin\\sh.exe" props.["MsysBasePath"]
override this.GenerateFullPathToTool() = conf.GetMetadata "Sh"
override this.GenerateCommandLineCommands() = this.Arguments
override this.GetWorkingDirectory() = this.WorkingDirectory
@ -71,43 +61,33 @@ type ShellWrapper(props : Map<String, String>) =
if this.GenerateFullPathToTool() |> IO.File.Exists |> not then
failwith "sh.exe not found. Make sure the MSYS root is set to a correct location."
this.WorkingDirectory <- cwd this.WorkingDirectory
if not <| IO.Directory.Exists this.WorkingDirectory then ignore <| IO.Directory.CreateDirectory this.WorkingDirectory
this.UseCommandProcessor <- false
this.StandardOutputImportance <- "High"
this.EnvironmentVariables <- [|
"CC=cl";
"CPP=cl -E";
"CFLAGS=-nologo"
"PATH=" + props.["MsysBasePath"] + "\\bin;" + props.["NativeExecutablePath"];
"INCLUDE=" + props.["AegisubSourceBase"] + "//include;" + props.["IncludePath"];
"LIB=" + props.["AegisubLibraryDir"] + ";" + props.["LibraryPath"];
"PKG_CONFIG_PATH=" + (mungePath props.["ProjectDir"] props.["AegisubLibraryDir"]) + "/pkgconfig"
|]
this.EnvironmentVariables <- [| for x in ["CC"; "CPP"; "CFLAGS"; "PATH"; "INCLUDE"; "LIB"]
-> sprintf "%s=%s" <| x <| conf.GetMetadata x |]
base.Execute()
type ExecShellScript() =
inherit Task()
// Task arguments
member val WorkingDirectory = "" with get, set
member val Command = "" with get, set
member val Script = "" with get, set
[<Required>] member val WorkingDirectory = "" with get, set
[<Required>] member val Command = "" with get, set
[<Required>] member val Configuration : ITaskItem = null with get, set
member val Arguments = "" with get, set
member private this.realArgs (props : Map<String, String>) =
member private this.realArgs () =
let cleanArgs = this.Arguments.Replace("\r", "").Replace('\n', ' ')
if this.Script.Length > 0
then sprintf "%s %s" (mungePath props.["ProjectDir"] this.Script) cleanArgs
else sprintf "-c '%s %s'" this.Command cleanArgs
sprintf "-c '%s %s'" (mungePath this.Command) cleanArgs
override this.Execute() =
try
let props = propertyMap this.BuildEngine
let sw = ShellWrapper(props,
let sw = ShellWrapper(this.Configuration,
BuildEngine = this.BuildEngine,
HostObject = this.HostObject,
Arguments = this.realArgs props,
Arguments = this.realArgs(),
WorkingDirectory = this.WorkingDirectory)
sw.Execute()
@ -118,15 +98,12 @@ type ExecShellScript() =
type MsysPath() =
inherit Task()
member val ProjectDir = "" with get, set
member val Path = "" with get, set
[<Output>]
member val Result = "" with get, set
[<Output>] member val Result = "" with get, set
override this.Execute() =
try
this.Result <- mungePath this.ProjectDir this.Path
this.Result <- mungePath this.Path
true
with Failure(e) ->
this.Log.LogError(e)

View File

@ -33,6 +33,7 @@
<Import Project="$(MSBuildThisFileDirectory)Aegisub\standard-libraries.props" />
<Import Project="$(MSBuildThisFileDirectory)standard-settings.props" />
<Import Project="$(MSBuildThisFileDirectory)standard-outdirs.props" />
<Import Project="$(MSBuildThisFileDirectory)tasks.props" />
</ImportGroup>
<!-- The standard targets need to go last for all paths to be proper -->

View File

@ -31,10 +31,6 @@
<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">
<CfgDebug Condition="'$(Configuration)' == 'Debug'">--enable-debug --disable-stripping --extra-cflags=-MDd</CfgDebug>
<CfgDebug Condition="'$(Configuration)' == 'Release'">--disable-debug --extra-cflags=-MD</CfgDebug>
@ -63,23 +59,24 @@
--extra-cflags=-D_SYSCRT
--extra-cflags=-wd4005
--extra-cflags=-wd4189
--extra-cflags=-FI$(MSBuildThisFileDirectory)dynamic_msvcrt.h
--extra-cflags=-FIdynamic_msvcrt.h
--toolchain=msvc
$(CfgEnableDebug)
$(CfgDebug)
</CfgArgs>
<AbsSrcDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(FfmpegSrcDir)'))</AbsSrcDir>
</PropertyGroup>
<ItemGroup>
<ConfigureInput Include="$(FfmpegSrcDir)\configure" />
<ConfigureInput Include="$(AbsSrcDir)\configure" />
<ConfigureOutput Include="$(AegisubObjectDir)config.*" />
<ConfigureOutput Include="$(AegisubObjectDir)Makefile" />
<ConfigureOutput Include="$(AegisubObjectDir)libavutil\avconfig.h" />
<CompileInput Include="$(FfmpegSrcDir)\*.mak" />
<CompileInput Include="$(FfmpegSrcDir)\**\*.c" />
<CompileInput Include="$(FfmpegSrcDir)\**\*.asm" />
<CompileInput Include="$(FfmpegSrcDir)\**\Makefile" />
<CompileInput Include="$(AbsSrcDir)\*.mak" />
<CompileInput Include="$(AbsSrcDir)\**\*.c" />
<CompileInput Include="$(AbsSrcDir)\**\*.asm" />
<CompileInput Include="$(AbsSrcDir)\**\Makefile" />
<CompileOutput Include="$(AegisubObjectDir)libavcodec\libavcodec.a" />
<CompileOutput Include="$(AegisubObjectDir)libavformat\libavformat.a" />
@ -96,22 +93,23 @@
Inputs="@(ConfigureInput)"
Outputs="@(ConfigureOutput)"
>
<MsysPath ProjectDir="$(MSBuildThisFileDirectory)" Path="$(AegisubObjectDir)\temp">
<MsysPath Path="$(AegisubObjectDir)\temp">
<Output TaskParameter="Result" PropertyName="CfgPrefix" />
</MsysPath>
<MsysPath ProjectDir="$(MSBuildThisFileDirectory)" Path="../../include">
<MsysPath Path="$(MSBuildThisFileDirectory)../../include">
<Output TaskParameter="Result" PropertyName="CfgIncludePrefix" />
</MsysPath>
<MsysPath ProjectDir="$(MSBuildThisFileDirectory)" Path="../../lib/$(Platform)/$(Configuration)">
<MsysPath Path="$(AegisubLibraryDir)">
<Output TaskParameter="Result" PropertyName="CfgLibPrefix" />
</MsysPath>
<ExecShellScript
Script="$(FfmpegSrcDir)\configure"
Command="$(AbsSrcDir)\configure"
Arguments="$(CfgArgs) --prefix=$(CfgPrefix) --libdir=$(CfgLibPrefix) --incdir=$(CfgIncludePrefix)"
WorkingDirectory="$(AegisubObjectDir)"
Configuration="@(ExecShellScript)"
/>
<!-- Ensure that Makefile has a recent modified time to avoid
@ -127,6 +125,7 @@
Command="make"
Arguments="-j$(NUMBER_OF_PROCESSORS)"
WorkingDirectory="$(AegisubObjectDir)"
Configuration="@(ExecShellScript)"
/>
</Target>
@ -137,11 +136,12 @@
<ExecShellScript
Command="make install"
WorkingDirectory="$(AegisubObjectDir)"
Configuration="@(ExecShellScript)"
/>
</Target>
<Target Name="Build">
<Error Condition="!Exists('$(FfmpegSrcDir)')" Text="FFmpeg source not found at '$(FfmpegSrcDir)'" />
<Error Condition="!Exists('$(AbsSrcDir)')" Text="FFmpeg source not found at '$(AbsSrcDir)'" />
<CallTarget Targets="Configure" />
<CallTarget Targets="Compile" />

View File

@ -31,51 +31,56 @@
<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>
<CfgDebug Condition="'$(Configuration)' == 'Debug'">--enable-debug CFLAGS=-MDd</CfgDebug>
<CfgDebug Condition="'$(Configuration)' == 'Release'">--disable-debug CFLAGS=-MD</CfgDebug>
<CfgArgs>
--enable-static
--disable-shared
--disable-dependency-tracking
--without-glib
$(CfgEnableDebug)
</CfgArgs>
<AbsSrcDir>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)$(FribidiSrcDir)'))</AbsSrcDir>
</PropertyGroup>
<ItemGroup>
<AutomakeFiles Include="$(FribidiSrcDir)\**\*.am" />
<SourceFiles Include="$(FribidiSrcDir)\**\*.c" />
<SourceFiles Include="$(FribidiSrcDir)\**\*.h" />
<AutomakeFiles Include="$(AbsSrcDir)\**\*.am" />
<SourceFiles Include="$(AbsSrcDir)\**\*.c" />
<SourceFiles Include="$(AbsSrcDir)\**\*.h" />
</ItemGroup>
<Target Name="Bootstrap"
Inputs="$(FribidiSrcDir)\configure.ac;@(AutomakeFiles)"
Outputs="$(FribidiSrcDir)\configure"
Inputs="$(AbsSrcDir)\configure.ac;@(AutomakeFiles)"
Outputs="$(AbsSrcDir)\configure"
>
<ExecShellScript
Script="$(FribidiSrcDir)\bootstrap"
WorkingDirectory="$(FribidiSrcDir)"
Command="$(AbsSrcDir)\bootstrap"
WorkingDirectory="$(AbsSrcDir)"
Configuration="@(ExecShellScript)"
/>
</Target>
<Target Name="Configure"
Inputs="$(FribidiSrcDir)\configure"
Inputs="$(AbsSrcDir)\configure"
Outputs="$(AegisubObjectDir)Makefile"
>
<MsysPath ProjectDir="$(MSBuildThisFileDirectory)" Path="$(AegisubObjectDir)\temp">
<MsysPath Path="$(AegisubObjectDir)\temp">
<Output TaskParameter="Result" PropertyName="CfgPrefix" />
</MsysPath>
<MsysPath ProjectDir="$(MSBuildThisFileDirectory)" Path="../../include">
<MsysPath Path="$(MSBuildThisFileDirectory)../../include">
<Output TaskParameter="Result" PropertyName="CfgIncludePrefix" />
</MsysPath>
<MsysPath ProjectDir="$(MSBuildThisFileDirectory)" Path="../../lib/$(Platform)/$(Configuration)">
<MsysPath Path="$(AegisubLibraryDir)">
<Output TaskParameter="Result" PropertyName="CfgLibPrefix" />
</MsysPath>
<ExecShellScript
Script="$(FribidiSrcDir)\configure"
Command="$(AbsSrcDir)\configure"
Arguments="$(CfgArgs) --prefix=$(CfgPrefix) --libdir=$(CfgLibPrefix) --includedir=$(CfgIncludePrefix)"
WorkingDirectory="$(AegisubObjectDir)"
Configuration="@(ExecShellScript)"
/>
<!-- fribidi defines the symbols to export twice, which causes errors -->
@ -93,6 +98,7 @@
Command="make"
Arguments="-j$(NUMBER_OF_PROCESSORS)"
WorkingDirectory="$(AegisubObjectDir)"
Configuration="@(ExecShellScript)"
/>
<Touch Files="$(AegisubObjectDir)lib\.libs\fribidi.lib" />
</Target>
@ -104,11 +110,12 @@
<ExecShellScript
Command="make install"
WorkingDirectory="$(AegisubObjectDir)"
Configuration="@(ExecShellScript)"
/>
</Target>
<Target Name="Build">
<Error Condition="!Exists('$(FribidiSrcDir)')" Text="Fribidi source not found at '$(FribidiSrcDir)'" />
<Error Condition="!Exists('$(AbsSrcDir)')" Text="Fribidi source not found at '$(AbsSrcDir)'" />
<CallTarget Targets="Bootstrap;Configure;Compile;Install" />
</Target>

View File

@ -3,10 +3,10 @@
<PropertyGroup>
<_PropertySheetDisplayName>Path definitions</_PropertySheetDisplayName>
</PropertyGroup>
<PropertyGroup>
<!-- Base for Aegisub source code -->
<AegisubSourceBase Condition="'$(AegisubSourceBase)'==''">$(MSBuildThisFileDirectory)..\</AegisubSourceBase>
<AegisubSourceBase Condition="'$(AegisubSourceBase)'==''">$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\'))</AegisubSourceBase>
<!-- Base for contrib libraries source code -->
<AegisubContribBase Condition="'$(AegisubContribBase)'==''">$(AegisubSourceBase)..\contrib\</AegisubContribBase>
<!-- Base for built files -->

25
aegisub/build/tasks.props Normal file
View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_PropertySheetDisplayName>Custom Tasks</_PropertySheetDisplayName>
</PropertyGroup>
<ItemGroup>
<ExecShellScript Include=".">
<CC>cl</CC>
<CPP>cl -E</CPP>
<CFLAGS>-nologo</CFLAGS>
<PATH>$(MsysBasePath)\bin;$(NativeExecutablePath)</PATH>
<INCLUDE>$(MSBuildProjectDirectory);$(AegisubSourceBase)\include;$(IncludePath)</INCLUDE>
<LIB>$(AegisubLibraryDir);$(LibraryPath)</LIB>
<Configuration>$(Configuration)</Configuration>
<Platform>$(Platform)</Platform>
<Sh>$(MsysBasePath)\bin\sh.exe</Sh>
</ExecShellScript>
</ItemGroup>
<UsingTask TaskName="ExecShellScript" AssemblyFile="$(AegisubBinaryDir)BuildTasks.dll" />
<UsingTask TaskName="MsysPath" AssemblyFile="$(AegisubBinaryDir)BuildTasks.dll" />
<UsingTask TaskName="UpdateFile" AssemblyFile="$(AegisubBinaryDir)BuildTasks.dll" />
</Project>