summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKalle Viironen <kalle.viironen@digia.com>2014-02-03 13:40:30 +0200
committerKalle Viironen <kalle.viironen@digia.com>2014-02-03 13:40:39 +0200
commit1e480819567a9e28cf525be0c05aae264fb0b516 (patch)
tree773b3278fc9b5d40f9ade9b8fa9a98723e346335
parentc7ff23c24a2ee2daf412efb6c4b80a3dd125db6d (diff)
parent94d952e6e963b9736c5e79f4ba9c9c0eb4f5c162 (diff)
Merge branch 'dev' into stable
-rw-r--r--appcontroller.pro19
-rw-r--r--main.cpp21
-rw-r--r--portlist.cpp29
-rw-r--r--portlist.h29
-rw-r--r--process.cpp95
-rw-r--r--process.h19
6 files changed, 170 insertions, 42 deletions
diff --git a/appcontroller.pro b/appcontroller.pro
index 7ad5acc..ac7eb83 100644
--- a/appcontroller.pro
+++ b/appcontroller.pro
@@ -15,3 +15,22 @@ android {
target.path = $$[INSTALL_ROOT]/usr/bin
}
INSTALLS+=target
+
+# Find out git hash
+unix:system(which git):HAS_GIT=TRUE
+win32:system(where git.exe):HAS_GIT=TRUE
+contains(HAS_GIT, TRUE) {
+ GIT_HASH=$$system(git log -1 --format=%H)
+ !system(git diff-index --quiet HEAD): GIT_HASH="$$GIT_HASH-dirty"
+ GIT_VERSION=$$system(git describe --tags --exact-match)
+ isEmpty(GIT_VERSION) : GIT_VERSION="unknown"
+} else {
+ GIT_HASH="unknown"
+ GIT_VERSION="unknown"
+}
+
+isEmpty(GIT_VERSION) : error("No suitable tag found")
+isEmpty(GIT_HASH) : error("No hash available")
+
+DEFINES+="GIT_HASH=\\\"$$GIT_HASH\\\""
+DEFINES+="GIT_VERSION=\\\"$$GIT_VERSION\\\""
diff --git a/main.cpp b/main.cpp
index 4802ac3..a1e0157 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,3 +1,21 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of QtEnterprise Embedded.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
#include "process.h"
#include "portlist.h"
#include <QCoreApplication>
@@ -254,6 +272,9 @@ int main(int argc, char **argv)
return 1;
} else if (arg == "--print-debug") {
config.flags |= Config::PrintDebugMessages;
+ } else if (arg == "--version") {
+ printf("Appcontroller version: " GIT_VERSION "\nGit revision: " GIT_HASH "\n");
+ return 0;
} else {
args.prepend(arg);
break;
diff --git a/portlist.cpp b/portlist.cpp
index 054a9a2..a7fbd97 100644
--- a/portlist.cpp
+++ b/portlist.cpp
@@ -1,29 +1,18 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
**
-** This file is part of Qt Creator.
+** This file is part of QtEnterprise Embedded.
**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and Digia.
**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
**
****************************************************************************/
diff --git a/portlist.h b/portlist.h
index 2146c39..0761c62 100644
--- a/portlist.h
+++ b/portlist.h
@@ -1,29 +1,18 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
**
-** This file is part of Qt Creator.
+** This file is part of QtEnterprise Embedded.
**
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
+** a written agreement between you and Digia.
**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
**
****************************************************************************/
diff --git a/process.cpp b/process.cpp
index 21cfb55..0f7d404 100644
--- a/process.cpp
+++ b/process.cpp
@@ -1,3 +1,21 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of QtEnterprise Embedded.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
#include "process.h"
#include <QCoreApplication>
#include <unistd.h>
@@ -160,11 +178,17 @@ void Process::finished(int exitCode, QProcess::ExitStatus exitStatus)
void Process::startup(QStringList args)
{
+#ifdef Q_OS_ANDROID
+ QProcessEnvironment pe = interactiveProcessEnvironment();
+#else
QProcessEnvironment pe = QProcessEnvironment::systemEnvironment();
+#endif
foreach (const QString &key, mConfig.env.keys()) {
- qDebug() << key << mConfig.env.value(key);
- pe.insert(key, mConfig.env.value(key));
+ if (!pe.contains(key)) {
+ qDebug() << key << mConfig.env.value(key);
+ pe.insert(key, mConfig.env.value(key));
+ }
}
if (!mConfig.base.isEmpty())
pe.insert(QLatin1String("B2QT_BASE"), mConfig.base);
@@ -221,3 +245,70 @@ void Process::setConfig(const Config &config)
{
mConfig = config;
}
+
+QProcessEnvironment Process::interactiveProcessEnvironment() const
+{
+ QProcessEnvironment env;
+
+ QProcess process;
+ process.start("sh");
+ if (!process.waitForStarted(3000)) {
+ printf("Could not start shell.\n");
+ return env;
+ }
+
+ process.write("source /system/etc/mkshrc\n");
+ process.write("export -p\n");
+ process.closeWriteChannel();
+
+ printf("waiting for process to finish\n");
+ if (!process.waitForFinished(1000)) {
+ printf("did not finish: terminate\n");
+ process.terminate();
+ if (!process.waitForFinished(1000)) {
+ printf("did not terminate: kill\n");
+ process.kill();
+ if (!process.waitForFinished(1000)) {
+ printf("Could not stop process.\n");
+ }
+ }
+ }
+
+ QList<QByteArray> list = process.readAllStandardOutput().split('\n');
+ if (list.isEmpty())
+ printf("Failed to read environment output\n");
+
+ foreach (QByteArray entry, list) {
+ if (entry.startsWith("export ")) {
+ entry = entry.mid(7);
+ } else if (entry.startsWith("declare -x ")) {
+ entry = entry.mid(11);
+ } else {
+ continue;
+ }
+
+ QByteArray key;
+ QByteArray value;
+ int index = entry.indexOf('=');
+
+ if (index > 0) {
+ key = entry.left(index);
+ value = entry.mid(index + 1);
+ } else {
+ key = entry;
+ // value is empty
+ }
+
+ // Remove simple escaping.
+ // This is not complete.
+ if (value.startsWith('\'') and value.endsWith('\''))
+ value = value.mid(1, value.size()-2);
+ else if (value.startsWith('"') and value.endsWith('"'))
+ value = value.mid(1, value.size()-2);
+
+ env.insert(key, value);
+ }
+
+ return env;
+}
+
diff --git a/process.h b/process.h
index 3ce5d96..bacfc41 100644
--- a/process.h
+++ b/process.h
@@ -1,3 +1,21 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc
+** All rights reserved.
+** For any questions to Digia, please use contact form at http://qt.digia.com
+**
+** This file is part of QtEnterprise Embedded.
+**
+** Licensees holding valid Qt Enterprise licenses may use this file in
+** accordance with the Qt Enterprise License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia.
+**
+** If you have questions regarding the use of this file, please use
+** contact form at http://qt.digia.com
+**
+****************************************************************************/
+
#include <QObject>
#include <QProcess>
#include <QMap>
@@ -45,6 +63,7 @@ private slots:
void incomingConnection(int);
private:
void startup(QStringList);
+ QProcessEnvironment interactiveProcessEnvironment() const;
QProcess *mProcess;
int mDebuggee;
bool mDebug;