Skip to content

Commit

Permalink
a new executable 'simulator' for application testing
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Sep 27, 2024
1 parent 8698e6b commit 8a64e45
Show file tree
Hide file tree
Showing 18 changed files with 1,745 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/build_ubuntu_latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: build ubuntu latest

on:
pull_request:
branches:
- simulator
push:
branches:
- simulator

jobs:
build:
runs-on: ubuntu-latest
environment: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update package list
run: sudo apt-get update
- name: Install software-properties-common
run: sudo apt-get install software-properties-common
- name: Install clang compiler and tools
run: |
sudo apt-get -y install clang ccache cmake pkg-config curl wget
- name: Install dependencies
run: |
sudo apt-get install -y \
libc++-dev libomp-dev liblzma-dev libxml2-dev libmarisa-dev \
libqt5remoteobjects5-bin libqt5quickwidgets5 \
libqt5quickcontrols2-5 libqt5qmlmodels5 libqt5qml5 \
libqt5positioning5 libqt5dbus5 libqt5remoteobjects5-dev \
libqt5svg5-dev libqt5sensors5-dev \
qttools5-dev qttools5-dev-tools qtdeclarative5-dev \
qtquickcontrols2-5-dev qtmultimedia5-dev qtpositioning5-dev \
qml-module-qtquick2 qml-module-qtgraphicaleffects \
qml-module-qtquick-layouts qml-module-qtquick-controls2 \
qml-module-qt-labs-settings \
libreadline-dev
- name: Fetch submodules
run: git submodule init && git submodule update
- name: Configure build
run: |
cmake -B build \
-DBUILD_DEVICE_MOBILE=ON \
-DBUILD_SIMULATOR=ON -DBUILD_SIMULATOR_WITH_READLINE=ON \
-Wno-dev
- name: Build
run: cmake --build build
- name: Install
run: sudo cmake --install build

5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ project(osmin C CXX)

option(INSTALL_TESTS "Install the tests on make install" OFF)
option(BUILD_DEVICE_MOBILE "Enable behaviors for mobile devices" OFF)
option(BUILD_SIMULATOR "Build the simulation tool for OSMIN" OFF)

set(APP_VERSION "1.12.10")
set(APP_VERSION_CODE 75)
Expand Down Expand Up @@ -252,3 +253,7 @@ else()
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)
endif()

if((NOT ANDROID) AND UNIX AND BUILD_SIMULATOR)
add_subdirectory(simulator)
endif()
74 changes: 74 additions & 0 deletions simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
cmake_minimum_required(VERSION 3.8.2)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

unset(CMAKE_IGNORE_PATH)

set(OSMIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src)

include_directories(BEFORE SYSTEM
${PROJECT_BINARY_DIR}
${OSMIN_SRC_DIR}
${LIBOSMSCOUT_INCLUDE_DIRS}
)

option(BUILD_SIMULATOR_WITH_READLINE "Enable Readline support" ON)

if(SIMULATOR_WITH_READLINE)
find_package(Readline QUIET)
if(READLINE_FOUND)
include_directories(${Readline_INCLUDE_DIR})
add_definitions("-DHAVE_READLINE")
endif()
endif()

set(simulator_SOURCES main.cpp
simulatedcompass.cpp
simulatedpositionsource.cpp
simulatedsensorplugin.cpp
commandline.cpp
simulator.cpp
gpxrunner.cpp
${OSMIN_SRC_DIR}/converter.cpp
${OSMIN_SRC_DIR}/csvparser.cpp
${OSMIN_SRC_DIR}/gpxfilemodel.cpp
${OSMIN_SRC_DIR}/tracker.cpp
${OSMIN_SRC_DIR}/service.cpp
${OSMIN_SRC_DIR}/signalhandler.cpp
${OSMIN_SRC_DIR}/utils.cpp
${OSMIN_SRC_DIR}/compass/genericcompass.cpp
${OSMIN_SRC_DIR}/compass/plugin.cpp
)
set(simulator_HEADERS
commandline.h
gpxrunner.h
simulatedcompass.h
simulatedpositionsource.h
simulatedsensorplugin.h
simulator.h
simulatorbreaker.h
${OSMIN_SRC_DIR}/converter.h
${OSMIN_SRC_DIR}/locked.h
${OSMIN_SRC_DIR}/gpxfilemodel.h
${OSMIN_SRC_DIR}/tracker.h
${OSMIN_SRC_DIR}/service.h
${OSMIN_SRC_DIR}/signalhandler.h
)

qt5_generate_repc(simulator_SOURCES
${OSMIN_SRC_DIR}/servicemessenger.rep SOURCE)
qt5_generate_repc(simulator_SOURCES
${OSMIN_SRC_DIR}/servicemessenger.rep REPLICA)

add_executable(simulator ${simulator_SOURCES} ${simulator_HEADERS})

target_link_libraries(simulator PRIVATE
${LIBOSMSCOUT_LIBRARIES}
Qt5::RemoteObjects Qt5::Positioning
Qt5::Sensors Qt5::Core
)

if(READLINE_FOUND)
target_link_libraries(simulator PRIVATE ${Readline_LIBRARY})
endif()

set_target_properties(simulator PROPERTIES OUTPUT_NAME "osmin-simulator")
47 changes: 47 additions & 0 deletions simulator/cmake/FindReadline.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# - Try to find readline include dirs and libraries
#
# Usage of this module as follows:
#
# find_package(Readline)
#
# Variables used by this module, they can change the default behaviour and need
# to be set before calling find_package:
#
# Readline_ROOT_DIR Set this variable to the root installation of
# readline if the module has problems finding the
# proper installation path.
#
# Variables defined by this module:
#
# READLINE_FOUND System has readline, include and lib dirs found
# Readline_INCLUDE_DIR The readline include directories.
# Readline_LIBRARY The readline library.

find_path(Readline_ROOT_DIR
NAMES include/readline/readline.h
)

find_path(Readline_INCLUDE_DIR
NAMES readline/readline.h
HINTS ${Readline_ROOT_DIR}/include
)

find_library(Readline_LIBRARY
NAMES readline
HINTS ${Readline_ROOT_DIR}/lib
)

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_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)

mark_as_advanced(
Readline_ROOT_DIR
Readline_INCLUDE_DIR
Readline_LIBRARY
)
Loading

0 comments on commit 8a64e45

Please sign in to comment.