代理配置#
因為 gclient 不支持設置代理,如沒有配置網關代理,可以使用全局透明代理 Windows 下 Mellow,Linux 可用 QV2ray
記得將原來的 git 等代理取消掉,因為 gclient 會用 git
工具下載#
- 工具
python2,gn,ninja,gclinet,git 直接下 prebuilt 丟環境變量即可 - VS
vs installer 勾上 C++ 桌面開發 (+ATLMFC),Windows 平台開發 。環境變量可以丟可以不丟,不丟直接用 VS 自帶的 command prompt 即可 - Debugging Tools
The SDK Debugging Tools must also be installed. If the Windows 10 SDK was installed via the Visual Studio installer, then they can be installed by going to: Control Panel → Programs → Programs and Features → Select the “Windows Software Development Kit” → Change → Change → Check “Debugging Tools For Windows” → Change. Or, you can download the standalone SDK installer and use it to install the Debugging Tools.
獲取代碼#
mkdir repo
cd repo
gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git
gclient sync
cd pdfium
生成構建文件#
- gn 配置文件
gn args out/Debug #ninja
gn gen --ide=vs out\Debug #vs
- 內容
use_goma = false # Googlers only. Make sure goma is installed and running first.
is_debug = true # Enable debugging features.
# Set true to enable experimental Skia backend.
pdf_use_skia = false
# Set true to enable experimental Skia backend (paths only).
pdf_use_skia_paths = false
pdf_enable_xfa = true # Set false to remove XFA support (implies JS support).
pdf_enable_v8 = true # Set false to remove Javascript support.
pdf_is_standalone = true # Set for a non-embedded build.
is_component_build = false # Disable component build (Though it should work)
clang_use_chrome_plugins = false # Currently must be false.</pre>
修復#
ERROR at //build/config/win/visual_studio_version.gni:27:7: Script returned non-zero exit code.exec_script("../../vs_toolchain.py", ["get_toolchain_dir"], "scope")
解決: set DEPOT_TOOLS_WIN_TOOLCHAIN=0
使用本地 Win Toolchian,如無效,手動加到環境變量,重開控制台
ERROR at //build/timestamp.gni:31:19: Script returned non-zero exit code.
解決: 使用 cmd 重新 sync gclient sync
, 貌似是一個 powershell 的命令問題。
Downloading https://commondatastorage.googleapis.com/chromium-browser-clang/Win/clang-n344329-9284abd0-6.tgz <urlopen error [Errno 11004] getaddrinfo failed>
解決:應該是 dns 劫持問題,ip.sb 上面查一個 commondatastorage.googleapis.com 的 ip, 加到 C:\Windows\System32\drivers\etc\hosts
上
構建#
ninja -C out/Debug pdfium_test
執行測試#