Skip to content

Build V8 Windows (Fiber Support) #4

Build V8 Windows (Fiber Support)

Build V8 Windows (Fiber Support) #4

name: Build V8 Windows (Fiber Support)
on:
workflow_dispatch:
inputs:
build_type:
description: 'Build Configuration'
required: true
default: 'release'
type: choice
options:
- release
- debug
linkage_type:
description: 'Linkage Type'
required: true
default: 'static'
type: choice
options:
- static
- shared
target_arch:
description: 'Target CPU Architecture'
required: true
default: 'x64'
type: choice
options:
- x64
- x86
- arm64
v8_version:
description: 'V8 Version (Tag or Branch)'
required: true
default: '12.4.254.15'
type: string
jobs:
build-v8:
name: Build V8 (${{ inputs.target_arch }} - ${{ inputs.linkage_type }} - ${{ inputs.build_type }})
runs-on: windows-latest
timeout-minutes: 360
env:
DEPOT_TOOLS_WIN_TOOLCHAIN: '0' # Use local Visual Studio
PYTHONIOENCODING: 'utf-8'
steps:
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Install Depot Tools
shell: powershell
run: |
Invoke-WebRequest -Uri "https://storage.googleapis.com/chrome-infra/depot_tools.zip" -OutFile "depot_tools.zip"
Expand-Archive -Path "depot_tools.zip" -DestinationPath "C:\depot_tools"
"C:\depot_tools" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Initialize Depot Tools
shell: powershell
run: |
$env:PATH = "C:\depot_tools;" + $env:PATH
gclient --version
- name: Fetch V8 Source
shell: powershell
working-directory: ${{ github.workspace }}
run: |
$env:PATH = "C:\depot_tools;" + $env:PATH
fetch v8
cd v8
git checkout ${{ inputs.v8_version }}
gclient sync
- name: Generate GN Args
shell: powershell
id: gn_args
run: |
# --- HELPER: Escape quotes for GN (target_cpu="x64" -> target_cpu=\"x64\") ---
function GnStr { param($k, $v) return "$k=\`"$v\`"" }
function GnBool { param($k, $v) return "$k=$v" }
$a = @()
# --- DETERMINE DYNAMIC VALUES ---
# We use standard If/Else instead of ternary (? :) to ensure PowerShell compatibility
$isShared = "false"
if ("${{ inputs.linkage_type }}" -eq "shared") { $isShared = "true" }
$isDebug = "false"
$symbolLevel = "0"
if ("${{ inputs.build_type }}" -eq "debug") {
$isDebug = "true"
$symbolLevel = "2"
}
# --- CORE BUILD SETTINGS ---
$a += GnBool "is_component_build" $isShared
$a += GnBool "is_debug" $isDebug
$a += GnStr "target_cpu" "${{ inputs.target_arch }}"
$a += GnStr "target_os" "win"
# --- MSVC COMPATIBILITY ---
$a += GnBool "is_clang" "false"
$a += GnBool "use_custom_libcxx" "false"
# --- FIBJS / FIBER STABILITY FLAGS ---
$a += GnBool "v8_enable_turbofan" "true"
$a += GnBool "cppgc_enable_caged_heap" "false"
$a += GnBool "v8_enable_pointer_compression" "false"
$a += GnBool "v8_enable_sandbox" "false"
$a += GnBool "v8_control_flow_integrity" "false"
$a += GnBool "v8_use_external_startup_data" "false"
$a += GnBool "v8_use_libm_trig_functions" "false"
$a += GnBool "v8_enable_short_builtin_calls" "false"
$a += GnBool "v8_enable_lazy_source_positions" "false"
$a += GnBool "v8_enable_allocation_folding" "false"
$a += GnBool "v8_allocation_site_tracking" "false"
$a += GnBool "v8_enable_system_instrumentation" "false"
$a += GnBool "v8_enable_lite_mode" "false"
$a += GnBool "v8_enable_gdbjit" "false"
$a += GnBool "v8_enable_webassembly" "true"
# --- STATIC / MONOLITH ---
if ("${{ inputs.linkage_type }}" -eq "static") {
$a += GnBool "v8_monolithic" "true"
}
# --- CLEANUP ---
$a += GnBool "v8_deprecation_warnings" "false"
$a += GnBool "v8_imminent_deprecation_warnings" "false"
$a += GnBool "v8_enable_tests" "false"
$a += GnBool "symbol_level" $symbolLevel
# Join all args with a space
$finalArgs = $a -join " "
Write-Host "Args: $finalArgs"
echo "ARGS=$finalArgs" >> $env:GITHUB_OUTPUT
- name: Configure Build
shell: powershell
working-directory: ${{ github.workspace }}\v8
run: |
$env:PATH = "C:\depot_tools;" + $env:PATH
gn gen out.gn/build --args="${{ steps.gn_args.outputs.ARGS }}"
- name: Compile
shell: powershell
working-directory: ${{ github.workspace }}\v8
run: |
$env:PATH = "C:\depot_tools;" + $env:PATH
$target = "${{ inputs.linkage_type == 'static' && 'v8_monolith' || 'v8' }}"
autoninja -C out.gn/build $target
- name: Collect Artifacts
shell: powershell
working-directory: ${{ github.workspace }}
run: |
New-Item -ItemType Directory -Force -Path "artifacts\lib"
New-Item -ItemType Directory -Force -Path "artifacts\include"
New-Item -ItemType Directory -Force -Path "artifacts\bin"
Copy-Item -Path "v8\include\*" -Destination "artifacts\include" -Recurse
$build = "v8\out.gn\build"
Get-ChildItem -Path $build -Filter "*.lib" | Copy-Item -Destination "artifacts\lib"
Get-ChildItem -Path $build -Filter "*.dll" | Copy-Item -Destination "artifacts\bin"
Get-ChildItem -Path $build -Filter "*.pdb" | Copy-Item -Destination "artifacts\bin"
- name: Upload
uses: actions/upload-artifact@v4
with:
name: v8-win-${{ inputs.target_arch }}-${{ inputs.linkage_type }}-${{ inputs.build_type }}
path: artifacts/