Skip to content

Commit

Permalink
build: generate wpe-bridge sources at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosgcampos committed Feb 21, 2019
1 parent bbbb525 commit d9ab6de
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 241 deletions.
22 changes: 20 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ find_package(EGL REQUIRED)
find_package(GLIB REQUIRED COMPONENTS gio)
find_package(Wayland REQUIRED)
find_package(WaylandEGL REQUIRED)
find_package(WaylandScanner REQUIRED)
find_package(WPE REQUIRED)

if (EGL_DEFINITIONS)
Expand All @@ -41,6 +42,7 @@ endif ()

set(WPEBACKEND_FDO_INCLUDE_DIRECTORIES
"include"
${CMAKE_BINARY_DIR}
${EGL_INCLUDE_DIRS}
${GLIB_INCLUDE_DIRS}
${WAYLAND_INCLUDE_DIRS}
Expand All @@ -64,7 +66,13 @@ set(WPEBACKEND_FDO_PUBLIC_HEADERS
include/wpe-fdo/fdo.h
)

set(WPEBACKEND_FDO_GENERATED_SOURCES
${CMAKE_BINARY_DIR}/bridge/wpe-bridge-protocol.c
)

set(WPEBACKEND_FDO_SOURCES
${WPEBACKEND_FDO_GENERATED_SOURCES}

src/fdo.cpp
src/initialize-egl.cpp
src/renderer-backend-egl.cpp
Expand All @@ -73,12 +81,22 @@ set(WPEBACKEND_FDO_SOURCES
src/view-backend-exportable-private.cpp
src/ws.cpp

src/bridge/wpe-bridge-protocol.c

src/linux-dmabuf/linux-dmabuf.c
src/linux-dmabuf/linux-dmabuf-protocol.c
)

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bridge)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-protocol.c
${CMAKE_BINARY_DIR}/bridge/wpe-bridge-client-protocol.h
${CMAKE_BINARY_DIR}/bridge/wpe-bridge-server-protocol.h
DEPENDS ${CMAKE_SOURCE_DIR}/src/bridge/wpe-bridge.xml
COMMAND ${WAYLAND_SCANNER} ${WAYLAND_SCANNER_CODE_ARG} < ${CMAKE_SOURCE_DIR}/src/bridge/wpe-bridge.xml > ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-protocol.c
COMMAND ${WAYLAND_SCANNER} client-header < ${CMAKE_SOURCE_DIR}/src/bridge/wpe-bridge.xml > ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-client-protocol.h
COMMAND ${WAYLAND_SCANNER} server-header < ${CMAKE_SOURCE_DIR}/src/bridge/wpe-bridge.xml > ${CMAKE_BINARY_DIR}/bridge/wpe-bridge-server-protocol.h
VERBATIM
)

option(EXPORTABLE_EGL "Enable the exportable EGL interface" ON)

if (EXPORTABLE_EGL)
Expand Down
42 changes: 42 additions & 0 deletions cmake/FindWaylandScanner.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# - Try to find wayland-scanner.
# Once done, this will define
#
# WAYLAND_SCANNER_FOUND - system has Wayland.
# WAYLAND_SCANNER - the path to the wayland-scanner binary
# WAYLAND_SCANNER_CODE_ARG - the code argument to pass
#
# Copyright (C) 2019 Igalia S.L.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

find_package(PkgConfig)
pkg_check_modules(WAYLAND_SCANNER wayland-scanner)

pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner)
if (WAYLAND_SCANNER_VERSION VERSION_LESS "1.15")
set(WAYLAND_SCANNER_CODE_ARG "code")
else ()
set(WAYLAND_SCANNER_CODE_ARG "private-code")
endif ()

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SCANNER DEFAULT_MSG WAYLAND_SCANNER)
107 changes: 0 additions & 107 deletions src/bridge/wpe-bridge-client-protocol.h

This file was deleted.

48 changes: 0 additions & 48 deletions src/bridge/wpe-bridge-protocol.c

This file was deleted.

84 changes: 0 additions & 84 deletions src/bridge/wpe-bridge-server-protocol.h

This file was deleted.

0 comments on commit d9ab6de

Please sign in to comment.