Skip to content

Commit 1e48081

Browse files
author
Kalle Viironen
committed
Merge branch 'dev' into stable
Change-Id: Ifd34de3f6318a48d539980ce16da16a5a9665f71
2 parents c7ff23c + 94d952e commit 1e48081

File tree

6 files changed

+170
-42
lines changed

6 files changed

+170
-42
lines changed

appcontroller.pro

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,22 @@ android {
1515
target.path = $$[INSTALL_ROOT]/usr/bin
1616
}
1717
INSTALLS+=target
18+
19+
# Find out git hash
20+
unix:system(which git):HAS_GIT=TRUE
21+
win32:system(where git.exe):HAS_GIT=TRUE
22+
contains(HAS_GIT, TRUE) {
23+
GIT_HASH=$$system(git log -1 --format=%H)
24+
!system(git diff-index --quiet HEAD): GIT_HASH="$$GIT_HASH-dirty"
25+
GIT_VERSION=$$system(git describe --tags --exact-match)
26+
isEmpty(GIT_VERSION) : GIT_VERSION="unknown"
27+
} else {
28+
GIT_HASH="unknown"
29+
GIT_VERSION="unknown"
30+
}
31+
32+
isEmpty(GIT_VERSION) : error("No suitable tag found")
33+
isEmpty(GIT_HASH) : error("No hash available")
34+
35+
DEFINES+="GIT_HASH=\\\"$$GIT_HASH\\\""
36+
DEFINES+="GIT_VERSION=\\\"$$GIT_VERSION\\\""

