|
24 | 24 | [string] $V8Snapshot = "bootstrap", |
25 | 25 | [switch] $UpstreamV8, |
26 | 26 | [switch] $ThinLto, |
27 | | - [switch] $PartitionAlloc |
| 27 | + [switch] $PartitionAlloc, |
| 28 | + [switch] $V8ChildBuild |
28 | 29 | ) |
29 | 30 |
|
30 | 31 | $ErrorActionPreference = "Stop" |
@@ -70,85 +71,110 @@ if ([string]::IsNullOrWhiteSpace($V8Root)) { |
70 | 71 | if ([string]::IsNullOrWhiteSpace($V8Workspace)) { |
71 | 72 | $V8Workspace = Join-Path $repoRoot "artifacts/native-engine-v8/$Rid" |
72 | 73 | } |
73 | | - $depotTools = Join-Path $V8Workspace "depot_tools" |
74 | 74 | $V8Root = Join-Path $V8Workspace "v8" |
75 | | - New-Item -ItemType Directory -Force -Path $V8Workspace | Out-Null |
76 | | - # depot_tools may run without a persistent global Git configuration on |
77 | | - # hosted Windows runners. Force LF checkouts for the pinned V8 sources so |
78 | | - # the pinned native V8 patches apply identically on every platform. |
79 | | - $env:GIT_CONFIG_COUNT = "2" |
80 | | - $env:GIT_CONFIG_KEY_0 = "core.autocrlf" |
81 | | - $env:GIT_CONFIG_VALUE_0 = "false" |
82 | | - $env:GIT_CONFIG_KEY_1 = "core.eol" |
83 | | - $env:GIT_CONFIG_VALUE_1 = "lf" |
84 | | - if (-not (Test-Path (Join-Path $depotTools ".git"))) { |
85 | | - & git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git $depotTools |
86 | | - if ($LASTEXITCODE -ne 0) { throw "Failed to clone depot_tools." } |
| 75 | + $v8PreparedByChild = $false |
| 76 | + if ($IsWindows -and -not $V8ChildBuild) { |
| 77 | + Import-Module (Join-Path $PSScriptRoot "V8WindowsEnvironment.psm1") -Force |
| 78 | + $childArguments = @( |
| 79 | + "-Rid", $Rid, |
| 80 | + "-PackageVersion", $PackageVersion, |
| 81 | + "-V8Workspace", $V8Workspace, |
| 82 | + "-V8Revision", $v8Revision, |
| 83 | + "-V8ChildBuild" |
| 84 | + ) |
| 85 | + if ($UpstreamV8) { $childArguments += "-UpstreamV8" } |
| 86 | + if ($ThinLto) { $childArguments += "-ThinLto" } |
| 87 | + if ($PartitionAlloc) { $childArguments += "-PartitionAlloc" } |
| 88 | + Invoke-WebSceneV8ChildPowerShell ` |
| 89 | + -ScriptPath $PSCommandPath ` |
| 90 | + -ArgumentList $childArguments |
| 91 | + $v8PreparedByChild = $true |
87 | 92 | } |
88 | | - $env:Path = "$depotTools;$env:Path" |
89 | | - $depotToolsGit = Join-Path $depotTools "git.bat" |
90 | | - if (-not (Test-Path $depotToolsGit)) { |
91 | | - & (Join-Path $depotTools "bootstrap/win_tools.bat") |
92 | | - if ($LASTEXITCODE -ne 0) { throw "Failed to bootstrap depot_tools for Windows." } |
93 | | - } |
94 | | - $env:DEPOT_TOOLS_UPDATE = "0" |
95 | | - $env:DEPOT_TOOLS_WIN_TOOLCHAIN = "0" |
96 | 93 |
|
97 | | - if (-not (Test-Path (Join-Path $V8Workspace ".gclient"))) { |
| 94 | + if (-not $v8PreparedByChild) { |
| 95 | + $depotTools = Join-Path $V8Workspace "depot_tools" |
| 96 | + New-Item -ItemType Directory -Force -Path $V8Workspace | Out-Null |
| 97 | + # depot_tools may run without a persistent global Git configuration on |
| 98 | + # hosted Windows runners. Force LF checkouts for the pinned V8 sources so |
| 99 | + # the pinned native V8 patches apply identically on every platform. |
| 100 | + $env:GIT_CONFIG_COUNT = "2" |
| 101 | + $env:GIT_CONFIG_KEY_0 = "core.autocrlf" |
| 102 | + $env:GIT_CONFIG_VALUE_0 = "false" |
| 103 | + $env:GIT_CONFIG_KEY_1 = "core.eol" |
| 104 | + $env:GIT_CONFIG_VALUE_1 = "lf" |
| 105 | + if (-not (Test-Path (Join-Path $depotTools ".git"))) { |
| 106 | + & git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git $depotTools |
| 107 | + if ($LASTEXITCODE -ne 0) { throw "Failed to clone depot_tools." } |
| 108 | + } |
| 109 | + $env:Path = "$depotTools;$env:Path" |
| 110 | + $depotToolsGit = Join-Path $depotTools "git.bat" |
| 111 | + if (-not (Test-Path $depotToolsGit)) { |
| 112 | + & (Join-Path $depotTools "bootstrap/win_tools.bat") |
| 113 | + if ($LASTEXITCODE -ne 0) { throw "Failed to bootstrap depot_tools for Windows." } |
| 114 | + } |
| 115 | + $env:DEPOT_TOOLS_UPDATE = "0" |
| 116 | + $env:DEPOT_TOOLS_WIN_TOOLCHAIN = "0" |
| 117 | + |
| 118 | + if (-not (Test-Path (Join-Path $V8Workspace ".gclient"))) { |
| 119 | + Push-Location $V8Workspace |
| 120 | + try { & gclient.bat config https://chromium.googlesource.com/v8/v8 } |
| 121 | + finally { Pop-Location } |
| 122 | + if ($LASTEXITCODE -ne 0) { throw "Failed to configure the V8 checkout." } |
| 123 | + } |
98 | 124 | Push-Location $V8Workspace |
99 | | - try { & gclient.bat config https://chromium.googlesource.com/v8/v8 } |
| 125 | + try { & gclient.bat sync --no-history -r $v8Revision } |
100 | 126 | finally { Pop-Location } |
101 | | - if ($LASTEXITCODE -ne 0) { throw "Failed to configure the V8 checkout." } |
102 | | - } |
103 | | - Push-Location $V8Workspace |
104 | | - try { & gclient.bat sync --no-history -r $v8Revision } |
105 | | - finally { Pop-Location } |
106 | | - if ($LASTEXITCODE -ne 0) { throw "Failed to synchronize V8 $v8Revision." } |
| 127 | + if ($LASTEXITCODE -ne 0) { throw "Failed to synchronize V8 $v8Revision." } |
107 | 128 |
|
108 | | - function Apply-PatchOnce([string] $Checkout, [string] $PatchPath) { |
109 | | - & git -C $Checkout apply --check --ignore-space-change $PatchPath |
110 | | - if ($LASTEXITCODE -eq 0) { |
111 | | - & git -C $Checkout apply --ignore-space-change $PatchPath |
112 | | - if ($LASTEXITCODE -ne 0) { throw "Failed to apply V8 patch '$PatchPath'." } |
113 | | - return |
| 129 | + function Apply-PatchOnce([string] $Checkout, [string] $PatchPath) { |
| 130 | + & git -C $Checkout apply --check --ignore-space-change $PatchPath |
| 131 | + if ($LASTEXITCODE -eq 0) { |
| 132 | + & git -C $Checkout apply --ignore-space-change $PatchPath |
| 133 | + if ($LASTEXITCODE -ne 0) { throw "Failed to apply V8 patch '$PatchPath'." } |
| 134 | + return |
| 135 | + } |
| 136 | + & git -C $Checkout apply --reverse --check --ignore-space-change $PatchPath |
| 137 | + if ($LASTEXITCODE -ne 0) { |
| 138 | + throw "Cannot apply or recognize V8 patch '$PatchPath' in '$Checkout'." |
| 139 | + } |
114 | 140 | } |
115 | | - & git -C $Checkout apply --reverse --check --ignore-space-change $PatchPath |
116 | | - if ($LASTEXITCODE -ne 0) { |
117 | | - throw "Cannot apply or recognize V8 patch '$PatchPath' in '$Checkout'." |
| 141 | + # WebScene owns the JavaScript console bindings. The inspector bridge keeps |
| 142 | + # the original V8 values so CDP clients receive object ids and previews. |
| 143 | + Apply-PatchOnce $V8Root (Join-Path $repoRoot "third-party/v8-patches/V8InspectorConsolePatch.txt") |
| 144 | + if (-not $UpstreamV8 -and $v8Revision -ne "15.3.10") { |
| 145 | + Apply-PatchOnce $V8Root (Join-Path $repoRoot "third-party/v8-patches/V8Patch.txt") |
| 146 | + Apply-PatchOnce $V8Root (Join-Path $repoRoot "packaging/WebScene.NativeEngine.Runtime/patches/V8ToolchainPatch.txt") |
118 | 147 | } |
119 | | - } |
120 | | - # WebScene owns the JavaScript console bindings. The inspector bridge keeps |
121 | | - # the original V8 values so CDP clients receive object ids and previews. |
122 | | - Apply-PatchOnce $V8Root (Join-Path $repoRoot "third-party/v8-patches/V8InspectorConsolePatch.txt") |
123 | | - if (-not $UpstreamV8 -and $v8Revision -ne "15.3.10") { |
124 | | - Apply-PatchOnce $V8Root (Join-Path $repoRoot "third-party/v8-patches/V8Patch.txt") |
125 | | - Apply-PatchOnce $V8Root (Join-Path $repoRoot "packaging/WebScene.NativeEngine.Runtime/patches/V8ToolchainPatch.txt") |
126 | | - } |
127 | | - if ($ThinLto) { |
128 | | - Apply-PatchOnce $V8Root (Join-Path $repoRoot "packaging/WebScene.NativeEngine.Runtime/patches/V8ThinLtoPatch.txt") |
129 | | - } |
130 | | - if ($v8Revision -eq "15.3.10") { |
131 | | - # V8 15.3 needs two clang-cl/MSVC compatibility fixes: model the |
132 | | - # ExtendedMap ABI padding in Torque and use V8's FunctionRef directly |
133 | | - # in the backing-store allocation retry path. |
134 | | - Apply-PatchOnce $V8Root (Join-Path $repoRoot "packaging/WebScene.NativeEngine.Runtime/patches/V8WindowsCompatibilityPatch.txt") |
135 | | - } |
136 | | - if (-not $UpstreamV8 -and $v8Revision -ne "15.3.10") { |
137 | | - Apply-PatchOnce (Join-Path $V8Root "build") (Join-Path $repoRoot "third-party/v8-patches/BuildPatch.txt") |
138 | | - Apply-PatchOnce (Join-Path $V8Root "third_party/icu") (Join-Path $repoRoot "third-party/v8-patches/ICUPatch.txt") |
| 148 | + if ($ThinLto) { |
| 149 | + Apply-PatchOnce $V8Root (Join-Path $repoRoot "packaging/WebScene.NativeEngine.Runtime/patches/V8ThinLtoPatch.txt") |
| 150 | + } |
| 151 | + if ($v8Revision -eq "15.3.10") { |
| 152 | + # V8 15.3 needs two clang-cl/MSVC compatibility fixes: model the |
| 153 | + # ExtendedMap ABI padding in Torque and use V8's FunctionRef directly |
| 154 | + # in the backing-store allocation retry path. |
| 155 | + Apply-PatchOnce $V8Root (Join-Path $repoRoot "packaging/WebScene.NativeEngine.Runtime/patches/V8WindowsCompatibilityPatch.txt") |
| 156 | + } |
| 157 | + if (-not $UpstreamV8 -and $v8Revision -ne "15.3.10") { |
| 158 | + Apply-PatchOnce (Join-Path $V8Root "build") (Join-Path $repoRoot "third-party/v8-patches/BuildPatch.txt") |
| 159 | + Apply-PatchOnce (Join-Path $V8Root "third_party/icu") (Join-Path $repoRoot "third-party/v8-patches/ICUPatch.txt") |
| 160 | + } |
| 161 | + |
| 162 | + # Backslash-escaped quotes survive PowerShell's native argument marshalling |
| 163 | + # and reach GN as string delimiters. |
| 164 | + $gnArgs = 'chrome_pgo_phase=0 fatal_linker_warnings=false is_cfi=false is_component_build=false is_debug=false symbol_level=0 target_cpu=\"{0}\" treat_warnings_as_errors=false use_clang_modules=false use_custom_libcxx=false use_thin_lto={1} v8_embedder_string=\"-WebScene\" v8_enable_fuzztest=false v8_enable_partition_alloc={2} v8_enable_pointer_compression=true v8_enable_pointer_compression_shared_cage=true v8_enable_sandbox=false v8_enable_static_roots=false v8_enable_31bit_smis_on_64bit_arch=false v8_enable_temporal_support=false v8_monolithic=true v8_use_external_startup_data=false v8_target_cpu=\"{0}\"' -f $cpu, $thinLtoValue, $partitionAllocValue |
| 165 | + Push-Location $V8Root |
| 166 | + try { |
| 167 | + & gn.bat gen "out/$cpu/$v8Configuration" "--args=$gnArgs" |
| 168 | + if ($LASTEXITCODE -ne 0) { throw "Failed to generate the V8 build." } |
| 169 | + & ninja.exe -C "out/$cpu/$v8Configuration" "obj/v8_monolith.lib" |
| 170 | + if ($LASTEXITCODE -ne 0) { throw "Failed to build the V8 monolith." } |
| 171 | + } |
| 172 | + finally { Pop-Location } |
139 | 173 | } |
140 | 174 |
|
141 | | - # Backslash-escaped quotes survive PowerShell's native argument marshalling |
142 | | - # and reach GN as string delimiters. |
143 | | - $gnArgs = 'chrome_pgo_phase=0 fatal_linker_warnings=false is_cfi=false is_component_build=false is_debug=false symbol_level=0 target_cpu=\"{0}\" treat_warnings_as_errors=false use_clang_modules=false use_custom_libcxx=false use_thin_lto={1} v8_embedder_string=\"-WebScene\" v8_enable_fuzztest=false v8_enable_partition_alloc={2} v8_enable_pointer_compression=true v8_enable_pointer_compression_shared_cage=true v8_enable_sandbox=false v8_enable_static_roots=false v8_enable_31bit_smis_on_64bit_arch=false v8_enable_temporal_support=false v8_monolithic=true v8_use_external_startup_data=false v8_target_cpu=\"{0}\"' -f $cpu, $thinLtoValue, $partitionAllocValue |
144 | | - Push-Location $V8Root |
145 | | - try { |
146 | | - & gn.bat gen "out/$cpu/$v8Configuration" "--args=$gnArgs" |
147 | | - if ($LASTEXITCODE -ne 0) { throw "Failed to generate the V8 build." } |
148 | | - & ninja.exe -C "out/$cpu/$v8Configuration" "obj/v8_monolith.lib" |
149 | | - if ($LASTEXITCODE -ne 0) { throw "Failed to build the V8 monolith." } |
| 175 | + if ($V8ChildBuild) { |
| 176 | + return |
150 | 177 | } |
151 | | - finally { Pop-Location } |
152 | 178 | } |
153 | 179 |
|
154 | 180 | $v8OutputRoot = Join-Path $V8Root "out/$cpu/$v8Configuration" |
|
0 commit comments