chromium Windows build 中文

chromium

chromium Windows build (japanese) 繁體中文表示法

chromium 預先建置準備

chromium 建置說明
使用 “Checking out and Building Chromium for Windows” 作為參考建置原始碼。

  • 因為編譯 Chromium 需要較長時間,所以需要高規格的電腦。我測試了兩種類型的計算機。
  • Windows10 core-i3 4線程,記憶體16GiB SSD256GiB:處理時間約80-90小時
  • Windows11 core-i7 20線程,記憶體16GiB SSD 1TB:處理時間約5-6小時
  • 您需要在電腦上安裝 git
  • 驗證 Windows 支援字元編碼 (UTF-8)。
    這是因為下載(fetch)腳本假設使用 UTF-8,而 Shift-JIS 在進行 fetch 時會產生錯誤。

安裝 Visual Studio 和 Windows 11 SDK

取得並安裝 Visual Studio 2022 (>=17.0.0) 及 Windows 11 SDK 版本 10.0.22621.0。特別是 Visual Studio 有許多組件,但透過在 DOS 提示字元執行以下命令,可以安裝最小必要的組件。(可以節省時間)

C:\Users\Ichino\Downloads> VisualStudioSetup.exe ^
--add Microsoft.VisualStudio.Workload.NativeDesktop ^
--add Microsoft.VisualStudio.Component.VC.ATLMFC ^
--includeRecommended

輸入命令後會顯示安裝程式畫面。在該畫面上選擇下載並安裝,然後繼續進行安裝過程。

depot_tools安裝

從官方網站的連結下載 depot_tools.zip,然後解壓縮到任意的資料夾中。解壓縮 zip 檔案時,請使用右鍵點擊的選單進行操作。(實際上使用 7zip 解壓縮比較安全)

解壓縮檔案後,將depot_tools資料夾路徑設置為環境變數PATH的最前端,然後在DOS提示符號中執行以下命令(以更新depot_tools為最新版本)。

C:\src> gclient

取得 Chromium 原始碼

首先,我們會進行 Git 的初始設定。請在 DOS 提示字元中設定以下內容。

c:\src> git config --global user.name "Ichino"
c:\src> git config --global user.email "ichino@ichino-memo.com"
c:\src> git config --global core.autocrlf false
c:\src> git config --global core.filemode false
c:\src> git config --global branch.autosetuprebase always

接下來,為您的 Chromium 建置建立一個資料夾。

c:\src> mkdir chromium && cd chromium

我們將取得 Chromium 的原始碼。在我的環境中發生了錯誤,所以我重新執行了這個取得的動作。這次的 fetch 過程可能需要大約三個小時。

c:\src\chromium> fetch chromium
  • 成功日誌
    如果成功,將在 chromium 資料夾中產生一個名為 .gclient 的檔案。
