From c9ee3685360a99fb06354c2343f5643d808339ec Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Wed, 21 Aug 2024 07:21:40 -0700 Subject: [PATCH 1/2] [android] conditionally build ds2 for Android SDK Conditionally include the ds2 debug server in the Android SDK build in build.ps1 via the `-IncludeDS2` flag. --- utils/build.ps1 | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/utils/build.ps1 b/utils/build.ps1 index e228e6b468cce..3bb358c8a30cf 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -62,6 +62,10 @@ The version number of the Windows SDK to be used. Overrides the value resolved by the Visual Studio command prompt. If no such Windows SDK is installed, it will be downloaded from nuget. +.PARAMETER IncludeDS2 +Include the ds2 remote debug server in the SDK. +This component is currently only supported in Android builds. + .PARAMETER SkipBuild If set, does not run the build phase. @@ -125,6 +129,7 @@ param( [switch] $SkipBuild = $false, [switch] $SkipRedistInstall = $false, [switch] $SkipPackaging = $false, + [switch] $IncludeDS2 = $false, [string[]] $Test = @(), [string] $Stage = "", [string] $BuildTo = "", @@ -335,6 +340,16 @@ function Get-AndroidNDKPath { return $androidNDKPath } +function Get-FlexExecutable { + $flexExecutable = Join-Path -Path $BinaryCache -ChildPath "win_flex_bison\win_flex.exe" + return $flexExecutable +} + +function Get-BisonExecutable { + $bisonExecutable = Join-Path -Path $BinaryCache -ChildPath "win_flex_bison\win_bison.exe" + return $bisonExecutable +} + function Get-InstallDir($Arch) { if ($Arch -eq $HostArch) { $ProgramFilesName = "Program Files" @@ -431,6 +446,7 @@ enum HostComponent { LMDB SymbolKit DocC + RegsGen2 } function Get-HostProjectBinaryCache([HostComponent]$Project) { @@ -739,6 +755,15 @@ function Fetch-Dependencies { Extract-ZipFile -ZipFileName "android-ndk-$AndroidNDKVersion-windows.zip" -BinaryCache $BinaryCache -ExtractPath "android-ndk-$AndroidNDKVersion" -CreateExtractPath $false } + if ($IncludeDS2) { + $WinFlexBisonVersion = "2.5.25" + $WinFlexBisonURL = "https://github.com/lexxmark/winflexbison/releases/download/v$WinFlexBisonVersion/win_flex_bison-$WinFlexBisonVersion.zip" + $WinFlexBisonHash = "8D324B62BE33604B2C45AD1DD34AB93D722534448F55A16CA7292DE32B6AC135" + DownloadAndVerify $WinFlexBisonURL "$BinaryCache\win_flex_bison-$WinFlexBisonVersion.zip" $WinFlexBisonHash + + Extract-ZipFile -ZipFileName "win_flex_bison-$WinFlexBisonVersion.zip" -BinaryCache $BinaryCache -ExtractPath "win_flex_bison" + } + if ($WinSDKVersion) { try { # Check whether VsDevShell can already resolve the requested Windows SDK Version @@ -1490,6 +1515,39 @@ function Build-XML2([Platform]$Platform, $Arch) { } } +function Build-RegsGen2($Arch) { + $ArchName = $Arch.LLVMName + + Build-CMakeProject ` + -Src $SourceCache\ds2\Tools\RegsGen2 ` + -Bin "$(Get-HostProjectBinaryCache RegsGen2)" ` + -Arch $Arch ` + -BuildTargets default ` + -UseMSVCCompilers C,CXX ` + -Defines @{ + BISON_EXECUTABLE = "$(Get-BisonExecutable)"; + FLEX_EXECUTABLE = "$(Get-FlexExecutable)"; + } +} + +function Build-DS2([Platform]$Platform, $Arch) { + $ArchName = $Arch.LLVMTarget.Replace("$AndroidAPILevel","") + + Build-CMakeProject ` + -Src "$SourceCache\ds2" ` + -Bin "$($Arch.BinaryCache)\$Platform\ds2" ` + -InstallTo "$($Arch.PlatformInstallRoot)\Developer\Library\$ArchName" ` + -Arch $Arch ` + -Platform $Platform ` + -BuildTargets default ` + -Defines @{ + CMAKE_SYSTEM_NAME = $Platform.ToString(); + DS2_REGSGEN2 = "$(Get-HostProjectBinaryCache RegsGen2)/regsgen2.exe"; + BISON_EXECUTABLE = "$(Get-BisonExecutable)"; + FLEX_EXECUTABLE = "$(Get-FlexExecutable)"; + } +} + function Build-CURL([Platform]$Platform, $Arch) { $ArchName = $Arch.LLVMName @@ -2471,6 +2529,10 @@ if ($Clean) { } } +if (-not $SkipBuild -and $IncludeDS2) { + Invoke-BuildStep Build-RegsGen2 $HostArch +} + if (-not $SkipBuild) { foreach ($Arch in $WindowsSDKArchs) { Invoke-BuildStep Build-ZLib Windows $Arch @@ -2491,6 +2553,9 @@ if (-not $SkipBuild) { } foreach ($Arch in $AndroidSDKArchs) { + if ($IncludeDS2) { + Invoke-BuildStep Build-DS2 Android $Arch + } Invoke-BuildStep Build-ZLib Android $Arch Invoke-BuildStep Build-XML2 Android $Arch Invoke-BuildStep Build-CURL Android $Arch From a6684fd9c9451fb74f14da1a9e8ce024c1639558 Mon Sep 17 00:00:00 2001 From: Andrew Rogers Date: Tue, 3 Sep 2024 12:51:06 -0700 Subject: [PATCH 2/2] apply PR feedback --- utils/build.ps1 | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/utils/build.ps1 b/utils/build.ps1 index 3bb358c8a30cf..e7f4d163ea730 100644 --- a/utils/build.ps1 +++ b/utils/build.ps1 @@ -341,13 +341,11 @@ function Get-AndroidNDKPath { } function Get-FlexExecutable { - $flexExecutable = Join-Path -Path $BinaryCache -ChildPath "win_flex_bison\win_flex.exe" - return $flexExecutable + return Join-Path -Path $BinaryCache -ChildPath "win_flex_bison\win_flex.exe" } function Get-BisonExecutable { - $bisonExecutable = Join-Path -Path $BinaryCache -ChildPath "win_flex_bison\win_bison.exe" - return $bisonExecutable + return Join-Path -Path $BinaryCache -ChildPath "win_flex_bison\win_bison.exe" } function Get-InstallDir($Arch) { @@ -446,7 +444,6 @@ enum HostComponent { LMDB SymbolKit DocC - RegsGen2 } function Get-HostProjectBinaryCache([HostComponent]$Project) { @@ -462,6 +459,7 @@ enum BuildComponent { Compilers FoundationMacros TestingMacros + RegsGen2 } function Get-BuildProjectBinaryCache([BuildComponent]$Project) { @@ -1520,7 +1518,7 @@ function Build-RegsGen2($Arch) { Build-CMakeProject ` -Src $SourceCache\ds2\Tools\RegsGen2 ` - -Bin "$(Get-HostProjectBinaryCache RegsGen2)" ` + -Bin "$(Get-BuildProjectBinaryCache RegsGen2)" ` -Arch $Arch ` -BuildTargets default ` -UseMSVCCompilers C,CXX ` @@ -1542,7 +1540,7 @@ function Build-DS2([Platform]$Platform, $Arch) { -BuildTargets default ` -Defines @{ CMAKE_SYSTEM_NAME = $Platform.ToString(); - DS2_REGSGEN2 = "$(Get-HostProjectBinaryCache RegsGen2)/regsgen2.exe"; + DS2_REGSGEN2 = "$(Get-BuildProjectBinaryCache RegsGen2)/regsgen2.exe"; BISON_EXECUTABLE = "$(Get-BisonExecutable)"; FLEX_EXECUTABLE = "$(Get-FlexExecutable)"; } @@ -2517,6 +2515,9 @@ if (-not $SkipBuild) { if ($IsCrossCompiling) { Invoke-BuildStep Build-Compilers -Build $BuildArch } + if ($IncludeDS2) { + Invoke-BuildStep Build-RegsGen2 $BuildArch + } Invoke-BuildStep Build-CMark $HostArch Invoke-BuildStep Build-Compilers $HostArch @@ -2529,10 +2530,6 @@ if ($Clean) { } } -if (-not $SkipBuild -and $IncludeDS2) { - Invoke-BuildStep Build-RegsGen2 $HostArch -} - if (-not $SkipBuild) { foreach ($Arch in $WindowsSDKArchs) { Invoke-BuildStep Build-ZLib Windows $Arch