1
0
Fork 0
mirror of https://github.com/albfan/miraclecast.git synced 2025-03-09 23:38:56 +00:00

modify for merging to upstream

fix issues TingPing suggests
replace add_global_arguments() with add_project_arguments()
demo/miracle-wfdctl: maintain DBus interfaces by .vala files instead of generate from .xml which have only sync methods
remove headers from source list
some minor identation tweaks
complete migrate from cmake to meson
mirage to meson, not yet completed
This commit is contained in:
Derek Dai 2017-04-03 12:12:50 +08:00
parent 1bc0648f4b
commit 4836850bf9
21 changed files with 188 additions and 390 deletions

View file

@ -1,33 +0,0 @@
cmake_minimum_required(VERSION 2.8)
project(Miraclecast)
SET(PACKAGE_NAME miraclecast)
SET(PACKAGE_VERSION 1)
SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake
${CMAKE_MODULE_PATH})
set(CMAKE_C_FLAGS "-std=gnu11 ${CMAKE_C_FLAGS}")
add_definitions(-D_GNU_SOURCE)
SET(BUILD_BINDIR "${CMAKE_INSTALL_PREFIX}/bin")
OPTION(BUILD_ENABLE_DEBUG "Enable Debug" ON )
OPTION(RELY_UDEV "Rely in udev tag to select device" OFF )
OPTION(BUILD_TESTS "Enable TEST" ON )
if(BUILD_ENABLE_DEBUG)
add_definitions(-DBUILD_ENABLE_DEBUG)
endif()
find_package(PkgConfig)
pkg_check_modules (GLIB2 REQUIRED glib-2.0)
pkg_check_modules (UDEV REQUIRED libudev)
pkg_check_modules (SYSTEMD REQUIRED libsystemd)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/config.h.cmake ${CMAKE_BINARY_DIR}/config.h)
add_subdirectory(src)
add_subdirectory(res)
add_subdirectory(test)

View file

@ -1,29 +0,0 @@
# from http://websvn.kde.org/trunk/KDE/kdeedu/cmake/modules/FindReadline.cmake
# http://websvn.kde.org/trunk/KDE/kdeedu/cmake/modules/COPYING-CMAKE-SCRIPTS
# --> BSD licensed
#
# GNU Readline library finder
if(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY)
set(READLINE_FOUND TRUE)
else(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY)
FIND_PATH(READLINE_INCLUDE_DIR readline/readline.h
/usr/include/readline
)
# 2008-04-22 The next clause used to read like this:
#
# FIND_LIBRARY(READLINE_LIBRARY NAMES readline)
# FIND_LIBRARY(NCURSES_LIBRARY NAMES ncurses )
# include(FindPackageHandleStandardArgs)
# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG NCURSES_LIBRARY READLINE_INCLUDE_DIR READLINE_LIBRARY )
#
# I was advised to modify it such that it will find an ncurses library if
# required, but not if one was explicitly given, that is, it allows the
# default to be overridden. PH
FIND_LIBRARY(READLINE_LIBRARY NAMES readline)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Readline DEFAULT_MSG READLINE_INCLUDE_DIR READLINE_LIBRARY )
MARK_AS_ADVANCED(READLINE_INCLUDE_DIR READLINE_LIBRARY)
endif(READLINE_INCLUDE_DIR AND READLINE_LIBRARY AND NCURSES_LIBRARY)

View file

@ -1,8 +0,0 @@
#ifndef CONFIG_H
#define CONFIG_H
#cmakedefine BUILD_BINDIR "@BUILD_BINDIR@"
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
#endif // CONFIG_H

38
meson.build Normal file
View file

