Skip to content

Commit

Permalink
Merge branch 'release/0.10.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
truschival committed Apr 14, 2020
2 parents 206ed3a + 2091aeb commit cf7cb2d
Show file tree
Hide file tree
Showing 24 changed files with 214 additions and 328 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ jobs:
runs-on: ubuntu-latest
env:
BUILD_DIR_HOST: /tmp/build
INSTALL_DIR_HOST: /tmp/install
BUILD_DIR: /build
SRC_DIR: /src
BUILD_IMAGE: ruschi/devlinuxqt-pistache
CONTAINER_NAME: buildc
TEST_ARTIFACT: test-trace.tgz
INSTALL_DIR: /tmp/install
steps:
- name: Clone Repository
uses: actions/checkout@v1
Expand All @@ -32,16 +34,17 @@ jobs:
- name: Create build dir
run: |
mkdir -p $BUILD_DIR_HOST
chmod o+w $BUILD_DIR_HOST
touch $BUILD_DIR_HOST/created
ls -la $BUILD_DIR_HOST
mkdir -p $INSTALL_DIR_HOST
chmod 777 $BUILD_DIR_HOST $INSTALL_DIR_HOST
- name: Pull docker container
run: docker pull $BUILD_IMAGE
timeout-minutes: 5
- name: Start Docker
run: >
docker run -itd -u $UID:$GID --privileged --name $CONTAINER_NAME
-v$GITHUB_WORKSPACE:$SRC_DIR -v$BUILD_DIR_HOST:$BUILD_DIR
-v$GITHUB_WORKSPACE:$SRC_DIR
-v$BUILD_DIR_HOST:$BUILD_DIR
-v$INSTALL_DIR_HOST:$INSTALL_DIR
$BUILD_IMAGE
- name: Configure
run: >
Expand All @@ -66,8 +69,8 @@ jobs:
if: failure()
uses: actions/upload-artifact@v1
with:
name: $TEST_ARTIFACT
path: $BUILD_DIR_HOST/$TEST_ARTIFACT
name: ${{ env.TEST_ARTIFACT }}
path: ${{ env.BUILD_DIR_HOST }}/${{ env.TEST_ARTIFACT }}
- name: Collect coverage
run: >
docker exec -w $BUILD_DIR $CONTAINER_NAME
Expand All @@ -84,3 +87,7 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: /tmp/build/coverage.info
- name: Test make install
run: >
docker exec -w $BUILD_DIR -eDESTDIR=$INSTALL_DIR $CONTAINER_NAME
cmake --build $BUILD_DIR --target install
63 changes: 27 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
##
# Top-level CMakeLists.txt
##

cmake_minimum_required (VERSION 3.10)
SET(CMAKE_CXX_STANDARD 14)
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_WARN_DEPRECATED ON)
cmake_minimum_required(VERSION 3.10)
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_VERBOSE_MAKEFILE OFF)
SET(CMAKE_COLOR_MAKEFILE ON)
SET(CMAKE_WARN_DEPRECATED ON)
SET(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Add local macros
Expand All @@ -16,7 +15,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/CMakeModules/)
# Project Name
MESSAGE( STATUS "Running ${CMAKE_COMMAND} v${CMAKE_VERSION}" )
PROJECT(DigitalRooster
VERSION 0.10.1
VERSION 0.10.2
DESCRIPTION "A digital alarm clock and podcast player"
LANGUAGES CXX C
)
Expand All @@ -26,31 +25,31 @@ STRING(TIMESTAMP CMAKE_CONFIGURATION_TIME "%Y-%m-%d %H:%M:%S" UTC)
# Package-Config for components that CMake does not support directly
# include(FindPkgConfig)
if(POLICY CMP0071)
# POLICY since CMake 3.10 (https://cmake.org/cmake/help/git-stage/policy/CMP0071.html)
cmake_policy(SET CMP0071 NEW)
#CMake >=3.10 (https://cmake.org/cmake/help/git-stage/policy/CMP0071.html)
cmake_policy(SET CMP0071 NEW)
endif()

