summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@digia.com>2014-10-06 11:57:41 +0200
committerChristian Kandeler <christian.kandeler@digia.com>2014-10-06 12:16:58 +0200
commit698a6387f2705a1857a6ef2ed9e566f91faf76a6 (patch)
treeb5fbf3d39e10f0d551a8792511c32b23e599717d /src/lib
parentb3321f0b83e2c13d48ed810ba5a28e9bfcfc881d (diff)
downloadqbs-698a6387f2705a1857a6ef2ed9e566f91faf76a6.tar.gz
Add tools/architectures.h
The architecture-related functions do not belong into hostosinfo.h. What's even worse is that we currently include that private header in Qt Creator, which is a no-go. So introduce a new public header that supplies the required functionality. Change-Id: I413c1bcfdf799f3aa768ce5c116f0122da8ac81c Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/corelib/corelib.qbs2
-rw-r--r--src/lib/corelib/language/evaluatorscriptclass.cpp3
-rw-r--r--src/lib/corelib/qbs.h1
-rw-r--r--src/lib/corelib/tools/architectures.cpp106
-rw-r--r--src/lib/corelib/tools/architectures.h41
-rw-r--r--src/lib/corelib/tools/hostosinfo.h69
-rw-r--r--src/lib/corelib/tools/tools.pri3
7 files changed, 155 insertions, 70 deletions
diff --git a/src/lib/corelib/corelib.qbs b/src/lib/corelib/corelib.qbs
index f14a65757..297a09c0c 100644
--- a/src/lib/corelib/corelib.qbs
+++ b/src/lib/corelib/corelib.qbs
@@ -287,6 +287,7 @@ QbsLibrary {
name: "tools"
prefix: name + '/'
files: [
+ "architectures.cpp",
"buildgraphlocker.cpp",
"buildgraphlocker.h",
"buildoptions.cpp",
@@ -332,6 +333,7 @@ QbsLibrary {
name: "public tools headers"
prefix: "tools/"
files: [
+ "architectures.h",
"buildoptions.h",
"cleanoptions.h",
"codelocation.h",
diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp
index 788d75c7c..35ded7b2f 100644
--- a/src/lib/corelib/language/evaluatorscriptclass.cpp
+++ b/src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -36,6 +36,7 @@
#include "item.h"
#include "scriptengine.h"
#include "propertydeclaration.h"
+#include <tools/architectures.h>
#include <tools/hostosinfo.h>
#include <tools/qbsassert.h>
#include <tools/scripttools.h>
@@ -597,7 +598,7 @@ QScriptValue EvaluatorScriptClass::js_canonicalArchitecture(QScriptContext *cont
QLatin1String("canonicalArchitecture expects 1 argument"));
}
const QString architecture = context->argument(0).toString();
- return engine->toScriptValue(HostOsInfo::canonicalArchitecture(architecture));
+ return engine->toScriptValue(canonicalArchitecture(architecture));
}
} // namespace Internal
diff --git a/src/lib/corelib/qbs.h b/src/lib/corelib/qbs.h
index 6749fdbca..c71d9b9f7 100644
--- a/src/lib/corelib/qbs.h
+++ b/src/lib/corelib/qbs.h
@@ -34,6 +34,7 @@
#include "api/project.h"
#include "api/projectdata.h"
#include "logging/ilogsink.h"
+#include "tools/architectures.h"
#include "tools/buildoptions.h"
#include "tools/cleanoptions.h"
#include "tools/error.h"
diff --git a/src/lib/corelib/tools/architectures.cpp b/src/lib/corelib/tools/architectures.cpp
new file mode 100644
index 000000000..443ab0d76
--- /dev/null
+++ b/src/lib/corelib/tools/architectures.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Build Suite.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt 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 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.
+**
+** 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.
+**
+****************************************************************************/
+
+#include "architectures.h"
+
+#include <QMap>
+#include <QMapIterator>
+#include <QStringList>
+
+namespace qbs {
+
+QString canonicalArchitecture(const QString &architecture)
+{
+ QMap<QString, QStringList> archMap;
+ archMap.insert(QLatin1String("x86"), QStringList()
+ << QLatin1String("i386")
+ << QLatin1String("i486")
+ << QLatin1String("i586")
+ << QLatin1String("i686")
+ << QLatin1String("ia32")
+ << QLatin1String("ia-32")
+ << QLatin1String("x86_32")
+ << QLatin1String("x86-32")
+ << QLatin1String("intel32")
+ << QLatin1String("mingw32"));
+
+ archMap.insert(QLatin1String("x86_64"), QStringList()
+ << QLatin1String("x86-64")
+ << QLatin1String("x64")
+ << QLatin1String("amd64")
+ << QLatin1String("ia32e")
+ << QLatin1String("em64t")
+ << QLatin1String("intel64")
+ << QLatin1String("mingw64"));
+
+ archMap.insert(QLatin1String("ia64"), QStringList()
+ << QLatin1String("ia-64")
+ << QLatin1String("itanium"));
+
+ archMap.insert(QLatin1String("ppc"), QStringList()
+ << QLatin1String("powerpc"));
+
+ archMap.insert(QLatin1String("ppc64"), QStringList()
+ << QLatin1String("powerpc64"));
+
+ QMapIterator<QString, QStringList> i(archMap);
+ while (i.hasNext()) {
+ i.next();
+ if (i.value().contains(architecture.toLower()))
+ return i.key();
+ }
+
+ return architecture;
+
+}
+
+QString defaultEndianness(const QString &architecture)
+{
+ const QString canonicalArch = canonicalArchitecture(architecture);
+
+ QStringList little = QStringList()
+ << QLatin1String("x86")
+ << QLatin1String("x86_64")
+ << QLatin1String("arm")
+ << QLatin1String("arm64");
+
+ if (little.contains(canonicalArch))
+ return QLatin1String("little");
+
+ QStringList big = QStringList()
+ << QLatin1String("ppc")
+ << QLatin1String("ppc64");
+
+ if (big.contains(canonicalArch))
+ return QLatin1String("big");
+
+ return QString();
+}
+
+} // namespace qbs
diff --git a/src/lib/corelib/tools/architectures.h b/src/lib/corelib/tools/architectures.h
new file mode 100644
index 000000000..1fc4b5cb8
--- /dev/null
+++ b/src/lib/corelib/tools/architectures.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the Qt Build Suite.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt 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 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.
+**
+** 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.
+**
+****************************************************************************/
+#ifndef QBS_ARCHITECTURES_H
+#define QBS_ARCHITECTURES_H
+
+#include "qbs_export.h"
+
+namespace qbs {
+
+QBS_EXPORT QString canonicalArchitecture(const QString &architecture);
+QBS_EXPORT QString defaultEndianness(const QString &architecture);
+
+} // namespace qbs
+
+#endif // Include guard.
diff --git a/src/lib/corelib/tools/hostosinfo.h b/src/lib/corelib/tools/hostosinfo.h
index 6f556e661..68bcc251d 100644
--- a/src/lib/corelib/tools/hostosinfo.h
+++ b/src/lib/corelib/tools/hostosinfo.h
@@ -66,8 +66,6 @@ public:
static bool isLinuxHost() { return hostOs() == HostOsLinux; }
static bool isOsxHost() { return hostOs() == HostOsOsx; }
static inline bool isAnyUnixHost();
- static inline QString canonicalArchitecture(const QString &architecture);
- static inline QString defaultEndianness(const QString &architecture);
static QString appendExecutableSuffix(const QString &executable)
{
@@ -123,73 +121,6 @@ bool HostOsInfo::isAnyUnixHost()
#endif
}
-QString HostOsInfo::canonicalArchitecture(const QString &architecture)
-{
- QMap<QString, QStringList> archMap;
- archMap.insert(QLatin1String("x86"), QStringList()
- << QLatin1String("i386")
- << QLatin1String("i486")
- << QLatin1String("i586")
- << QLatin1String("i686")
- << QLatin1String("ia32")
- << QLatin1String("ia-32")
- << QLatin1String("x86_32")
- << QLatin1String("x86-32")
- << QLatin1String("intel32")
- << QLatin1String("mingw32"));
-
- archMap.insert(QLatin1String("x86_64"), QStringList()
- << QLatin1String("x86-64")
- << QLatin1String("x64")
- << QLatin1String("amd64")
- << QLatin1String("ia32e")
- << QLatin1String("em64t")
- << QLatin1String("intel64")
- << QLatin1String("mingw64"));
-
- archMap.insert(QLatin1String("ia64"), QStringList()
- << QLatin1String("ia-64")
- << QLatin1String("itanium"));
-
- archMap.insert(QLatin1String("ppc"), QStringList()
- << QLatin1String("powerpc"));
-
- archMap.insert(QLatin1String("ppc64"), QStringList()
- << QLatin1String("powerpc64"));
-
- QMapIterator<QString, QStringList> i(archMap);
- while (i.hasNext()) {
- i.next();
- if (i.value().contains(architecture.toLower()))
- return i.key();
- }
-
- return architecture;
-}
-
-QString HostOsInfo::defaultEndianness(const QString &architecture)
-{
- const QString canonicalArch = canonicalArchitecture(architecture);
-
- QStringList little = QStringList()
- << QLatin1String("x86")
- << QLatin1String("x86_64")
- << QLatin1String("arm")
- << QLatin1String("arm64");
-
- if (little.contains(canonicalArch))
- return QLatin1String("little");
-
- QStringList big = QStringList()
- << QLatin1String("ppc")
- << QLatin1String("ppc64");
-
- if (big.contains(canonicalArch))
- return QLatin1String("big");
-
- return QString();
-}
-
} // namespace Internal
} // namespace qbs
diff --git a/src/lib/corelib/tools/tools.pri b/src/lib/corelib/tools/tools.pri
index ed959daeb..a05efa8ca 100644
--- a/src/lib/corelib/tools/tools.pri
+++ b/src/lib/corelib/tools/tools.pri
@@ -1,6 +1,7 @@
INCLUDEPATH += $$PWD/../.. # for plugins
HEADERS += \
+ $$PWD/architectures.h \
$$PWD/buildgraphlocker.h \
$$PWD/codelocation.h \
$$PWD/error.h \
@@ -31,6 +32,7 @@ HEADERS += \
$$PWD/version.h
SOURCES += \
+ $$PWD/architectures.cpp \
$$PWD/buildgraphlocker.cpp \
$$PWD/codelocation.cpp \
$$PWD/error.cpp \
@@ -69,6 +71,7 @@ all_tests {
!qbs_no_dev_install {
tools_headers.files = \
+ $$PWD/architectures.h \
$$PWD/cleanoptions.h \
$$PWD/codelocation.h \
$$PWD/error.h \