Initial travis-ci support

pull/32/head
Olivier Martin 2017-06-30 13:16:59 +02:00
parent f7a5ced9d5
commit 2e88aec8e1
12 changed files with 170 additions and 14 deletions

139
.travis.yml Normal file
View File

@ -0,0 +1,139 @@
language: c
compiler:
- gcc
#Disable Clang for now until we support ARM cross-toolchain - clang
dist: trusty
addons:
apt:
packages:
- gcc-4.8-arm-linux-gnueabihf
- g++-arm-linux-gnueabihf
- gcc-4.8-aarch64-linux-gnu
- g++-aarch64-linux-gnu
- libbluetooth-dev
- rpm
script:
# Build default Gattlib - Debug
- mkdir build-debug && pushd build-debug
- cmake -DCMAKE_BUILD_TYPE=Debug .. && make
- popd
# Build and Package default Gattlib - Release
- mkdir build-release && pushd build-release
- cmake -DCMAKE_BUILD_TYPE=Release .. && make && cpack ..
- popd
# Build Gattlib with DBus support - Debug
- mkdir build-dbus-debug && pushd build-dbus-debug
- cmake -DGATTLIB_FORCE_DBUS=TRUE -DCMAKE_BUILD_TYPE=Debug .. && make
- popd
# Build and Package Gattlib with DBus support - Release
- mkdir build-dbus-release && pushd build-dbus-release
- cmake -DGATTLIB_FORCE_DBUS=TRUE -DCMAKE_BUILD_TYPE=Release .. && make && cpack ..
- popd
# Download tools
- wget https://raw.githubusercontent.com/labapart/labapart-tools/master/fixup-symlink.sh
- chmod +x fixup-symlink.sh
#
# Setup build for ARM 32-bit
#
# Download Debian packages
- mkdir debian-stretch-arm && pushd debian-stretch-arm
- wget http://ftp.de.debian.org/debian/pool/main/b/bluez/libbluetooth3_5.43-2_armhf.deb && dpkg -x libbluetooth3_5.43-2_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/b/bluez/libbluetooth-dev_5.43-2_armhf.deb && dpkg -x libbluetooth-dev_5.43-2_armhf.deb .
- wget http://security.debian.org/debian-security/pool/updates/main/g/glibc/libc6_2.24-11+deb9u1_armhf.deb && dpkg -x libc6_2.24-11+deb9u1_armhf.deb .
- wget http://security.debian.org/debian-security/pool/updates/main/g/glibc/libc6-dev_2.24-11+deb9u1_armhf.deb && dpkg -x libc6-dev_2.24-11+deb9u1_armhf.deb .
- wget http://security.debian.org/debian-security/pool/updates/main/l/linux/linux-libc-dev_4.9.30-2+deb9u2_armhf.deb && dpkg -x linux-libc-dev_4.9.30-2+deb9u2_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/g/glib2.0/libglib2.0-0_2.50.3-2_armhf.deb && dpkg -x libglib2.0-0_2.50.3-2_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/g/glib2.0/libglib2.0-dev_2.50.3-2_armhf.deb && dpkg -x libglib2.0-dev_2.50.3-2_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/g/gcc-6/libstdc++6_6.3.0-18_armhf.deb && dpkg -x libstdc++6_6.3.0-18_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/g/gcc-6/libstdc++-6-dev_6.3.0-18_armhf.deb && dpkg -x libstdc++-6-dev_6.3.0-18_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/p/pcre3/libpcre3_8.39-3_armhf.deb && dpkg -x libpcre3_8.39-3_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/libf/libffi/libffi6_3.2.1-6_armhf.deb && dpkg -x libffi6_3.2.1-6_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/g/glib2.0/libglib2.0-0_2.50.3-2_armhf.deb && dpkg -x libglib2.0-0_2.50.3-2_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/z/zlib/zlib1g_1.2.8.dfsg-5_armhf.deb && dpkg -x zlib1g_1.2.8.dfsg-5_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/libs/libselinux/libselinux1_2.6-3+b1_armhf.deb && dpkg -x libselinux1_2.6-3+b1_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/u/util-linux/libmount1_2.29.2-1_armhf.deb && dpkg -x libmount1_2.29.2-1_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/u/util-linux/libblkid1_2.29.2-1_armhf.deb && dpkg -x libblkid1_2.29.2-1_armhf.deb .
- wget http://ftp.de.debian.org/debian/pool/main/u/util-linux/libuuid1_2.29.2-1_armhf.deb && dpkg -x libuuid1_2.29.2-1_armhf.deb .
# Fixup broken links
- TARGETDIR=. ../fixup-symlink.sh
- popd
# Set environment variables
- export SYSROOT=$PWD/debian-stretch-arm
- export CROSS_COMPILE=arm-linux-gnueabihf-
# Build and Package Gattlib with DBus support - Release - ARM32
- mkdir build-dbus-release-arm32 && pushd build-dbus-release-arm32
- cmake -DGATTLIB_FORCE_DBUS=TRUE -DCMAKE_BUILD_TYPE=Release .. && make VERBOSE=1 && cpack ..
- popd
- echo "Broken links:"
- find . -type l ! -exec test -e {} \; -print
#
# Setup build for ARM 64-bit
#
# Download Debian packages
- mkdir debian-stretch-arm64 && pushd debian-stretch-arm64
- wget http://ftp.de.debian.org/debian/pool/main/b/bluez/libbluetooth3_5.43-2_arm64.deb && dpkg -x libbluetooth3_5.43-2_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/b/bluez/libbluetooth-dev_5.43-2_arm64.deb && dpkg -x libbluetooth-dev_5.43-2_arm64.deb .
- wget http://security.debian.org/debian-security/pool/updates/main/g/glibc/libc6_2.24-11+deb9u1_arm64.deb && dpkg -x libc6_2.24-11+deb9u1_arm64.deb .
- wget http://security.debian.org/debian-security/pool/updates/main/g/glibc/libc6-dev_2.24-11+deb9u1_arm64.deb && dpkg -x libc6-dev_2.24-11+deb9u1_arm64.deb .
- wget http://security.debian.org/debian-security/pool/updates/main/l/linux/linux-libc-dev_4.9.30-2+deb9u2_arm64.deb && dpkg -x linux-libc-dev_4.9.30-2+deb9u2_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/g/glib2.0/libglib2.0-0_2.50.3-2_arm64.deb && dpkg -x libglib2.0-0_2.50.3-2_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/g/glib2.0/libglib2.0-dev_2.50.3-2_arm64.deb && dpkg -x libglib2.0-dev_2.50.3-2_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/g/gcc-6/libstdc++6_6.3.0-18_arm64.deb && dpkg -x libstdc++6_6.3.0-18_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/g/gcc-6/libstdc++-6-dev_6.3.0-18_arm64.deb && dpkg -x libstdc++-6-dev_6.3.0-18_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/p/pcre3/libpcre3_8.39-3_arm64.deb && dpkg -x libpcre3_8.39-3_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/libf/libffi/libffi6_3.2.1-6_arm64.deb && dpkg -x libffi6_3.2.1-6_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/g/glib2.0/libglib2.0-0_2.50.3-2_arm64.deb && dpkg -x libglib2.0-0_2.50.3-2_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/z/zlib/zlib1g_1.2.8.dfsg-5_arm64.deb && dpkg -x zlib1g_1.2.8.dfsg-5_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/libs/libselinux/libselinux1_2.6-3+b1_arm64.deb && dpkg -x libselinux1_2.6-3+b1_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/u/util-linux/libmount1_2.29.2-1_arm64.deb && dpkg -x libmount1_2.29.2-1_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/u/util-linux/libblkid1_2.29.2-1_arm64.deb && dpkg -x libblkid1_2.29.2-1_arm64.deb .
- wget http://ftp.de.debian.org/debian/pool/main/u/util-linux/libuuid1_2.29.2-1_arm64.deb && dpkg -x libuuid1_2.29.2-1_arm64.deb .
# Fixup broken links
- TARGETDIR=. ../fixup-symlink.sh
- popd
# Set environment variables
- export SYSROOT=$PWD/debian-stretch-arm64
- export CROSS_COMPILE=aarch64-linux-gnu-
# Build and Package Gattlib with DBus support - Release - ARM64
- mkdir build-dbus-release-arm64 && pushd build-dbus-release-arm64
- cmake -DGATTLIB_FORCE_DBUS=TRUE -DCMAKE_BUILD_TYPE=Release .. && make VERBOSE=1 && cpack ..
- popd
before_deploy:
# Create directory to store the artifacts we want to deploy
- mkdir artifacts
# Copy packages to artifacts
- cp build-release/gattlib_${TRAVIS_TAG}_x86_64.deb ../artifacts/
- cp build-release/gattlib_${TRAVIS_TAG}_x86_64.rpm ../artifacts/
- cp build-release/gattlib_${TRAVIS_TAG}_x86_64.zip ../artifacts/
# Copy DBUS packages to artifacts
- cp build-dbus-debug/gattlib_${TRAVIS_TAG}_x86_64.deb ../artifacts/gattlib_dbus_${TRAVIS_TAG}_x86_64.deb
- cp build-dbus-debug/gattlib_${TRAVIS_TAG}_x86_64.rpm ../artifacts/gattlib_dbus_${TRAVIS_TAG}_x86_64.rpm
- cp build-dbus-debug/gattlib_${TRAVIS_TAG}_x86_64.zip ../artifacts/gattlib_dbus_${TRAVIS_TAG}_x86_64.zip
deploy:
provider: releases
api-key: ${GITHUB_OAUTH_TOKEN}
file_glob: true
file: artifacts/*
skip_cleanup: true
on:
tags: true

View File

@ -60,9 +60,15 @@ endif()
if (GATTLIB_DBUS)
# Build dbus-based gattlib
add_subdirectory(dbus)
# Add the Gattlib build directory for the examples
link_directories(${PROJECT_BINARY_DIR}/dbus)
else()
# Build bluez-based gattlib
add_subdirectory(bluez)
# Add the Gattlib build directory for the examples
link_directories(${PROJECT_BINARY_DIR}/bluez)
endif()
# Generate pkg-config file before building the examples
@ -87,15 +93,24 @@ endif()
# Packaging
#
set(CPACK_PACKAGE_INSTALL_DIRECTORY /usr CACHE STRING "Install directory (default: /usr).")
set(CPACK_PACKAGE_VERSION 0.2)
if (ENV{TRAVIS_TAG})
set(CPACK_PACKAGE_VERSION $ENV{TRAVIS_TAG})
else()
set(CPACK_PACKAGE_VERSION dev)
endif()
set(CPACK_PACKAGE_CONTACT "Olivier Martin <olivier@labapart.com>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library to access GATT information from Bluetooth Low Energy (BLE) devices")
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_PACKAGE_ARCHITECTURE}")
#
# Debian package
# Debian, RPM and ZIP packages
#
set(CPACK_GENERATOR "DEB;RPM;ZIP")
if (CMAKE_SYSROOT)
# CPack does like RPM package in a cross-toolchain context
set(CPACK_GENERATOR "DEB;ZIP")
else()
set(CPACK_GENERATOR "DEB;RPM;ZIP")
endif()
# Detect platform architecture to use it for the Debian package
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_QUIET)

View File

@ -49,6 +49,7 @@ set(CMAKE_CXX_COMPILER $ENV{CROSS_COMPILE}g++)
# Specify the target environment
set(CMAKE_FIND_ROOT_PATH $ENV{SYSROOT})
set(CMAKE_SYSROOT $ENV{SYSROOT})
# Retrieve the machine supported by the toolchain
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE TOOLCHAIN_MACHINE OUTPUT_STRIP_TRAILING_WHITESPACE)
@ -57,7 +58,7 @@ execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpmachine OUTPUT_VARIABLE TOOLCHA
set(ENV{CFLAGS} "--sysroot=$ENV{SYSROOT} $ENV{CFLAGS}")
# Add '-rpath' to the linker flags
set(ENV{LDFLAGS} "-Wl,-rpath,$ENV{SYSROOT}/lib/${TOOLCHAIN_MACHINE} $ENV{LDFLAGS}")
set(ENV{LDFLAGS} "--sysroot=$ENV{SYSROOT} -Wl,-rpath,$ENV{SYSROOT}/lib/${TOOLCHAIN_MACHINE} $ENV{LDFLAGS}")
#
# Configure pkg-config for cross-compilation

View File

@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/labapart/gattlib.svg?branch=master)](https://travis-ci.org/labapart/gattlib)
GattLib is a library used to access Generic Attribute Profile (GATT) protocol of BLE (Bluetooth Low Energy) devices.
It has been introduced to allow to build applications that could easily communicate with BLE devices.

View File

@ -81,12 +81,11 @@ set(gattlib_SRCS gattlib_adapter.c
# Added Glib support
pkg_search_module(GLIB REQUIRED glib-2.0)
include_directories(${GLIB_INCLUDE_DIRS})
list(APPEND gattlib_LIBS ${GLIB_LIBRARIES})
list(APPEND gattlib_LIBS ${GLIB_LDFLAGS})
# Added Bluetooth support
include_directories(${BLUEZ_INCLUDE_DIRS})
link_directories(${BLUEZ_LIBRARY_DIRS})
list(APPEND gattlib_LIBS ${BLUEZ_LIBRARIES})
list(APPEND gattlib_LIBS ${BLUEZ_LDFLAGS})
include_directories(.)
if(BLUEZ_VERSION_MAJOR STREQUAL "4")

View File

@ -75,7 +75,7 @@ set(gattlib_SRCS gattlib.c
${CMAKE_CURRENT_BINARY_DIR}/org-bluez-gattdescriptor1.c
${CMAKE_CURRENT_BINARY_DIR}/org-bluez-gattservice1.c)
set(gattlib_LIBS ${GLIB_LIBRARIES} ${GIO_UNIX_LIBRARIES})
set(gattlib_LIBS ${GLIB_LDFLAGS} ${GIO_UNIX_LDFLAGS})
# Gattlib
add_library(gattlib SHARED ${gattlib_SRCS})

View File

@ -28,4 +28,4 @@ pkg_search_module(GATTLIB REQUIRED gattlib)
set(ble_scan_SRCS ble_scan.c)
add_executable(ble_scan ${ble_scan_SRCS})
target_link_libraries(ble_scan ${GATTLIB_LIBRARIES} pthread)
target_link_libraries(ble_scan ${GATTLIB_LDFLAGS} pthread)

View File

@ -28,4 +28,4 @@ pkg_search_module(GATTLIB REQUIRED gattlib)
set(discover_SRCS discover.c)
add_executable(discover ${discover_SRCS})
target_link_libraries(discover ${GATTLIB_LIBRARIES})
target_link_libraries(discover ${GATTLIB_LDFLAGS})

View File

@ -51,4 +51,4 @@ endif()
set(gatttool_SRCS gatttool.c interactive.c utils.c)
add_executable(gatttool ${gatttool_SRCS})
target_link_libraries(gatttool ${GATTLIB_LIBRARIES} ${GLIB_LIBRARIES} readline)
target_link_libraries(gatttool ${GATTLIB_LDFLAGS} ${GLIB_LDFLAGS} readline)

View File

@ -29,4 +29,4 @@ pkg_search_module(GATTLIB REQUIRED gattlib)
set(nordic_uart_SRCS nordic_uart.c)
add_executable(nordic_uart ${nordic_uart_SRCS})
target_link_libraries(nordic_uart ${GATTLIB_LIBRARIES})
target_link_libraries(nordic_uart ${GATTLIB_LDFLAGS})

View File

@ -31,4 +31,4 @@ include_directories(${GLIB_INCLUDE_DIRS})
set(notification_SRCS notification.c)
add_executable(notification ${notification_SRCS})
target_link_libraries(notification ${GATTLIB_LIBRARIES})
target_link_libraries(notification ${GATTLIB_LDFLAGS} ${GLIB_LDFLAGS})

View File

@ -29,4 +29,4 @@ pkg_search_module(GATTLIB REQUIRED gattlib)
set(read_write_SRCS read_write.c)
add_executable(read_write ${read_write_SRCS})
target_link_libraries(read_write ${GATTLIB_LIBRARIES})
target_link_libraries(read_write ${GATTLIB_LDFLAGS})