main.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2013 Digia Plc
4+
** All rights reserved.
5+
** For any questions to Digia, please use contact form at http://qt.digia.com
6+
**
7+
** This file is part of QtEnterprise Embedded.
8+
**
9+
** Licensees holding valid Qt Enterprise licenses may use this file in
10+
** accordance with the Qt Enterprise License Agreement provided with the
11+
** Software or, alternatively, in accordance with the terms contained in
12+
** a written agreement between you and Digia.
13+
**
14+
** If you have questions regarding the use of this file, please use
15+
** contact form at http://qt.digia.com
16+
**
17+
****************************************************************************/
18+
119
#include "process.h"
220
#include "portlist.h"
321
#include <QCoreApplication>
@@ -254,6 +272,9 @@ int main(int argc, char **argv)
254272
return 1;
255273
} else if (arg == "--print-debug") {
256274
config.flags |= Config::PrintDebugMessages;
275+
} else if (arg == "--version") {
276+
printf("Appcontroller version: " GIT_VERSION "\nGit revision: " GIT_HASH "\n");
277+
return 0;
257278
} else {
258279
args.prepend(arg);
259280
break;

portlist.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
/****************************************************************************
22
**
3-
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4-
** Contact: http://www.qt-project.org/legal
3+
** Copyright (C) 2013 Digia Plc
4+
** All rights reserved.
5+
** For any questions to Digia, please use contact form at http://qt.digia.com
56
**
6-
** This file is part of Qt Creator.
7+
** This file is part of QtEnterprise Embedded.
78
**
8-
** Commercial License Usage
9-
** Licensees holding valid commercial Qt licenses may use this file in
10-
** accordance with the commercial license agreement provided with the
9+
** Licensees holding valid Qt Enterprise licenses may use this file in
10+
** accordance with the Qt Enterprise License Agreement provided with the
1111
** Software or, alternatively, in accordance with the terms contained in
12-
** a written agreement between you and Digia. For licensing terms and
13-
** conditions see http://qt.digia.com/licensing. For further information
14-
** use the contact form at http://qt.digia.com/contact-us.
12+
** a written agreement between you and Digia.
1513
**
16-
** GNU Lesser General Public License Usage
17-
** Alternatively, this file may be used under the terms of the GNU Lesser
18-
** General Public License version 2.1 as published by the Free Software
19-
** Foundation and appearing in the file LICENSE.LGPL included in the
20-
** packaging of this file. Please review the following information to
21-
** ensure the GNU Lesser General Public License version 2.1 requirements
22-
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23-
**
24-
** In addition, as a special exception, Digia gives you certain additional
25-
** rights. These rights are described in the Digia Qt LGPL Exception
26-
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
14+
** If you have questions regarding the use of this file, please use
15+
** contact form at http://qt.digia.com
2716
**
2817
****************************************************************************/
2918

portlist.h

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
/****************************************************************************
22
**
3-
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
4-
** Contact: http://www.qt-project.org/legal
3+
** Copyright (C) 2013 Digia Plc
4+
** All rights reserved.
5+
** For any questions to Digia, please use contact form at http://qt.digia.com
56
**
6-
** This file is part of Qt Creator.
7+
** This file is part of QtEnterprise Embedded.
78
**
8-
** Commercial License Usage
9-
** Licensees holding valid commercial Qt licenses may use this file in
10-
** accordance with the commercial license agreement provided with the
9+
** Licensees holding valid Qt Enterprise licenses may use this file in
10+
** accordance with the Qt Enterprise License Agreement provided with the
1111
** Software or, alternatively, in accordance with the terms contained in
12-
** a written agreement between you and Digia. For licensing terms and
13-
** conditions see http://qt.digia.com/licensing. For further information
14-
** use the contact form at http://qt.digia.com/contact-us.
12+
** a written agreement between you and Digia.
1513
**
16-
** GNU Lesser General Public License Usage
17-
** Alternatively, this file may be used under the terms of the GNU Lesser
18-
** General Public License version 2.1 as published by the Free Software
19-
** Foundation and appearing in the file LICENSE.LGPL included in the
20-
** packaging of this file. Please review the following information to
21-
** ensure the GNU Lesser General Public License version 2.1 requirements
22-
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23-
**
24-
** In addition, as a special exception, Digia gives you certain additional
25-
** rights. These rights are described in the Digia Qt LGPL Exception
26-
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
14+
** If you have questions regarding the use of this file, please use
15+
** contact form at http://qt.digia.com
2716
**
2817
****************************************************************************/
2918

process.cpp

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2013 Digia Plc
4+
** All rights reserved.
5+
** For any questions to Digia, please use contact form at http://qt.digia.com
6+
**
7+
** This file is part of QtEnterprise Embedded.
8+
**
9+
** Licensees holding valid Qt Enterprise licenses may use this file in
10+
** accordance with the Qt Enterprise License Agreement provided with the
11+
** Software or, alternatively, in accordance with the terms contained in
12+
** a written agreement between you and Digia.
13+
**
14+
** If you have questions regarding the use of this file, please use
15+
** contact form at http://qt.digia.com
16+
**
17+
****************************************************************************/
18+
119
#include "process.h"
220
#include <QCoreApplication>
321
#include <unistd.h>
@@ -160,11 +178,17 @@ void Process::finished(int exitCode, QProcess::ExitStatus exitStatus)
160178

161179
void Process::startup(QStringList args)
162180
{
181+
#ifdef Q_OS_ANDROID
182+
QProcessEnvironment pe = interactiveProcessEnvironment();
183+
#else
163184
QProcessEnvironment pe = QProcessEnvironment::systemEnvironment();
185+
#endif
164186

165187
foreach (const QString &key, mConfig.env.keys()) {
166-
qDebug() << key << mConfig.env.value(key);
167-
pe.insert(key, mConfig.env.value(key));
188+
if (!pe.contains(key)) {
189+
qDebug() << key << mConfig.env.value(key);
190+
pe.insert(key, mConfig.env.value(key));
191+
}
168192
}
169193
if (!mConfig.base.isEmpty())
170194
pe.insert(QLatin1String("B2QT_BASE"), mConfig.base);
@@ -221,3 +245,70 @@ void Process::setConfig(const Config &config)
221245
{
222246
mConfig = config;
223247
}
248+
249+
QProcessEnvironment Process::interactiveProcessEnvironment() const
250+
{
251+
QProcessEnvironment env;
252+
253+
QProcess process;
254+
process.start("sh");
255+
if (!process.waitForStarted(3000)) {
256+
printf("Could not start shell.\n");
257+
return env;
258+
}
259+
260+
process.write("source /system/etc/mkshrc\n");
261+
process.write("export -p\n");
262+
process.closeWriteChannel();
263+
264+
printf("waiting for process to finish\n");
265+
if (!process.waitForFinished(1000)) {
266+
printf("did not finish: terminate\n");
267+
process.terminate();
268+
if (!process.waitForFinished(1000)) {
269+
printf("did not terminate: kill\n");
270+
process.kill();
271+
if (!process.waitForFinished(1000)) {
272+
printf("Could not stop process.\n");
273+
}
274+
}
275+
}
276+
277+
QList<QByteArray> list = process.readAllStandardOutput().split('\n');
278+
if (list.isEmpty())
279+
printf("Failed to read environment output\n");
280+
281+
foreach (QByteArray entry, list) {
282+
if (entry.startsWith("export ")) {
283+
entry = entry.mid(7);
284+
} else if (entry.startsWith("declare -x ")) {
285+
entry = entry.mid(11);
286+
} else {
287+
continue;
288+
}
289+
290+
QByteArray key;
291+
QByteArray value;
292+
int index = entry.indexOf('=');
293+
294+
if (index > 0) {
295+
key = entry.left(index);
296+
value = entry.mid(index + 1);
297+
} else {
298+
key = entry;
299+
// value is empty
300+
}
301+
302+
// Remove simple escaping.
303+
// This is not complete.
304+
if (value.startsWith('\'') and value.endsWith('\''))
305+
value = value.mid(1, value.size()-2);
306+
else if (value.startsWith('"') and value.endsWith('"'))
307+
value = value.mid(1, value.size()-2);
308+
309+
env.insert(key, value);
310+
}
311+
312+
return env;
313+
}
314+

process.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
/****************************************************************************
2+
**
3+
** Copyright (C) 2013 Digia Plc
4+
** All rights reserved.
5+
** For any questions to Digia, please use contact form at http://qt.digia.com
6+
**
7+
** This file is part of QtEnterprise Embedded.
8+
**
9+
** Licensees holding valid Qt Enterprise licenses may use this file in
10+
** accordance with the Qt Enterprise License Agreement provided with the
11+
** Software or, alternatively, in accordance with the terms contained in
12+
** a written agreement between you and Digia.
13+
**
14+
** If you have questions regarding the use of this file, please use
15+
** contact form at http://qt.digia.com
16+
**
17+
****************************************************************************/
18+
119
#include <QObject>
220
#include <QProcess>
321
#include <QMap>
@@ -45,6 +63,7 @@ private slots:
4563
void incomingConnection(int);
4664
private:
4765
void startup(QStringList);
66+
QProcessEnvironment interactiveProcessEnvironment() const;
4867
QProcess *mProcess;
4968
int mDebuggee;
5069
bool mDebug;

0 commit comments

Comments
 (0)