| 1 | <?xml version="1.0" encoding="utf-8"?>
|
|---|
| 2 | <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="All">
|
|---|
| 3 |
|
|---|
| 4 | <PropertyGroup>
|
|---|
| 5 | <ProjectDir>$([System.IO.Path]::GetFullPath(`$(MSBuildThisFileDirectory)..`))\</ProjectDir>
|
|---|
| 6 | <TempDir>$(Temp)\ffmpegbuild\</TempDir>
|
|---|
| 7 | <FFMpegDir>$(TempDir)ffmpeg\</FFMpegDir>
|
|---|
| 8 | <MSysDir>$(TempDir)msys64\</MSysDir>
|
|---|
| 9 | <SevenZip>$(TempDir)7za.exe</SevenZip>
|
|---|
| 10 | </PropertyGroup>
|
|---|
| 11 |
|
|---|
| 12 | <Import Project="..\buildtools\tools\msbuildtasks.targets"/>
|
|---|
| 13 |
|
|---|
| 14 | <Target Name="All" DependsOnTargets="Download;Build;CopyIncludes">
|
|---|
| 15 | </Target>
|
|---|
| 16 |
|
|---|
| 17 | <Target Name="Download">
|
|---|
| 18 | <!--Get ffmpeg-->
|
|---|
| 19 | <Exec Condition="!Exists( '$(FFMpegDir)' )" Command="git clone git://source.ffmpeg.org/ffmpeg.git $(FFMpegDir)"/>
|
|---|
| 20 | <Exec Condition="Exists( '$(FFMpegDir)' )" Command="git --git-dir=$(FFMpegDir).git --work-tree=$(FFMpegDir) pull" />
|
|---|
| 21 |
|
|---|
| 22 | <!--Get msys-->
|
|---|
| 23 | <!--Webdownload doesn't do redirect so unfortunately we have to use use a full path, not sure how long this will work-->
|
|---|
| 24 | <WebDownload Condition="!Exists( '$(MSysDir)' )"
|
|---|
| 25 | FileUri="http://downloads.sourceforge.net/project/msys2/Base/x86_64/msys2-base-x86_64-20150916.tar.xz?r=&ts=1444906988&use_mirror=heanet"
|
|---|
| 26 | FileName="$(TempDir)msys2.tar.xz"/>
|
|---|
| 27 |
|
|---|
| 28 | <!--Get 7z and extract msys-->
|
|---|
| 29 | <WebDownload Condition="!Exists( '$(SevenZip)' )" FileUri="http://7-zip.org/a/7za920.zip" FileName="$(TempDir)7z.zip"/>
|
|---|
| 30 | <Unzip Condition="!Exists( '$(SevenZip)' )" ZipFileName="$(TempDir)7z.zip" TargetDirectory="$(TempDir)"/>
|
|---|
| 31 |
|
|---|
| 32 | <Exec Condition="!Exists( '$(MSysDir)' )" Command="$(SevenZip) e -y -o$(TempDir) $(TempDir)msys2.tar.xz"/>
|
|---|
| 33 | <Exec Condition="!Exists( '$(MSysDir)' )" Command="$(SevenZip) x -y -o$(TempDir) $(TempDir)msys2.tar"/>
|
|---|
| 34 |
|
|---|
| 35 | <!--Get yasm-->
|
|---|
| 36 | <WebDownload Condition="!Exists( '$(TempDir)yasm.exe' )"
|
|---|
| 37 | FileUri="http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win64.exe"
|
|---|
| 38 | FileName="$(TempDir)yasm.exe"/>
|
|---|
| 39 | </Target>
|
|---|
| 40 |
|
|---|
| 41 | <Target Name="Build">
|
|---|
| 42 | <PropertyGroup>
|
|---|
| 43 | <Bash>$(TempDir)msys64\usr\bin\bash.exe</Bash>
|
|---|
| 44 | <BashBuildScript>$(TempDir)build.sh</BashBuildScript>
|
|---|
| 45 | <CmdBuildScript>$(TempDir)build.bat</CmdBuildScript>
|
|---|
| 46 | </PropertyGroup>
|
|---|
| 47 |
|
|---|
| 48 | <!--Install what's needed-->
|
|---|
| 49 | <!--Run dummy command first to make sure msys is setup; ContinueOnError for pgp errors which don't matter-->
|
|---|
| 50 | <Exec Condition="!Exists( '$(MSysDir)usr\bin\make.exe' )" Command="$(Bash) -l -c "echo"" ContinueOnError="True" />
|
|---|
| 51 | <Exec Condition="!Exists( '$(MSysDir)usr\bin\make.exe' )" Command="$(Bash) -l -c "pacman -S --noconfirm make"" />
|
|---|
| 52 |
|
|---|
| 53 | <!--The bash build script-->
|
|---|
| 54 | <ItemGroup>
|
|---|
| 55 | <BashBuildScriptLines Include="#!/bin/bash"/>
|
|---|
| 56 | <BashBuildScriptLines Include="cd $(FFMpegDir.Replace( '\', '/' ))"/>
|
|---|
| 57 | <BashBuildScriptLines Include="export PATH=/$(TempDir.Replace( '\', '/' ).Replace( ':', '/' ).Replace( '//', '/' )):$PATH"/>
|
|---|
| 58 | <BashBuildScriptLines Include="./configure --enable-shared --toolchain=msvc"/>
|
|---|
| 59 | <BashBuildScriptLines Include="make clean"/>
|
|---|
| 60 | <BashBuildScriptLines Include="make -j4"/>
|
|---|
| 61 | <BashBuildScriptLines Include="make install"/>
|
|---|
| 62 | </ItemGroup>
|
|---|
| 63 | <WriteLinesToFile File="$(BashBuildScript)" Lines="@(BashBuildScriptLines)" OverWrite="True"/>
|
|---|
| 64 |
|
|---|
| 65 | <!--Invoke bash from a commandline with the proper environment variables set depending on x86/x64 builds,
|
|---|
| 66 | ffmpeg's configure will then automatically build the correct one; unfortunately the output dll/lib
|
|---|
| 67 | names are the same and I don't see a way to change that so we copy to different directories..-->
|
|---|
| 68 | <ItemGroup>
|
|---|
| 69 | <X86BatLines Include="call "$(VCINSTALLDIR)\vcvarsall.bat" x86"/>
|
|---|
| 70 | <X64BatLines Include="call "$(VCINSTALLDIR)\vcvarsall.bat" amd64"/>
|
|---|
| 71 | <BatLines Include="$(Bash) -l -c "$(BashBuildScript.Replace( '\', '/' ))""/>
|
|---|
| 72 | </ItemGroup>
|
|---|
| 73 | <Error Condition="'$(VCINSTALLDIR)' == ''" Text="This script must be ran from a VS command prompt"/>
|
|---|
| 74 |
|
|---|
| 75 | <WriteLinesToFile File="$(CmdBuildScript)" Lines="@(X86BatLines);@(BatLines)" OverWrite="True"/>
|
|---|
| 76 | <Exec Command="cmd.exe /C $(CmdBuildScript)"/>
|
|---|
| 77 | <MSBuild Projects="$(MsBuildThisFile)" Targets="CopyLibs" Properties="FFMpegDestName=ffmpeg_x86"/>
|
|---|
| 78 |
|
|---|
| 79 | <WriteLinesToFile File="$(CmdBuildScript)" Lines="@(X64BatLines);@(BatLines)" OverWrite="True"/>
|
|---|
| 80 | <Exec Command="cmd.exe /C $(CmdBuildScript)"/>
|
|---|
| 81 | <MSBuild Projects="$(MsBuildThisFile)" Targets="CopyLibs" Properties="FFMpegDestName=ffmpeg_x64"/>
|
|---|
| 82 | </Target>
|
|---|
| 83 |
|
|---|
| 84 | <Target Name="CopyIncludes">
|
|---|
| 85 | <ItemGroup>
|
|---|
| 86 | <IncludeFiles Include="$(MSysDir)usr\local\include\libav*\*"/>
|
|---|
| 87 | <IncludeFiles Include="$(MSysDir)usr\local\include\libsw*\*"/>
|
|---|
| 88 | </ItemGroup>
|
|---|
| 89 | <Copy SourceFiles="@(IncludeFiles)" DestinationFolder="$(ProjectDir)_include\%(RecursiveDir)"/>
|
|---|
| 90 | </Target>
|
|---|
| 91 |
|
|---|
| 92 | <Target Name="CopyLibs">
|
|---|
| 93 | <ItemGroup>
|
|---|
| 94 | <DllFiles Include="$(FFMpegDir)\ffmpeg.exe"/>
|
|---|
| 95 | <DllFiles Include="$(FFMpegDir)lib*\*-*.dll"/>
|
|---|
| 96 | <LibFiles Include="$(FFMpegDir)lib*\*.lib"/>
|
|---|
| 97 | </ItemGroup>
|
|---|
| 98 | <Copy SourceFiles="@(DllFiles)" DestinationFolder="$(ProjectDir)_bin\$(FFMpegDestName)"/>
|
|---|
| 99 | <Copy SourceFiles="@(LibFiles)" DestinationFolder="$(ProjectDir)_lib\$(FFMpegDestName)"/>
|
|---|
| 100 | </Target>
|
|---|
| 101 |
|
|---|
| 102 | </Project>
|
|---|