@ -0,0 +1,38 @@
project('Miraclecast',
'c',
version: '1',
meson_version: '>=0.39',
default_options: ['buildtype=debugoptimized', 'c_std=gnu11']
)
add_project_arguments('-D_GNU_SOURCE', language: 'c')
conf_data = configuration_data()
conf_data.set('BUILD_BINDIR',
'"' + join_paths(get_option('prefix'), get_option('bindir')) + '"'
)
conf_data.set('PACKAGE_STRING',
'"@0@ @1@"'.format(meson.project_name(), meson.project_version())
)
configure_file(output: 'config.h',
configuration: conf_data
)
c_compiler = meson.get_compiler('c')
readline = c_compiler.find_library('readline', required: false)
if readline.found()
add_project_arguments('-DHAVE_READLINE', language: 'c')
endif
if get_option('build-enable-debug')
add_project_arguments('-DBUILD_ENABLE_DEBUG', language: 'c')
endif
glib2 = dependency('glib-2.0')
udev = dependency('libudev')
libsystemd = dependency('libsystemd')
subdir('src')
subdir('res')
subdir('test')

16
meson_options.txt Normal file
View file

@ -0,0 +1,16 @@
option('build-enable-debug',
type: 'boolean',
value: true,
description: 'Enable Debug')
option('rely-udev',
type: 'boolean',
value: false,
description: 'Rely in udev tag to select device')
option('build-tests',
type: 'boolean',
value: true,
description: 'Enable TEST')
option('build-demo',
type: 'boolean',
value: false,
description: 'Enable DEMO')

View file

@ -1,12 +0,0 @@
########### install files ###############
install(
PROGRAMS miracle-gst gstplayer uibc-viewer
DESTINATION bin
)
INSTALL(
FILES org.freedesktop.miracle.conf
DESTINATION /etc/dbus-1/system.d
)

8
res/meson-install-scripts.sh Executable file
View file

@ -0,0 +1,8 @@
#!/bin/sh
RESDIR="${MESON_SOURCE_ROOT}/res"
BINDIR="${MESON_INSTALL_DESTDIR_PREFIX}/$1"
install -dv "$BINDIR"
install -v "$RESDIR"/miracle-gst "$BINDIR"
install -v "$RESDIR"/gstplayer "$BINDIR"
install -v "$RESDIR"/uibc-viewer "$BINDIR"

6
res/meson.build Normal file
View file

@ -0,0 +1,6 @@
meson.add_install_script('meson-install-scripts.sh', get_option('bindir'))
install_data(
'org.freedesktop.miracle.conf',
install_dir: join_paths('/', get_option('sysconfdir'), 'dbus-1', 'system.d')
)

View file

@ -1,38 +0,0 @@
set(CMAKE_C_FLAGS "-std=gnu11 ${CMAKE_C_FLAGS}")
add_subdirectory(shared)
add_subdirectory(wifi)
add_subdirectory(dhcp)
add_subdirectory(ctl)
add_subdirectory(uibc)
set(miracled_SRCS miracled.h miracled.c)
add_executable(miracled ${miracled_SRCS})
target_link_libraries(miracled miracle-shared)
install(TARGETS miracled DESTINATION bin)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared)
########### install files ###############
#original Makefile.am contents follow:
#include $(top_srcdir)/common.am
#SUBDIRS = shared wifi dhcp ctl
#
#bin_PROGRAMS = miracled
#
#miracled_SOURCES = \
# miracled.h \
# miracled.c
#miracled_CPPFLAGS = \
# $(AM_CPPFLAGS) \
# $(DEPS_CFLAGS)
#miracled_LDADD = \
# shared/libmiracle-shared.la \
# $(DEPS_LIBS)
#

View file