C:\src\chromium>fetch chromium
Updating depot_tools...
Running: 'C:\Users\ichino\.vpython-root\54046a\Scripts\python.exe' 'C:\src\depot_tools\gclient.py' root
Running: 'C:\Users\ichino\.vpython-root\54046a\Scripts\python.exe' 'C:\src\depot_tools\gclient.py' config --spec 'solutions = [
  {
    "name": "src",
    "url": "https://chromium.googlesource.com/chromium/src.git",
    "managed": False,
    "custom_deps": {},
    "custom_vars": {},
  },
]
'
Running: 'C:\Users\ichino\.vpython-root\54046a\Scripts\python.exe' 'C:\src\depot_tools\gclient.py' sync
1>________ running 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://chromium.googlesource.com/chromium/src.git C:\src\chromium\_gclient_src_qlpp7ox2' in 'C:\src\chromium'
1>Cloning into 'C:\src\chromium\_gclient_src_qlpp7ox2'...
1>remote: Sending approximately 40.84 GiB ...Counting objects: 1
.
.
.
Running hooks:  53% (78/145) cros_simplechrome_artifacts_with_no_vm_intRunning hooks:  54% (79/145) cros_simplechrome_artifacts_with_vm_internRunning hooks:  55% (80/145) cros_simplechrome_artifacts_with_vm for laRunning hooks:  55% (81/145) cros_simplechrome_artifacts_with_no_vm forRunning hooks:  56% (82/145) cros_simplechrome_artifacts_with_vm_internRunning hooks:  57% (83/145) cros_simplechrome_artifacts_with_no_vm_intRunning hooks:  57% (84/145) Fetch PGO profiles for win32
Hook 'python3 src/testing/generate_location_tags.py --out src/testing/location_tags.json' took 44.38 secs
Hook 'python3 src/third_party/depot_tools/download_from_google_storage.py --no_auth --quiet --bucket chromium-style-perftest -d src/third_party/blink/renderer/core/css/perftest_data' took 25.86 secs
Running hooks: 100% (145/145), done.
Running: git submodule foreach 'git config -f $toplevel/.git/config submodule.$name.ignore all'
Running: git config --add remote.origin.fetch '+refs/tags/*:refs/tags/*'
Running: git config diff.ignoreSubmodules all
  • 故障日誌
C:\src\chromium>fetch chromium
Updating depot_tools...
Running: 'C:\Users\ichino\.vpython-root\54046a\Scripts\python.exe' 'C:\src\depot_tools\gclient.py' root
Running: 'C:\Users\ichino\.vpython-root\54046a\Scripts\python.exe' 'C:\src\depot_tools\gclient.py' config --spec 'solutions = [
  {
    "name": "src",
    "url": "https://chromium.googlesource.com/chromium/src.git",
    "managed": False,
    "custom_deps": {},
    "custom_vars": {},
  },
]
'
.
.
.
1>error: 29040 bytes of body are still expected.13 GiB | 6.57 MiB/s
1>fetch-pack: unexpected disconnect while reading sideband packet
1>fatal: early EOF
1>fatal: fetch-pack: invalid index-pack output
1>WARNING: subprocess '"git" "-c" "core.deltaBaseCacheLimit=2g" "clone" "--no-checkout" "--progress" "https://chromium.googlesource.com/chromium/src.git" "C:\src\chromium\_gclient_src_9diwfm34"' in C:\src\chromium failed; will retry after a short nap...
Syncing projects: 100% ( 1/ 1) src

