From 2260e85751467db9c361346e5bea5bd6b41b1718 Mon Sep 17 00:00:00 2001 From: Matt Ranostay Date: Fri, 11 Aug 2017 15:21:46 -0700 Subject: binding: bluetooth: switch from qmake to cmake Switch from legacy qmake to cmake to build binding Bug-AGL: SPEC-822 Change-Id: Ia2683dda11380c17285768bf6818893cbc5fda08 Signed-off-by: Matt Ranostay --- .gitmodules | 3 + CMakeLists.txt | 21 +++ agl-service-bluetooth.pro | 3 - binding-bluetooth/CMakeLists.txt | 49 +++++++ binding-bluetooth/binding.pri | 6 - binding-bluetooth/export.map | 1 - conf.d/app-templates | 1 + conf.d/autobuild/agl/autobuild | 60 +++++++++ conf.d/autobuild/linux/autobuild | 60 +++++++++ conf.d/cmake/config.cmake | 163 ++++++++++++++++++++++ conf.d/wgt/config.xml.in | 24 ++++ package/config.xml | 20 --- package/icon.svg | 283 --------------------------------------- package/package.pro | 21 --- 14 files changed, 381 insertions(+), 334 deletions(-) create mode 100644 .gitmodules create mode 100644 CMakeLists.txt delete mode 100644 agl-service-bluetooth.pro create mode 100644 binding-bluetooth/CMakeLists.txt delete mode 100644 binding-bluetooth/binding.pri delete mode 100644 binding-bluetooth/export.map create mode 160000 conf.d/app-templates create mode 100755 conf.d/autobuild/agl/autobuild create mode 100755 conf.d/autobuild/linux/autobuild create mode 100644 conf.d/cmake/config.cmake create mode 100644 conf.d/wgt/config.xml.in delete mode 100644 package/config.xml delete mode 100644 package/icon.svg delete mode 100644 package/package.pro diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b545da1 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "conf.d/app-templates"] + path = conf.d/app-templates + url = https://gerrit.automotivelinux.org/gerrit/apps/app-templates diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..b485097 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,21 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Romain Forlot +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +CMAKE_MINIMUM_REQUIRED(VERSION 3.3) + +include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) diff --git a/agl-service-bluetooth.pro b/agl-service-bluetooth.pro deleted file mode 100644 index 5f02cd8..0000000 --- a/agl-service-bluetooth.pro +++ /dev/null @@ -1,3 +0,0 @@ -TEMPLATE = subdirs -SUBDIRS = binding-bluetooth package -package.depends += binding-bluetooth diff --git a/binding-bluetooth/CMakeLists.txt b/binding-bluetooth/CMakeLists.txt new file mode 100644 index 0000000..08f8066 --- /dev/null +++ b/binding-bluetooth/CMakeLists.txt @@ -0,0 +1,49 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll +# contrib: Romain Forlot +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +# Add target to project dependency list +PROJECT_TARGET_ADD(bluetooth-binding) + + # Define project Targets + add_library(${TARGET_NAME} MODULE + bluetooth-api.c + bluetooth-manager.c + bluetooth-agent.c + lib_agent.c + ofono-client.c + lib_ofono.c + lib_ofono_modem.c + bluez-client.c + lib_bluez.c) + + # Binder exposes a unique public entry point + SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES + PREFIX "libafm-" + LABELS "BINDING" + LINK_FLAGS ${BINDINGS_LINK_FLAG} + OUTPUT_NAME ${TARGET_NAME} + ) + + # Library dependencies (include updates automatically) + TARGET_LINK_LIBRARIES(${TARGET_NAME} ${link_libraries}) + + # installation directory + INSTALL(TARGETS ${TARGET_NAME} + LIBRARY DESTINATION ${BINDINGS_INSTALL_DIR}) + diff --git a/binding-bluetooth/binding.pri b/binding-bluetooth/binding.pri deleted file mode 100644 index 3448a56..0000000 --- a/binding-bluetooth/binding.pri +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin use_c_linker -CONFIG -= qt -QMAKE_CFLAGS += -Wextra -Wconversion -Wno-unused-parameter -Werror=maybe-uninitialized -Werror=implicit-function-declaration -ffunction-sections -fdata-sections -Wl,--as-needed -Wl,--gc-sections - -DESTDIR = $${OUT_PWD}/../package/root/lib diff --git a/binding-bluetooth/export.map b/binding-bluetooth/export.map deleted file mode 100644 index eea0d7b..0000000 --- a/binding-bluetooth/export.map +++ /dev/null @@ -1 +0,0 @@ -{ global: afbBindingV2*; local: *; }; diff --git a/conf.d/app-templates b/conf.d/app-templates new file mode 160000 index 0000000..8967162 --- /dev/null +++ b/conf.d/app-templates @@ -0,0 +1 @@ +Subproject commit 8967162dd12bce89f9ae27f5c9bce7b78624e3fd diff --git a/conf.d/autobuild/agl/autobuild b/conf.d/autobuild/agl/autobuild new file mode 100755 index 0000000..759f6be --- /dev/null +++ b/conf.d/autobuild/agl/autobuild @@ -0,0 +1,60 @@ +#!/usr/bin/make -f +# Copyright (C) 2015, 2016 "IoT.bzh" +# Author "Romain Forlot" +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +THISFILE := $(lastword $(MAKEFILE_LIST)) +BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build) +DEST := ${BUILD_DIR}/target + +.PHONY: all clean distclean configure build package help + +all: help + +help: + @echo "List of targets available:" + @echo "" + @echo "- all" + @echo "- clean" + @echo "- distclean" + @echo "- configure" + @echo "- build" + @echo "- package" + @echo "" + @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt" + @echo "Don't use your build dir as DEST as wgt file is generated at this location" + +clean: + @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean + +distclean: + @rm -rf ${BUILD_DIR} + +configure: ${BUILD_DIR}/Makefile + +build: configure + @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all + +package: build + @mkdir -p ${BUILD_DIR}/$@/bin + @mkdir -p ${BUILD_DIR}/$@/etc + @mkdir -p ${BUILD_DIR}/$@/lib + @mkdir -p ${BUILD_DIR}/$@/htdocs + @mkdir -p ${BUILD_DIR}/$@/data + @cmake --build ${BUILD_DIR} --target widget + @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST} + +${BUILD_DIR}/Makefile: + @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR} + @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..) diff --git a/conf.d/autobuild/linux/autobuild b/conf.d/autobuild/linux/autobuild new file mode 100755 index 0000000..759f6be --- /dev/null +++ b/conf.d/autobuild/linux/autobuild @@ -0,0 +1,60 @@ +#!/usr/bin/make -f +# Copyright (C) 2015, 2016 "IoT.bzh" +# Author "Romain Forlot" +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +THISFILE := $(lastword $(MAKEFILE_LIST)) +BUILD_DIR := $(abspath $(dir $(THISFILE)/../../../../..)/build) +DEST := ${BUILD_DIR}/target + +.PHONY: all clean distclean configure build package help + +all: help + +help: + @echo "List of targets available:" + @echo "" + @echo "- all" + @echo "- clean" + @echo "- distclean" + @echo "- configure" + @echo "- build" + @echo "- package" + @echo "" + @echo "Usage: ./conf.d/autobuild/agl/autobuild package DEST=${HOME}/opt" + @echo "Don't use your build dir as DEST as wgt file is generated at this location" + +clean: + @([ -d ${BUILD_DIR} ] && make -C ${BUILD_DIR} clean) || echo Nothing to clean + +distclean: + @rm -rf ${BUILD_DIR} + +configure: ${BUILD_DIR}/Makefile + +build: configure + @cmake --build ${BUILD_DIR} ${BUILD_ARGS} --target all + +package: build + @mkdir -p ${BUILD_DIR}/$@/bin + @mkdir -p ${BUILD_DIR}/$@/etc + @mkdir -p ${BUILD_DIR}/$@/lib + @mkdir -p ${BUILD_DIR}/$@/htdocs + @mkdir -p ${BUILD_DIR}/$@/data + @cmake --build ${BUILD_DIR} --target widget + @mkdir -p ${DEST} && cp ${BUILD_DIR}/*wgt ${DEST} + +${BUILD_DIR}/Makefile: + @[ -d ${BUILD_DIR} ] || mkdir -p ${BUILD_DIR} + @[ -f ${BUILD_DIR}/Makefile ] || (cd ${BUILD_DIR} && cmake ${CONFIGURE_ARGS} ..) diff --git a/conf.d/cmake/config.cmake b/conf.d/cmake/config.cmake new file mode 100644 index 0000000..df7336c --- /dev/null +++ b/conf.d/cmake/config.cmake @@ -0,0 +1,163 @@ +########################################################################### +# Copyright 2015, 2016, 2017 IoT.bzh +# +# author: Fulup Ar Foll +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +########################################################################### + +# Project Info +# ------------------ +set(PROJECT_NAME agl-service-bluetooth) +set(PROJECT_VERSION "1.0") +set(PROJECT_PRETTY_NAME "Bluetooth binding service") +set(PROJECT_DESCRIPTION "Expose Bluetooth Low Level APIs through AGL Framework") +set(PROJECT_ICON "icon.png") +set(PROJECT_AUTHOR "Tasuku Suzuki") +set(PROJECT_AUTHOR_MAIL "tasuku.suzuki@qt.io") +set(PROJECT_LICENSE "APL2.0") +set(PROJECT_LANGUAGES,"C") + +# Where are stored default templates files from submodule or subtree app-templates in your project tree +# relative to the root project directory +set(PROJECT_APP_TEMPLATES_DIR "conf.d/app-templates") + +# Where are stored your external libraries for your project. This is 3rd party library that you don't maintain +# but used and must be built and linked. +# set(PROJECT_LIBDIR "libs") + +# Where are stored data for your application. Pictures, static resources must be placed in that folder. +# set(PROJECT_RESOURCES "data") + +# Which directories inspect to find CMakeLists.txt target files +# set(PROJECT_SRC_DIR_PATTERN "*") + +# Compilation Mode (DEBUG, RELEASE) +# ---------------------------------- +set(CMAKE_BUILD_TYPE "DEBUG") + +# Kernel selection if needed. You can choose between a +# mandatory version to impose a minimal version. +# Or check Kernel minimal version and just print a Warning +# about missing features and define a preprocessor variable +# to be used as preprocessor condition in code to disable +# incompatibles features. Preprocessor define is named +# KERNEL_MINIMAL_VERSION_OK. +# +# NOTE*** FOR NOW IT CHECKS KERNEL Yocto environment and +# Yocto SDK Kernel version. +# ----------------------------------------------- +#set(kernel_mandatory_version 4.8) + +# Compiler selection if needed. Impose a minimal version. +# ----------------------------------------------- +set (gcc_minimal_version 4.9) + +# PKG_CONFIG required packages +# ----------------------------- +set (PKG_REQUIRED_LIST + json-c + libsystemd>=222 + afb-daemon + json-c + glib-2.0 + gio-2.0 + gobject-2.0 + gio-unix-2.0 + zlib +) + +# Static constante definition +# ----------------------------- +add_compile_options(-DPB_FIELD_16BIT) +add_compile_options($<$:-pthread>) + +# Customize link option +# ----------------------------- +list (APPEND link_libraries -pthread) + +# (BUG!!!) as PKG_CONFIG_PATH does not work [should be an env variable] +# --------------------------------------------------------------------- +set(CMAKE_INSTALL_PREFIX $ENV{HOME}/opt) +set(CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}/lib64/pkgconfig ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) +set(LD_LIBRARY_PATH ${CMAKE_INSTALL_PREFIX}/lib64 ${CMAKE_INSTALL_PREFIX}/lib) + +# Optional location for config.xml.in +# ----------------------------------- +set(WIDGET_CONFIG_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/conf.d/wgt/config.xml.in) + +# Mandatory widget Mimetype specification of the main unit +# -------------------------------------------------------------------------- +# Choose between : +#- text/html : HTML application, +# content.src designates the home page of the application +# +#- application/vnd.agl.native : AGL compatible native, +# content.src designates the relative path of the binary. +# +# - application/vnd.agl.service: AGL service, content.src is not used. +# +#- ***application/x-executable***: Native application, +# content.src designates the relative path of the binary. +# For such application, only security setup is made. +# +set(WIDGET_TYPE application/vnd.agl.service) + +# Mandatory Widget entry point file of the main unit +# -------------------------------------------------------------- +# This is the file that will be executed, loaded, +# at launch time by the application framework. +# +set(WIDGET_ENTRY_POINT lib/libafm-bluetooth-binding.so) + +# Print a helper message when every thing is finished +# ---------------------------------------------------- +set(CLOSING_MESSAGE "Test with: afb-daemon --rootdir=\$\$(pwd)/package --binding=\$\$(pwd)/package/${WIDGET_ENTRY_POINT} --port=1234 --tracereq=common --token=\"1\" --verbose") +set(PACKAGE_MESSAGE "Install widget file using in the target : afm-util install ${PROJECT_NAME}.wgt") + + + +# Optional dependencies order +# --------------------------- +#set(EXTRA_DEPENDENCIES_ORDER) + +# Optional Extra global include path +# ----------------------------------- +#set(EXTRA_INCLUDE_DIRS) + +# Optional extra libraries +# ------------------------- +#set(EXTRA_LINK_LIBRARIES) + +# Optional force binding installation +# ------------------------------------ +# set(BINDINGS_INSTALL_PREFIX PrefixPath ) + +# Optional force binding Linking flag +# ------------------------------------ +# set(BINDINGS_LINK_FLAG LinkOptions ) + +# Optional force package prefix generation, like widget +# ----------------------------------------------------- +# set(PKG_PREFIX DestinationPath) + +# Optional Application Framework security token +# and port use for remote debugging. +#------------------------------------------------------------ +#set(AFB_TOKEN "" CACHE PATH "Default AFB_TOKEN") +#set(AFB_REMPORT "1234" CACHE PATH "Default AFB_TOKEN") + +# This include is mandatory and MUST happens at the end +# of this file, else you expose you to unexpected behavior +# ----------------------------------------------------------- +include(${PROJECT_APP_TEMPLATES_DIR}/cmake/common.cmake) diff --git a/conf.d/wgt/config.xml.in b/conf.d/wgt/config.xml.in new file mode 100644 index 0000000..6ba14dd --- /dev/null +++ b/conf.d/wgt/config.xml.in @@ -0,0 +1,24 @@ + + + @PROJECT_NAME@ + + + @PROJECT_DESCRIPTION@ + @PROJECT_AUTHOR@ <@PROJECT_AUTHOR_MAIL@> + @PROJECT_LICENSE@ + + + + + + + + + + + + + + + + diff --git a/package/config.xml b/package/config.xml deleted file mode 100644 index b0ef0c4..0000000 --- a/package/config.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - agl-service-bluetooth - - - Bluetooth binding service - Tasuku Suzuki <tasuku.suzuki@qt.io> - APL2.0 - - - - - - - - - - - - diff --git a/package/icon.svg b/package/icon.svg deleted file mode 100644 index 6628784..0000000 --- a/package/icon.svg +++ /dev/null @@ -1,283 +0,0 @@ - - - -image/svg+xmlSETTINGS - \ No newline at end of file diff --git a/package/package.pro b/package/package.pro deleted file mode 100644 index 23f2fe1..0000000 --- a/package/package.pro +++ /dev/null @@ -1,21 +0,0 @@ - -DISTFILES = icon.svg config.xml - -!equals($$_PRO_FILE_PWD_, $$OUT_PWD) { - copy_icon.target = $$OUT_PWD/root/icon.svg - copy_icon.depends = $$_PRO_FILE_PWD_/icon.svg - copy_icon.commands = $(COPY_FILE) \"$$replace(copy_icon.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_icon.target, /, $$QMAKE_DIR_SEP)\" - QMAKE_EXTRA_TARGETS += copy_icon - PRE_TARGETDEPS += $$copy_icon.target - - copy_config.target = $$OUT_PWD/root/config.xml - copy_config.depends = $$_PRO_FILE_PWD_/config.xml - copy_config.commands = $(COPY_FILE) \"$$replace(copy_config.depends, /, $$QMAKE_DIR_SEP)\" \"$$replace(copy_config.target, /, $$QMAKE_DIR_SEP)\" - QMAKE_EXTRA_TARGETS += copy_config - PRE_TARGETDEPS += $$copy_config.target -} - -wgt.target = package -wgt.commands = wgtpkg-pack -f -o agl-service-bluetooth.wgt root - -QMAKE_EXTRA_TARGETS += wgt -- cgit 1.2.3-korg