@ -1,86 +0,0 @@
find_package(Readline)
########### next target ###############
set(miracle-wifictl_SRCS ctl.h
ctl-cli.c
ctl-wifi.c
wifictl.c)
add_executable(miracle-wifictl ${miracle-wifictl_SRCS})
install(TARGETS miracle-wifictl DESTINATION bin)
if(READLINE_FOUND)
message(STATUS "Compiling with Readline support")
set_property(TARGET miracle-wifictl
APPEND
PROPERTY COMPILE_DEFINITIONS HAVE_READLINE)
target_link_libraries(miracle-wifictl ${READLINE_LIBRARY})
endif(READLINE_FOUND)
target_link_libraries(miracle-wifictl miracle-shared)
########### next target ###############
set(miracle-sinkctl_SRCS ctl.h
ctl-cli.c
ctl-sink.h
ctl-sink.c
ctl-wifi.c
sinkctl.c
wfd.c)
add_executable(miracle-sinkctl ${miracle-sinkctl_SRCS})
install(TARGETS miracle-sinkctl DESTINATION bin)
if(READLINE_FOUND)
message(STATUS "Compiling with Readline support")
set_property(TARGET miracle-sinkctl
APPEND
PROPERTY COMPILE_DEFINITIONS HAVE_READLINE)
target_link_libraries(miracle-sinkctl ${READLINE_LIBRARY})
endif(READLINE_FOUND)
target_link_libraries(miracle-sinkctl miracle-shared)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared)
########### install files ###############
#original Makefile.am contents follow:
#include $(top_srcdir)/common.am
#bin_PROGRAMS = miracle-wifictl miracle-sinkctl
#
#miracle_wifictl_SOURCES = \
# ctl.h \
# ctl-cli.c \
# ctl-wifi.c \
# wifictl.c
#miracle_wifictl_CPPFLAGS = \
# $(AM_CPPFLAGS) \
# $(DEPS_CFLAGS)
#miracle_wifictl_LDADD = \
# ../shared/libmiracle-shared.la \
# -lreadline \
# $(DEPS_LIBS)
#
#miracle_sinkctl_SOURCES = \
# ctl.h \
# ctl-cli.c \
# ctl-sink.c \
# ctl-wifi.c \
# sinkctl.c
#miracle_sinkctl_CPPFLAGS = \
# $(AM_CPPFLAGS) \
# $(DEPS_CFLAGS)
#miracle_sinkctl_LDADD = \
# ../shared/libmiracle-shared.la \
# -lreadline \
# $(DEPS_LIBS)
#
#

24
src/ctl/meson.build Normal file
View file

@ -0,0 +1,24 @@
inc = include_directories('../..')
deps = [libsystemd, libmiracle_shared_dep]
if readline.found()
deps += readline
endif
miracle_wifictl_srcs = ['ctl-cli.c', 'ctl-wifi.c', 'wifictl.c']
executable('miracle-wifictl', miracle_wifictl_srcs,
install: true,
include_directories: inc,
dependencies: deps
)
miracle_sinkctl_srcs = ['ctl-cli.c',
'ctl-sink.c',
'ctl-wifi.c',
'sinkctl.c',
'wfd.c'
]
executable('miracle-sinkctl', miracle_sinkctl_srcs,
install: true,
include_directories: inc,
dependencies: deps
)

View file

@ -1,62 +0,0 @@
########### next target ###############
set(miracle-dhcp_SRCS dhcp.c
gdhcp.h
unaligned.h
common.h
common.c
ipv4ll.h
ipv4ll.c
client.c
server.c)
add_executable(miracle-dhcp ${miracle-dhcp_SRCS})
find_package(PkgConfig)
pkg_check_modules (GLIB2 REQUIRED glib-2.0)
pkg_check_modules (UDEV REQUIRED libudev)
link_directories( ${UDEV_LIBRARY_DIRS})
include_directories( ${UDEV_INCLUDE_DIRS})
target_link_libraries(miracle-dhcp ${UDEV_LIBRARIES})
link_directories( ${GLIB2_LIBRARY_DIRS})
include_directories( ${GLIB2_INCLUDE_DIRS})
target_link_libraries(miracle-dhcp ${GLIB2_LIBRARIES})
target_link_libraries(miracle-dhcp miracle-shared)
install(TARGETS miracle-dhcp DESTINATION bin)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared)
########### install files ###############
#original Makefile.am contents follow:
#include $(top_srcdir)/common.am
#bin_PROGRAMS = miracle-dhcp
#
#miracle_dhcp_SOURCES = \
# dhcp.c \
# gdhcp.h \
# unaligned.h \
# common.h \
# common.c \
# ipv4ll.h \
# ipv4ll.c \
# client.c \
# server.c
#miracle_dhcp_CPPFLAGS = \
# $(AM_CPPFLAGS) \
# $(DEPS_CFLAGS) \
# $(GDHCP_CFLAGS)
#miracle_dhcp_LDADD = \
# ../shared/libmiracle-shared.la \
# $(DEPS_LIBS) \
# $(GDHCP_LIBS)
#
#
#