#-------------------------------------------------------------------------------
# user Configuration + Defaults
#-------------------------------------------------------------------------------
option(BUILD_TESTS "Build Tests" On)
option(HAS_WPA_SUPPLICANT "Target has wpa_supplicant" Off)
option(REST_API "Use the REST API" On)
option(REST_API "Use the REST API" Off)
option(PROFILE "Build with Profiling" Off)
option(TEST_COVERAGE "Test Coverage" Off)
option(BUILD_GTEST_FROM_SRC "Rebuild google test as external project" On)
option(BUILD_SHARED_LIBS "Build shared libraries (DLLs)." Off)

# most likely we have wpa_supplicant on Unix,linux etc.
if(UNIX)
option(HAS_WPA_SUPPLICANT "Target has wpa_supplicant" On)
else(UNIX)
option(HAS_WPA_SUPPLICANT "Target has wpa_supplicant" Off)
endif(UNIX)
IF(UNIX)
option(HAS_WPA_SUPPLICANT "Target has wpa_supplicant" On)
ELSE(UNIX)
option(HAS_WPA_SUPPLICANT "Target has wpa_supplicant" Off)
ENDIF(UNIX)

SET(SYSTEM_TARGET_NAME "Host"
CACHE STRING "Target: {Host|Rpi}")
SET(SETTINGS_FILE_NAME "${CMAKE_PROJECT_NAME}.json"
SET(SETTINGS_FILE_NAME "digitalrooster.json"
CACHE STRING "application configuration file name")
SET(WIFI_INTERFACE "/var/run/wpa_supplicant/wlp2s0"
CACHE STRING "wpa_supplicant interface contrl socket path")
Expand All @@ -60,13 +59,13 @@ SET(GENERATED_DIR "${CMAKE_BINARY_DIR}/generated" CACHE INTERNAL "" )
SET(REST_API_PORT "6666" CACHE STRING "Rest API TCP Port")

#-------------------------------------------------------------------------------
# Command line parameters or default
# Command line parameters or default
#-------------------------------------------------------------------------------
IF(NOT CMAKE_BUILD_TYPE)
#Default to Release-Build
SET(CMAKE_BUILD_TYPE Release
CACHE STRING "Choose the type of build : Debug Release RelWithDebInfo"
FORCE)
#Default to Release-Build
SET(CMAKE_BUILD_TYPE Release
CACHE STRING "Choose the type of build : Debug Release RelWithDebInfo"
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)

# User did not provide install prefix via cmake commandline
Expand Down Expand Up @@ -176,18 +175,18 @@ ELSEIF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
SET(WARNING_FLAGS -Wall -Wextra -fmessage-length=0 -Wno-unused-parameter )

LIST(APPEND CUSTOM_C_FLAGS -ffunction-sections -fdata-sections )
LIST(APPEND CUSTOM_CXX_FLAGS -ffunction-sections -fdata-sections )
LIST(APPEND CUSTOM_CXX_FLAGS -ffunction-sections -fdata-sections )

# Link final Executable with Map, clean up unused sections
LIST(APPEND CUSTOM_LINK_FLAGS -Wl,--gc-sections -Wl,-Map,Symbols.map )
LIST(APPEND CUSTOM_LINK_FLAGS -Wl,--gc-sections -Wl,-Map,Symbols.map )
ENDIF()

LIST(APPEND CUSTOM_C_FLAGS ${WARNING_FLAGS})
LIST(APPEND CUSTOM_CXX_FLAGS ${WARNING_FLAGS})

IF(TEST_COVERAGE AND NOT MSVC)
include(CodeCoverage) # does not work for MSVC
APPEND_COVERAGE_COMPILER_FLAGS()
include(CodeCoverage) # does not work for MSVC
APPEND_COVERAGE_COMPILER_FLAGS()
ENDIF()

IF(PROFILE)
Expand Down Expand Up @@ -241,7 +240,7 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/libhwif/)
add_subdirectory(${PROJECT_SOURCE_DIR}/libsrc/) #libsrc depends on libhwif

