From c56b75f6511015edb4417df81d97aa6181e5480e Mon Sep 17 00:00:00 2001 From: Loïc Collignon Date: Mon, 2 Jul 2018 15:38:32 +0200 Subject: Allow to build and run on native linux host MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make libhomescreen and libmanager dependencies optional so that you can build, run and debug on a native linux host, to allow faster development. Change-Id: Ice0b7e196e9a88dc7f0f8e9894eb9091c6ba566e Signed-off-by: Loïc Collignon --- CMakeLists.txt | 1 - app/CMakeLists.txt | 18 ++++++++++++------ app/main.cpp | 31 ++++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 806ae35..37683ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.3) set(AFB_HELPERS_QTWSCLIENT ON CACHE BOOL "enable Qt's WebSocket client" FORCE) add_definitions(-DUSE_API_DYN) -#add_definitions(-DAFB_BINDING_WANT_DYNAPI) include(${CMAKE_CURRENT_SOURCE_DIR}/conf.d/cmake/config.cmake) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 8f8bd1e..25da122 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -25,6 +25,12 @@ qt5_add_resources(RESOURCES Mixer.qrc) PROJECT_TARGET_ADD(mixer) +option(NATIVE_BUILD "Build for native environment, without homescreen and window manager" OFF) +if(NATIVE_BUILD) + message(STATUS "Native build is ON") + add_definitions(-DNATIVE_BUILD) +endif() + add_executable(mixer main.cpp mixer.cpp @@ -49,9 +55,9 @@ target_link_libraries(mixer afb-helpers ) -#add_custom_command(TARGET ${TARGET_NAME} -#PRE_BUILD -#COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/../package/htdocs -#COMMAND cp -rv ${CMAKE_CURRENT_SOURCE_DIR}/../htdocs ${CMAKE_CURRENT_BINARY_DIR}/../package/ -#COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/../package/etc -#COMMAND cp -rv ${CMAKE_CURRENT_SOURCE_DIR}/../etc ${CMAKE_CURRENT_BINARY_DIR}/../package/) +if(NOT NATIVE_BUILD) + target_link_libraries(mixer + homescreen + qtWindowmanagerWrapper + ) +endif() diff --git a/app/main.cpp b/app/main.cpp index 9c6339f..60b2951 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -30,8 +30,12 @@ #include #include #include +#ifndef NATIVE_BUILD #include #include +#else +#include +#endif #include "mixer.h" int main(int argc, char *argv[]) @@ -50,7 +54,7 @@ int main(int argc, char *argv[]) parser.process(app); QStringList positionalArguments = parser.positionalArguments(); - qmlRegisterType("Mixer", 1, 0, "Mixer"); + qmlRegisterType("Mixer", 1, 0, "Mixer"); QQmlApplicationEngine engine; if (positionalArguments.length() == 2) { @@ -68,6 +72,7 @@ int main(int argc, char *argv[]) context->setContextProperty(QStringLiteral("bindingAddress"), bindingAddress); std::string token = secret.toStdString(); +#ifndef NATIVE_BUILD LibHomeScreen* hs = new LibHomeScreen(); QLibWindowmanager* qwm = new QLibWindowmanager(); @@ -100,14 +105,30 @@ int main(int argc, char *argv[]) } } }); - +#endif engine.load(QUrl(QStringLiteral("qrc:/Mixer.qml"))); // Find the instantiated model QObject and connect the signals/slots - QList mobjs = engine.rootObjects(); + QList mobjs = engine.rootObjects(); + if (mobjs.empty()) + { + qDebug() << "[ERROR] Failed to load QML!"; + return -1; + } - QQuickWindow *window = qobject_cast(mobjs.first()); - QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface())); + QQuickWindow *window = qobject_cast(mobjs.first()); +#ifdef NATIVE_BUILD + window->setFlags(window->flags() & ~Qt::FramelessWindowHint); // Remove the borderless flag + window->setHeight(QGuiApplication::primaryScreen()->geometry().height()); +#else + QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface())); +#endif } + else + { + qDebug() << "[ERROR] No port and token specified!"; + return -1; + } + return app.exec(); } -- cgit 1.2.3-korg