11
src/dhcp/meson.build Normal file
View file

@ -0,0 +1,11 @@
miracle_dhcp_srcs = ['dhcp.c',
'common.c',
'ipv4ll.c',
'client.c',
'server.c'
]
executable('miracle-dhcp', miracle_dhcp_srcs,
install: true,
include_directories: include_directories('../..'),
dependencies: [glib2, udev, libmiracle_shared_dep]
)

11
src/meson.build Normal file
View file

@ -0,0 +1,11 @@
subdir('shared')
subdir('wifi')
subdir('dhcp')
subdir('ctl')
subdir('uibc')
executable('miracled', 'miracled.c',
dependencies: libmiracle_shared_dep,
include_directories: include_directories('..'),
install: true
)

View file

@ -1,53 +0,0 @@
set(CMAKE_C_FLAGS "-std=gnu11")
find_package(PkgConfig)
pkg_check_modules (SYSTEMD REQUIRED systemd>=213)
set(miracle-shared_SOURCES rtsp.h
rtsp.c
shl_dlist.h
shl_htable.h
shl_htable.c
shl_log.h
shl_log.c
shl_macro.h
shl_ring.h
shl_ring.c
shl_util.h
shl_util.c
util.h
wpas.h
wpas.c)
add_library(miracle-shared STATIC ${miracle-shared_SOURCES})
target_link_libraries (miracle-shared systemd)
########### install files ###############
#original Makefile.am contents follow:
#include $(top_srcdir)/common.am
#noinst_LTLIBRARIES = libmiracle-shared.la
#
#libmiracle_shared_la_SOURCES = \
# rtsp.h \
# rtsp.c \
# shl_dlist.h \
# shl_htable.h \
# shl_htable.c \
# shl_log.h \
# shl_log.c \
# shl_macro.h \
# shl_ring.h \
# shl_ring.c \
# shl_util.h \
# shl_util.c \
# util.h \
# wpas.h \
# wpas.c
#libmiracle_shared_la_LIBADD = -lsystemd
#
#
#

22
src/shared/meson.build Normal file
View file

@ -0,0 +1,22 @@
libmiracle_shared = static_library('miracle-shared',
'rtsp.h',
'rtsp.c',
'shl_dlist.h',
'shl_htable.h',
'shl_htable.c',
'shl_log.h',
'shl_log.c',
'shl_macro.h',
'shl_ring.h',
'shl_ring.c',
'shl_util.h',
'shl_util.c',
'util.h',
'wpas.h',
'wpas.c',
dependencies: [libsystemd]
)
libmiracle_shared_dep = declare_dependency(
include_directories: include_directories('.'),
link_with: libmiracle_shared
)

View file

@ -1,10 +0,0 @@
set(miracle-uibcctl_SRCS miracle-uibcctl.h
miracle-uibcctl.c)
add_executable(miracle-uibcctl ${miracle-uibcctl_SRCS})
target_link_libraries(miracle-uibcctl PRIVATE miracle-shared)
target_link_libraries(miracle-uibcctl PUBLIC m)
install(TARGETS miracle-uibcctl DESTINATION bin)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared)

5
src/uibc/meson.build Normal file
View file

@ -0,0 +1,5 @@
m = c_compiler.find_library('m', required: false)
executable('miracle-uibcctl', 'miracle-uibcctl.h', 'miracle-uibcctl.c',
install: true,
dependencies: [m, libmiracle_shared_dep]
)

