From 08e9c31ea46a8bf588f59aa5f4f0c3a70c663040 Mon Sep 17 00:00:00 2001 From: tudorms <48035227+tudorms@users.noreply.github.com> Date: Tue, 11 Aug 2020 00:52:29 -0700 Subject: [PATCH] Add UWP (and ARM64) targets (#20) * Add UWP (and ARM64) targets * Use AppPlatform instead of Architecture; pass arguments as arrays to LocalBuild --- .ado/build-dll.yml | 2 + ReactNative.V8Jsi.Windows.targets | 31 ++++----- azure-pipelines.yml | 35 ++++++++-- config.json | 4 +- localbuild.ps1 | 30 ++++---- scripts/Install-VSFeatures.ps1 | 112 ------------------------------ scripts/build.ps1 | 25 ++++--- 7 files changed, 73 insertions(+), 166 deletions(-) delete mode 100644 scripts/Install-VSFeatures.ps1 diff --git a/.ado/build-dll.yml b/.ado/build-dll.yml index 215c1aa..69c53e7 100644 --- a/.ado/build-dll.yml +++ b/.ado/build-dll.yml @@ -1,5 +1,6 @@ parameters: outputPath: + appPlatform: steps: - task: PowerShell@2 @@ -30,6 +31,7 @@ steps: -SourcesPath:$(Build.SourcesDirectory) -Platform:$(BuildPlatform) -Configuration:$(BuildConfiguration) + -AppPlatform:${{parameters.appPlatform}} - task: PublishBuildArtifacts@1 displayName: "Publish artifacts" diff --git a/ReactNative.V8Jsi.Windows.targets b/ReactNative.V8Jsi.Windows.targets index 27c3c0b..3f6ad20 100644 --- a/ReactNative.V8Jsi.Windows.targets +++ b/ReactNative.V8Jsi.Windows.targets @@ -1,10 +1,15 @@ + + + uwp + + $(Platform) + + x86 + - $(MSBuildThisFileDirectory)..\..\lib\Debug\x64;%(AdditionalLibraryDirectories) - $(MSBuildThisFileDirectory)..\..\lib\Release\x64;%(AdditionalLibraryDirectories) - $(MSBuildThisFileDirectory)..\..\lib\Debug\x86;%(AdditionalLibraryDirectories) - $(MSBuildThisFileDirectory)..\..\lib\Release\x86;%(AdditionalLibraryDirectories) + $(MSBuildThisFileDirectory)..\..\lib\$(V8AppPlatform)\$(Configuration)\$(V8Platform);%(AdditionalLibraryDirectories) v8jsi.dll.lib;%(AdditionalDependencies) v8jsi.dll;%(DelayLoadDLLs) @@ -12,20 +17,8 @@ $(MSBuildThisFileDirectory)include;%(AdditionalIncludeDirectories) - - - - - - - - - - - - - - - + + + \ No newline at end of file diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 31eb0e0..c67c666 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -22,21 +22,43 @@ jobs: X64Debug: BuildConfiguration: Debug BuildPlatform: x64 + AppPlatform: win32 X86Debug: BuildConfiguration: Debug BuildPlatform: x86 + AppPlatform: win32 X64Release: BuildConfiguration: Release BuildPlatform: x64 + AppPlatform: win32 X86Release: BuildConfiguration: Release BuildPlatform: x86 - #X64Release-Clang: - # BuildConfiguration: Release-Clang - # BuildPlatform: x64 - #X86Release-Clang: - # BuildConfiguration: Release-Clang - # BuildPlatform: x86 + AppPlatform: win32 + UWPX64Debug: + BuildConfiguration: Debug + BuildPlatform: x64 + AppPlatform: uwp + UWPX86Debug: + BuildConfiguration: Debug + BuildPlatform: x86 + AppPlatform: uwp + UWPARM64Debug: + BuildConfiguration: Debug + BuildPlatform: arm64 + AppPlatform: uwp + UWPX64Release: + BuildConfiguration: Release + BuildPlatform: x64 + AppPlatform: uwp + UWPX86Release: + BuildConfiguration: Release + BuildPlatform: x86 + AppPlatform: uwp + UWPARM64Release: + BuildConfiguration: Release + BuildPlatform: arm64 + AppPlatform: uwp steps: - task: UsePythonVersion@0 @@ -47,6 +69,7 @@ jobs: - template: .ado/build-dll.yml parameters: outputPath: $(Build.ArtifactStagingDirectory) + appPlatform: $(AppPlatform) - job: V8JsiPublishNuget dependsOn: diff --git a/config.json b/config.json index 6ce58e6..acae430 100644 --- a/config.json +++ b/config.json @@ -1,4 +1,4 @@ { - "version": "0.3.2", - "v8ref": "refs/branch-heads/8.4" + "version": "0.3.3", + "v8ref": "refs/branch-heads/8.5" } \ No newline at end of file diff --git a/localbuild.ps1 b/localbuild.ps1 index f592d28..c646974 100644 --- a/localbuild.ps1 +++ b/localbuild.ps1 @@ -1,16 +1,17 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT license. param( - [string]$Platform = "x64", #"arm64", - [string]$Configuration = "Debug", # "UWP-Release" "Release-Clang" + [string]$SourcesPath = $PSScriptRoot, + [string]$OutputPath = "$PSScriptRoot\out", + [ValidateSet("x64", "x86", "arm64")] + [String[]]$Platform = @("x64"), + [ValidateSet("debug", "release")] + [String[]]$Configuration = @("debug"), + [ValidateSet("win32", "uwp")] + [String[]]$AppPlatform = @("win32"), [bool]$Setup = $true ) -$OutputPath = "$PSScriptRoot\out" -$SourcesPath = $PSScriptRoot -$Platforms = "x64", "x86"#, "arm64" -$Configurations = "Debug", "Release", "UWP-Release"#, "Release-Clang", "EXPERIMENTAL-libcpp-Clang" - if ($Setup) { Write-Host "Downloading environment..." & ".\scripts\download_depottools.ps1" -SourcesPath $SourcesPath @@ -21,7 +22,7 @@ if ($Setup) { } Write-Host "Fetching code..." - & ".\scripts\fetch_code.ps1" -SourcesPath $SourcesPath -OutputPath $OutputPath -Configuration $Configuration + & ".\scripts\fetch_code.ps1" -SourcesPath $SourcesPath -OutputPath $OutputPath -Configuration $Configuration[0] if (!$?) { Write-Host "Failed to retrieve the v8 code" @@ -29,17 +30,14 @@ if ($Setup) { } } -if ($Platform -like "all") { - foreach ($Plat in $Platforms) { - foreach ($Config in $Configurations) { - Write-Host "Building $Plat $Config..." - & ".\scripts\build.ps1" -SourcesPath $SourcesPath -OutputPath $OutputPath -Platform $Plat -Configuration $Config +foreach ($Plat in $Platform) { + foreach ($Config in $Configuration) { + foreach ($AppPlat in $AppPlatform) { + Write-Host "Building $AppPlat $Plat $Config..." + & ".\scripts\build.ps1" -SourcesPath $SourcesPath -OutputPath $OutputPath -Platform $Plat -Configuration $Config -AppPlatform $AppPlat } } } -else { - & ".\scripts\build.ps1" -SourcesPath $SourcesPath -OutputPath $OutputPath -Platform $Platform -Configuration $Configuration -} if (!$?) { Write-Host "Build failure" diff --git a/scripts/Install-VSFeatures.ps1 b/scripts/Install-VSFeatures.ps1 deleted file mode 100644 index d3145eb..0000000 --- a/scripts/Install-VSFeatures.ps1 +++ /dev/null @@ -1,112 +0,0 @@ -param ( - [Parameter(Mandatory=$true)] - [string[]] $Components, - [uri] $InstallerUri = "https://aka.ms/vs/16/release/vs_enterprise.exe", - [string] $VsInstaller = "${env:System_DefaultWorkingDirectory}\vs_Enterprise.exe", - [string] $VsInstallOutputDir = "${env:System_DefaultWorkingDirectory}\vs", - [System.IO.FileInfo] $VsInstallPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2019\Enterprise", - [System.IO.FileInfo] $VsInstallerPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer", - [switch] $Collect = $false, - [switch] $Cleanup = $false, - [switch] $UseWebInstaller = $false, - [string] $OutputPath = "$PSScriptRoot\out" -) - -$Components | ForEach-Object { - $componentList += '--add', $_ -} - -$LocalVsInstaller = "$VsInstallerPath\vs_installershell.exe" - -$UseWebInstaller = $UseWebInstaller -or -not (Test-Path -Path "$LocalVsInstaller") - -if ($UseWebInstaller) { - Write-Host "Downloading web installer..." - - Invoke-WebRequest -Method Get ` - -Uri $InstallerUri ` - -OutFile $VsInstaller - - New-Item -ItemType directory -Path $VsInstallOutputDir - - Write-Host "Running web installer to download requested components..." - - Start-Process ` - -FilePath "$VsInstaller" ` - -ArgumentList ( ` - '--layout', "$VsInstallOutputDir", - '--wait', - '--norestart', - '--quiet' + ` - $componentList - ) ` - -Wait ` - -PassThru - - Write-Host "Running downloaded VS installer to add requested components..." - - Start-Process ` - -FilePath "$VsInstallOutputDir\vs_Enterprise.exe" ` - -ArgumentList ( - 'modify', - '--installPath', "`"$VsInstallPath`"" , - '--wait', - '--norestart', - '--quiet' + ` - $componentList - ) ` - -Wait ` - -PassThru ` - -OutVariable returnCode - - if ($Cleanup) { - Write-Host "Cleaning up..." - - Remove-Item -Path $VsInstaller - Remove-Item -Path $VsInstallOutputDir -Recurse - } - -} else { - Write-Host "Downloading latest Bootstrapper to update local installer..." - - Invoke-WebRequest -Method Get -Uri $InstallerUri -OutFile $VsInstaller - - Start-Process ` - -FilePath "$VsInstaller" ` - -ArgumentList ( '--update', '--wait', '--quiet' ) ` - -Wait ` - -PassThru - - Write-Host "Running local installer to add requested components..." - - Start-Process ` - -FilePath "$LocalVsInstaller" ` - -ArgumentList ( - 'modify', - '--installPath', "`"$VsInstallPath`"" , - '--norestart', - '--quiet' + ` - $componentList - ) ` - -Wait ` - -OutVariable returnCode -} - -if ($Collect) { - Invoke-WebRequest -Method Get ` - -Uri 'https://download.microsoft.com/download/8/3/4/834E83F6-C377-4DCE-A757-69A418B6C6DF/Collect.exe' ` - -OutFile ${env:System_DefaultWorkingDirectory}\Collect.exe - - # Should generate ${env:Temp}\vslogs.zip - Start-Process ` - -FilePath "${env:System_DefaultWorkingDirectory}\Collect.exe" ` - -Wait ` - -PassThru - - New-Item -ItemType Directory -Force ${env:System_DefaultWorkingDirectory}\vslogs - Expand-Archive -Path ${env:TEMP}\vslogs.zip -DestinationPath ${env:System_DefaultWorkingDirectory}\vslogs\ - Copy-Item -Path ${env:TEMP}\vslogs.zip -Destination $OutputPath - - Write-Host "VC versions after installation:" - Get-ChildItem -Name "$VsInstallPath\VC\Tools\MSVC\" -} diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 8e91611..61c9b0b 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -4,7 +4,10 @@ param( [string]$OutputPath = "$PSScriptRoot\out", [string]$SourcesPath = $PSScriptRoot, [string]$Platform = "x64", - [string]$Configuration = "Release" + [string]$Configuration = "Release", + [string]$AppPlatform = "win32", + [switch]$UseClang, + [switch]$UseLibCpp ) $workpath = Join-Path $SourcesPath "build" @@ -22,18 +25,18 @@ if ($Configuration -like "*android") { $gnargs += ' use_goma=false target_os=\"android\" target_cpu=\"' + $Platform + '\"' } else { - if (-not ($Configuration -like "*libcpp*")) { + if (-not ($UseLibCpp)) { $gnargs += ' use_custom_libcxx=false' } - if ($Configuration -like "UWP*") { + if ($AppPlatform -eq "uwp") { # the default target_winuwp_family="app" (which translates to WINAPI_FAMILY=WINAPI_FAMILY_PC_APP) blows up with too many errors $gnargs += ' target_os=\"winuwp\" target_winuwp_family=\"desktop\"' } $gnargs += ' target_cpu=\"' + $Platform + '\"' - if ($Configuration -like "*clang") { + if ($UseClang) { #TODO (#2): we need to figure out how to actually build DEBUG with clang-cl (won't work today due to STL iterator issues) $gnargs += ' is_clang=true' } @@ -54,7 +57,7 @@ else { $gnargs += ' enable_iterator_debugging=false is_debug=false' } -$buildoutput = Join-Path $workpath "v8build\v8\out\$Platform\$Configuration" +$buildoutput = Join-Path $workpath "v8build\v8\out\$AppPlatform\$Platform\$Configuration" Write-Host "gn command line: gn gen $buildoutput --args='$gnargs'" & gn gen $buildoutput --args="$gnargs" @@ -83,21 +86,21 @@ if (!(Test-Path -Path "$OutputPath\build\native\include\jsi")) { if (!(Test-Path -Path "$OutputPath\license")) { New-Item -ItemType "directory" -Path "$OutputPath\license" | Out-Null } -if (!(Test-Path -Path "$OutputPath\lib\$Configuration\$Platform")) { - New-Item -ItemType "directory" -Path "$OutputPath\lib\$Configuration\$Platform" | Out-Null +if (!(Test-Path -Path "$OutputPath\lib\$AppPlatform\$Configuration\$Platform")) { + New-Item -ItemType "directory" -Path "$OutputPath\lib\$AppPlatform\$Configuration\$Platform" | Out-Null } # Binaries if (!$PSVersionTable.Platform -or $IsWindows) { - Copy-Item "$buildoutput\v8jsi.dll" -Destination "$OutputPath\lib\$Configuration\$Platform" - Copy-Item "$buildoutput\v8jsi.dll.lib" -Destination "$OutputPath\lib\$Configuration\$Platform" - Copy-Item "$buildoutput\v8jsi.dll.pdb" -Destination "$OutputPath\lib\$Configuration\$Platform" + Copy-Item "$buildoutput\v8jsi.dll" -Destination "$OutputPath\lib\$AppPlatform\$Configuration\$Platform" + Copy-Item "$buildoutput\v8jsi.dll.lib" -Destination "$OutputPath\lib\$AppPlatform\$Configuration\$Platform" + Copy-Item "$buildoutput\v8jsi.dll.pdb" -Destination "$OutputPath\lib\$AppPlatform\$Configuration\$Platform" } else { #TODO (#2): .so } -Copy-Item "$buildoutput\args.gn" -Destination "$OutputPath\lib\$Configuration\$Platform" +Copy-Item "$buildoutput\args.gn" -Destination "$OutputPath\lib\$AppPlatform\$Configuration\$Platform" # Headers Copy-Item "$jsigitpath\public\ScriptStore.h" -Destination "$OutputPath\build\native\include\"