forked from qt-creator/qt-creator
Share some code between gcc and gcce tool chains.
This commit is contained in:
@@ -149,6 +149,9 @@ QByteArray GccToolChain::predefinedMacros()
|
||||
<< QLatin1String("-");
|
||||
|
||||
QProcess cpp;
|
||||
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
cpp.setEnvironment(env.toStringList());
|
||||
cpp.start(m_gcc, arguments);
|
||||
cpp.closeWriteChannel();
|
||||
cpp.waitForFinished();
|
||||
@@ -167,6 +170,9 @@ QList<HeaderPath> GccToolChain::systemHeaderPaths()
|
||||
<< QLatin1String("-");
|
||||
|
||||
QProcess cpp;
|
||||
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
cpp.setEnvironment(env.toStringList());
|
||||
cpp.setReadChannelMode(QProcess::MergedChannels);
|
||||
cpp.start(m_gcc, arguments);
|
||||
cpp.closeWriteChannel();
|
||||
|
||||
@@ -108,8 +108,7 @@ protected:
|
||||
virtual bool equals(ToolChain *other) const = 0;
|
||||
};
|
||||
|
||||
namespace Internal {
|
||||
class GccToolChain : public ToolChain
|
||||
class PROJECTEXPLORER_EXPORT GccToolChain : public ToolChain
|
||||
{
|
||||
public:
|
||||
GccToolChain(const QString &gcc);
|
||||
@@ -122,14 +121,14 @@ public:
|
||||
|
||||
protected:
|
||||
virtual bool equals(ToolChain *other) const;
|
||||
private:
|
||||
QString m_gcc;
|
||||
QByteArray m_predefinedMacros;
|
||||
QList<HeaderPath> m_systemHeaderPaths;
|
||||
private:
|
||||
QString m_gcc;
|
||||
};
|
||||
|
||||
// TODO this class needs to fleshed out more
|
||||
class MinGWToolChain : public GccToolChain
|
||||
class PROJECTEXPLORER_EXPORT MinGWToolChain : public GccToolChain
|
||||
{
|
||||
public:
|
||||
MinGWToolChain(const QString &gcc, const QString &mingwPath);
|
||||
@@ -143,7 +142,7 @@ private:
|
||||
};
|
||||
|
||||
// TODO some stuff needs to be moved into this
|
||||
class MSVCToolChain : public ToolChain
|
||||
class PROJECTEXPLORER_EXPORT MSVCToolChain : public ToolChain
|
||||
{
|
||||
public:
|
||||
MSVCToolChain(const QString &name, bool amd64 = false);
|
||||
@@ -164,7 +163,7 @@ private:
|
||||
};
|
||||
|
||||
// TODO some stuff needs to be moved into here
|
||||
class WinCEToolChain : public MSVCToolChain
|
||||
class PROJECTEXPLORER_EXPORT WinCEToolChain : public MSVCToolChain
|
||||
{
|
||||
public:
|
||||
WinCEToolChain(const QString &name, const QString &platform);
|
||||
@@ -178,7 +177,6 @@ private:
|
||||
QString m_platform;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE(ProjectExplorer::ToolChain::ToolChainType);
|
||||
|
||||
@@ -14,7 +14,8 @@ namespace {
|
||||
}
|
||||
|
||||
GCCEToolChain::GCCEToolChain(S60Devices::Device device)
|
||||
: m_deviceId(device.id),
|
||||
: GccToolChain(QLatin1String(GCCE_COMMAND)),
|
||||
m_deviceId(device.id),
|
||||
m_deviceName(device.name),
|
||||
m_deviceRoot(device.epocRoot)
|
||||
{
|
||||
@@ -26,80 +27,9 @@ ToolChain::ToolChainType GCCEToolChain::type() const
|
||||
return ToolChain::GCCE;
|
||||
}
|
||||
|
||||
QByteArray GCCEToolChain::predefinedMacros()
|
||||
{
|
||||
if (m_predefinedMacros.isEmpty()) {
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("-xc++")
|
||||
<< QLatin1String("-E")
|
||||
<< QLatin1String("-dM")
|
||||
<< QLatin1String("-");
|
||||
|
||||
QProcess cpp;
|
||||
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
cpp.setEnvironment(env.toStringList());
|
||||
cpp.start(QLatin1String(GCCE_COMMAND), arguments);
|
||||
cpp.closeWriteChannel();
|
||||
cpp.waitForFinished();
|
||||
m_predefinedMacros = cpp.readAllStandardOutput();
|
||||
}
|
||||
return m_predefinedMacros;
|
||||
}
|
||||
|
||||
QList<HeaderPath> GCCEToolChain::systemHeaderPaths()
|
||||
{
|
||||
if (m_systemHeaderPaths.isEmpty()) {
|
||||
QStringList arguments;
|
||||
arguments << QLatin1String("-xc++")
|
||||
<< QLatin1String("-E")
|
||||
<< QLatin1String("-v")
|
||||
<< QLatin1String("-");
|
||||
|
||||
QProcess cpp;
|
||||
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
|
||||
addToEnvironment(env);
|
||||
cpp.setEnvironment(env.toStringList());
|
||||
cpp.setReadChannelMode(QProcess::MergedChannels);
|
||||
cpp.start(QLatin1String(GCCE_COMMAND), arguments);
|
||||
cpp.closeWriteChannel();
|
||||
cpp.waitForFinished();
|
||||
|
||||
QByteArray line;
|
||||
while (cpp.canReadLine()) {
|
||||
line = cpp.readLine();
|
||||
if (line.startsWith("#include"))
|
||||
break;
|
||||
}
|
||||
|
||||
if (! line.isEmpty() && line.startsWith("#include")) {
|
||||
HeaderPath::Kind kind = HeaderPath::UserHeaderPath;
|
||||
while (cpp.canReadLine()) {
|
||||
line = cpp.readLine();
|
||||
if (line.startsWith("#include")) {
|
||||
kind = HeaderPath::GlobalHeaderPath;
|
||||
} else if (! line.isEmpty() && QChar(line.at(0)).isSpace()) {
|
||||
HeaderPath::Kind thisHeaderKind = kind;
|
||||
|
||||
line = line.trimmed();
|
||||
if (line.endsWith('\n'))
|
||||
line.chop(1);
|
||||
|
||||
int index = line.indexOf(" (framework directory)");
|
||||
if (index != -1) {
|
||||
line = line.left(index);
|
||||
thisHeaderKind = HeaderPath::FrameworkHeaderPath;
|
||||
}
|
||||
|
||||
m_systemHeaderPaths.append(HeaderPath(QFile::decodeName(line), thisHeaderKind));
|
||||
} else if (line.startsWith("End of search list.")) {
|
||||
break;
|
||||
} else {
|
||||
qWarning() << "ignore line:" << line;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GccToolChain::systemHeaderPaths();
|
||||
m_systemHeaderPaths.append(HeaderPath(QString("%1\\epoc32\\include").arg(m_deviceRoot), HeaderPath::GlobalHeaderPath));
|
||||
m_systemHeaderPaths.append(HeaderPath(QString("%1\\epoc32\\include\\stdapis").arg(m_deviceRoot), HeaderPath::GlobalHeaderPath));
|
||||
m_systemHeaderPaths.append(HeaderPath(QString("%1\\epoc32\\include\\stdapis\\sys").arg(m_deviceRoot), HeaderPath::GlobalHeaderPath));
|
||||
|
||||
@@ -9,11 +9,10 @@
|
||||
namespace Qt4ProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class GCCEToolChain : public ProjectExplorer::ToolChain
|
||||
class GCCEToolChain : public ProjectExplorer::GccToolChain
|
||||
{
|
||||
public:
|
||||
GCCEToolChain(S60Devices::Device device);
|
||||
QByteArray predefinedMacros();
|
||||
QList<ProjectExplorer::HeaderPath> systemHeaderPaths();
|
||||
void addToEnvironment(ProjectExplorer::Environment &env);
|
||||
ProjectExplorer::ToolChain::ToolChainType type() const;
|
||||
@@ -29,8 +28,6 @@ private:
|
||||
QString m_deviceId;
|
||||
QString m_deviceName;
|
||||
QString m_deviceRoot;
|
||||
QByteArray m_predefinedMacros;
|
||||
QList<ProjectExplorer::HeaderPath> m_systemHeaderPaths;
|
||||
const ProjectExplorer::Project *m_project;
|
||||
};
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
* must probably be compiled for different toolchains
|
||||
|
||||
* Tool chains
|
||||
* derive GCCE tool chain from GCC toolchain to get the includes/defines
|
||||
implementation
|
||||
* delete toolchain in more intelligent way (create a new one and
|
||||
check if it's the same as the old one, has the advantage that
|
||||
cached data doesn't need to be retrieved again)
|
||||
|
||||
Reference in New Issue
Block a user