下载编译
在ubuntu18.04上会碰到一些编译包依赖,需要解决依赖问题,如果是ubuntu20会更好一些。
step1: 下载代码
https://wpewebkit.org/releases/
下载以下4个tar包:
cog-0.5.1.tar.xz*
libwpe-1.10.0.tar.xz*
wpebackend-fdo-1.6.0.tar.xz*
wpewebkit-2.32.0.tar.xz*
step2: 解压到source目录
cog-0.5.1 libwpe-1.10.0 wpebackend-fdo-1.6.0 wpewebkit-2.32.0
step3: build libwpe
cd libwpe-1.10.0/
mkdir build
cd build/
cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=Yes \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=/home/hui/disk4t/codes/wpe/source/inst
make -j8 install
step4: 配置环境变量
export PATH=$PATH:/home/hui/disk4t/codes/wpe/source/inst/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hui/disk4t/codes/wpe/source/inst/lib:/home/hui/disk4t/codes/wpe/source/inst/lib/x86_64-linux-gnu
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/home/hui/disk4t/codes/wpe/source/inst/lib/pkgconfig:/home/hui/disk4t/codes/wpe/source/inst/lib/x86_64-linux-gnu/pkgconfig
step5: build wpebackend-fdo
cd wpebackend-fdo-1.6.0
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/home/hui/disk4t/codes/wpe/source/inst
make -j8 install
step6: build wpewebkit
./Tools/wpe/install-dependencies
mkdir build
cd build/
cmake .. -DCMAKE_BUILD_TYPE=Debug -DPORT=WPE -DENABLE_MINIBROWSER=ON \
-DCMAKE_CXX_FLAGS="-fpermissive" \
-DCMAKE_INSTALL_PREFIX=/home/hui/disk4t/codes/wpe/source/inst \
-DWPE_INCLUDE_DIR=/home/hui/disk4t/codes/wpe/source/inst/include/wpe-1.0 \
-GNinja
ninja install
增加debug选项:
-DCMAKE_CXX_FLAGS_DEBUG "-O0 -g"
或者?
--enable-debug-symbols=full --disable-optimizations
Enabled features
这个是在cmake执行完最后输出的Enabled features列表:
-- Enabled features:
-- ENABLE_ACCESSIBILITY .......................... ON
-- ENABLE_BUBBLEWRAP_SANDBOX OFF
-- ENABLE_ENCRYPTED_MEDIA ........................ OFF
-- ENABLE_GTKDOC OFF
-- ENABLE_MEDIA_SOURCE ........................... ON
-- ENABLE_VIDEO ON
-- ENABLE_WEBDRIVER .............................. ON
-- ENABLE_WEB_AUDIO ON
-- ENABLE_WEB_CRYPTO ............................. ON
-- ENABLE_WPE_QT_API OFF
-- ENABLE_XSLT ................................... ON
-- USE_OPENJPEG ON
-- USE_SOUP2 ..................................... ON
-- USE_SYSTEMD ON
-- USE_WOFF2 ..................................... ON
编译成功
-- Installing: /home/hui/disk4t/codes/wpe/source/inst/lib/libWPEWebKit-1.0.so.4.14.1
-- Installing: /home/hui/disk4t/codes/wpe/source/inst/lib/libWPEWebKit-1.0.so.4
-- Set runtime path of "/home/hui/disk4t/codes/wpe/source/inst/lib/libWPEWebKit-1.0.so.4.14.1" to ""
-- Installing: /home/hui/disk4t/codes/wpe/source/inst/lib/libWPEWebKit-1.0.so
-- Installing: /home/hui/disk4t/codes/wpe/source/inst/libexec/wpe-webkit-1.0/WPEWebProcess
-- Set runtime path of "/home/hui/disk4t/codes/wpe/source/inst/libexec/wpe-webkit-1.0/WPEWebProcess" to ""
-- Installing: /home/hui/disk4t/codes/wpe/source/inst/libexec/wpe-webkit-1.0/WPENetworkProcess
-- Set runtime path of "/home/hui/disk4t/codes/wpe/source/inst/libexec/wpe-webkit-1.0/WPENetworkProcess" to ""
-- Installing: /home/hui/disk4t/codes/wpe/source/inst/bin/WPEWebDriver
-- Installing: /home/hui/disk4t/codes/wpe/source/inst/libexec/wpe-webkit-1.0/MiniBrowser
-- Set runtime path of "/home/hui/disk4t/codes/wpe/source/inst/libexec/wpe-webkit-1.0/MiniBrowser" to ""
step7:build cog
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/hui/disk4t/codes/wpe/source/inst -GNinja
ninja install
step8:run browser
weston --socket=wpe 一个窗口启动weston
在启动的窗口中打开terminal,配置环境变量
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/hui/disk4t/codes/wpe/source/inst/lib
然后测试打开百度,成功:
cog --platform=fdo https://www.baidu.com
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-1dtsqMMq-1644371370587)(/home/hui/.config/Typora/typora-user-images/image-20220208142602582.png)]
使用x11运行cog
下载编译cog-0.10.0
为了支持X11,下载cog-0.10.0,cmake过程中发现需要wpebackend-fdo-1.18.3,下载 wpebackend-fdo-1.18.3编译,编译和1.16.0没多大区别。
cd cog-0.10.0
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/home/hui/disk4t/codes/wpe/source/inst -DCOG_PLATFORM_X11=ON -GNinja
install libinput
-- No package 'libinput' found
CMake Error at /home/hui/.local/lib/python2.7/site-packages/cmake/data/share/cmake-3.22/Modules/FindPkgConfig.cmake:603 (message):
A required package was not found
Call Stack (most recent call first):
/home/hui/.local/lib/python2.7/site-packages/cmake/data/share/cmake-3.22/Modules/FindPkgConfig.cmake:825 (_pkg_check_modules_internal)
platform/drm/CMakeLists.txt:7 (pkg_check_modules)
# 安装libinput-dev后解决
sudo apt install libinput-dev
x11支持增加编译项开关:
-DCOG_PLATFORM_X11=ON
run cog
编译完成后运行即可,对比前面fdo和x11是有区别的:
cog --platform=x11 www.baidu.com
html5 video
https://www.w3.org/2010/05/video/mediaevents.html
setup debug
export GST_DEBUG="3,webkit*:7" GST_DEBUG_NO_COLOR=1 WEBKIT_FORCE_SANDBOX=0
cog --platform=x11 https://www.w3.org/2010/05/video/mediaevents.html
build & run error
build webkit error :fpermissive
/usr/include/c++/8/functional:78:5: error: ‘std::invoke_result_t<_Callable, _Args ...> std::invoke(_Callable&&, _Args&& ...) [with _Callable = WebCore::Color::isBlackColor(const WebCore::Color&)::<lambda(const auto:11&)>; _Args = {WebCore::BoundedGammaEncoded<float, WebCore::A98RGBDescriptor<float> >}; std::invoke_result_t<_Callable, _Args ...> = bool]’, declared using local type ‘WebCore::Color::isBlackColor(const WebCore::Color&)::<lambda(const auto:11&)>’, is used but never defined [-fpermissive]
invoke(_Callable&& __fn, _Args&&... __args)
^~~~~~
cmake中增加fpermissive
-DCMAKE_CXX_FLAGS="-fpermissive"
build webkit error:braces around scalar initializer for type
/home/hui/disk4t/codes/wpe/source/wpewebkit-2.32.0/Source/WebCore/platform/graphics/gstreamer/ImageDecoderGStreamer.cpp:258:5: error: braces around scalar initializer for type ‘gboolean (*)(GstAppSink*, gpointer)’ {aka ‘int (*)(_GstAppSink*, void*)’}
};
^
检查代码发现GstAppSinkCallbacks的定义,我用gstreamer1.19.3 编译的,这个原型增加了一个函数,所以这个用到GstAppSinkCallbacks的地方需要修改一下:
typedef struct {
void (*eos) (GstAppSink *appsink, gpointer user_data);
GstFlowReturn (*new_preroll) (GstAppSink *appsink, gpointer user_data);
GstFlowReturn (*new_sample) (GstAppSink *appsink, gpointer user_data);
gboolean (*new_event) (GstAppSink *appsink, gpointer user_data);
/*< private >*/
gpointer _gst_reserved[GST_PADDING - 1];
} GstAppSinkCallbacks;
static GstAppSinkCallbacks callbacks = {
nullptr,
[](GstAppSink* sink, gpointer userData) -> GstFlowReturn {
return static_cast<AudioSourceProviderGStreamer*>(userData)->handleSample(sink, true);
},
[](GstAppSink* sink, gpointer userData) -> GstFlowReturn {
return static_cast<AudioSourceProviderGStreamer*>(userData)->handleSample(sink, false);
},
+ nullptr,
{ nullptr }
};
build webkit error:constexpr访问non-constexpr
wpewebkit-2.32.0/Source/WebCore/testing/Internals.cpp
c++ error: call to non-‘constexpr’ function ‘void WTFReportAssertionFailure
constexpr TreeType convertType(Internals::TreeType type)
{
switch (type) {
case Internals::Tree:
return Tree;
case Internals::ShadowIncludingTree:
return ShadowIncludingTree;
case Internals::ComposedTree:
return ComposedTree;
}
+ // ASSERT_NOT_REACHED();
return Tree;
}
build cog-0.5.1 error: text-input-unstable-v3
CMake Error at cmake/FindWaylandProtocols.cmake:110 (message):
Cannot find Wayland protocol 'text-input-unstable-v3'
Call Stack (most recent call first):
CMakeLists.txt:321 (add_wayland_protocol)
install wayland-protocols_1.20:
wget http://archive.ubuntu.com/ubuntu/pool/main/w/wayland-protocols/wayland-protocols_1.20-1_all.deb
sudo dpkg -i wayland-protocols_1.20-1_all.deb
cog-0.5.1不支持x11,下载cog-0.10.0支持,cog-0.13.0版本太新又有编译问题。
cog run error
$ cog www.baidu.com
wpe: could not load the impl library. Is there any backend installed?: libWPEBackend-default.so: cannot open shared object file: No such file or directory
Aborted (core dumped)
需要指定platform参数
cog --platform=x11 www.baidu.com