Commit d3c05574 authored by Daniel Teske's avatar Daniel Teske
Browse files

Make Toolchain::makeCommand return a full path to the make command



Requires passing in the environment to use. Also now the mingw toolchain
has a fall back to make.exe on windows. And the msvc toolchain falls
back to nmake even if the "use Jom" option is used.

Task-number: QTCREATORBUG-7831

Change-Id: I850a96da41a380eef8c6992e27a72fb63958c456
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarPeter Kümmel <syntheticpp@gmx.net>
parent f89352d7
......@@ -152,13 +152,15 @@ QList<Utils::FileName> AndroidToolChain::suggestedMkspecList() const
return QList<Utils::FileName>()<< Utils::FileName::fromString(QLatin1String("android-g++"));
}
QString AndroidToolChain::makeCommand() const
QString AndroidToolChain::makeCommand(const Utils::Environment &env) const
{
#if defined(Q_OS_WIN)
return QLatin1String("ma-make.exe");
QString make = QLatin1String("ma-make.exe");
#else
return QLatin1String("make");
QString make = QLatin1String("make");
#endif
QString tmp = env.searchInPath(make);
return tmp.isEmpty() ? make : tmp;
}
void AndroidToolChain::setQtVersionId(int id)
......
......@@ -56,7 +56,7 @@ public:
QVariantMap toMap() const;
bool fromMap(const QVariantMap &data);
QList<Utils::FileName> suggestedMkspecList() const;
QString makeCommand() const;
QString makeCommand(const Utils::Environment &env) const;
void setQtVersionId(int);
int qtVersionId() const;
......
......@@ -189,7 +189,7 @@ bool MakeStep::init()
pp->setMacroExpander(bc->macroExpander());
pp->setEnvironment(bc->environment());
pp->setWorkingDirectory(bc->buildDirectory());
pp->setCommand(tc ? tc->makeCommand() : QLatin1String("make"));
pp->setCommand(tc ? tc->makeCommand(bc->environment()) : QLatin1String("make"));
pp->setArguments(arguments);
setOutputParser(new GnuMakeParser());
......@@ -295,6 +295,7 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) :
makeStep, SLOT(setAdditionalArguments(QString)));
connect(makeStep, SIGNAL(additionalArgumentsChanged(QString)),
this, SLOT(updateDetails()));
connect(m_makeStep->project(), SIGNAL(environmentChanged()), this, SLOT(updateDetails()));
}
QString MakeStepConfigWidget::displayName() const
......@@ -320,7 +321,7 @@ void MakeStepConfigWidget::updateDetails()
param.setMacroExpander(bc->macroExpander());
param.setEnvironment(bc->environment());
param.setWorkingDirectory(bc->buildDirectory());
param.setCommand(tc->makeCommand());
param.setCommand(tc->makeCommand(bc->environment()));
param.setArguments(arguments);
m_summaryText = param.summary(displayName());
} else {
......
......@@ -151,7 +151,7 @@ bool MakeStep::init()
pp->setEnvironment(bc->environment());
pp->setWorkingDirectory(bc->buildDirectory());
if (tc)
pp->setCommand(tc->makeCommand());
pp->setCommand(tc->makeCommand(bc->environment()));
else
pp->setCommand(QLatin1String("make"));
pp->setArguments(arguments);
......@@ -283,6 +283,7 @@ MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep)
connect(pro, SIGNAL(buildTargetsChanged()),
this, SLOT(buildTargetsChanged()));
connect(pro, SIGNAL(environmentChanged()), this, SLOT(updateDetails()));
}
void MakeStepConfigWidget::additionalArgumentsEdited()
......@@ -336,7 +337,7 @@ void MakeStepConfigWidget::updateDetails()
param.setMacroExpander(bc->macroExpander());
param.setEnvironment(bc->environment());
param.setWorkingDirectory(bc->buildDirectory());
param.setCommand(tc->makeCommand());
param.setCommand(tc->makeCommand(bc->environment()));
param.setArguments(arguments);
m_summaryText = param.summary(displayName());
} else {
......
......@@ -119,7 +119,7 @@ bool GenericMakeStep::init()
pp->setMacroExpander(bc->macroExpander());
pp->setWorkingDirectory(bc->buildDirectory());
pp->setEnvironment(bc->environment());
pp->setCommand(makeCommand());
pp->setCommand(makeCommand(bc->environment()));
pp->setArguments(allArguments());
// If we are cleaning, then make can fail with an error code, but that doesn't mean
......@@ -173,13 +173,13 @@ QString GenericMakeStep::allArguments() const
return args;
}
QString GenericMakeStep::makeCommand() const
QString GenericMakeStep::makeCommand(const Utils::Environment &environment) const
{
QString command = m_makeCommand;
if (command.isEmpty()) {
ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit());
if (tc)
command = tc->makeCommand();
command = tc->makeCommand(environment);
else
command = QLatin1String("make");
}
......@@ -264,6 +264,11 @@ GenericMakeStepConfigWidget::GenericMakeStepConfigWidget(GenericMakeStep *makeSt
connect(m_makeStep->target(), SIGNAL(kitChanged()),
this, SLOT(updateMakeOverrrideLabel()));
connect(pro, SIGNAL(environmentChanged()),
this, SLOT(updateMakeOverrrideLabel()));
connect(pro, SIGNAL(environmentChanged()),
this, SLOT(updateDetails()));
}
GenericMakeStepConfigWidget::~GenericMakeStepConfigWidget()
......@@ -278,7 +283,11 @@ QString GenericMakeStepConfigWidget::displayName() const
void GenericMakeStepConfigWidget::updateMakeOverrrideLabel()
{
m_ui->makeLabel->setText(tr("Override %1:").arg(m_makeStep->makeCommand()));
GenericBuildConfiguration *bc = m_makeStep->genericBuildConfiguration();
if (!bc)
bc = static_cast<GenericBuildConfiguration *>(m_makeStep->target()->activeBuildConfiguration());
m_ui->makeLabel->setText(tr("Override %1:").arg(m_makeStep->makeCommand(bc->environment())));
}
void GenericMakeStepConfigWidget::updateDetails()
......@@ -291,7 +300,7 @@ void GenericMakeStepConfigWidget::updateDetails()
param.setMacroExpander(bc->macroExpander());
param.setWorkingDirectory(bc->buildDirectory());
param.setEnvironment(bc->environment());
param.setCommand(m_makeStep->makeCommand());
param.setCommand(m_makeStep->makeCommand(bc->environment()));
param.setArguments(m_makeStep->allArguments());
m_summaryText = param.summary(displayName());
emit updateSummary();
......
......@@ -66,7 +66,7 @@ public:
bool buildsTarget(const QString &target) const;
void setBuildTarget(const QString &target, bool on);
QString allArguments() const;
QString makeCommand() const;
QString makeCommand(const Utils::Environment &environment) const;
void setClean(bool clean);
bool isClean() const;
......
......@@ -316,7 +316,7 @@ void MaemoPublisherFremantleFree::handleProcessFinished(bool failedToStart)
finishWithFailure(QString(), tr("Make distclean failed: %1")
.arg(ProjectExplorer::ToolChainKitInformation::msgNoToolChainInTarget()));
}
m_process->start(tc->makeCommand(), QStringList() << QLatin1String("distclean"));
m_process->start(tc->makeCommand(m_buildConfig->environment()), QStringList() << QLatin1String("distclean"));
}
break;
case RunningMakeDistclean:
......
......@@ -132,12 +132,25 @@ void AbstractMsvcToolChain::addToEnvironment(Utils::Environment &env) const
env = m_resultEnvironment;
}
QString AbstractMsvcToolChain::makeCommand() const
QString AbstractMsvcToolChain::makeCommand(const Utils::Environment &environment) const
{
if (ProjectExplorerPlugin::instance()->projectExplorerSettings().useJom) {
return findInstalledJom();
bool useJom = ProjectExplorerPlugin::instance()->projectExplorerSettings().useJom;
const QString jom = QLatin1String("jom.exe");
const QString nmake = QLatin1String("nmake.exe");
QString tmp;
if (useJom) {
tmp = environment.searchInPath(jom, QStringList()
<< QCoreApplication::applicationDirPath());
if (!tmp.isEmpty())
return tmp;
}
return QLatin1String("nmake.exe");
tmp = environment.searchInPath(nmake);
if (!tmp.isEmpty())
return tmp;
// Nothing found :(
return useJom ? jom : nmake;
}
Utils::FileName AbstractMsvcToolChain::compilerCommand() const
......@@ -266,23 +279,6 @@ bool AbstractMsvcToolChain::generateEnvironmentSettings(Utils::Environment &env,
return true;
}
QString AbstractMsvcToolChain::findInstalledJom()
{
if (Abi::hostAbi().os() != Abi::WindowsOS) {
qWarning() << "Jom can only be used on Windows";
return QString();
}
// We want jom! Try to find it.
const QString jom = QLatin1String("jom.exe");
const QFileInfo installedJom = QFileInfo(QCoreApplication::applicationDirPath()
+ QLatin1Char('/') + jom);
if (installedJom.isFile() && installedJom.isExecutable())
return installedJom.absoluteFilePath();
else
return jom;
}
bool AbstractMsvcToolChain::operator ==(const ToolChain &other) const
{
if (!ToolChain::operator ==(other))
......
......@@ -56,14 +56,13 @@ public:
QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const;
void addToEnvironment(Utils::Environment &env) const;
QString makeCommand() const;
QString makeCommand(const Utils::Environment &environment) const;
Utils::FileName compilerCommand() const;
IOutputParser *outputParser() const;
bool canClone() const;
QString varsBat() const { return m_vcvarsBat; }
static QString findInstalledJom();
bool operator ==(const ToolChain &) const;
......
......@@ -451,9 +451,11 @@ QList<FileName> GccToolChain::suggestedMkspecList() const
return QList<FileName>();
}
QString GccToolChain::makeCommand() const
QString GccToolChain::makeCommand(const Utils::Environment &environment) const
{
return QLatin1String("make");
QString make = QLatin1String("make");
QString tmp = environment.searchInPath(make);
return tmp.isEmpty() ? make : tmp;
}
IOutputParser *GccToolChain::outputParser() const
......@@ -763,13 +765,23 @@ QString ClangToolChain::typeDisplayName() const
return Internal::ClangToolChainFactory::tr("Clang");
}
QString ClangToolChain::makeCommand() const
QString ClangToolChain::makeCommand(const Utils::Environment &environment) const
{
QStringList makes;
#if defined(Q_OS_WIN)
return QLatin1String("mingw32-make.exe");
makes << QLatin1String("mingw32-make.exe");
makes << QLatin1String("make.exe");
#else
return QLatin1String("make");
makes << QLatin1String("make");
#endif
QString tmp;
foreach (const QString &make, makes) {
tmp = environment.searchInPath(make);
if (!tmp.isEmpty())
return tmp;
}
return makes.first();
}
QList<FileName> ClangToolChain::suggestedMkspecList() const
......@@ -882,13 +894,23 @@ QList<FileName> MingwToolChain::suggestedMkspecList() const
#endif
}
QString MingwToolChain::makeCommand() const
QString MingwToolChain::makeCommand(const Utils::Environment &environment) const
{
QStringList makes;
#ifdef Q_OS_WIN
return QLatin1String("mingw32-make.exe");
makes << QLatin1String("mingw32-make.exe");
makes << QLatin1String("make.exe");
#else
return QLatin1String("make");
makes << QLatin1String("make");
#endif
QString tmp;
foreach (const QString &make, makes) {
tmp = environment.searchInPath(make);
if (!tmp.isEmpty())
return tmp;
}
return makes.first();
}
ToolChain *MingwToolChain::clone() const
......
......@@ -66,7 +66,7 @@ public:
QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const;
void addToEnvironment(Utils::Environment &env) const;
QString makeCommand() const;
QString makeCommand(const Utils::Environment &environment) const;
QList<Utils::FileName> suggestedMkspecList() const;
IOutputParser *outputParser() const;
......@@ -120,7 +120,7 @@ class PROJECTEXPLORER_EXPORT ClangToolChain : public GccToolChain
public:
QString type() const;
QString typeDisplayName() const;
QString makeCommand() const;
QString makeCommand(const Utils::Environment &environment) const;
IOutputParser *outputParser() const;
......@@ -144,7 +144,7 @@ class PROJECTEXPLORER_EXPORT MingwToolChain : public GccToolChain
public:
QString type() const;
QString typeDisplayName() const;
QString makeCommand() const;
QString makeCommand(const Utils::Environment &environment) const;
ToolChain *clone() const;
......
......@@ -90,7 +90,7 @@ public:
virtual CompilerFlags compilerFlags(const QStringList &cxxflags) const = 0;
virtual QList<HeaderPath> systemHeaderPaths(const Utils::FileName &sysRoot) const = 0;
virtual void addToEnvironment(Utils::Environment &env) const = 0;
virtual QString makeCommand() const = 0;
virtual QString makeCommand(const Utils::Environment &env) const = 0;
virtual Utils::FileName compilerCommand() const = 0;
virtual QString defaultMakeTarget() const;
......
......@@ -162,7 +162,7 @@ bool MakeStep::init()
workingDirectory = bc->buildDirectory();
pp->setWorkingDirectory(workingDirectory);
QString makeCmd = tc->makeCommand();
QString makeCmd = tc->makeCommand(bc->environment());
if (!m_makeCmd.isEmpty())
makeCmd = m_makeCmd;
pp->setCommand(makeCmd);
......@@ -403,8 +403,12 @@ void MakeStepConfigWidget::updateDetails()
{
ToolChain *tc
= ToolChainKitInformation::toolChain(m_makeStep->target()->kit());
if (tc)
m_ui->makeLabel->setText(tr("Override %1:").arg(tc->makeCommand()));
Qt4BuildConfiguration *bc = m_makeStep->qt4BuildConfiguration();
if (!bc)
bc = qobject_cast<Qt4BuildConfiguration *>(m_makeStep->target()->activeBuildConfiguration());
if (tc && bc)
m_ui->makeLabel->setText(tr("Override %1:").arg(tc->makeCommand(bc->environment())));
else
m_ui->makeLabel->setText(tr("Make:"));
......@@ -412,9 +416,6 @@ void MakeStepConfigWidget::updateDetails()
setSummaryText(tr("<b>Make:</b> %1").arg(ProjectExplorer::ToolChainKitInformation::msgNoToolChainInTarget()));
return;
}
Qt4BuildConfiguration *bc = m_makeStep->qt4BuildConfiguration();
if (!bc)
bc = qobject_cast<Qt4BuildConfiguration *>(m_makeStep->target()->activeBuildConfiguration());
if (!bc) {
setSummaryText(tr("<b>Make:</b> No Qt4 build configuration."));
return;
......@@ -423,7 +424,7 @@ void MakeStepConfigWidget::updateDetails()
ProcessParameters param;
param.setMacroExpander(bc->macroExpander());
param.setWorkingDirectory(bc->buildDirectory());
QString makeCmd = tc->makeCommand();
QString makeCmd = tc->makeCommand(bc->environment());
if (!m_makeStep->makeCommand().isEmpty())
makeCmd = m_makeStep->makeCommand();
param.setCommand(makeCmd);
......
......@@ -111,7 +111,7 @@ DebuggingHelperBuildTask::DebuggingHelperBuildTask(const BaseQtVersion *version,
m_qmakeArguments << QLatin1String("CONFIG+=x86_64");
}
}
m_makeCommand = toolChain->makeCommand();
m_makeCommand = toolChain->makeCommand(m_environment);
m_mkspec = version->mkspec();
// Make sure QtVersion cache is invalidated
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment