Skip to content

Instantly share code, notes, and snippets.

@nczz
Created July 11, 2026 13:57
Show Gist options
  • Select an option

  • Save nczz/64883b0992d93e939f5ac2432a5ddf4f to your computer and use it in GitHub Desktop.

Select an option

Save nczz/64883b0992d93e939f5ac2432a5ddf4f to your computer and use it in GitHub Desktop.
Chromium 150 Windows Toolchain 打包 SOP(macOS Cross-Compile 用)

Chromium 150 Windows Toolchain 打包 SOP(macOS Cross-Compile 用)

在 Windows 11 Pro 上產出 Chromium 150.0.7871.101 所需的 Windows SDK toolchain zip, 供 macOS (Apple Silicon) cross-compile 使用。

目標版本

參數
Chromium 150.0.7871.101
Toolchain Hash e66617bc68
Visual Studio 2026 (18.0)
MSVC Toolset VC145
Windows SDK 10.0.26100.0

Windows 端操作(一次性,約 30 分鐘)

Step 1:安裝 Git + Python

winget install --id Git.Git -e --source winget --accept-package-agreements --accept-source-agreements
winget install --id Python.Python.3.12 -e --source winget --accept-package-agreements --accept-source-agreements

重新開啟 PowerShell(管理員) 讓 PATH 生效。

Step 2:安裝 VS 2026 Build Tools

Invoke-WebRequest -Uri "https://aka.ms/vs/18/stable/vs_buildtools.exe" -OutFile "C:\vs_buildtools.exe"

& "C:\vs_buildtools.exe" install `
    --add Microsoft.VisualStudio.Workload.NativeDesktop `
    --add Microsoft.VisualStudio.Component.VC.ATLMFC `
    --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
    --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 `
    --add Microsoft.VisualStudio.Component.VC.MFC.ARM64 `
    --includeRecommended --passive

等安裝 UI 顯示完成。

重要:必須包含 Microsoft.VisualStudio.Component.VC.Tools.x86.x64, 否則 x64/x86 的 CRT Redist DLLs 不會被安裝。

Step 3:安裝 Windows SDK(含 Debugging Tools)

Invoke-WebRequest -Uri "https://go.microsoft.com/fwlink/?linkid=2272610" -OutFile "C:\winsdksetup.exe"

& "C:\winsdksetup.exe" /features OptionId.WindowsDesktopDebuggers OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64 /quiet

Step 4:取得 depot_tools 並修正 vswhere 問題

cd C:\
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

Build Tools 的安裝不會被 vswhere 預設搜尋到,需要修正:

(Get-Content "C:\depot_tools\win_toolchain\package_from_installed.py") `
    -replace "vswhere.exe -prerelease", "vswhere.exe -prerelease -products *" |
    Set-Content "C:\depot_tools\win_toolchain\package_from_installed.py"

Step 5:打包

cd C:\depot_tools\win_toolchain
python package_from_installed.py 2026 -w 10.0.26100.0

完成後在 C:\depot_tools\win_toolchain\ 產出 <hash>.zip(約 1-3 GB)。

# 確認產出
Get-ChildItem "C:\depot_tools\win_toolchain\*.zip"

Step 6:傳到 Mac

用 scp、雲端硬碟、或 USB 將 zip 傳到 Mac。


macOS 端使用

放置 zip

mkdir -p ~/Projects/chromium-win-sdk-prep/output
mv <hash>.zip ~/Projects/chromium-win-sdk-prep/output/

設定環境變數

export DEPOT_TOOLS_WIN_TOOLCHAIN_BASE_URL="$HOME/Projects/chromium-win-sdk-prep/output"

# 如果產出的 hash 不是 e66617bc68,需要映射:
export GYP_MSVS_HASH_e66617bc68="<實際hash>"

修改 .gclient

cd ~/Projects/browser-source/browseforge-chromium
# 在 .gclient 末尾加入(如果還沒加):
echo "target_os = ['win']" >> .gclient

驗證 toolchain

cd ~/Projects/browser-source/browseforge-chromium/src
python3 build/vs_toolchain.py update --force
python3 build/vs_toolchain.py get_toolchain_dir

應該輸出 vs_pathsdk_version = "10.0.26100.0"vs_version = "2026" 等。

編譯 Windows Chrome

gn gen out/win --args='target_os="win" target_cpu="x64" is_official_build=true is_debug=false symbol_level=0 enable_nacl=false'
autoninja -C out/win chrome

踩過的坑

問題 原因 解法
vswhere 找不到 Build Tools vswhere 預設只搜 Visual Studio 完整版 修改腳本加 -products *
缺 x64/x86 CRT Redist 安裝時沒加 VC.Tools.x86.x64 元件 補裝該元件
--wait 參數報錯 VS 2026 installer 不支援此參數 去掉 --wait,用 --passive
Python 找不到 Windows 預設無 Python winget install Python.Python.3.12
macOS 上純下載 SDK 缺 Debuggers Debugging Tools 不在 VS Build Tools 套件裡 必須在 Windows 上用 SDK installer 安裝
macOS hash 不匹配 自行打包的內容跟 Google 官方不同 GYP_MSVS_HASH_ 環境變數映射

備註

  • 整個 Windows 操作只需做一次,產出的 zip 可無限次在 Mac 上使用
  • 同一個 Chromium 版本只要用同一個 zip
  • 升級 Chromium 版本時,檢查 src/build/vs_toolchain.pyTOOLCHAIN_HASHSDK_VERSION 是否變了,變了才需要重新打包
  • zip 傳輸建議用 rsync --progressscp -C(壓縮傳輸)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment