参考链接:Building Weston
https://gitee.com/slamdunk1016/weston_demo.git
1、首先设置环境变量
写个简单的set-env.sh脚本方便运行:
#!/bin/bash
export WLD=/home/your_user_name/work/weston/install # change this to another location if you prefer
export LD_LIBRARY_PATH=$WLD/lib/x86_64-linux-gnu
export PKG_CONFIG_PATH=$WLD/lib/x86_64-linux-gnu/pkgconfig/:$WLD/share/pkgconfig/
export ACLOCAL_PATH=$WLD/share/aclocal
export PATH=$WLD/bin:$PATH
2、安装软件包
ubuntu20.04下直接sudo apt-get install即可
sudo apt install libxml2 libxml2-dev xdot xmlto libjpeg-dev libwebp-dev libsystemd-dev liblcms2-dev libegl-mesa0 libgbm-dev freerdp2-dev
libx11-xcb-dev libxcb-composite0 libcolord-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libpipewire-0.3-dev
sudo apt install python3-pip
pip3 install --user meson
3、编译源码
目录结构主要包括以下几个部分:
install是新建目录,对应第一步中环境变量$WLD,其它都是源码目录
1)Wayland libraries
git clone https://gitlab.freedesktop.org/wayland/wayland.git
cd wayland
meson build/ --prefix=$WLD
ninja -C build/ install
cd ..
2)wayland protocols
git clone https://gitlab.freedesktop.org/wayland/wayland-protocols.git
cd wayland-protocols
meson build/ --prefix=$WLD
ninja -C build/ install
3)libinput
sudo apt install libmtdev-dev libudev-dev libevdev-dev libwacom-dev check libgtk-3-dev libunwind8-dev libcairo2-dev
git clone git://anongit.freedesktop.org/wayland/libinput
cd libinput
meson build/ --prefix=$WLD
ninja -C build/ install
cd ..
4)weston demo
git clone https://gitlab.freedesktop.org/wayland/weston.git
cd weston
meson build/ --prefix=$WLD -Dpipewire=false
ninja -C build/ install
cd ..
使用meson 重新配置时可以加上reconfig参数,如果没起效果最好把build目录删掉重新配置。
#$meson --reconfig build/ --prefix=$WLD -Drenderer-gl=false -Dbackend-rdp=false -Dxwayland=false -Dcolor-management-colord=false -Dremoting=false -Dpipewire=false -Dsimple-dmabuf-drm=auto
4、运行weston
编译好的weston在install/bin/目录下:
1)首先设置一下weston.ini配置文件
将编译出来的weston.ini文件copy到/home/.config/weston.ini
weston_demo$ find -name weston.ini
./weston/build/ivi-shell/weston.ini
./weston/build/compositor/weston.ini
cp ./weston/build/ivi-shell/weston.ini ~/.config/
[core]
shell=ivi-shell.so
modules=hmi-controller.so
[ivi-shell]
ivi-shell-user-interface=weston-ivi-shell-user-interface
#developermode=true
cursor-theme=default
cursor-size=32
base-layer-id=1000
base-layer-id-offset=10000
workspace-background-layer-id=2000
workspace-layer-id=3000
application-layer-id=4000
transition-duration=300
background-image=/home/yc/work/weston/install/share/weston/background.png
background-id=1001
panel-image=/home/yc/work/weston/install/share/weston/panel.png
panel-id=1002
surface-id-offset=10
tiling-image=/home/yc/work/weston/install/share/weston/tiling.png
tiling-id=1003
sidebyside-image=/home/yc/work/weston/install/share/weston/sidebyside.png
sidebyside-id=1004
fullscreen-image=/home/yc/work/weston/install/share/weston/fullscreen.png
fullscreen-id=1005
random-image=/home/yc/work/weston/install/share/weston/random.png
random-id=1006
home-image=/home/yc/work/weston/install/share/weston/home.png
home-id=1007
workspace-background-color=0x99000000
workspace-background-id=2001
[ivi-launcher]
workspace-id=0
icon-id=4001
icon=/home/yc/work/weston/install/share/weston/icon_ivi_flower.png
path=/home/yc/work/weston/install/bin/weston-flower
[ivi-launcher]
workspace-id=0
icon-id=4002
icon=/home/yc/work/weston/install/share/weston/icon_ivi_clickdot.png
path=/home/yc/work/weston/install/bin/weston-clickdot
[ivi-launcher]
workspace-id=1
icon-id=4003
icon=/home/yc/work/weston/install/share/weston/icon_ivi_simple-egl.png
path=/home/yc/work/weston/install/bin/weston-simple-egl
[ivi-launcher]
workspace-id=1
icon-id=4004
icon=/home/yc/work/weston/install/share/weston/icon_ivi_simple-shm.png
path=/home/yc/work/weston/install/bin/weston-simple-shm
[ivi-launcher]
workspace-id=2
icon-id=4005
icon=/home/yc/work/weston/install/share/weston/icon_ivi_smoke.png
path=/home/yc/work/weston/install/bin/weston-smoke
[ivi-launcher]
workspace-id=3
icon-id=4006
icon=/home/yc/work/weston/install/share/weston/icon_ivi_flower.png
path=/home/yc/work/weston/install/bin/weston-flower
[ivi-launcher]
workspace-id=3
icon-id=4007
icon=/home/yc/work/weston/install/share/weston/icon_ivi_clickdot.png
path=/home/yc/work/weston/install/bin/weston-clickdot
[ivi-launcher]
workspace-id=3
icon-id=4008
icon=/home/yc/work/weston/install/share/weston/icon_ivi_simple-egl.png
path=/home/yc/work/weston/install/bin/weston-simple-egl
[ivi-launcher]
workspace-id=3
icon-id=4009
icon=/home/yc/work/weston/install/share/weston/icon_ivi_simple-shm.png
path=/home/yc/work/weston/install/bin/weston-simple-shm
[ivi-launcher]
workspace-id=3
icon-id=4010
icon=/home/yc/work/weston/install/share/weston/icon_ivi_smoke.png
path=/home/yc/work/weston/install/bin/weston-smoke
2)在命令行直接运行weston命令
我这里默认使用X11作为backend:
weston$ weston
Date: 2022-02-28 CST
[19:22:20.882] weston 10.0.90
https://wayland.freedesktop.org
Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
Build: 10.0.0-45-g08dbd29e
[19:22:20.882] Command line: weston
[19:22:20.882] OS: Linux, 5.13.0-30-generic, #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022, x86_64
[19:22:20.882] Flight recorder: enabled
[19:22:20.882] Using config file '/home/yc/.config/weston.ini'
[19:22:20.883] Output repaint window is 7 ms maximum.
[19:22:20.883] Loading module '/home/yc/work/weston/install/lib/x86_64-linux-gnu/libweston-11/x11-backend.so'
[19:22:20.884] Loading module '/home/yc/work/weston/install/lib/x86_64-linux-gnu/libweston-11/gl-renderer.so'
[19:22:20.887] EGL client extensions: EGL_EXT_platform_base EGL_EXT_device_base
EGL_EXT_device_enumeration EGL_EXT_device_query
EGL_KHR_client_get_all_proc_addresses EGL_EXT_client_extensions
EGL_KHR_debug EGL_KHR_platform_x11 EGL_EXT_platform_x11
EGL_EXT_platform_device EGL_EXT_platform_wayland
EGL_KHR_platform_wayland EGL_MESA_platform_xcb
EGL_MESA_platform_gbm EGL_KHR_platform_gbm
EGL_MESA_platform_surfaceless
[19:22:20.889] EGL device extensions: EGL_NV_device_cuda EGL_EXT_device_drm
EGL_EXT_device_query_name
[19:22:20.889] EGL version: 1.5
[19:22:20.889] EGL vendor: NVIDIA
[19:22:20.889] EGL client APIs: OpenGL_ES OpenGL
[19:22:20.889] EGL extensions: EGL_EXT_buffer_age EGL_EXT_client_sync
EGL_EXT_create_context_robustness EGL_EXT_image_dma_buf_import
EGL_EXT_image_dma_buf_import_modifiers
EGL_MESA_image_dma_buf_export EGL_EXT_output_base
EGL_EXT_stream_acquire_mode EGL_EXT_sync_reuse
EGL_IMG_context_priority EGL_KHR_config_attribs
EGL_KHR_create_context_no_error EGL_KHR_context_flush_control
EGL_KHR_create_context EGL_KHR_fence_sync
EGL_KHR_get_all_proc_addresses EGL_KHR_partial_update
EGL_KHR_swap_buffers_with_damage EGL_KHR_no_config_context
EGL_KHR_gl_colorspace EGL_KHR_gl_renderbuffer_image
EGL_KHR_gl_texture_2D_image EGL_KHR_gl_texture_3D_image
EGL_KHR_gl_texture_cubemap_image EGL_KHR_image
EGL_KHR_image_base EGL_KHR_image_pixmap EGL_KHR_reusable_sync
EGL_KHR_stream EGL_KHR_stream_attrib
EGL_KHR_stream_consumer_gltexture
EGL_KHR_stream_cross_process_fd EGL_KHR_stream_fifo
EGL_KHR_stream_producer_eglsurface EGL_KHR_surfaceless_context
EGL_KHR_wait_sync EGL_NV_nvrm_fence_sync EGL_NV_post_sub_buffer
EGL_NV_quadruple_buffer EGL_NV_stream_consumer_eglimage
EGL_NV_stream_cross_display EGL_NV_stream_cross_object
EGL_NV_stream_cross_process EGL_NV_stream_cross_system
EGL_NV_stream_dma EGL_NV_stream_flush EGL_NV_stream_metadata
EGL_NV_stream_remote EGL_NV_stream_reset EGL_NV_stream_socket
EGL_NV_stream_socket_inet EGL_NV_stream_socket_unix
EGL_NV_stream_sync EGL_NV_stream_fifo_next
EGL_NV_stream_fifo_synchronous
EGL_NV_stream_consumer_gltexture_yuv EGL_NV_stream_attrib
EGL_NV_stream_origin EGL_NV_system_time
EGL_NV_output_drm_flip_event EGL_NV_triple_buffer
EGL_NV_robustness_video_memory_purge
[19:22:20.889] warning: Disabling render GPU timeline and explicit synchronization due to missing EGL_ANDROID_native_fence_sync extension
[19:22:20.890] EGL_KHR_surfaceless_context available
[19:22:20.918] GL version: OpenGL ES 3.2 NVIDIA 470.103.01
[19:22:20.918] GLSL version: OpenGL ES GLSL ES 3.20
[19:22:20.918] GL vendor: NVIDIA Corporation
[19:22:20.918] GL renderer: NVIDIA GeForce GT 730/PCIe/SSE2
[19:22:20.918] GL extensions: GL_EXT_base_instance GL_EXT_blend_func_extended
GL_EXT_blend_minmax GL_EXT_buffer_storage GL_EXT_clear_texture
GL_EXT_clip_control GL_EXT_clip_cull_distance
GL_EXT_color_buffer_float GL_EXT_color_buffer_half_float
GL_EXT_conservative_depth GL_EXT_copy_image GL_EXT_depth_clamp
GL_EXT_debug_label GL_EXT_discard_framebuffer
GL_EXT_disjoint_timer_query GL_EXT_draw_buffers_indexed
GL_EXT_draw_elements_base_vertex GL_EXT_EGL_image_array
GL_EXT_EGL_image_storage GL_EXT_EGL_image_external_wrap_modes
GL_EXT_float_blend GL_EXT_frag_depth GL_EXT_geometry_point_size
GL_EXT_geometry_shader GL_EXT_gpu_shader5
GL_EXT_map_buffer_range GL_EXT_multi_draw_indirect
GL_EXT_multisample_compatibility
GL_EXT_multiview_texture_multisample
GL_EXT_multiview_timer_query GL_EXT_occlusion_query_boolean
GL_EXT_polygon_offset_clamp GL_EXT_primitive_bounding_box
GL_EXT_render_snorm GL_EXT_robustness
GL_EXT_separate_shader_objects GL_EXT_shader_group_vote
GL_EXT_shader_implicit_conversions GL_EXT_shader_integer_mix
GL_EXT_shader_io_blocks
GL_EXT_shader_non_constant_global_initializers
GL_EXT_shader_texture_lod GL_EXT_shadow_samplers
GL_EXT_sparse_texture GL_EXT_sRGB GL_EXT_sRGB_write_control
GL_EXT_tessellation_point_size GL_EXT_tessellation_shader
GL_EXT_texture_border_clamp GL_EXT_texture_buffer
GL_EXT_texture_compression_bptc GL_EXT_texture_compression_dxt1
GL_EXT_texture_compression_rgtc GL_EXT_texture_compression_s3tc
GL_EXT_texture_cube_map_array GL_EXT_texture_filter_anisotropic
GL_EXT_texture_format_BGRA8888
GL_EXT_texture_mirror_clamp_to_edge GL_EXT_texture_norm16
GL_EXT_texture_query_lod GL_EXT_texture_rg
GL_EXT_texture_shadow_lod GL_EXT_texture_sRGB_R8
GL_EXT_texture_sRGB_decode GL_EXT_texture_storage
GL_EXT_texture_view GL_EXT_draw_transform_feedback
GL_EXT_unpack_subimage GL_EXT_window_rectangles
GL_KHR_context_flush_control GL_KHR_debug GL_EXT_memory_object
GL_EXT_memory_object_fd GL_KHR_parallel_shader_compile
GL_KHR_no_error GL_KHR_robust_buffer_access_behavior
GL_KHR_robustness GL_EXT_semaphore GL_EXT_semaphore_fd
GL_NV_timeline_semaphore GL_KHR_shader_subgroup
GL_KHR_texture_compression_astc_ldr
GL_KHR_texture_compression_astc_sliced_3d
GL_KHR_texture_compression_astc_hdr GL_NV_bgr
GL_NV_bindless_texture GL_NV_blend_equation_advanced
GL_NV_conditional_render GL_NV_copy_buffer GL_NV_copy_image
GL_NV_draw_buffers GL_NV_draw_instanced GL_NV_draw_texture
GL_NV_draw_vulkan_image GL_NV_EGL_stream_consumer_external
GL_NV_explicit_attrib_location GL_NV_fbo_color_attachments
GL_NV_framebuffer_blit GL_NV_framebuffer_multisample
GL_NV_generate_mipmap_sRGB GL_NV_instanced_arrays
GL_NV_internalformat_sample_query GL_NV_gpu_shader5
GL_NV_image_formats GL_NV_occlusion_query_samples
GL_NV_non_square_matrices GL_NV_pack_subimage
GL_NV_packed_float GL_NV_packed_float_linear
GL_NV_path_rendering GL_NV_pixel_buffer_object
GL_NV_polygon_mode GL_NV_read_buffer GL_NV_read_depth
GL_NV_read_depth_stencil GL_NV_read_stencil
GL_NV_shader_noperspective_interpolation
GL_NV_shader_subgroup_partitioned GL_NV_shadow_samplers_array
GL_NV_shadow_samplers_cube GL_NV_sRGB_formats
GL_NV_texture_array GL_NV_texture_barrier
GL_NV_texture_border_clamp GL_NV_texture_compression_latc
GL_NV_texture_compression_s3tc
GL_NV_texture_compression_s3tc_update GL_NV_timer_query
GL_NV_viewport_array GL_KHR_blend_equation_advanced
GL_OES_compressed_ETC1_RGB8_texture
GL_EXT_compressed_ETC1_RGB8_sub_texture GL_OES_depth24
GL_OES_depth32 GL_OES_depth_texture
GL_OES_depth_texture_cube_map GL_OES_copy_image
GL_OES_draw_buffers_indexed GL_OES_draw_elements_base_vertex
GL_OES_texture_border_clamp GL_OES_tessellation_point_size
GL_OES_tessellation_shader GL_OES_texture_buffer
GL_OES_geometry_point_size GL_OES_geometry_shader
GL_OES_gpu_shader5 GL_OES_shader_io_blocks GL_OES_texture_view
GL_OES_primitive_bounding_box GL_OES_EGL_image
GL_OES_EGL_image_external GL_OES_EGL_image_external_essl3
GL_OES_EGL_sync GL_OES_element_index_uint
GL_OES_fbo_render_mipmap GL_OES_get_program_binary
GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8
GL_OES_sample_shading GL_OES_sample_variables
GL_OES_shader_image_atomic
GL_OES_shader_multisample_interpolation
GL_OES_standard_derivatives GL_OES_surfaceless_context
GL_OES_texture_cube_map_array GL_OES_texture_npot
GL_OES_texture_float GL_OES_texture_float_linear
GL_OES_texture_half_float GL_OES_texture_half_float_linear
GL_OES_texture_stencil8
GL_OES_texture_storage_multisample_2d_array
GL_OES_vertex_array_object GL_OES_vertex_half_float
GL_OES_viewport_array GL_OVR_multiview GL_OVR_multiview2
GL_ANDROID_extension_pack_es31a
[19:22:20.919] GL ES 3.2 - renderer features:
read-back format: RGBA
EGL Wayland extension: no
[19:22:20.919] Using gl renderer
[19:22:20.921] XCB-XKB not available during build
[19:22:20.921] Registered plugin API 'weston_windowed_output_api_v1' of size 16
[19:22:20.921] Color manager: no-op
[19:22:20.921] Output 'screen0' using color profile: built-in default sRGB SDR profile
[19:22:20.921] Chosen EGL config details: id: 64 rgba: 8 8 8 0 buf: 24 dep: 0 stcl: 0 int: 0-8 type: win|pix|pbf vis_id: 0x2b
[19:22:20.922] x11 output 1024x600, window id 136314886
[19:22:20.922] Output 'screen0' enabled with head(s) screen0
[19:22:20.922] Compositor capabilities:
arbitrary surface rotation: yes
screen capture uses y-flip: yes
cursor planes: no
arbitrary resolutions: no
view mask clipping: yes
explicit sync: no
color operations: yes
presentation clock: CLOCK_MONOTONIC_RAW, id 4
presentation clock resolution: 0.000000001 s
[19:22:20.922] Loading module '/home/yc/work/weston/install/lib/x86_64-linux-gnu/weston/ivi-shell.so'
[19:22:20.923] Note: support for the deprecated wl_shell interface is disabled. If a legacy client still needs it, it can be re-enabled by passing -Ddeprecated-wl-shell=true to Meson when building Weston.
[19:22:20.923] Registered plugin API 'ivi_layout_api_v1' of size 376
[19:22:20.923] Loading module '/home/yc/work/weston/install/lib/x86_64-linux-gnu/weston/hmi-controller.so'
[19:22:20.923] launching '/home/yc/work/weston/install/libexec/weston-ivi-shell-user-interface'
如果要用DRM作为backend,需要先切换到虚拟终端Ctrl+Alt+F4 /F3,再运行weston -B=drm-backend.so,测试结束后切回ubuntu 图形界面:Ctrl+Alt+F2
weston -B=drm-backend.so
如果不切换终端 会出现以下错误:
logind: cannot take control over session 2,ubuntu默认图形界面是session2,编译的weston程序应该是没有权限,需要换个会话。
$ weston -B=drm-backend.so
Date: 2022-03-01 CST
[09:48:24.541] weston 10.0.90
https://wayland.freedesktop.org
Bug reports to: https://gitlab.freedesktop.org/wayland/weston/issues/
Build: 10.0.0-45-g08dbd29e
[09:48:24.541] Command line: weston -B=drm-backend.so
[09:48:24.541] OS: Linux, 5.13.0-30-generic, #33~20.04.1-Ubuntu SMP Mon Feb 7 14:25:10 UTC 2022, x86_64
[09:48:24.541] Flight recorder: enabled
[09:48:24.541] Using config file '/home/yc/.config/weston.ini'
[09:48:24.541] Output repaint window is 7 ms maximum.
[09:48:24.541] Loading module '/home/yc/work/weston/install/lib/x86_64-linux-gnu/libweston-11/drm-backend.so'
[09:48:24.542] initializing drm backend
[09:48:24.542] Trying logind launcher...
[09:48:24.544] logind: cannot take control over session 2
[09:48:24.544] logind: cannot setup systemd-logind helper error: (Input/output error), using legacy fallback
[09:48:24.544] Trying weston_launch launcher...
[09:48:24.544] could not get launcher fd from env
[09:48:24.544] Trying direct launcher...
[09:48:24.544] fatal: drm backend should be run using weston-launch binary, or your system should provide the logind D-Bus API.
[09:48:24.544] fatal: failed to create compositor backend
Internal warning: debug scope 'drm-backend' has not been destroyed.
Tips:
ubuntu下查看会话
loginctl list-sessions
SESSION UID USER SEAT TTY
197 1000 yc seat0 tty3
2 1000 yc seat0 tty2
c1 125 gdm seat0 tty1
3 sessions listed.
关闭会话:loginctl kill-session 197
Reference
https://en.wikipedia.org/wiki/Wayland_(display_server_protocol)