if(REST_API)
add_subdirectory(${PROJECT_SOURCE_DIR}/REST/)
add_subdirectory(${PROJECT_SOURCE_DIR}/REST/)
endif(REST_API)

add_subdirectory(${PROJECT_SOURCE_DIR}/qtgui/)
Expand All @@ -250,13 +249,6 @@ add_subdirectory(${PROJECT_SOURCE_DIR}/qtgui/)
# configuration install
#-------------------------------------------------------------------------------

#default configuration installation
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/config/digitalrooster.json"
"${SETTINGS_PATH}/${SETTINGS_FILE_NAME}"
COPYONLY
)

# Tests
if(BUILD_TESTS)
# enable Cmake's make test
Expand All @@ -269,7 +261,8 @@ endif(BUILD_TESTS)
# --------------------------------------------------------------------
#SET(CPACK_GENERATOR TGZ)
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
SET(CPACK_PACKAGE_VENDOR "Thomas Ruschival")
SET(CPACK_PACKAGE_VENDOR "Thomas Ruschival")
SET(CPACK_PACKAGE_CONTACT "thomas@ruschival.de")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION})
SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
SET(CPACK_PACKAGE_INSTALL_DIRECTORY ${PROJECT_NAME}-${PROJECT_VERSION})
Expand All @@ -280,7 +273,5 @@ SET(CPACK_COMPONENT_DEVELOP_DESCRIPTION "Components needed for development")
SET(CPACK_COMPONENT_APIDOC_DESCRIPTION "API Documentation")
SET(CPACK_NSIS_CONTACT "thomas@ruschival.de")
SET(CPACK_NSIS_MODIFY_PATH ON)

INCLUDE(CPack)

MESSAGE(STATUS "** end CMakeLists.txt **\n")
2 changes: 1 addition & 1 deletion REST/ApiHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ using namespace Pistache::Rest;
using namespace DigitalRooster;
using namespace DigitalRooster::REST;

static Q_LOGGING_CATEGORY(CLASS_LC, "RestAdapter");
static Q_LOGGING_CATEGORY(CLASS_LC, "ApiHandler");

/*****************************************************************************/

Expand Down
5 changes: 3 additions & 2 deletions REST/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ set(LIBRARY_NAME restconfig)
set(COMPONENT_NAME ${LIBRARY_NAME})
# Interface/binary version
SET(COMPONENT_VERSION ${PROJECT_VERSION})
#includes etc. in folder (no subfolder here)
SET(COMPONENT_PATH "")

# Check if Pistache is installed
# Pistache does not yet provide a CMake Findpackage
# --> fall back to pkgconfig
# Pistache does not yet provide a CMake Findpackage --> fall back to pkgconfig
include(FindPkgConfig)
pkg_search_module(PISTACHE REQUIRED libpistache>=0.0.2)

Expand Down
6 changes: 3 additions & 3 deletions REST/openapi.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
openapi: "3.0.0"
info:
description: Open API for Digital Rooster
version: "0.8.0"
version: "1.0"
title: DigitalRooster
license:
name: GPLv3

servers:
- url: '{server}/v1'
- url: '{server}/api/1.0/'
variables:
server:
default: http://0.0.0.0:8080
default: http://0.0.0.0:6666

