mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-12 01:30:49 +01:00
msbuild: some config and tweaks
This commit is contained in:
parent
e6c3527ee5
commit
607913abc2
1
msvc-build-clean.bat
Normal file
1
msvc-build-clean.bat
Normal file
@ -0,0 +1 @@
|
|||||||
|
powershell -ExecutionPolicy Bypass -NoProfile -File .\msvc-build.ps1 Clean
|
143
msvc-build.ps1
143
msvc-build.ps1
@ -1,17 +1,37 @@
|
|||||||
[CmdletBinding()]
|
[CmdletBinding()]
|
||||||
Param(
|
Param(
|
||||||
[Parameter(Position=0, mandatory=$true)]
|
[Parameter(Position=0, mandatory=$true)]
|
||||||
[ValidateSet("Init", "Build")]
|
[ValidateSet("Init", "Build", "Rebuild", "Clean")]
|
||||||
[string]$Task
|
[string]$Task
|
||||||
)
|
)
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# CONFIG
|
||||||
|
# set these vars to override project defaults
|
||||||
|
###############################################################################
|
||||||
|
# - values: "" (p), "v140" (MSVC 2015), "v141" (MSVC 2017), "v141_xp" (XP support), "v142" (MSVC 2019), etc
|
||||||
|
$toolset = ""
|
||||||
|
# - values: "" (default), "7.0" (Win7 SDK), "8.1" (Win8 SDK), "10.0" (Win10 SDK), etc
|
||||||
|
$sdk = ""
|
||||||
|
# - values: "" (default), "Win32"
|
||||||
|
$platform = ""
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
$solution = "vgmstream_full.sln"
|
||||||
|
$dependencies = "dependencies"
|
||||||
|
$vswhere = "$dependencies/vswhere.exe"
|
||||||
|
$config = "/p:Configuration=Release"
|
||||||
|
# not used ATM
|
||||||
|
$enable_aac = 0
|
||||||
|
|
||||||
|
if ($platform) { $platform = "/p:Platform=" + $platform }
|
||||||
|
if ($toolset) { $toolset = "/p:PlatformToolset=" + $toolset }
|
||||||
|
if ($sdk) { $sdk = "/p:WindowsTargetPlatformVersion=" + $sdk }
|
||||||
|
|
||||||
# https://stackoverflow.com/a/41618979/9919772
|
# https://stackoverflow.com/a/41618979/9919772
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
|
|
||||||
$solution = "vgmstream_full.sln"
|
# helper
|
||||||
$vswhere = "dependencies/vswhere.exe"
|
|
||||||
$config = "/p:Configuration=Release"
|
|
||||||
|
|
||||||
function Unzip
|
function Unzip
|
||||||
{
|
{
|
||||||
param([string]$zipfile, [string]$outpath)
|
param([string]$zipfile, [string]$outpath)
|
||||||
@ -19,6 +39,7 @@ function Unzip
|
|||||||
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
|
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# helper
|
||||||
function Download
|
function Download
|
||||||
{
|
{
|
||||||
param([string]$uri, [string]$outfile)
|
param([string]$uri, [string]$outfile)
|
||||||
@ -27,67 +48,119 @@ function Download
|
|||||||
$wc.Downloadfile($uri, $outfile)
|
$wc.Downloadfile($uri, $outfile)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# download and unzip dependencies
|
||||||
function Init
|
function Init
|
||||||
{
|
{
|
||||||
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
Add-Type -AssemblyName System.IO.Compression.FileSystem
|
||||||
|
|
||||||
Remove-Item -Path "dependencies" -Recurse -ErrorAction Ignore
|
Remove-Item -Path "$dependencies" -Recurse -ErrorAction Ignore
|
||||||
New-Item dependencies -Type directory -Force | out-null
|
New-Item "$dependencies" -Type directory -Force | out-null
|
||||||
|
|
||||||
#Download "https://github.com/kode54/fdk-aac/archive/master.zip" "dependencies\fdk-aac.zip"
|
# vswhere: MSBuild locator
|
||||||
#Download "https://github.com/kode54/qaac/archive/master.zip" "dependencies\qaac.zip"
|
# may already be in %ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
|
||||||
Download "https://www.nuget.org/api/v2/package/wtl/9.1.1" "dependencies\wtl.zip"
|
# so could test that and skip this step
|
||||||
Download "https://github.com/Microsoft/vswhere/releases/download/2.6.7/vswhere.exe" "dependencies\vswhere.exe"
|
Download "https://github.com/Microsoft/vswhere/releases/download/2.6.7/vswhere.exe" "$dependencies\vswhere.exe"
|
||||||
|
|
||||||
# foobar anti-hotlink (random link) defeater
|
# foobar: wtl
|
||||||
#Download "https://www.foobar2000.org/SDK" "dependencies\SDK"
|
Download "https://www.nuget.org/api/v2/package/wtl/9.1.1" "$dependencies\wtl.zip"
|
||||||
#$key = (Select-String -Path dependencies\SDK -Pattern "\/([a-f0-9]+)\/SDK-2018-01-11\.zip").matches.groups[1]
|
Unzip "$dependencies\wtl.zip" "$dependencies\wtl_tmp"
|
||||||
#Remove-Item -Path "dependencies\SDK"
|
Move-Item "$dependencies\wtl_tmp\lib\native" "$dependencies\wtl"
|
||||||
#Download "https://www.foobar2000.org/files/$key/SDK-2018-01-11.zip" "dependencies\foobar.zip"
|
Remove-Item -Path "$dependencies\wtl_tmp" -Recurse
|
||||||
|
|
||||||
# foobar direct link, but 2019< sdks gone ATM
|
# foobar: sdk anti-hotlink (random link) defeater
|
||||||
#Download "https://www.foobar2000.org/files/SDK-2018-01-11.zip" "dependencies\foobar.zip"
|
#Download "https://www.foobar2000.org/SDK" "$dependencies\SDK"
|
||||||
|
#$key = (Select-String -Path $dependencies\SDK -Pattern "\/([a-f0-9]+)\/SDK-2018-01-11\.zip").matches.groups[1]
|
||||||
|
#Remove-Item -Path "$dependencies\SDK"
|
||||||
|
#Download "https://www.foobar2000.org/files/$key/SDK-2018-01-11.zip" "$dependencies\foobar.zip"
|
||||||
|
|
||||||
# mirror
|
# foobar: sdk direct link, but 2019< sdks gone ATM
|
||||||
Download "https://github.com/vgmstream/vgmstream-deps/raw/master/foobar2000/SDK-2018-02-05.zip" "dependencies\foobar.zip"
|
#Download "https://www.foobar2000.org/files/SDK-2018-01-11.zip" "$dependencies\foobar.zip"
|
||||||
|
|
||||||
#Unzip "dependencies\fdk-aac.zip" "dependencies\fdk-aac_tmp"
|
# foobar: sdk static mirror
|
||||||
#Unzip "dependencies\qaac.zip" "dependencies\qaac_tmp"
|
Download "https://github.com/vgmstream/vgmstream-deps/raw/master/foobar2000/SDK-2018-02-05.zip" "$dependencies\foobar.zip"
|
||||||
Unzip "dependencies\wtl.zip" "dependencies\wtl_tmp"
|
Unzip "$dependencies\foobar.zip" "$dependencies\foobar"
|
||||||
Unzip "dependencies\foobar.zip" "dependencies\foobar"
|
|
||||||
|
|
||||||
#Move-Item "dependencies\fdk-aac_tmp\fdk-aac-master" "dependencies\fdk-aac"
|
# foobar: aac (not used ATM)
|
||||||
#Move-Item "dependencies\qaac_tmp\qaac-master" "dependencies\qaac"
|
if ($enable_aac)
|
||||||
Move-Item "dependencies\wtl_tmp\lib\native" "dependencies\wtl"
|
{
|
||||||
|
Download "https://github.com/kode54/fdk-aac/archive/master.zip" "$dependencies\fdk-aac.zip"
|
||||||
|
Download "https://github.com/kode54/qaac/archive/master.zip" "$dependencies\qaac.zip"
|
||||||
|
Unzip "$dependencies\fdk-aac.zip" "$dependencies\fdk-aac_tmp"
|
||||||
|
Unzip "$dependencies\qaac.zip" "$dependencies\qaac_tmp"
|
||||||
|
Move-Item "$dependencies\fdk-aac_tmp\fdk-aac-master" "$dependencies\fdk-aac"
|
||||||
|
Move-Item "$dependencies\qaac_tmp\qaac-master" "$dependencies\qaac"
|
||||||
|
Remove-Item -Path "$dependencies\fdk-aac_tmp" -Recurse
|
||||||
|
Remove-Item -Path "$dependencies\qaac_tmp" -Recurse
|
||||||
|
}
|
||||||
|
|
||||||
#Remove-Item -Path "dependencies\fdk-aac_tmp" -Recurse
|
# open foobar sdk project and modify WTL path
|
||||||
#Remove-Item -Path "dependencies\qaac_tmp" -Recurse
|
# (maybe should just pass include to CL envvar: set CL=/I"(path)\WTL\Include")
|
||||||
Remove-Item -Path "dependencies\wtl_tmp" -Recurse
|
[xml]$proj = Get-Content $dependencies\foobar\foobar2000\ATLHelpers\foobar2000_ATL_helpers.vcxproj
|
||||||
|
|
||||||
[xml]$proj = Get-Content dependencies\foobar\foobar2000\ATLHelpers\foobar2000_ATL_helpers.vcxproj
|
|
||||||
$proj.project.ItemDefinitionGroup | ForEach-Object {
|
$proj.project.ItemDefinitionGroup | ForEach-Object {
|
||||||
$includes = $proj.CreateElement("AdditionalIncludeDirectories", $proj.project.NamespaceURI)
|
$includes = $proj.CreateElement("AdditionalIncludeDirectories", $proj.project.NamespaceURI)
|
||||||
$includes.InnerText = "../../../wtl/include"
|
$includes.InnerText = "../../../wtl/include"
|
||||||
$_.ClCompile.AppendChild($includes)
|
$_.ClCompile.AppendChild($includes)
|
||||||
}
|
}
|
||||||
$proj.Save("dependencies\foobar\foobar2000\ATLHelpers\foobar2000_ATL_helpers.vcxproj")
|
$proj.Save("$dependencies\foobar\foobar2000\ATLHelpers\foobar2000_ATL_helpers.vcxproj")
|
||||||
}
|
}
|
||||||
|
|
||||||
function Build
|
# main build
|
||||||
|
function CallMsbuild
|
||||||
{
|
{
|
||||||
|
param([string]$target)
|
||||||
|
if ($target) { $target = "/t:" + $target }
|
||||||
|
|
||||||
|
# download dependencies if needed
|
||||||
if(!(Test-Path $vswhere)) { Init }
|
if(!(Test-Path $vswhere)) { Init }
|
||||||
|
|
||||||
|
|
||||||
|
# autolocate MSBuild path
|
||||||
$msbuild = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
|
$msbuild = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe
|
||||||
|
|
||||||
if(!($msbuild -and $(Test-Path $msbuild))) {
|
if(!($msbuild -and $(Test-Path $msbuild))) {
|
||||||
Write-Error "Unable to find MSBuild. Is Visual Studio installed?"
|
Write-Error "Unable to find MSBuild. Is Visual Studio installed?"
|
||||||
}
|
}
|
||||||
|
|
||||||
& $msbuild $solution $config /m
|
# main build (pass config separate and not as a single string)
|
||||||
|
& $msbuild $solution $config $platform $toolset $sdk $target /m
|
||||||
|
}
|
||||||
|
|
||||||
|
function Build
|
||||||
|
{
|
||||||
|
CallMsbuild "Build"
|
||||||
|
}
|
||||||
|
|
||||||
|
function Rebuild
|
||||||
|
{
|
||||||
|
CallMsbuild "Rebuild"
|
||||||
|
}
|
||||||
|
function Clean
|
||||||
|
{
|
||||||
|
CallMsbuild "Clean"
|
||||||
|
# todo fix the above, for now:
|
||||||
|
#Remove-Item -Path "$dependencies" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "cli/Debug" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "cli/Release" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "ext_libs/Debug" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "ext_libs/Release" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "ext_libs/Getopt/Release" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "ext_libs/Getopt/Release" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "fb2k/Debug" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "fb2k/Release" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "src/Debug" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "src/Release" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "winamp/Debug" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "winamp/Release" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "xmplay/Debug" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "xmplay/Release" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "Debug" -Recurse -ErrorAction Ignore
|
||||||
|
Remove-Item -Path "Release" -Recurse -ErrorAction Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($Task)
|
switch ($Task)
|
||||||
{
|
{
|
||||||
"Init" { Init }
|
"Init" { Init }
|
||||||
"Build" { Build }
|
"Build" { Build }
|
||||||
|
"Rebuild" { Rebuild }
|
||||||
|
"Clean" { Clean }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user