aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Collignon <loic.collignon@iot.bzh>2018-07-02 15:38:32 +0200
committerLoïc Collignon <loic.collignon@iot.bzh>2018-07-05 14:18:51 +0200
commitaa44f33c00ba79f71d78f5e0b48cb584967cc461 (patch)
tree9e16f578f4451aa4299d571871bd04992add2c2c
parentd17d33074d8282553130b5f62eb71d82068c1a30 (diff)
Allow to build and run on native linux host
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 <loic.collignon@iot.bzh>
-rw-r--r--CMakeLists.txt1
-rw-r--r--app/CMakeLists.txt18
-rw-r--r--app/main.cpp31
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 f1ae467..b513a32 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 <QtQuick/qquickitem.h>
#include <QtQuick/qquickview.h>
#include <QQuickWindow>
+#ifndef NATIVE_BUILD
#include <libhomescreen.hpp>
#include <qlibwindowmanager.h>
+#else
+#include <QScreen>
+#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>("Mixer", 1, 0, "Mixer");
+ qmlRegisterType<Mixer>("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<QObject *> mobjs = engine.rootObjects();
+ QList<QObject*> mobjs = engine.rootObjects();
+ if (mobjs.empty())
+ {
+ qDebug() << "[ERROR] Failed to load QML!";
+ return -1;
+ }
- QQuickWindow *window = qobject_cast<QQuickWindow *>(mobjs.first());
- QObject::connect(window, SIGNAL(frameSwapped()), qwm, SLOT(slotActivateSurface()));
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(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();
}