如何从铬源构建无头示例浏览器?

时间:2019-01-21 08:33:24

标签: c++ chromium

我正在尝试从铬源构建无头示例作为C ++库

https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md#usage-as-a-c_library
G:\chromium\src\headless>gn gen  --args=is_debug=true --root=../ ../out/test
Done. Made 10741 targets from 1804 files in 21901ms
G:\chromium\src\headless>ninja -C ../out/test headless_example
ninja: Entering directory `../out/test'
[24577/24577] LINK headless_example.exe headless_example.exe.pdb

G:\chromium\src\headless>

构建后,我正在尝试启动headless_example.exe,但出现错误

G:\chromium\src\out\test>headless_example.exe
[0121/145957.684:FATAL:command_line.cc(234)] Check failed: current_process_comma
ndline_.
Backtrace:
        base::debug::StackTrace::StackTrace [0x000007FEDF41AF29+105] (G:\chromiu
m\src\base\debug\stack_trace_win.cc:281)
        base::debug::StackTrace::StackTrace [0x000007FEDF419EC5+37] (G:\chromium
\src\base\debug\stack_trace.cc:203)
        logging::LogMessage::~LogMessage [0x000007FEDF46BA86+134] (G:\chromium\s
rc\base\logging.cc:591)
        base::CommandLine::ForCurrentProcess [0x000007FEDF3CE65B+155] (G:\chromi
um\src\base\command_line.cc:235)
        headless::HeadlessBrowserMain [0x000007FED0F3DEDC+332] (G:\chromium\src\
headless\lib\browser\headless_browser_impl.cc:284)
        main [0x000000013FA225F1+257] (G:\chromium\src\headless\app\headless_exa
mple.cc:195)
        invoke_main [0x00000001402F0804+52] (f:\dd\vctools\crt\vcstartup\src\sta
rtup\exe_common.inl:79)
        __scrt_common_main_seh [0x00000001402F093E+302] (f:\dd\vctools\crt\vcsta
rtup\src\startup\exe_common.inl:288)
        __scrt_common_main [0x00000001402F09BE+14] (f:\dd\vctools\crt\vcstartup\
src\startup\exe_common.inl:331)
        mainCRTStartup [0x00000001402F09D9+9] (f:\dd\vctools\crt\vcstartup\src\s
tartup\exe_main.cpp:17)
        BaseThreadInitThunk [0x0000000077BB59CD+13]
        RtlUserThreadStart [0x0000000077D1385D+29]

如何构建和运行headless_example?

更新

我的步骤

  1. gn gen --ide = vs2017 --filters =“ // headless” out \ Headless
  2. 忍者-C out \ Headless headless_example

构建6小时后

  1. cd out / Headless
  2. ./ headless_example.exe

我也遇到同样的错误。

但是我成功构建并运行了chromedriver

我的Debug / args.gn

./ out / Debug / args.gn

# GN args template for the Headless Chrome library
#
# Add import to arg.gn in out directory and run gn gen on the directory to use.
# E.g. for out directory out/foo:
# echo 'import("//build/args/headless.gn")' > out/foo/args.gn
# gn gen out/foo
#
# Use gn args to add your own build preference args.

use_ozone = true
ozone_auto_platforms = false
ozone_platform = "headless"
ozone_platform_headless = true

# Embed resource.pak into binary to simplify deployment.
headless_use_embedded_resources = true

# Expose headless bindings for freetype library bundled with Chromium.
headless_fontconfig_utils = true

# Remove a dependency on a system fontconfig library.
use_bundled_fontconfig = true

# In order to simplify deployment we build ICU data file
# into binary.
icu_use_data_file = false

# Use embedded data instead external files for headless in order
# to simplify deployment.
v8_use_external_startup_data = false

enable_nacl = false
enable_print_preview = false
enable_remoting = false
use_alsa = false
use_cups = false
use_dbus = false
use_gio = false
use_kerberos = false
use_libpci = false
use_pulseaudio = false
use_udev = false
rtc_use_pipewire = false

1 个答案:

答案 0 :(得分:0)

>gn gen  --args=is_debug=true --root=../ ../out/test

您在上方输入的gn gen命令不正确。请尝试以下命令:

>cp ../build/args/headless.gn out/Debug/args.gn
>gn gen --root=../ ../out/test
>ninja -C ../out/test headless_example