Skip to content

Commit

Permalink
Merge #2300
Browse files Browse the repository at this point in the history
2300: Move generated protocol code to build directory r=Saviq a=wmww

This removes generated Wayland protocol code from the project source, and instead always generates these files as part of the build process (as discussed on mattermost)

Co-authored-by: William Wold <wm@wmww.sh>
Co-authored-by: Alan Griffiths <alan@octopull.co.uk>
  • Loading branch information
3 people committed Mar 17, 2022
2 parents 118d890 + cb145e9 commit 637984b
Show file tree
Hide file tree
Showing 37 changed files with 2,838 additions and 8,732 deletions.
20 changes: 20 additions & 0 deletions cmake/MirCommon.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,23 @@ function (mir_check_no_unreleased_symbols TARGET DEPENDENT_TARGET)
)
add_dependencies(${DEPENDENT_TARGET} ${TARGET_NAME})
endfunction()

function (mir_generate_protocol_wrapper TARGET_NAME NAME_PREFIX PROTOCOL_FILE)
if (NAME_PREFIX STREQUAL "")
set(NAME_PREFIX "@") # won't match anything
endif()
get_filename_component(PROTOCOL_NAME "${PROTOCOL_FILE}" NAME_WE)
set(OUTPUT_PATH_HEADER "${CMAKE_CURRENT_BINARY_DIR}/${PROTOCOL_NAME}_wrapper.h")
set(OUTPUT_PATH_SRC "${CMAKE_CURRENT_BINARY_DIR}/${PROTOCOL_NAME}_wrapper.cpp")
set(PROTOCOL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${PROTOCOL_FILE}")
add_custom_command(
OUTPUT "${OUTPUT_PATH_HEADER}" "${OUTPUT_PATH_SRC}"
VERBATIM
COMMAND "sh" "-c"
"${CMAKE_BINARY_DIR}/bin/mir_wayland_generator ${NAME_PREFIX} ${PROTOCOL_PATH} header > ${OUTPUT_PATH_HEADER}"
COMMAND "sh" "-c"
"${CMAKE_BINARY_DIR}/bin/mir_wayland_generator ${NAME_PREFIX} ${PROTOCOL_PATH} source > ${OUTPUT_PATH_SRC}"
DEPENDS mir_wayland_generator "${PROTOCOL_PATH}"
)
target_sources("${TARGET_NAME}" PRIVATE "${OUTPUT_PATH_HEADER}" "${OUTPUT_PATH_SRC}")
endfunction()
33 changes: 2 additions & 31 deletions src/platform/graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
set(DMABUF_PROTO_HEADER ${CMAKE_CURRENT_BINARY_DIR}/linux-dmabuf-unstable-v1_wrapper.h)
set(DMABUF_PROTO_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/linux-dmabuf-unstable-v1_wrapper.cpp)

set(DRM_FORMATS_FILE ${CMAKE_CURRENT_BINARY_DIR}/drm-formats)
set(DRM_FORMATS_BIG_ENDIAN_FILE ${CMAKE_CURRENT_BINARY_DIR}/drm-formats-big-endian)

Expand Down Expand Up @@ -28,8 +25,6 @@ add_library(mirplatformgraphicscommon OBJECT
cpu_buffers.cpp
egl_logger.cpp
${PROJECT_SOURCE_DIR}/include/platform/mir/graphics/egl_logger.h
${DMABUF_PROTO_HEADER}
${DMABUF_PROTO_SOURCE}
${PROJECT_SOURCE_DIR}/include/platform/mir/graphics/linux_dmabuf.h
linux_dmabuf.cpp
${DRM_FORMATS_FILE}
Expand All @@ -38,6 +33,8 @@ add_library(mirplatformgraphicscommon OBJECT
${PROJECT_SOURCE_DIR}/include/platform/mir/graphics/drm_formats.h
)

mir_generate_protocol_wrapper(mirplatformgraphicscommon "zwp_" protocol/linux-dmabuf-unstable-v1.xml)

if (DRM_VERSION VERSION_GREATER 2.4.107)
target_compile_definitions(
mirplatformgraphicscommon
Expand All @@ -49,32 +46,6 @@ if (DRM_VERSION VERSION_GREATER 2.4.107)
${DRM_LDFLAGS} ${DRM_LIBRARIES})
endif()

set(LINUX_DMABUF_PROTO "${CMAKE_CURRENT_SOURCE_DIR}/protocol/linux-dmabuf-unstable-v1.xml")
set(WAYLAND_GENERATOR "${CMAKE_BINARY_DIR}/bin/mir_wayland_generator")

add_custom_command(
OUTPUT
linux-dmabuf-unstable-v1_wrapper.h
VERBATIM
COMMAND
"sh" "-c"
"${WAYLAND_GENERATOR} zwp_ ${LINUX_DMABUF_PROTO} header > ${DMABUF_PROTO_HEADER}"
DEPENDS
${LINUX_DMABUF_PROTO}
mir_wayland_generator
)
add_custom_command(
OUTPUT
linux-dmabuf-unstable-v1_wrapper.cpp
VERBATIM
COMMAND
"sh" "-c"
"${WAYLAND_GENERATOR} zwp_ ${LINUX_DMABUF_PROTO} source > ${DMABUF_PROTO_SOURCE}"
DEPENDS
${LINUX_DMABUF_PROTO}
mir_wayland_generator
)

add_custom_command(
OUTPUT
drm-formats
Expand Down
17 changes: 14 additions & 3 deletions src/wayland/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,28 @@ set(symbol_map ${CMAKE_CURRENT_SOURCE_DIR}/symbols.map)
add_compile_definitions(MIR_LOG_COMPONENT_FALLBACK="mirwayland")

add_subdirectory(generator/)
add_subdirectory(generated/)

set(STANDARD_SOURCES
wayland_base.cpp
)

add_library(mirwayland SHARED
${GENERATED_FILES}
${STANDARD_SOURCES}
)

mir_generate_protocol_wrapper(mirwayland "wl_" protocol/wayland.xml)
mir_generate_protocol_wrapper(mirwayland "z" protocol/xdg-shell-unstable-v6.xml)
mir_generate_protocol_wrapper(mirwayland "" protocol/xdg-shell.xml)
mir_generate_protocol_wrapper(mirwayland "z" protocol/xdg-output-unstable-v1.xml)
mir_generate_protocol_wrapper(mirwayland "zwlr_" protocol/wlr-layer-shell-unstable-v1.xml)
mir_generate_protocol_wrapper(mirwayland "zwlr_" protocol/wlr-foreign-toplevel-management-unstable-v1.xml)
mir_generate_protocol_wrapper(mirwayland "zwp_" protocol/pointer-constraints-unstable-v1.xml)
mir_generate_protocol_wrapper(mirwayland "zwp_" protocol/relative-pointer-unstable-v1.xml)
mir_generate_protocol_wrapper(mirwayland "zwp_" protocol/virtual-keyboard-unstable-v1.xml)
mir_generate_protocol_wrapper(mirwayland "zwp_" protocol/text-input-unstable-v3.xml)
mir_generate_protocol_wrapper(mirwayland "zwp_" protocol/text-input-unstable-v2.xml)
mir_generate_protocol_wrapper(mirwayland "zwp_" protocol/input-method-unstable-v2.xml)

target_link_libraries(mirwayland
PUBLIC
mircore
Expand All @@ -25,7 +36,7 @@ target_link_libraries(mirwayland
target_include_directories(mirwayland
PUBLIC
${PROJECT_SOURCE_DIR}/include/wayland
${CMAKE_CURRENT_SOURCE_DIR}/generated
${CMAKE_CURRENT_BINARY_DIR}
)

set_target_properties(mirwayland
Expand Down
56 changes: 0 additions & 56 deletions src/wayland/generated/CMakeLists.txt

This file was deleted.

0 comments on commit 637984b

Please sign in to comment.