aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Kampas <martin.kampas@jolla.com>2018-02-15 08:04:05 +0100
committerSvetlana Abramenkova <sabramenkova@luxoft.com>2020-02-17 17:09:19 +0300
commitc051f6446f4c80e24254ffa6e3bdf2286b2dc27a (patch)
treeb988658638462868ab8bf739e58f8a923b50a6b0
parent6b71d03501bd933eebc4ea4390711893ef82364c (diff)
Bench: Build to a bundle on macOS
Change-Id: Ibdd81551a409e3942fbd5530093fcb454c5f4157 Reviewed-by: Svetlana Abramenkova <sabramenkova@luxoft.com>
-rw-r--r--src/bench/Info.plist23
-rw-r--r--src/bench/bench.pro27
-rw-r--r--src/bench/cocoahelper.h34
-rw-r--r--src/bench/cocoahelper.mm40
-rw-r--r--src/bench/mac_wrapper.sh.in2
-rw-r--r--src/bench/main.cpp9
-rw-r--r--src/bench/options.cpp3
7 files changed, 136 insertions, 2 deletions
diff --git a/src/bench/Info.plist b/src/bench/Info.plist
new file mode 100644
index 0000000..51188a1
--- /dev/null
+++ b/src/bench/Info.plist
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+ <key>CFBundleIconFile</key>
+ <string>@ICON@</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleGetInfoString</key>
+ <string>Created by Qt/QMake</string>
+ <key>CFBundleSignature</key>
+ <string>@TYPEINFO@</string>
+ <key>CFBundleExecutable</key>
+ <string>@EXECUTABLE@</string>
+ <key>CFBundleIdentifier</key>
+ <string>@BUNDLEIDENTIFIER@</string>
+
+ <key>LSBackgroundOnly</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/src/bench/bench.pro b/src/bench/bench.pro
index 576973a..7fd356f 100644
--- a/src/bench/bench.pro
+++ b/src/bench/bench.pro
@@ -1,12 +1,19 @@
include(../../qmllive.pri)
TEMPLATE = app
-TARGET = qmllivebench
+macx*:TARGET = "QML Live Bench"
+else:TARGET = qmllivebench
DESTDIR = $$BUILD_DIR/bin
CONFIG += c++11
QT *= gui core quick widgets core-private
+macx* {
+ LIBS += -framework AppKit -framework Foundation
+ OBJECTIVE_SOURCES += cocoahelper.mm
+ HEADERS += cocoahelper.h
+}
+
SOURCES += \
aboutdialog.cpp \
main.cpp \
@@ -73,9 +80,25 @@ include(../widgets/widgets.pri)
include(../lib.pri)
# install rules
-macx*: CONFIG -= app_bundle
target.path = $$PREFIX/bin
INSTALLS += target
win32: RC_FILE = ../../icons/appicon.rc
macx*: ICON = ../../icons/appicon.icns
+
+DISTFILES += mac_wrapper.sh.in
+
+macx* {
+ QMAKE_INFO_PLIST = $$PWD/Info.plist
+
+ make_wrapper.target = $${DESTDIR}/qmllivebench
+ make_wrapper.depends = $$PWD/mac_wrapper.sh.in
+ make_wrapper.commands = sed \"s/%TARGET%/$${TARGET}/g\" $${make_wrapper.depends} > $${make_wrapper.target} \
+ && chmod +x $${make_wrapper.target}
+ QMAKE_EXTRA_TARGETS += make_wrapper
+ PRE_TARGETDEPS += $${make_wrapper.target}
+ wrapper.files = $${make_wrapper.target}
+ wrapper.path = $${target.path}
+ wrapper.CONFIG += no_check_exist executable
+ INSTALLS += wrapper
+}
diff --git a/src/bench/cocoahelper.h b/src/bench/cocoahelper.h
new file mode 100644
index 0000000..9c14a13
--- /dev/null
+++ b/src/bench/cocoahelper.h
@@ -0,0 +1,34 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Jolla Ltd
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QmlLive tool.
+**
+** $QT_BEGIN_LICENSE:GPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: GPL-3.0
+**
+****************************************************************************/
+
+#pragma once
+
+void transformToForegroundApplication();
diff --git a/src/bench/cocoahelper.mm b/src/bench/cocoahelper.mm
new file mode 100644
index 0000000..5808507
--- /dev/null
+++ b/src/bench/cocoahelper.mm
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 Jolla Ltd
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QmlLive tool.
+**
+** $QT_BEGIN_LICENSE:GPL-QTAS$
+** Commercial License Usage
+** Licensees holding valid commercial Qt Automotive Suite licenses may use
+** this file in accordance with the commercial license agreement provided
+** with the Software or, alternatively, in accordance with the terms
+** contained in a written agreement between you and The Qt Company. For
+** licensing terms and conditions see https://www.qt.io/terms-conditions.
+** For further information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 or (at your option) any later version
+** approved by the KDE Free Qt Foundation. The licenses are as published by
+** the Free Software Foundation and appearing in the file LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+** SPDX-License-Identifier: GPL-3.0
+**
+****************************************************************************/
+
+#include <Cocoa/Cocoa.h>
+
+#include "cocoahelper.h"
+
+void transformToForegroundApplication() {
+ ProcessSerialNumber psn;
+ if (GetCurrentProcess(&psn) == noErr)
+ TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+}
diff --git a/src/bench/mac_wrapper.sh.in b/src/bench/mac_wrapper.sh.in
new file mode 100644
index 0000000..9eb147b
--- /dev/null
+++ b/src/bench/mac_wrapper.sh.in
@@ -0,0 +1,2 @@
+#!/bin/bash
+exec "$(dirname "$0")/%TARGET%.app/Contents/MacOS/%TARGET%" "$@"
diff --git a/src/bench/main.cpp b/src/bench/main.cpp
index 4485cdf..41b8d41 100644
--- a/src/bench/main.cpp
+++ b/src/bench/main.cpp
@@ -45,6 +45,10 @@
#include <signal.h>
+#ifdef Q_OS_MACOS
+#include "cocoahelper.h"
+#endif
+
class Application : public QApplication
{
Q_OBJECT
@@ -126,6 +130,11 @@ Application *Application::create(int &argc, char **argv)
// Cannot instantiate the actual application yet
parseArguments(QCoreApplication(argc, argv).arguments(), s_options = new Options);
+#ifdef Q_OS_MACOS
+ if (isMaster() && !s_options->remoteOnly() && !s_options->hasNoninteractiveOptions())
+ transformToForegroundApplication();
+#endif
+
if (isMaster())
return new MasterApplication(argc, argv);
else
diff --git a/src/bench/options.cpp b/src/bench/options.cpp
index fe79e53..05d7a52 100644
--- a/src/bench/options.cpp
+++ b/src/bench/options.cpp
@@ -46,6 +46,9 @@ Options::Options(QObject *parent)
bool Options::hasNoninteractiveOptions() const
{
+ if (m_ping)
+ return true;
+
if (!m_hostsToAdd.isEmpty())
return true;