1 param 2 ( 3 [string]$vsGenerator="Visual Studio 16 2019" 4 ) 5 6 # Using a custom triplet due to mixed static and dynamic dependencies 7 # Only libsndfile is static, all others are dynamically linked 8 $targetTriplet = "x64-windows-csound" 9 10 echo "Downloading Csound dependencies..." 11 echo "vsGenerator: $vsGenerator" 12 echo "Build type: $targetTriplet" 13 14 $startTime = (Get-Date).TimeOfDay 15 $currentDir = Split-Path $MyInvocation.MyCommand.Path 16 $cacheDir = $currentDir + "\cache\" 17 $csoundDir = $currentDir + "\.." 18 $vcpkgDir = "" 19 20 # Find VCPKG from path if it already exists 21 # Otherwise use the local Csound version that will be installed 22 $systemVCPKG = $(Get-Command vcpkg -ErrorAction SilentlyContinue).Source 23 $vcpkgDir = "" 24 25 # Test if VCPKG is already installed on system 26 # Download locally to outside the repo 27 if ($systemVCPKG) 28 { 29 echo "vcpkg already installed on system, updating" 30 $vcpkgDir = Split-Path -Parent $systemVCPKG 31 cd $vcpkgDir 32 # Update and rebuild vcpkg 33 git pull 34 # git checkout 7b7908b 35 bootstrap-vcpkg.bat 36 # Remove any outdated packages (they will be installed again below) 37 vcpkg remove --outdated --recurse 38 vcpkg update # Not really functional it seems yet 39 cd $currentDir 40 } 41 elseif (Test-Path "..\..\vcpkg") 42 { 43 cd ..\..\vcpkg 44 $env:Path += ";" + $(Get-Location) 45 $vcpkgDir = $(Get-Location) 46 [Environment]::SetEnvironmentVariable("VCPKGDir", $env:vcpkgDir, [EnvironmentVariableTarget]::User) 47 echo "vcpkg already installed locally, updating" 48 # Update and rebuild vcpkg 49 git pull 50 # git checkout 7b7908b 51 bootstrap-vcpkg.bat 52 # Remove any outdated packages (they will be installed again below) 53 vcpkg remove --outdated --recurse 54 vcpkg update 55 cd $currentDir 56 } 57 else 58 { 59 cd ..\.. 60 echo "vcpkg missing, downloading and installing..." 61 git clone --depth 1 http://github.com/Microsoft/vcpkg.git 62 cd vcpkg 63 git checkout 7b7908b 64 $env:Path += ";" + $(Get-Location) 65 $vcpkgDir = $(Get-Location) 66 [Environment]::SetEnvironmentVariable("VCPKGDir", $env:vcpkgDir, [EnvironmentVariableTarget]::User) 67 bootstrap-vcpkg.bat 68 vcpkg integrate install 69 cd $currentDir 70 } 71 72 # Generate VCPKG AlwaysAllowDownloads file if needed 73 New-Item -type file $vcpkgDir\downloads\AlwaysAllowDownloads -errorAction SilentlyContinue | Out-Null 74 75 # Download all vcpkg packages available 76 echo "Downloading VC packages..." 77 78 # Download asiosdk and extract before doing portaudio installation 79 if (-not (Test-Path $vcpkgDir/buildtrees/portaudio/src/asiosdk)) { 80 echo "ASIOSDK not installed into VCPKG" 81 New-Item -ItemType Directory -Force -Path $cacheDir 82 if (-not (Test-Path .\cache\asiosdk.zip)) { 83 Invoke-WebRequest https://www.steinberg.net/asiosdk -OutFile cache/asiosdk.zip 84 } 85 Expand-Archive -Path cache/asiosdk.zip -DestinationPath $vcpkgDir/buildtrees/portaudio/src -Force 86 Move-Item -Path $vcpkgDir/buildtrees/portaudio/src/asiosdk_* -Destination $vcpkgDir/buildtrees/portaudio/src/asiosdk -ErrorAction SilentlyContinue 87 # Remove portaudio and it will get rebuilt with asio support in the next step 88 vcpkg --triplet $targetTriplet remove portaudio --overlay-triplets=. 89 } 90 91 vcpkg --triplet $targetTriplet install ` 92 eigen3 fltk zlib libflac libogg libvorbis libsndfile libsamplerate portaudio liblo hdf5 dirent libstk fluidsynth ` 93 --overlay-triplets=. 94 95 echo "Downloading and installing non-VCPKG packages..." 96 97 choco install swig -y --version=4.0.1 --allow-downgrade 98 choco upgrade swig -y --version=4.0.1 --allow-downgrade 99 100 choco install winflexbison -y 101 choco upgrade winflexbison -y 102 103 $endTime = (Get-Date).TimeOfDay 104 $duration = $endTime - $startTime 105 106 echo "Total duration: $($duration.TotalMinutes) minutes" 107 echo "-------------------------------------------------" 108 echo "Generating Csound Visual Studio solution..." 109 echo "vsGenerator: $vsGenerator" 110 111 $vcpkgCmake = "$vcpkgDir\scripts\buildsystems\vcpkg.cmake" 112 echo "VCPKG script: '$vcpkgCmake'" 113 114 cd $currentDir 115 116 # TEMPORARILY USE THE FOLLOWING SELF-BUILT PORTMIDI UNTIL VCPKG PROVIDES ONE 117 # THAT IS UP TO DATE 118 119 $depsDir = $currentDir + "\deps\" 120 $stageDir = $currentDir + "\staging\" 121 $depsBinDir = $depsDir + "bin\" 122 $depsLibDir = $depsDir + "lib\" 123 $depsIncDir = $depsDir + "include\" 124 125 mkdir cache -ErrorAction SilentlyContinue 126 mkdir deps -ErrorAction SilentlyContinue 127 mkdir $depsLibDir -ErrorAction SilentlyContinue 128 mkdir $depsBinDir -ErrorAction SilentlyContinue 129 mkdir $depsIncDir -ErrorAction SilentlyContinue 130 mkdir staging -ErrorAction SilentlyContinue 131 132 cd $depsDir 133 134 if (Test-Path "portmidi") 135 { 136 cd portmidi 137 svn update 138 cd .. 139 echo "Portmidi already downloaded, updated" 140 } 141 else 142 { 143 svn checkout "https://svn.code.sf.net/p/portmedia/code" portmidi 144 } 145 146 cd portmidi\portmidi\trunk 147 rm -Path build -Force -Recurse -ErrorAction SilentlyContinue 148 mkdir build -ErrorAction SilentlyContinue 149 cd build 150 cmake .. -G $vsGenerator -DCMAKE_BUILD_TYPE="Release" 151 cmake --build . --config Release 152 copy .\Release\portmidi.dll -Destination $depsBinDir -Force 153 copy .\Release\portmidi.lib -Destination $depsLibDir -Force 154 copy .\Release\portmidi_s.lib -Destination $depsLibDir -Force 155 copy .\Release\pmjni.dll -Destination $depsBinDir -Force 156 copy .\Release\pmjni.lib -Destination $depsLibDir -Force 157 copy ..\pm_common\portmidi.h -Destination $depsIncDir -Force 158 copy ..\porttime\porttime.h -Destination $depsIncDir -Force 159 160 # END CUSTOM PORTMIDI # 161 162 163 cd $currentDir 164 mkdir csound-vs -ErrorAction SilentlyContinue 165 cd csound-vs -ErrorAction SilentlyContinue 166 167 # Default to Release build type. Note: ReleaseWithDebInfo is broken as VCPKG does not currently support this mode properly 168 cmake ..\.. -G $vsGenerator ` 169 -Wno-dev -Wdeprecated ` 170 -DCMAKE_BUILD_TYPE="Release" ` 171 -DVCPKG_TARGET_TRIPLET="$targetTriplet" ` 172 -DCMAKE_TOOLCHAIN_FILE="$vcpkgCmake" ` 173 -DCMAKE_INSTALL_PREFIX=dist ` 174 -DCUSTOM_CMAKE="..\Custom-vs.cmake" ` 175 # -DSTATIC_CRT="ON" 176