View file

@ -1,59 +0,0 @@
########### next target ###############
set(miracle-wifid_SRCS wifid.h
wifid.c
wifid-dbus.c
wifid-link.c
wifid-peer.c
wifid-supplicant.c)
add_executable(miracle-wifid ${miracle-wifid_SRCS})
target_link_libraries(miracle-wifid ${KDE4_KDECORE_LIBS})
cmake_policy(SET CMP0015 NEW)
include_directories(shared)
link_directories(shared)
target_link_libraries(miracle-wifid miracle-shared)
find_package(PkgConfig)
pkg_check_modules (GLIB2 REQUIRED glib-2.0)
pkg_check_modules (UDEV REQUIRED libudev)
#link_directories( ${UDEV_LIBRARY_DIRS})
#include_directories( ${UDEV_INCLUDE_DIRS})
target_link_libraries(miracle-wifid ${UDEV_LIBRARIES})
#link_directories( ${GLIB2_LIBRARY_DIRS})
#include_directories( ${GLIB2_INCLUDE_DIRS})
target_link_libraries(miracle-wifid ${GLIB2_LIBRARIES})
install(TARGETS miracle-wifid DESTINATION bin)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/shared)
########### install files ###############
#set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake-extensions/ )
#original Makefile.am contents follow:
#include $(top_srcdir)/common.am
#bin_PROGRAMS = miracle-wifid
#
#miracle_wifid_SOURCES = \
# wifid.h \
# wifid.c \
# wifid-dbus.c \
# wifid-link.c \
# wifid-peer.c \
# wifid-supplicant.c
#miracle_wifid_CPPFLAGS = \
# $(AM_CPPFLAGS) \
# $(DEPS_CFLAGS)
#miracle_wifid_LDADD = \
# ../shared/libmiracle-shared.la \
# $(DEPS_LIBS)
#

14
src/wifi/meson.build Normal file
View file

@ -0,0 +1,14 @@
inc = include_directories('../..')
miracle_wifid_src = ['wifid.h',
'wifid.c',
'wifid-dbus.c',
'wifid-link.c',
'wifid-peer.c',
'wifid-supplicant.c'
]
executable('miracle-wifid', miracle_wifid_src,
include_directories: inc,
install: true,
dependencies: [udev, glib2, libsystemd, libmiracle_shared_dep]
)

33
test/meson.build Normal file
View file

@ -0,0 +1,33 @@
check = dependency('check', required: false)
deps = [udev, glib2, check, libsystemd, libmiracle_shared_dep]
if check.found()
test_rtsp = executable('test_rtsp', 'test_rtsp.c', dependencies: deps)
test_wpas = executable('test_wpas', 'test_wpas.c', dependencies: deps)
test_valgrind = executable('test_valgrind',
'test_valgrind.c',
dependencies: deps
)
valgrind = find_program('valgrind')
# set(VALGRIND CK_FORK=no valgrind --tool=memcheck --leak-check=yes --show-reachable=yes --leak-resolution=high --error-exitcode=1 --suppressions=${CMAKE_SOURCE_DIR}/test.supp)
#
# add_custom_target(memcheck-verify
# DEPENDS test_rtsp test_wpas test_valgrind
# COMMAND ${VALGRIND} --log-file=/dev/null ./test_valgrind >/dev/null |
# test 1 = $$?
# COMMENT "verify memcheck")
#
# add_custom_target(memcheck
# DEPENDS memcheck-verify
# COMMAND for i in $(MEMTESTS) |
# do |
# ${VALGRIND} --log-file=${CMAKE_SOURCE_DIR}/$$i.memlog |
# ${CMAKE_SOURCE_DIR}/$$i >/dev/null || (echo "memcheck failed on: $$i" ; exit 1) ; |
# done
# SOURCES test_rtsp test_valgrind test_wpas
# COMMENT "verify memcheck")
endif