Skip to content

[android] conditionally build DS2 for the Android SDK #76113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions utils/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -125,6 +129,7 @@ param(
[switch] $SkipBuild = $false,
[switch] $SkipRedistInstall = $false,
[switch] $SkipPackaging = $false,
[switch] $IncludeDS2 = $false,
[string[]] $Test = @(),
[string] $Stage = "",
[string] $BuildTo = "",
Expand Down Expand Up @@ -335,6 +340,14 @@ function Get-AndroidNDKPath {
return $androidNDKPath
}

function Get-FlexExecutable {
return Join-Path -Path $BinaryCache -ChildPath "win_flex_bison\win_flex.exe"
}

function Get-BisonExecutable {
return Join-Path -Path $BinaryCache -ChildPath "win_flex_bison\win_bison.exe"
}

function Get-InstallDir($Arch) {
if ($Arch -eq $HostArch) {
$ProgramFilesName = "Program Files"
Expand Down Expand Up @@ -446,6 +459,7 @@ enum BuildComponent {
Compilers
FoundationMacros
TestingMacros
RegsGen2
}

function Get-BuildProjectBinaryCache([BuildComponent]$Project) {
Expand Down Expand Up @@ -739,6 +753,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
Expand Down Expand Up @@ -1490,6 +1513,39 @@ function Build-XML2([Platform]$Platform, $Arch) {
}
}

function Build-RegsGen2($Arch) {
$ArchName = $Arch.LLVMName

Build-CMakeProject `
-Src $SourceCache\ds2\Tools\RegsGen2 `
-Bin "$(Get-BuildProjectBinaryCache 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-BuildProjectBinaryCache RegsGen2)/regsgen2.exe";
BISON_EXECUTABLE = "$(Get-BisonExecutable)";
FLEX_EXECUTABLE = "$(Get-FlexExecutable)";
}
}

function Build-CURL([Platform]$Platform, $Arch) {
$ArchName = $Arch.LLVMName

Expand Down Expand Up @@ -2459,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
Expand Down Expand Up @@ -2491,6 +2550,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
Expand Down