Share some code between gcc and gcce tool chains.

This commit is contained in:
con
2009-07-14 12:14:58 +02:00
parent 37a146d05c
commit d0627b1b95
5 changed files with 16 additions and 87 deletions

View File

@@ -149,6 +149,9 @@ QByteArray GccToolChain::predefinedMacros()
<< QLatin1String("-"); << QLatin1String("-");
QProcess cpp; QProcess cpp;
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
addToEnvironment(env);
cpp.setEnvironment(env.toStringList());
cpp.start(m_gcc, arguments); cpp.start(m_gcc, arguments);
cpp.closeWriteChannel(); cpp.closeWriteChannel();
cpp.waitForFinished(); cpp.waitForFinished();
@@ -167,6 +170,9 @@ QList<HeaderPath> GccToolChain::systemHeaderPaths()
<< QLatin1String("-"); << QLatin1String("-");
QProcess cpp; QProcess cpp;
ProjectExplorer::Environment env = ProjectExplorer::Environment::systemEnvironment();
addToEnvironment(env);
cpp.setEnvironment(env.toStringList());
cpp.setReadChannelMode(QProcess::MergedChannels); cpp.setReadChannelMode(QProcess::MergedChannels);
cpp.start(m_gcc, arguments); cpp.start(m_gcc, arguments);
cpp.closeWriteChannel(); cpp.closeWriteChannel();

View File

@@ -108,8 +108,7 @@ protected:
virtual bool equals(ToolChain *other) const = 0; virtual bool equals(ToolChain *other) const = 0;
}; };
namespace Internal { class PROJECTEXPLORER_EXPORT GccToolChain : public ToolChain
class GccToolChain : public ToolChain
{ {
public: public:
GccToolChain(const QString &gcc); GccToolChain(const QString &gcc);
@@ -122,14 +121,14 @@ public:
protected: protected:
virtual bool equals(ToolChain *other) const; virtual bool equals(ToolChain *other) const;
private:
QString m_gcc;
QByteArray m_predefinedMacros; QByteArray m_predefinedMacros;
QList<HeaderPath> m_systemHeaderPaths; QList<HeaderPath> m_systemHeaderPaths;
private:
QString m_gcc;
}; };
// TODO this class needs to fleshed out more // TODO this class needs to fleshed out more
class MinGWToolChain : public GccToolChain class PROJECTEXPLORER_EXPORT MinGWToolChain : public GccToolChain
{ {
public: public:
MinGWToolChain(const QString &gcc, const QString &mingwPath); MinGWToolChain(const QString &gcc, const QString &mingwPath);
@@ -143,7 +142,7 @@ private:
}; };
// TODO some stuff needs to be moved into this // TODO some stuff needs to be moved into this
class MSVCToolChain : public ToolChain class PROJECTEXPLORER_EXPORT MSVCToolChain : public ToolChain
{ {
public: public:
MSVCToolChain(const QString &name, bool amd64 = false); MSVCToolChain(const QString &name, bool amd64 = false);
@@ -164,7 +163,7 @@ private:
}; };
// TODO some stuff needs to be moved into here // TODO some stuff needs to be moved into here
class WinCEToolChain : public MSVCToolChain class PROJECTEXPLORER_EXPORT WinCEToolChain : public MSVCToolChain
{ {
public: public:
WinCEToolChain(const QString &name, const QString &platform); WinCEToolChain(const QString &name, const QString &platform);
@@ -178,7 +177,6 @@ private:
QString m_platform; QString m_platform;
}; };
}
} }
Q_DECLARE_METATYPE(ProjectExplorer::ToolChain::ToolChainType); Q_DECLARE_METATYPE(ProjectExplorer::ToolChain::ToolChainType);

View File

@@ -14,7 +14,8 @@ namespace {
} }
GCCEToolChain::GCCEToolChain(S60Devices::Device device) GCCEToolChain::GCCEToolChain(S60Devices::Device device)
: m_deviceId(device.id), : GccToolChain(QLatin1String(GCCE_COMMAND)),
m_deviceId(device.id),
m_deviceName(device.name), m_deviceName(device.name),
m_deviceRoot(device.epocRoot) m_deviceRoot(device.epocRoot)
{ {
@@ -26,80 +27,9 @@ ToolChain::ToolChainType GCCEToolChain::type() const
return ToolChain::GCCE; 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() QList<HeaderPath> GCCEToolChain::systemHeaderPaths()
{ {
if (m_systemHeaderPaths.isEmpty()) { GccToolChain::systemHeaderPaths();
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;
}
}
}
}
m_systemHeaderPaths.append(HeaderPath(QString("%1\\epoc32\\include").arg(m_deviceRoot), HeaderPath::GlobalHeaderPath)); 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").arg(m_deviceRoot), HeaderPath::GlobalHeaderPath));
m_systemHeaderPaths.append(HeaderPath(QString("%1\\epoc32\\include\\stdapis\\sys").arg(m_deviceRoot), HeaderPath::GlobalHeaderPath)); m_systemHeaderPaths.append(HeaderPath(QString("%1\\epoc32\\include\\stdapis\\sys").arg(m_deviceRoot), HeaderPath::GlobalHeaderPath));

View File

@@ -9,11 +9,10 @@
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
namespace Internal { namespace Internal {
class GCCEToolChain : public ProjectExplorer::ToolChain class GCCEToolChain : public ProjectExplorer::GccToolChain
{ {
public: public:
GCCEToolChain(S60Devices::Device device); GCCEToolChain(S60Devices::Device device);
QByteArray predefinedMacros();
QList<ProjectExplorer::HeaderPath> systemHeaderPaths(); QList<ProjectExplorer::HeaderPath> systemHeaderPaths();
void addToEnvironment(ProjectExplorer::Environment &env); void addToEnvironment(ProjectExplorer::Environment &env);
ProjectExplorer::ToolChain::ToolChainType type() const; ProjectExplorer::ToolChain::ToolChainType type() const;
@@ -29,8 +28,6 @@ private:
QString m_deviceId; QString m_deviceId;
QString m_deviceName; QString m_deviceName;
QString m_deviceRoot; QString m_deviceRoot;
QByteArray m_predefinedMacros;
QList<ProjectExplorer::HeaderPath> m_systemHeaderPaths;
const ProjectExplorer::Project *m_project; const ProjectExplorer::Project *m_project;
}; };

View File

@@ -13,8 +13,6 @@
* must probably be compiled for different toolchains * must probably be compiled for different toolchains
* Tool chains * 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 * 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 check if it's the same as the old one, has the advantage that
cached data doesn't need to be retrieved again) cached data doesn't need to be retrieved again)