###############################################################################
components:
Expand Down
37 changes: 25 additions & 12 deletions buildscripts/build_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,26 @@ log_step () {
tempdir=$(mktemp -d)
# Host directory mapped to container
export BUILD_DIR_HOST=$tempdir/build
# Temporary dir where to install result
export INSTALL_DIR_HOST=$tempdir/install
# Mapped name in container where cmake is run
export BUILD_DIR=$tempdir/build_in_container
# Host checks out sources to this directory and maps it to container
export SRC_DIR=$tempdir/src
# in github actions the workspace is where the sources are located
export GITHUB_WORKSPACE=$SRC_DIR
# install directory in container
export INSTALL_DIR=/tmp/install

export BUILD_IMAGE=ruschi/devlinuxqt-pistache
export CONTAINER_NAME=buildc
export TEST_ARTIFACT=test-trace.tgz

# name: Create build dir
mkdir -p $BUILD_DIR_HOST
chmod o+w $BUILD_DIR_HOST
mkdir -p $INSTALL_DIR_HOST
# let container create dirs in tempdir
chmod 777 $BUILD_DIR_HOST $INSTALL_DIR_HOST

log_step "HOST: Cloning to $GITHUB_WORKSPACE"
git clone /home/ruschi/Coding/DigitalRooster $GITHUB_WORKSPACE
Expand All @@ -44,16 +50,18 @@ docker pull $BUILD_IMAGE

log_step "Start container $CONTAINER_NAME"
docker run -itd -u $UID:$GID --privileged --name $CONTAINER_NAME \
-v$GITHUB_WORKSPACE:$SRC_DIR -v$BUILD_DIR_HOST:$BUILD_DIR \
$BUILD_IMAGE
-v$GITHUB_WORKSPACE:$SRC_DIR \
-v$BUILD_DIR_HOST:$BUILD_DIR \
-v$INSTALL_DIR_HOST:$INSTALL_DIR \
$BUILD_IMAGE

log_step "$CONTAINER_NAME: Configure"
docker exec $CONTAINER_NAME cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=On \
-H$SRC_DIR -B$BUILD_DIR \
-DBUILD_TESTS=On -DTEST_COVERAGE=On -DBUILD_GTEST_FROM_SRC=On \
-DREST_API=On
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=On \
-H$SRC_DIR -B$BUILD_DIR \
-DBUILD_TESTS=On -DTEST_COVERAGE=On -DBUILD_GTEST_FROM_SRC=On \
-DREST_API=On

log_step "$CONTAINER_NAME: Build "
docker exec $CONTAINER_NAME cmake --build $BUILD_DIR --parallel
Expand All @@ -69,19 +77,24 @@ tar -C $BUILD_DIR_HOST -czf $TEST_ARTIFACT \
test_trace.log \
gtest_results.xml

log_step "$CONTAINER_NAME: make install to $TEST_INSTALL_DIR"
docker exec -w $BUILD_DIR -eDESTDIR=$INSTALL_DIR $CONTAINER_NAME \
cmake --build . --target install

log_step "$CONTAINER_NAME: Gather coverage stats"
docker exec -w $BUILD_DIR $CONTAINER_NAME \
lcov --directory $BUILD_DIR --capture --output-file $BUILD_DIR/coverage.info
lcov --directory $BUILD_DIR --capture \
--output-file $BUILD_DIR/coverage.info

log_step "$CONTAINER_NAME: Prune coverage stats"
docker exec -w $BUILD_DIR $CONTAINER_NAME \
lcov --remove $BUILD_DIR/coverage.info \
--output-file $BUILD_DIR/coverage.info \
"/usr/*" "*/GTestExternal/*" "*/__/*"


log_step "HOST: create coverage repor"
genhtml $BUILD_DIR/coverage.info --output-directory $BUILD_DIR/lcov_html
log_step "HOST: create coverage report"
docker exec -w $BUILD_DIR $CONTAINER_NAME \
genhtml $BUILD_DIR/coverage.info --output-directory $BUILD_DIR/lcov_html

log_step "HOST: Cleanup"
docker stop $CONTAINER_NAME
Expand Down
Loading

0 comments on commit cf7cb2d

Please sign in to comment.