src (ERROR)
----------------------------------------
[0:00:00] Started.
[0:01:08]
Traceback (most recent call last):
  File "C:\src\depot_tools\gclient_scm.py", line 1185, in _Clone
    self._Run(clone_cmd,
  File "C:\src\depot_tools\gclient_scm.py", line 1531, in _Run
    gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs)
  File "C:\src\depot_tools\gclient_utils.py", line 715, in CheckCallAndFilter
    raise subprocess2.CalledProcessError(
subprocess2.CalledProcessError: Command 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://chromium.googlesource.com/chromium/src.git C:\\src\\chromium\\_gclient_src_9diwfm34' returned non-zero exit status 128 in C:\src\chromium
[0:22:11] _____ Conflicting directory found in C:\src\chromium\src. Moving to C:\src\chromium\_bad_scm\srcguswswnw.
----------------------------------------


Warnings:
Conflicting directory C:\src\chromium\src moved to C:\src\chromium\_bad_scm\srcguswswnw.
Traceback (most recent call last):
  File "C:\src\depot_tools\gclient_scm.py", line 663, in update
    self._Clone(revision, url, options)
  File "C:\src\depot_tools\gclient_scm.py", line 1185, in _Clone
    self._Run(clone_cmd,
  File "C:\src\depot_tools\gclient_scm.py", line 1531, in _Run
    gclient_utils.CheckCallAndFilter(cmd, env=env, **kwargs)
  File "C:\src\depot_tools\gclient_utils.py", line 715, in CheckCallAndFilter
    raise subprocess2.CalledProcessError(
subprocess2.CalledProcessError: Command 'git -c core.deltaBaseCacheLimit=2g clone --no-checkout --progress https://chromium.googlesource.com/chromium/src.git C:\\src\\chromium\\_gclient_src_9diwfm34' returned non-zero exit status 128 in C:\src\chromium

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\ichino\.vpython-root\54046a\lib\shutil.py", line 791, in move
    os.rename(src, real_dst)
FileNotFoundError: [WinError 2] 指定されたファイルが見つかりません。: 'C:\\src\\chromium\\src' -> 'C:\\src\\chromium\\_bad_scm\\srcguswswnw\\src'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\src\depot_tools\metrics.py", line 301, in print_notice_and_exit
    yield
  File "C:\src\depot_tools\gclient.py", line 3555, in <module>
    sys.exit(main(sys.argv[1:]))
  File "C:\src\depot_tools\gclient.py", line 3541, in main
    return dispatcher.execute(OptionParser(), argv)
  File "C:\src\depot_tools\subcommand.py", line 252, in execute
    return command(parser, args[1:])
  File "C:\src\depot_tools\gclient.py", line 3085, in CMDsync
    ret = client.RunOnDeps('update', args)
  File "C:\src\depot_tools\gclient.py", line 2041, in RunOnDeps
    work_queue.flush(revision_overrides,
  File "C:\src\depot_tools\gclient_utils.py", line 1016, in flush
    reraise(e[0], e[1], e[2])
  File "C:\src\depot_tools\gclient_utils.py", line 70, in reraise
    raise value
  File "C:\src\depot_tools\gclient_utils.py", line 1093, in run
    self.item.run(*self.args, **self.kwargs)
  File "C:\src\depot_tools\gclient.py", line 1016, in run
    self._got_revision = self._used_scm.RunCommand(command, options, args,
  File "C:\src\depot_tools\gclient_scm.py", line 128, in RunCommand
    return getattr(self, command)(options, args, file_list)
  File "C:\src\depot_tools\gclient_scm.py", line 564, in wrapper
    return_val = f(*args)
  File "C:\src\depot_tools\gclient_scm.py", line 666, in update
    self._DeleteOrMove(options.force)
  File "C:\src\depot_tools\gclient_scm.py", line 203, in _DeleteOrMove
    shutil.move(self.checkout_path, dest_path)
  File "C:\Users\ichino\.vpython-root\54046a\lib\shutil.py", line 811, in move
    copy_function(src, real_dst)
  File "C:\Users\ichino\.vpython-root\54046a\lib\shutil.py", line 435, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "C:\Users\ichino\.vpython-root\54046a\lib\shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\src\\chromium\\src'
Subprocess failed with return code 1.

此外,即使在錯誤後執行以下指令,取得依然並未成功。

c:\src\chromium> gclient sync

chromium 配置

在建構 Chromium 之前,我們會進行配置,例如添加除錯符號等設定。
前往下載的 src 資料夾,並執行 gn 指令(實際上有許多參數,會在另一個機會進行指導)。

c:\src\chromium> cd src
c:\src\chromium\src> gn gen out\Default

Chromium 的建置

c:\src\chromium\src> autoninja -C out\Default chrome
  • 成功日誌
C:\src\chromium\src>autoninja -C out\Default chrome
"C:\src\depot_tools\bootstrap-2@3_8_10_chromium_26_bin\python3\bin\python3.exe" C:\src\depot_tools\ninja.py -C out\Default chrome -j 22
ninja: Entering directory `out\Default'
[58860/58860] STAMP obj/chrome/chrome.stamp

執行已建置完成的 Chromium

c:\src\chromium\src> out\Default\chrome.exe

初次啟動時會建立快取,因此直到瀏覽器顯示出來可能需要一些時間。稍等片刻,Chromium 的畫面就會出現。

宣傳

我哋開始日本直送銷售啦。

https://shopee.tw/inazuma.distribution