summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/application.cpp4
-rw-r--r--src/app/application.h4
-rw-r--r--src/app/main.cpp61
-rw-r--r--src/jomlib/commandexecutor.cpp33
-rw-r--r--src/jomlib/commandexecutor.h9
-rw-r--r--src/jomlib/dependencygraph.cpp4
-rw-r--r--src/jomlib/dependencygraph.h4
-rw-r--r--src/jomlib/exception.cpp4
-rw-r--r--src/jomlib/exception.h4
-rw-r--r--src/jomlib/fastfileinfo.cpp4
-rw-r--r--src/jomlib/fastfileinfo.h4
-rw-r--r--src/jomlib/filetime.cpp4
-rw-r--r--src/jomlib/filetime.h5
-rw-r--r--src/jomlib/helperfunctions.cpp4
-rw-r--r--src/jomlib/helperfunctions.h4
-rw-r--r--src/jomlib/iocompletionport.cpp4
-rw-r--r--src/jomlib/iocompletionport.h4
-rw-r--r--src/jomlib/jobclient.cpp114
-rw-r--r--src/jomlib/jobclient.h69
-rw-r--r--src/jomlib/jobclientacquirehelper.cpp40
-rw-r--r--src/jomlib/jobclientacquirehelper.h47
-rw-r--r--src/jomlib/jobserver.cpp70
-rw-r--r--src/jomlib/jobserver.h51
-rw-r--r--src/jomlib/jomlib.pro30
-rw-r--r--src/jomlib/macrotable.cpp4
-rw-r--r--src/jomlib/macrotable.h4
-rw-r--r--src/jomlib/makefile.cpp4
-rw-r--r--src/jomlib/makefile.h4
-rw-r--r--src/jomlib/makefilefactory.cpp4
-rw-r--r--src/jomlib/makefilefactory.h4
-rw-r--r--src/jomlib/makefilelinereader.cpp4
-rw-r--r--src/jomlib/makefilelinereader.h4
-rw-r--r--src/jomlib/options.cpp4
-rw-r--r--src/jomlib/options.h4
-rw-r--r--src/jomlib/parser.cpp4
-rw-r--r--src/jomlib/parser.h4
-rw-r--r--src/jomlib/ppexpr-lex.inc73
-rw-r--r--src/jomlib/ppexpr.g4
-rw-r--r--src/jomlib/ppexpr.l4
-rw-r--r--src/jomlib/ppexpr_grammar.cpp104
-rw-r--r--src/jomlib/ppexpr_grammar_p.h4
-rw-r--r--src/jomlib/preprocessor.cpp4
-rw-r--r--src/jomlib/preprocessor.h4
-rw-r--r--src/jomlib/process.cpp4
-rw-r--r--src/jomlib/process.h4
-rw-r--r--src/jomlib/process_qt.cpp4
-rw-r--r--src/jomlib/processenvironment.h4
-rw-r--r--src/jomlib/stable.h4
-rw-r--r--src/jomlib/targetexecutor.cpp162
-rw-r--r--src/jomlib/targetexecutor.h19
50 files changed, 726 insertions, 301 deletions
diff --git a/src/app/application.cpp b/src/app/application.cpp
index 54baedb..2cc98aa 100644
--- a/src/app/application.cpp
+++ b/src/app/application.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/app/application.h b/src/app/application.h
index 1b3618b..b8fa181 100644
--- a/src/app/application.h
+++ b/src/app/application.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/app/main.cpp b/src/app/main.cpp
index 16882ca..3ed24af 100644
--- a/src/app/main.cpp
+++ b/src/app/main.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
@@ -19,6 +19,7 @@
****************************************************************************/
#include "application.h"
#include <helperfunctions.h>
+#include <jobserver.h>
#include <options.h>
#include <parser.h>
#include <preprocessor.h>
@@ -42,8 +43,8 @@
using namespace NMakeFile;
const int nVersionMajor = 1;
-const int nVersionMinor = 0;
-const int nVersionPatch = 16;
+const int nVersionMinor = 1;
+const int nVersionPatch = 0;
static void showLogo()
{
@@ -107,6 +108,42 @@ QStringList getCommandLineArguments()
return commandLineArguments;
}
+static bool initJobServer(const Application &app, ProcessEnvironment *environment,
+ JobServer **outJobServer)
+{
+ bool mustCreateJobServer = false;
+ if (app.isSubJOM()) {
+ int inheritedMaxNumberOfJobs = g_options.maxNumberOfJobs;
+ const QString str = environment->value(QLatin1String("_JOMJOBCOUNT_"));
+ if (!str.isEmpty()) {
+ bool ok;
+ const int n = str.toInt(&ok);
+ if (ok && n > 0)
+ inheritedMaxNumberOfJobs = n;
+ }
+ if (g_options.isMaxNumberOfJobsSet
+ && g_options.maxNumberOfJobs != inheritedMaxNumberOfJobs)
+ {
+ fprintf(stderr, "jom: Overriding inherited number of jobs %d with %d. "
+ "New jobserver created.\n",
+ inheritedMaxNumberOfJobs, g_options.maxNumberOfJobs);
+ mustCreateJobServer = true;
+ }
+ } else {
+ mustCreateJobServer = true;
+ }
+
+ if (mustCreateJobServer) {
+ JobServer *jobServer = new JobServer(environment);
+ *outJobServer = jobServer;
+ if (!jobServer->start(g_options.maxNumberOfJobs)) {
+ fprintf(stderr, "Cannot start job server: %s.", qPrintable(jobServer->errorString()));
+ return false;
+ }
+ }
+ return true;
+}
+
int main(int argc, char* argv[])
{
int result = 0;
@@ -152,15 +189,11 @@ int main(int argc, char* argv[])
mkfile->dumpTargets();
}
- // ### HACK: pass the modified MAKEFLAGS variable to our environment.
- if (g_options.isMaxNumberOfJobsSet) {
- ProcessEnvironment environment = mkfile->macroTable()->environment();
- const QString makeFlags = mkfile->macroTable()->macroValue(QLatin1String("MAKEFLAGS"));
- environment[QLatin1String("MAKEFLAGS")] = makeFlags;
- MacroTable *mt = const_cast<MacroTable *>(mkfile->macroTable());
- mt->setEnvironment(environment);
- qSetEnvironmentVariable(QLatin1String("MAKEFLAGS"), makeFlags);
- }
+ JobServer *jobServer = 0;
+ ProcessEnvironment processEnvironment = mkfile->macroTable()->environment();
+ if (!initJobServer(app, &processEnvironment, &jobServer))
+ return 3;
+ QScopedPointer<JobServer> jobServerDeleter(jobServer);
if (options->printWorkingDir) {
printf("jom: Entering directory '%s\n",
@@ -168,7 +201,7 @@ int main(int argc, char* argv[])
fflush(stdout);
}
- TargetExecutor executor(mkfile->macroTable()->environment());
+ TargetExecutor executor(processEnvironment);
QObject::connect(&executor, SIGNAL(finished(int)), &app, SLOT(exit(int)));
g_pTargetExecutor = &executor;
executor.apply(mkfile.data(), mf.activeTargets());
diff --git a/src/jomlib/commandexecutor.cpp b/src/jomlib/commandexecutor.cpp
index 99c8832..f007e18 100644
--- a/src/jomlib/commandexecutor.cpp
+++ b/src/jomlib/commandexecutor.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
@@ -38,8 +38,6 @@ QString CommandExecutor::m_tempPath;
CommandExecutor::CommandExecutor(QObject* parent, const ProcessEnvironment &environment)
: QObject(parent),
m_pTarget(0),
- m_blocked(false),
- m_processFinishedWhileBlocked(false),
m_ignoreProcessErrors(false),
m_active(false)
{
@@ -86,22 +84,6 @@ void CommandExecutor::start(DescriptionBlock* target)
executeCurrentCommandLine();
}
-void CommandExecutor::block()
-{
- m_blocked = true;
-}
-
-void CommandExecutor::unblock()
-{
- if (m_blocked) {
- m_blocked = false;
- if (m_processFinishedWhileBlocked) {
- m_processFinishedWhileBlocked = false;
- onProcessFinished(m_process.exitCode(), m_process.exitStatus());
- }
- }
-}
-
void CommandExecutor::onProcessError(Process::ProcessError error)
{
//qDebug() << "onProcessError" << error;
@@ -112,11 +94,6 @@ void CommandExecutor::onProcessError(Process::ProcessError error)
void CommandExecutor::onProcessFinished(int exitCode, Process::ExitStatus exitStatus)
{
//qDebug() << "onProcessFinished" << m_pTarget->m_targetName;
- if (m_blocked) {
- m_processFinishedWhileBlocked = true;
- return;
- }
-
if (exitStatus != Process::NormalExit)
exitCode = 2;
@@ -170,11 +147,8 @@ static bool startsWithShellBuiltin(const QString &commandLine)
void CommandExecutor::executeCurrentCommandLine()
{
- m_processFinishedWhileBlocked = false;
const Command& cmd = m_pTarget->m_commands.at(m_currentCommandIdx);
QString commandLine = cmd.m_commandLine;
- int jomCallIdx = commandLine.indexOf(m_pTarget->makefile()->options()->fullAppPath);
- bool spawnJOM = (jomCallIdx >= 0);
if (m_pTarget->makefile()->options()->dryRun
|| (!cmd.m_silent && !m_pTarget->makefile()->options()->suppressExecutedCommandsDisplay))
@@ -230,9 +204,6 @@ void CommandExecutor::executeCurrentCommandLine()
}
}
- if (spawnJOM)
- emit subJomStarted();
-
bool executionSucceeded = false;
if (simpleCmdLine && !startsWithShellBuiltin(commandLine)) {
// ### It would be cool if we would not try to start every command directly.
diff --git a/src/jomlib/commandexecutor.h b/src/jomlib/commandexecutor.h
index 61be592..22bce72 100644
--- a/src/jomlib/commandexecutor.h
+++ b/src/jomlib/commandexecutor.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
@@ -41,8 +41,6 @@ public:
void start(DescriptionBlock* target);
DescriptionBlock* target() { return m_pTarget; }
- void block();
- void unblock();
bool isActive() const { return m_active; }
void waitForFinished();
void cleanupTempFiles();
@@ -55,7 +53,6 @@ public slots:
signals:
void environmentChanged(const ProcessEnvironment &environment);
void finished(CommandExecutor* process, bool abortMakeProcess);
- void subJomStarted();
private slots:
void onProcessError(Process::ProcessError error);
@@ -76,8 +73,6 @@ private:
static QString m_tempPath;
Process m_process;
DescriptionBlock* m_pTarget;
- bool m_blocked;
- bool m_processFinishedWhileBlocked;
struct TempFile
{
diff --git a/src/jomlib/dependencygraph.cpp b/src/jomlib/dependencygraph.cpp
index b6c51d7..9396910 100644
--- a/src/jomlib/dependencygraph.cpp
+++ b/src/jomlib/dependencygraph.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/dependencygraph.h b/src/jomlib/dependencygraph.h
index 0c7f862..4d9f991 100644
--- a/src/jomlib/dependencygraph.h
+++ b/src/jomlib/dependencygraph.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/exception.cpp b/src/jomlib/exception.cpp
index 60da2a1..744ef5b 100644
--- a/src/jomlib/exception.cpp
+++ b/src/jomlib/exception.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/exception.h b/src/jomlib/exception.h
index 9419baf..233d7be 100644
--- a/src/jomlib/exception.h
+++ b/src/jomlib/exception.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/fastfileinfo.cpp b/src/jomlib/fastfileinfo.cpp
index efa3f21..fef1497 100644
--- a/src/jomlib/fastfileinfo.cpp
+++ b/src/jomlib/fastfileinfo.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/fastfileinfo.h b/src/jomlib/fastfileinfo.h
index f84ab34..bf816e5 100644
--- a/src/jomlib/fastfileinfo.h
+++ b/src/jomlib/fastfileinfo.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/filetime.cpp b/src/jomlib/filetime.cpp
index a36a3a9..d749c6b 100644
--- a/src/jomlib/filetime.cpp
+++ b/src/jomlib/filetime.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/filetime.h b/src/jomlib/filetime.h
index b2149ba..d9d159c 100644
--- a/src/jomlib/filetime.h
+++ b/src/jomlib/filetime.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
@@ -50,6 +50,7 @@ public:
void clear();
bool isValid() const;
QString toString() const;
+ InternalType internalRepresentation() const { return m_fileTime; }
static FileTime currentTime();
diff --git a/src/jomlib/helperfunctions.cpp b/src/jomlib/helperfunctions.cpp
index a34885e..b17af33 100644
--- a/src/jomlib/helperfunctions.cpp
+++ b/src/jomlib/helperfunctions.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/helperfunctions.h b/src/jomlib/helperfunctions.h
index dbf630e..b72e85c 100644
--- a/src/jomlib/helperfunctions.h
+++ b/src/jomlib/helperfunctions.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/iocompletionport.cpp b/src/jomlib/iocompletionport.cpp
index e2f0d3a..6bbf9d7 100644
--- a/src/jomlib/iocompletionport.cpp
+++ b/src/jomlib/iocompletionport.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/iocompletionport.h b/src/jomlib/iocompletionport.h
index 91aea49..91d49d0 100644
--- a/src/jomlib/iocompletionport.h
+++ b/src/jomlib/iocompletionport.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/jobclient.cpp b/src/jomlib/jobclient.cpp
new file mode 100644
index 0000000..4391794
--- /dev/null
+++ b/src/jomlib/jobclient.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
+ **
+ ** This file is part of the jom project on Trolltech Labs.
+ **
+ ** This file may be used under the terms of the GNU General Public
+ ** License version 2.0 or 3.0 as published by the Free Software Foundation
+ ** and appearing in the file LICENSE.GPL included in the packaging of
+ ** this file. Please review the following information to ensure GNU
+ ** General Public Licensing requirements will be met:
+ ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+ ** http://www.gnu.org/copyleft/gpl.html.
+ **
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ **
+ ****************************************************************************/
+
+#include "jobclient.h"
+#include "jobclientacquirehelper.h"
+#include "helperfunctions.h"
+
+#include <QSystemSemaphore>
+#include <QThread>
+
+namespace NMakeFile {
+
+JobClient::JobClient(ProcessEnvironment *environment, QObject *parent)
+ : QObject(parent)
+ , m_environment(environment)
+ , m_semaphore(0)
+ , m_acquireThread(new QThread(this))
+ , m_acquireHelper(0)
+ , m_isAcquiring(false)
+{
+}
+
+JobClient::~JobClient()
+{
+ if (isAcquiring())
+ qWarning("JobClient destroyed while still acquiring.");
+ m_acquireThread->quit();
+ m_acquireThread->wait(2500);
+ delete m_acquireHelper;
+ delete m_semaphore;
+}
+
+bool JobClient::start()
+{
+ Q_ASSERT(!m_semaphore && !m_acquireHelper);
+ Q_ASSERT(!m_acquireThread->isRunning());
+
+ const QString semaphoreKey = m_environment->value(QLatin1String("_JOMSRVKEY_"));
+ if (semaphoreKey.isEmpty()) {
+ setError(QLatin1String("Cannot determine jobserver name."));
+ return false;
+ }
+ m_semaphore = new QSystemSemaphore(semaphoreKey);
+ if (m_semaphore->error() != QSystemSemaphore::NoError) {
+ setError(m_semaphore->errorString());
+ return false;
+ }
+
+ m_acquireHelper = new JobClientAcquireHelper(m_semaphore);
+ m_acquireHelper->moveToThread(m_acquireThread);
+ connect(this, &JobClient::startAcquisition, m_acquireHelper, &JobClientAcquireHelper::acquire);
+ connect(m_acquireHelper, &JobClientAcquireHelper::acquired, this, &JobClient::onHelperAcquired);
+ m_acquireThread->start();
+ return true;
+}
+
+void JobClient::asyncAcquire()
+{
+ Q_ASSERT(m_semaphore);
+ Q_ASSERT(m_acquireHelper);
+ Q_ASSERT(m_acquireThread->isRunning());
+
+ m_isAcquiring = true;
+ emit startAcquisition();
+}
+
+void JobClient::onHelperAcquired()
+{
+ m_isAcquiring = false;
+ emit acquired();
+}
+
+bool JobClient::isAcquiring() const
+{
+ return m_isAcquiring;
+}
+
+void JobClient::release()
+{
+ Q_ASSERT(m_semaphore);
+
+ if (!m_semaphore->release())
+ qWarning("QSystemSemaphore::release failed: %s (%d)",
+ qPrintable(m_semaphore->errorString()), m_semaphore->error());
+}
+
+QString JobClient::errorString() const
+{
+ return m_errorString;
+}
+
+void JobClient::setError(const QString &errorMessage)
+{
+ m_errorString = errorMessage;
+}
+
+} // namespace NMakeFile
diff --git a/src/jomlib/jobclient.h b/src/jomlib/jobclient.h
new file mode 100644
index 0000000..b6e844d
--- /dev/null
+++ b/src/jomlib/jobclient.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
+ **
+ ** This file is part of the jom project on Trolltech Labs.
+ **
+ ** This file may be used under the terms of the GNU General Public
+ ** License version 2.0 or 3.0 as published by the Free Software Foundation
+ ** and appearing in the file LICENSE.GPL included in the packaging of
+ ** this file. Please review the following information to ensure GNU
+ ** General Public Licensing requirements will be met:
+ ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+ ** http://www.gnu.org/copyleft/gpl.html.
+ **
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ **
+ ****************************************************************************/
+
+#ifndef JOBCLIENT_H
+#define JOBCLIENT_H
+
+#include "processenvironment.h"
+#include <QObject>
+
+QT_BEGIN_NAMESPACE
+class QSystemSemaphore;
+class QThread;
+QT_END_NAMESPACE
+
+namespace NMakeFile {
+
+class JobClientAcquireHelper;
+
+class JobClient : public QObject
+{
+ Q_OBJECT
+public:
+ explicit JobClient(ProcessEnvironment *environment, QObject *parent = 0);
+ ~JobClient();
+
+ bool start();
+ void asyncAcquire();
+ bool isAcquiring() const;
+ void release();
+ QString errorString() const;
+
+signals:
+ void startAcquisition();
+ void acquired();
+
+private slots:
+ void onHelperAcquired();
+
+private:
+ void setError(const QString &errorMessage);
+
+ ProcessEnvironment *m_environment;
+ QString m_errorString;
+ QSystemSemaphore *m_semaphore;
+ QThread *m_acquireThread;
+ JobClientAcquireHelper *m_acquireHelper;
+ bool m_isAcquiring;
+};
+
+} // namespace NMakeFile
+
+#endif // JOBCLIENT_H
diff --git a/src/jomlib/jobclientacquirehelper.cpp b/src/jomlib/jobclientacquirehelper.cpp
new file mode 100644
index 0000000..a92913b
--- /dev/null
+++ b/src/jomlib/jobclientacquirehelper.cpp
@@ -0,0 +1,40 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
+ **
+ ** This file is part of the jom project on Trolltech Labs.
+ **
+ ** This file may be used under the terms of the GNU General Public
+ ** License version 2.0 or 3.0 as published by the Free Software Foundation
+ ** and appearing in the file LICENSE.GPL included in the packaging of
+ ** this file. Please review the following information to ensure GNU
+ ** General Public Licensing requirements will be met:
+ ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+ ** http://www.gnu.org/copyleft/gpl.html.
+ **
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ **
+ ****************************************************************************/
+
+#include "jobclientacquirehelper.h"
+
+namespace NMakeFile {
+
+JobClientAcquireHelper::JobClientAcquireHelper(QSystemSemaphore *semaphore)
+ : m_semaphore(semaphore)
+{
+}
+
+void JobClientAcquireHelper::acquire()
+{
+ if (!m_semaphore->acquire()) {
+ qWarning("QSystemSemaphore::acquire failed: %s (%d)",
+ qPrintable(m_semaphore->errorString()), m_semaphore->error());
+ return;
+ }
+ emit acquired();
+}
+
+} // namespace NMakeFile
diff --git a/src/jomlib/jobclientacquirehelper.h b/src/jomlib/jobclientacquirehelper.h
new file mode 100644
index 0000000..d0f82c8
--- /dev/null
+++ b/src/jomlib/jobclientacquirehelper.h
@@ -0,0 +1,47 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
+ **
+ ** This file is part of the jom project on Trolltech Labs.
+ **
+ ** This file may be used under the terms of the GNU General Public
+ ** License version 2.0 or 3.0 as published by the Free Software Foundation
+ ** and appearing in the file LICENSE.GPL included in the packaging of
+ ** this file. Please review the following information to ensure GNU
+ ** General Public Licensing requirements will be met:
+ ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+ ** http://www.gnu.org/copyleft/gpl.html.
+ **
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ **
+ ****************************************************************************/
+
+#ifndef JOBCLIENTACQUIRETHREAD_H
+#define JOBCLIENTACQUIRETHREAD_H
+
+#include <QObject>
+#include <QSystemSemaphore>
+
+namespace NMakeFile {
+
+class JobClientAcquireHelper : public QObject
+{
+ Q_OBJECT
+public:
+ explicit JobClientAcquireHelper(QSystemSemaphore *semaphore);
+
+public slots:
+ void acquire();
+
+signals:
+ void acquired();
+
+private:
+ QSystemSemaphore *m_semaphore;
+};
+
+} // namespace NMakeFile
+
+#endif // JOBCLIENTACQUIRETHREAD_H
diff --git a/src/jomlib/jobserver.cpp b/src/jomlib/jobserver.cpp
new file mode 100644
index 0000000..cd4ce67
--- /dev/null
+++ b/src/jomlib/jobserver.cpp
@@ -0,0 +1,70 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
+ **
+ ** This file is part of the jom project on Trolltech Labs.
+ **
+ ** This file may be used under the terms of the GNU General Public
+ ** License version 2.0 or 3.0 as published by the Free Software Foundation
+ ** and appearing in the file LICENSE.GPL included in the packaging of
+ ** this file. Please review the following information to ensure GNU
+ ** General Public Licensing requirements will be met:
+ ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+ ** http://www.gnu.org/copyleft/gpl.html.
+ **
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ **
+ ****************************************************************************/
+
+#include "jobserver.h"
+#include "filetime.h"
+#include "helperfunctions.h"
+#include <QByteArray>
+#include <QCoreApplication>
+#include <QSystemSemaphore>
+
+namespace NMakeFile {
+
+JobServer::JobServer(ProcessEnvironment *environment)
+ : m_semaphore(0)
+ , m_environment(environment)
+{
+}
+
+JobServer::~JobServer()
+{
+ delete m_semaphore;
+}
+
+bool JobServer::start(int maxNumberOfJobs)
+{
+ Q_ASSERT(m_environment);
+
+ const uint randomId = (FileTime::currentTime().internalRepresentation() % UINT_MAX)
+ ^ reinterpret_cast<uint>(&maxNumberOfJobs);
+ const QString semaphoreKey = QLatin1String("jomsrv-")
+ + QString::number(QCoreApplication::applicationPid()) + QLatin1Char('-')
+ + QString::number(randomId);
+ m_semaphore = new QSystemSemaphore(semaphoreKey, maxNumberOfJobs - 1, QSystemSemaphore::Create);
+ if (m_semaphore->error() != QSystemSemaphore::NoError) {
+ setError(m_semaphore->errorString());
+ return false;
+ }
+ m_environment->insert(QLatin1String("_JOMSRVKEY_"), semaphoreKey);
+ m_environment->insert(QLatin1String("_JOMJOBCOUNT_"), QString::number(maxNumberOfJobs));
+ return true;
+}
+
+QString JobServer::errorString() const
+{
+ return m_errorString;
+}
+
+void JobServer::setError(const QString &errorMessage)
+{
+ m_errorString = errorMessage;
+}
+
+} // namespace NMakeFile
diff --git a/src/jomlib/jobserver.h b/src/jomlib/jobserver.h
new file mode 100644
index 0000000..30251bb
--- /dev/null
+++ b/src/jomlib/jobserver.h
@@ -0,0 +1,51 @@
+/****************************************************************************
+ **
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
+ **
+ ** This file is part of the jom project on Trolltech Labs.
+ **
+ ** This file may be used under the terms of the GNU General Public
+ ** License version 2.0 or 3.0 as published by the Free Software Foundation
+ ** and appearing in the file LICENSE.GPL included in the packaging of
+ ** this file. Please review the following information to ensure GNU
+ ** General Public Licensing requirements will be met:
+ ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
+ ** http://www.gnu.org/copyleft/gpl.html.
+ **
+ ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ **
+ ****************************************************************************/
+
+#ifndef JOBSERVER_H
+#define JOBSERVER_H
+
+#include "processenvironment.h"
+
+QT_BEGIN_NAMESPACE
+class QSystemSemaphore;
+QT_END_NAMESPACE
+
+namespace NMakeFile {
+
+class JobServer
+{
+public:
+ JobServer(ProcessEnvironment *environment);
+ ~JobServer();
+
+ bool start(int maxNumberOfJobs);
+ QString errorString() const;
+
+private:
+ void setError(const QString &errorMessage);
+
+ QString m_errorString;
+ QSystemSemaphore *m_semaphore;
+ ProcessEnvironment *m_environment;
+};
+
+} // namespace NMakeFile
+
+#endif // JOBSERVER_H
diff --git a/src/jomlib/jomlib.pro b/src/jomlib/jomlib.pro
index e81e65e..63408d3 100644
--- a/src/jomlib/jomlib.pro
+++ b/src/jomlib/jomlib.pro
@@ -12,13 +12,22 @@ build_pass:CONFIG(debug, debug|release) {
TARGET = $$join(TARGET,,,d)
}
-isEmpty(MSYSPATH):MSYSPATH=C:\\msys
-!exists($$MSYSPATH): MSYSPATH=D:\\msys
+isEmpty(MSYSPATH):MSYSPATH=C:/msys
+!exists($$MSYSPATH): MSYSPATH=D:/msys
+!exists($$MSYSPATH): MSYSPATH=C:/msys64
+MSYS_BIN_PATHS = 1.0/bin usr/bin
!exists($$MSYSPATH) {
!build_pass:message("Can't locate path to MSYS. This is needed for flex.")
-} else:!exists($$MSYSPATH\\1.0\\bin\\flex.exe) {
- !build_pass:message("MSYSPATH is set but flex cannot be found.")
} else {
+ for(bin_path, MSYS_BIN_PATHS) {
+ test_flex_bin = $$MSYSPATH/$$bin_path/flex.exe
+ exists($$test_flex_bin):FLEX_BIN = $$test_flex_bin
+ }
+ isEmpty(FLEX_BIN) {
+ !build_pass:message("MSYSPATH is set but flex cannot be found.")
+ }
+}
+!isEmpty(FLEX_BIN) {
# One special extra compiler for ppexpr.l because
# msys flex does not understand backslashes and I have no way
# to translate the slashes in ${QMAKE_FILE_IN}. /me rolls eyes...
@@ -26,7 +35,7 @@ isEmpty(MSYSPATH):MSYSPATH=C:\\msys
flex.name = flex ppexpr.l
flex.input = PPEXPR_FLEX_FILE
flex.output = ${QMAKE_FILE_BASE}-lex.inc
- flex.commands = $$MSYSPATH\\1.0\\bin\\flex.exe --noline $$PPEXPR_FLEX_FILE
+ flex.commands = $$FLEX_BIN --noline $$PPEXPR_FLEX_FILE
flex.CONFIG += no_link explicit_dependencies
QMAKE_EXTRA_COMPILERS += flex
@@ -57,6 +66,7 @@ HEADERS += \
fastfileinfo.h \
filetime.h \
helperfunctions.h \
+ jobserver.h \
makefile.h \
makefilefactory.h \
makefilelinereader.h \
@@ -70,12 +80,16 @@ HEADERS += \
targetexecutor.h \
commandexecutor.h \
process.h \
- processenvironment.h
+ processenvironment.h \
+ iocompletionport.h \
+ jobclient.h \
+ jobclientacquirehelper.h
SOURCES += \
fastfileinfo.cpp \
filetime.cpp \
helperfunctions.cpp \
+ jobserver.cpp \
macrotable.cpp \
makefile.cpp \
makefilefactory.cpp \
@@ -88,7 +102,9 @@ SOURCES += \
ppexpr_grammar.cpp \
ppexprparser.cpp \
targetexecutor.cpp \
- commandexecutor.cpp
+ commandexecutor.cpp \
+ jobclient.cpp \
+ jobclientacquirehelper.cpp
OTHER_FILES += \
ppexpr.g \
diff --git a/src/jomlib/macrotable.cpp b/src/jomlib/macrotable.cpp
index e4ea541..1639bfa 100644
--- a/src/jomlib/macrotable.cpp
+++ b/src/jomlib/macrotable.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/macrotable.h b/src/jomlib/macrotable.h
index efd2ef3..c3ded68 100644
--- a/src/jomlib/macrotable.h
+++ b/src/jomlib/macrotable.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/makefile.cpp b/src/jomlib/makefile.cpp
index 255b47f..e001109 100644
--- a/src/jomlib/makefile.cpp
+++ b/src/jomlib/makefile.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/makefile.h b/src/jomlib/makefile.h
index 3fbf405..3ccd5ca 100644
--- a/src/jomlib/makefile.h
+++ b/src/jomlib/makefile.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/makefilefactory.cpp b/src/jomlib/makefilefactory.cpp
index 07e4fb4..fa13b83 100644
--- a/src/jomlib/makefilefactory.cpp
+++ b/src/jomlib/makefilefactory.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/makefilefactory.h b/src/jomlib/makefilefactory.h
index 5d29107..7aadfc1 100644
--- a/src/jomlib/makefilefactory.h
+++ b/src/jomlib/makefilefactory.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/makefilelinereader.cpp b/src/jomlib/makefilelinereader.cpp
index 1c9d165..dac8070 100644
--- a/src/jomlib/makefilelinereader.cpp
+++ b/src/jomlib/makefilelinereader.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/makefilelinereader.h b/src/jomlib/makefilelinereader.h
index 8b3aecd..fa3fe0a 100644
--- a/src/jomlib/makefilelinereader.h
+++ b/src/jomlib/makefilelinereader.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/options.cpp b/src/jomlib/options.cpp
index 6d930b9..b656f33 100644
--- a/src/jomlib/options.cpp
+++ b/src/jomlib/options.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/options.h b/src/jomlib/options.h
index 8ec4d06..6f97696 100644
--- a/src/jomlib/options.h
+++ b/src/jomlib/options.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/parser.cpp b/src/jomlib/parser.cpp
index b362d65..c141bef 100644
--- a/src/jomlib/parser.cpp
+++ b/src/jomlib/parser.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/parser.h b/src/jomlib/parser.h
index 042b439..bba91db 100644
--- a/src/jomlib/parser.h
+++ b/src/jomlib/parser.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/ppexpr-lex.inc b/src/jomlib/ppexpr-lex.inc
index ff34b1e..f9681c5 100644
--- a/src/jomlib/ppexpr-lex.inc
+++ b/src/jomlib/ppexpr-lex.inc
@@ -8,7 +8,7 @@
#define FLEX_SCANNER
#define YY_FLEX_MAJOR_VERSION 2
#define YY_FLEX_MINOR_VERSION 5
-#define YY_FLEX_SUBMINOR_VERSION 35
+#define YY_FLEX_SUBMINOR_VERSION 39
#if YY_FLEX_SUBMINOR_VERSION > 0
#define FLEX_BETA
#endif
@@ -141,15 +141,7 @@ typedef unsigned int flex_uint32_t;
/* Size of default input buffer. */
#ifndef YY_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k.
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
- * Ditto for the __ia64__ case accordingly.
- */
-#define YY_BUF_SIZE 32768
-#else
#define YY_BUF_SIZE 16384
-#endif /* __ia64__ */
#endif
/* The state buf must be large enough to hold one state per character in the main buffer.
@@ -161,7 +153,12 @@ typedef unsigned int flex_uint32_t;
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
-extern int yyleng;
+#ifndef YY_TYPEDEF_YY_SIZE_T
+#define YY_TYPEDEF_YY_SIZE_T
+typedef size_t yy_size_t;
+#endif
+
+extern yy_size_t yyleng;
extern FILE *yyin, *yyout;
@@ -170,6 +167,7 @@ extern FILE *yyin, *yyout;
#define EOB_ACT_LAST_MATCH 2
#define YY_LESS_LINENO(n)
+ #define YY_LINENO_REWIND_TO(ptr)
/* Return all but the first "n" matched characters back to the input stream. */
#define yyless(n) \
@@ -187,11 +185,6 @@ extern FILE *yyin, *yyout;
#define unput(c) yyunput( c, (yytext_ptr) )
-#ifndef YY_TYPEDEF_YY_SIZE_T
-#define YY_TYPEDEF_YY_SIZE_T
-typedef size_t yy_size_t;
-#endif
-
#ifndef YY_STRUCT_YY_BUFFER_STATE
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
@@ -209,7 +202,7 @@ struct yy_buffer_state
/* Number of characters read into yy_ch_buf, not including EOB
* characters.
*/
- int yy_n_chars;
+ yy_size_t yy_n_chars;
/* Whether we "own" the buffer - i.e., we know we created it,
* and can realloc() it to grow it, and should free() it to
@@ -279,8 +272,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
/* yy_hold_char holds the character lost when yytext is formed. */
static char yy_hold_char;
-static int yy_n_chars; /* number of characters read into yy_ch_buf */
-int yyleng;
+static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
+yy_size_t yyleng;
/* Points to current character in buffer. */
static char *yy_c_buf_p = (char *) 0;
@@ -308,7 +301,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
+YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
void *yyalloc (yy_size_t );
void *yyrealloc (void *,yy_size_t );
@@ -530,8 +523,8 @@ int yy_flex_debug = 0;
char *yytext;
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
@@ -606,7 +599,7 @@ FILE *yyget_out (void );
void yyset_out (FILE * out_str );
-int yyget_leng (void );
+yy_size_t yyget_leng (void );
char *yyget_text (void );
@@ -648,12 +641,7 @@ static int input (void );
/* Amount of stuff to slurp up with each read. */
#ifndef YY_READ_BUF_SIZE
-#ifdef __ia64__
-/* On IA-64, the buffer size is 16k, not 8k */
-#define YY_READ_BUF_SIZE 16384
-#else
#define YY_READ_BUF_SIZE 8192
-#endif /* __ia64__ */
#endif
/* Copy whatever the last rule matched to the standard output. */
@@ -780,6 +768,8 @@ YY_DECL
yy_load_buffer_state( );
}
+ {
+
while ( 1 ) /* loops until end-of-file is reached */
{
yy_cp = (yy_c_buf_p);
@@ -796,7 +786,7 @@ YY_DECL
yy_match:
do
{
- register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] )
{
(yy_last_accepting_state) = yy_current_state;
@@ -1196,6 +1186,7 @@ case YY_STATE_EOF(STATE_SHELLCOMMAND):
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
+ } /* end of user's declarations */
} /* end of yylex */
/* yy_get_next_buffer - try to read in a new buffer
@@ -1251,21 +1242,21 @@ static int yy_get_next_buffer (void)
else
{
- int num_to_read =
+ yy_size_t num_to_read =
YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
while ( num_to_read <= 0 )
{ /* Not enough room in the buffer - grow it. */
/* just a shorter name for the current buffer */
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
int yy_c_buf_p_offset =
(int) ((yy_c_buf_p) - b->yy_ch_buf);
if ( b->yy_is_our_buffer )
{
- int new_size = b->yy_buf_size * 2;
+ yy_size_t new_size = b->yy_buf_size * 2;
if ( new_size <= 0 )
b->yy_buf_size += b->yy_buf_size / 8;
@@ -1296,7 +1287,7 @@ static int yy_get_next_buffer (void)
/* Read in more data. */
YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
- (yy_n_chars), (size_t) num_to_read );
+ (yy_n_chars), num_to_read );
YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
}
@@ -1391,7 +1382,7 @@ static int yy_get_next_buffer (void)
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
yy_is_jam = (yy_current_state == 85);
- return yy_is_jam ? 0 : yy_current_state;
+ return yy_is_jam ? 0 : yy_current_state;
}
static void yyunput (int c, register char * yy_bp )
@@ -1406,7 +1397,7 @@ static int yy_get_next_buffer (void)
if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
{ /* need to shift things up to make room */
/* +2 for EOB chars. */
- register int number_to_move = (yy_n_chars) + 2;
+ register yy_size_t number_to_move = (yy_n_chars) + 2;
register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
register char *source =
@@ -1455,7 +1446,7 @@ static int yy_get_next_buffer (void)
else
{ /* need more input */
- int offset = (yy_c_buf_p) - (yytext_ptr);
+ yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
++(yy_c_buf_p);
switch ( yy_get_next_buffer( ) )
@@ -1615,10 +1606,6 @@ static void yy_load_buffer_state (void)
yyfree((void *) b );
}
-#ifndef __cplusplus
-extern int isatty (int );
-#endif /* __cplusplus */
-
/* Initializes or reinitializes a buffer.
* This function is sometimes called more than once on the same buffer,
* such as during a yyrestart() or at EOF.
@@ -1731,7 +1718,7 @@ void yypop_buffer_state (void)
*/
static void yyensure_buffer_stack (void)
{
- int num_to_alloc;
+ yy_size_t num_to_alloc;
if (!(yy_buffer_stack)) {
@@ -1828,12 +1815,12 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
*
* @return the newly allocated buffer state object.
*/
-YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
+YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
{
YY_BUFFER_STATE b;
char *buf;
yy_size_t n;
- int i;
+ yy_size_t i;
/* Get memory for full buffer, including space for trailing EOB's. */
n = _yybytes_len + 2;
@@ -1915,7 +1902,7 @@ FILE *yyget_out (void)
/** Get the length of the current token.
*
*/
-int yyget_leng (void)
+yy_size_t yyget_leng (void)
{
return yyleng;
}
diff --git a/src/jomlib/ppexpr.g b/src/jomlib/ppexpr.g
index 127ce9f..851a0c8 100644
--- a/src/jomlib/ppexpr.g
+++ b/src/jomlib/ppexpr.g
@@ -1,7 +1,7 @@
----------------------------------------------------------------------------
--
--- Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
--- Contact: http://www.qt-project.org/legal
+-- Copyright (C) 2015 The Qt Company Ltd.
+-- Contact: http://www.qt.io/licensing/
--
-- This file is part of the jom project on Trolltech Labs.
--
diff --git a/src/jomlib/ppexpr.l b/src/jomlib/ppexpr.l
index 39afa0c..5164989 100644
--- a/src/jomlib/ppexpr.l
+++ b/src/jomlib/ppexpr.l
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/ppexpr_grammar.cpp b/src/jomlib/ppexpr_grammar.cpp
index 8a10479..95185af 100644
--- a/src/jomlib/ppexpr_grammar.cpp
+++ b/src/jomlib/ppexpr_grammar.cpp
@@ -82,63 +82,67 @@ const short ppexpr_grammar::goto_default [] = {
0};
const short ppexpr_grammar::action_index [] = {
- 93, 13, 10, 58, 3, -25, 2, 1, -25, -25,
- 16, -25, 89, -6, -3, -1, -25, -25, -25, 33,
- 117, 86, 93, 117, -25, -25, -25, -25, -25, -25,
- 21, -2, -25, -25, -25, 32, 42, 45, 69, 69,
- 69, -11, 45, 45, -10, 69, 45, 9, 45, 45,
- 45, -25, -25, -25, 12, -10, -6, -11, -11, -11,
- -6,
+ 117, 1, 2, 76, 5, -25, 3, 0, -25, -25,
+ 45, -25, 113, 6, -8, 18, -25, -25, -25, 57,
+ 110, 117, 85, 141, -25, -25, -25, -25, -25, -25,
+ 23, -1, -25, -25, -25, 51, 93, 69, 25, 37,
+ 69, 15, 69, 69, -3, 69, 93, 18, 69, 69,
+ 69, -25, -25, -25, 18, 16, 20, 20, -9, 4,
+ 8,
- -11, -4, -2, 7, -3, -11, -11, -11, -11, -11,
+ -11, -9, -7, 3, -8, -11, -11, -11, -11, -11,
-11, -11, -11, -11, -11, -11, -11, -11, -11, -11,
- 10, 0, 16, 19, -11, -11, -11, -11, -11, -11,
- -11, -11, -11, -11, -11, 5, -1, 8, 12, 22,
- 15, -11, 3, 13, -11, 9, 4, -11, -8, -5,
- -7, -11, -11, -11, -11, -11, -11, -11, -11, -11,
+ 1, 12, 4, 21, -11, -11, -11, -11, -11, -11,
+ -11, -11, -11, -11, -11, 10, 15, 16, 0, 6,
+ 7, -11, 11, 13, -11, 9, 17, -11, -1, 2,
+ 5, -11, -11, -11, -11, -11, -11, -11, -11, -11,
-11};
const short ppexpr_grammar::action_info [] = {
- 33, 34, 42, 43, 5, 46, 45, 42, 43, 30,
- 31, 5, 46, 45, 5, 0, 50, 48, 49, 22,
- 23, 20, 21, 32, 0, 3, 50, 48, 49, 50,
- 48, 49, 3, 5, 0, 3, 22, 23, 20, 21,
- 0, 0, 0, 5, 0, 0, 5, 0, 4, 0,
- 0, 0, 1, 2, 3, 0, 24, 0, 4, 5,
- 6, 4, 1, 2, 3, 1, 2, 3, 0, 0,
- 5, 0, 0, 0, 4, 0, 0, 0, 1, 2,
- 3, 0, 0, 0, 0, 4, 0, 5, 6, 1,
- 2, 3, 0, 0, 5, 6, 35, 40, 39, 38,
- 37, 36, 4, 0, 0, 0, 1, 2, 3, 4,
- 0, 0, 0, 1, 2, 3, 0, 0, 5, 6,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 4, 0, 0, 0, 1, 2, 3,
- 0, 0,
+ 34, 33, 5, 5, 42, 43, 5, 46, 45, 0,
+ 30, 31, 46, 45, 0, 0, 0, 42, 43, 42,
+ 43, 42, 43, 3, 3, 32, 5, 3, 42, 43,
+ 0, 46, 45, 42, 43, 50, 48, 49, 5, 0,
+ 0, 4, 0, 0, 0, 1, 2, 3, 22, 23,
+ 20, 21, 5, 4, 0, 0, 0, 1, 2, 3,
+ 22, 23, 20, 21, 0, 0, 0, 4, 0, 0,
+ 5, 1, 2, 3, 0, 0, 0, 5, 6, 0,
+ 24, 0, 0, 0, 0, 4, 5, 6, 0, 1,
+ 2, 3, 4, 0, 5, 0, 1, 2, 3, 0,
+ 0, 4, 0, 0, 0, 1, 2, 3, 0, 4,
+ 0, 5, 6, 1, 2, 3, 0, 0, 5, 6,
+ 35, 40, 39, 38, 37, 36, 4, 0, 0, 0,
+ 1, 2, 3, 4, 0, 0, 0, 1, 2, 3,
+ 0, 0, 5, 6, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 4, 0, 0,
+ 0, 1, 2, 3, 0, 0,
- 51, 53, 26, 52, 56, 17, 29, 18, 19, 44,
- 41, 54, 25, 57, 0, 0, 47, 58, 27, 55,
- 60, 28, 0, 0, 0, 0, 0, 59, 0, 0,
- 0, 0, 0};
+ 17, 29, 18, 25, 19, 58, 27, 51, 0, 0,
+ 52, 59, 60, 53, 26, 41, 47, 44, 0, 55,
+ 56, 57, 0, 28, 54, 0, 0, 0, 0, 0,
+ 0, 0};
const short ppexpr_grammar::action_check [] = {
- 2, 0, 13, 14, 1, 15, 16, 13, 14, 7,
- 8, 1, 15, 16, 1, -1, 17, 18, 19, 3,
- 4, 5, 6, 2, -1, 22, 17, 18, 19, 17,
- 18, 19, 22, 1, -1, 22, 3, 4, 5, 6,
- -1, -1, -1, 1, -1, -1, 1, -1, 16, -1,
- -1, -1, 20, 21, 22, -1, 23, -1, 16, 1,
- 2, 16, 20, 21, 22, 20, 21, 22, -1, -1,
- 1, -1, -1, -1, 16, -1, -1, -1, 20, 21,
- 22, -1, -1, -1, -1, 16, -1, 1, 2, 20,
- 21, 22, -1, -1, 1, 2, 7, 8, 9, 10,
- 11, 12, 16, -1, -1, -1, 20, 21, 22, 16,
- -1, -1, -1, 20, 21, 22, -1, -1, 1, 2,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, 16, -1, -1, -1, 20, 21, 22,
- -1, -1,
+ 0, 2, 1, 1, 13, 14, 1, 15, 16, -1,
+ 7, 8, 15, 16, -1, -1, -1, 13, 14, 13,
+ 14, 13, 14, 22, 22, 2, 1, 22, 13, 14,
+ -1, 15, 16, 13, 14, 17, 18, 19, 1, -1,
+ -1, 16, -1, -1, -1, 20, 21, 22, 3, 4,
+ 5, 6, 1, 16, -1, -1, -1, 20, 21, 22,
+ 3, 4, 5, 6, -1, -1, -1, 16, -1, -1,
+ 1, 20, 21, 22, -1, -1, -1, 1, 2, -1,
+ 23, -1, -1, -1, -1, 16, 1, 2, -1, 20,
+ 21, 22, 16, -1, 1, -1, 20, 21, 22, -1,
+ -1, 16, -1, -1, -1, 20, 21, 22, -1, 16,
+ -1, 1, 2, 20, 21, 22, -1, -1, 1, 2,
+ 7, 8, 9, 10, 11, 12, 16, -1, -1, -1,
+ 20, 21, 22, 16, -1, -1, -1, 20, 21, 22,
+ -1, -1, 1, 2, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 16, -1, -1,
+ -1, 20, 21, 22, -1, -1,
- 8, 8, 2, 8, 5, 9, 9, 9, 1, 6,
- 5, 7, 2, 5, -1, -1, 7, 5, 2, 6,
- 5, 2, -1, -1, -1, -1, -1, 5, -1, -1,
- -1, -1, -1};
+ 9, 9, 9, 2, 1, 5, 2, 8, -1, -1,
+ 8, 5, 5, 8, 2, 5, 7, 6, -1, 6,
+ 5, 5, -1, 2, 7, -1, -1, -1, -1, -1,
+ -1, -1};
diff --git a/src/jomlib/ppexpr_grammar_p.h b/src/jomlib/ppexpr_grammar_p.h
index 5550aaa..8bc4480 100644
--- a/src/jomlib/ppexpr_grammar_p.h
+++ b/src/jomlib/ppexpr_grammar_p.h
@@ -39,8 +39,8 @@ public:
NON_TERMINAL_COUNT = 11,
GOTO_INDEX_OFFSET = 61,
- GOTO_INFO_OFFSET = 142,
- GOTO_CHECK_OFFSET = 142
+ GOTO_INFO_OFFSET = 166,
+ GOTO_CHECK_OFFSET = 166
};
static const char *const spell [];
diff --git a/src/jomlib/preprocessor.cpp b/src/jomlib/preprocessor.cpp
index 94f1125..1bf0682 100644
--- a/src/jomlib/preprocessor.cpp
+++ b/src/jomlib/preprocessor.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/preprocessor.h b/src/jomlib/preprocessor.h
index 0b4cd42..bf6773a 100644
--- a/src/jomlib/preprocessor.h
+++ b/src/jomlib/preprocessor.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/process.cpp b/src/jomlib/process.cpp
index 224bf9a..41e153c 100644
--- a/src/jomlib/process.cpp
+++ b/src/jomlib/process.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/process.h b/src/jomlib/process.h
index 5e96e4e..013142b 100644
--- a/src/jomlib/process.h
+++ b/src/jomlib/process.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/process_qt.cpp b/src/jomlib/process_qt.cpp
index dff228c..4a0fd6b 100644
--- a/src/jomlib/process_qt.cpp
+++ b/src/jomlib/process_qt.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/processenvironment.h b/src/jomlib/processenvironment.h
index f15e165..03fe65f 100644
--- a/src/jomlib/processenvironment.h
+++ b/src/jomlib/processenvironment.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/stable.h b/src/jomlib/stable.h
index 5b285b4..6294199 100644
--- a/src/jomlib/stable.h
+++ b/src/jomlib/stable.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
diff --git a/src/jomlib/targetexecutor.cpp b/src/jomlib/targetexecutor.cpp
index 937c06a..a9a6228 100644
--- a/src/jomlib/targetexecutor.cpp
+++ b/src/jomlib/targetexecutor.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
@@ -21,6 +21,7 @@
#include "targetexecutor.h"
#include "commandexecutor.h"
#include "dependencygraph.h"
+#include "jobclient.h"
#include "options.h"
#include "exception.h"
@@ -31,27 +32,29 @@
namespace NMakeFile {
TargetExecutor::TargetExecutor(const ProcessEnvironment &environment)
-: m_bAborted(false),
- m_blockingCommand(0),
- m_allCommandsSuccessfullyExecuted(true)
+ : m_environment(environment)
+ , m_jobClient(0)
+ , m_bAborted(false)
+ , m_allCommandsSuccessfullyExecuted(true)
{
m_makefile = 0;
m_depgraph = new DependencyGraph();
- for (int i=0; i < g_options.maxNumberOfJobs; ++i) {
- CommandExecutor* process = new CommandExecutor(this, environment);
- if (i == 0) process->setBufferedOutput(false);
- connect(process, SIGNAL(finished(CommandExecutor*, bool)), this, SLOT(onChildFinished(CommandExecutor*, bool)));
- connect(process, SIGNAL(subJomStarted()), this, SLOT(onSubJomStarted()));
- m_availableProcesses.append(process);
- m_processes.append(process);
- }
+ for (int i = 0; i < g_options.maxNumberOfJobs; ++i) {
+ CommandExecutor* executor = new CommandExecutor(this, environment);
+ connect(executor, SIGNAL(finished(CommandExecutor*, bool)),
+ this, SLOT(onChildFinished(CommandExecutor*, bool)));
- foreach (CommandExecutor *process, m_processes)
- foreach (CommandExecutor *otherProcess, m_processes)
- if (process != otherProcess)
- connect(process, SIGNAL(environmentChanged(const ProcessEnvironment &)),
- otherProcess, SLOT(setEnvironment(const ProcessEnvironment &)));
+ foreach (CommandExecutor *other, m_processes) {
+ connect(executor, SIGNAL(environmentChanged(const ProcessEnvironment &)),
+ other, SLOT(setEnvironment(const ProcessEnvironment &)));
+ connect(other, SIGNAL(environmentChanged(const ProcessEnvironment &)),
+ executor, SLOT(setEnvironment(const ProcessEnvironment &)));
+ }
+ m_processes.append(executor);
+ }
+ m_availableProcesses = m_processes;
+ m_availableProcesses.first()->setBufferedOutput(false);
}
TargetExecutor::~TargetExecutor()
@@ -59,17 +62,22 @@ TargetExecutor::~TargetExecutor()
delete m_depgraph;
}
-bool TargetExecutor::hasPendingTargets() const
-{
- return !m_pendingTargets.isEmpty() || m_availableProcesses.count() < m_processes.count();
-}
-
void TargetExecutor::apply(Makefile* mkfile, const QStringList& targets)
{
m_bAborted = false;
- m_blockingCommand = 0;
m_allCommandsSuccessfullyExecuted = true;
m_makefile = mkfile;
+ m_jobAcquisitionCount = 0;
+ m_nextTarget = 0;
+
+ if (!m_jobClient) {
+ m_jobClient = new JobClient(&m_environment, this);
+ if (!m_jobClient->start()) {
+ const QString msg = QLatin1String("Can't connect to job server: %1");
+ throw Exception(msg.arg(m_jobClient->errorString()));
+ }
+ connect(m_jobClient, &JobClient::acquired, this, &TargetExecutor::buildNextTarget);
+ }
DescriptionBlock* descblock;
if (targets.isEmpty()) {
@@ -96,39 +104,40 @@ void TargetExecutor::apply(Makefile* mkfile, const QStringList& targets)
else
m_depgraph->dump();
finishBuild(0);
+ return;
}
+
+ QMetaObject::invokeMethod(this, "startProcesses", Qt::QueuedConnection);
}
void TargetExecutor::startProcesses()
{
- if (m_bAborted || m_blockingCommand)
+ if (m_bAborted || m_jobClient->isAcquiring() || m_availableProcesses.isEmpty())
return;
try {
- DescriptionBlock* nextTarget = 0;
- while (!m_availableProcesses.isEmpty() && (nextTarget = m_depgraph->findAvailableTarget())) {
- if (nextTarget->m_commands.isEmpty()) {
- // Short cut for targets without commands.
- // We're not really interested in these.
- m_depgraph->removeLeaf(nextTarget);
- continue;
- }
-
- CommandExecutor* process = m_availableProcesses.takeFirst();
- process->start(nextTarget);
- if (m_bAborted || m_blockingCommand)
- return;
- }
+ if (!m_nextTarget)
+ findNextTarget();
- if (m_availableProcesses.count() == g_options.maxNumberOfJobs) {
- if (m_pendingTargets.isEmpty()) {
- finishBuild(0);
+ if (m_nextTarget) {
+ if (numberOfRunningProcesses() == 0) {
+ // Use up the internal job token.
+ buildNextTarget();
} else {
- m_depgraph->clear();
- nextTarget = m_pendingTargets.takeFirst();
- m_makefile->invalidateTimeStamps();
- m_depgraph->build(nextTarget);
- QMetaObject::invokeMethod(this, "startProcesses", Qt::QueuedConnection);
+ // Acquire a job token from the server. Will call buildNextTarget() when done.
+ m_jobAcquisitionCount++;
+ m_jobClient->asyncAcquire();
+ }
+ } else {
+ if (numberOfRunningProcesses() == 0) {
+ if (m_pendingTargets.isEmpty()) {
+ finishBuild(0);
+ } else {
+ m_depgraph->clear();
+ m_makefile->invalidateTimeStamps();
+ m_depgraph->build(m_pendingTargets.takeFirst());
+ QMetaObject::invokeMethod(this, "startProcesses", Qt::QueuedConnection);
+ }
}
}
} catch (Exception &e) {
@@ -138,6 +147,25 @@ void TargetExecutor::startProcesses()
}
}
+void TargetExecutor::buildNextTarget()
+{
+ Q_ASSERT(m_nextTarget);
+
+ if (m_bAborted)
+ return;
+
+ try {
+ CommandExecutor *executor = m_availableProcesses.takeFirst();
+ executor->start(m_nextTarget);
+ m_nextTarget = 0;
+ QMetaObject::invokeMethod(this, "startProcesses", Qt::QueuedConnection);
+ } catch (const Exception &e) {
+ m_bAborted = true;
+ fprintf(stderr, "Error: %s\n", qPrintable(e.message()));
+ finishBuild(1);
+ }
+}
+
void TargetExecutor::waitForProcesses()
{
foreach (CommandExecutor* process, m_processes)
@@ -156,23 +184,17 @@ void TargetExecutor::finishBuild(int exitCode)
emit finished(exitCode);
}
-void TargetExecutor::onSubJomStarted()
+void TargetExecutor::findNextTarget()
{
- //qDebug() << "BLOCK" << QCoreApplication::applicationPid();
-
- // Set the blocking sub jom command to direct output mode.
- CommandExecutor *subJomCmd = qobject_cast<CommandExecutor*>(sender());
- if (subJomCmd->isBufferedOutputSet()) {
- foreach (CommandExecutor *cmdex, m_processes)
- if (!cmdex->isBufferedOutputSet())
- cmdex->setBufferedOutput(true);
- subJomCmd->setBufferedOutput(false);
+ forever {
+ m_nextTarget = m_depgraph->findAvailableTarget();
+ if (m_nextTarget && m_nextTarget->m_commands.isEmpty()) {
+ // Short cut for targets without commands.
+ m_depgraph->removeLeaf(m_nextTarget);
+ } else {
+ return;
+ }
}
-
- m_blockingCommand = subJomCmd;
- foreach (CommandExecutor *cmdex, m_processes)
- if (cmdex != subJomCmd)
- cmdex->block();
}
void TargetExecutor::onChildFinished(CommandExecutor* executor, bool commandFailed)
@@ -180,6 +202,10 @@ void TargetExecutor::onChildFinished(CommandExecutor* executor, bool commandFail
Q_CHECK_PTR(executor->target());
FastFileInfo::clearCacheForFile(executor->target()->targetName());
m_depgraph->removeLeaf(executor->target());
+ if (m_jobAcquisitionCount > 0) {
+ m_jobClient->release();
+ m_jobAcquisitionCount--;
+ }
m_availableProcesses.append(executor);
if (!executor->isBufferedOutputSet()) {
executor->setBufferedOutput(true);
@@ -198,13 +224,6 @@ void TargetExecutor::onChildFinished(CommandExecutor* executor, bool commandFail
m_allCommandsSuccessfullyExecuted = false;
bool abortMakeProcess = commandFailed && !m_makefile->options()->buildUnrelatedTargetsOnError;
- if (!abortMakeProcess && m_blockingCommand && m_blockingCommand == executor) {
- //qDebug() << "UNBLOCK" << QCoreApplication::applicationPid();
- m_blockingCommand = 0;
- foreach (CommandExecutor *cmdex, m_processes)
- cmdex->unblock();
- }
-
if (abortMakeProcess) {
m_bAborted = true;
m_depgraph->clear();
@@ -216,6 +235,11 @@ void TargetExecutor::onChildFinished(CommandExecutor* executor, bool commandFail
QMetaObject::invokeMethod(this, "startProcesses", Qt::QueuedConnection);
}
+int TargetExecutor::numberOfRunningProcesses() const
+{
+ return m_processes.count() - m_availableProcesses.count();
+}
+
void TargetExecutor::removeTempFiles()
{
foreach (QObject* child, children()) {
diff --git a/src/jomlib/targetexecutor.h b/src/jomlib/targetexecutor.h
index e601a1e..f5497d2 100644
--- a/src/jomlib/targetexecutor.h
+++ b/src/jomlib/targetexecutor.h
@@ -1,7 +1,7 @@
/****************************************************************************
**
- ** Copyright (C) 2008-2014 Digia Plc and/or its subsidiary(-ies).
- ** Contact: http://www.qt-project.org/legal
+ ** Copyright (C) 2015 The Qt Company Ltd.
+ ** Contact: http://www.qt.io/licensing/
**
** This file is part of the jom project on Trolltech Labs.
**
@@ -33,6 +33,7 @@ namespace NMakeFile {
class CommandExecutor;
class DependencyGraph;
+class JobClient;
class TargetExecutor : public QObject {
Q_OBJECT
@@ -42,30 +43,32 @@ public:
void apply(Makefile* mkfile, const QStringList& targets);
void removeTempFiles();
- bool hasPendingTargets() const;
signals:
void finished(int exitCode);
-public slots:
- void startProcesses();
-
private slots:
- void onSubJomStarted();
+ void startProcesses();
+ void buildNextTarget();
void onChildFinished(CommandExecutor*, bool commandFailed);
private:
+ int numberOfRunningProcesses() const;
void waitForProcesses();
void finishBuild(int exitCode);
+ void findNextTarget();
private:
+ ProcessEnvironment m_environment;
Makefile* m_makefile;
DependencyGraph* m_depgraph;
QList<DescriptionBlock*> m_pendingTargets;
+ JobClient *m_jobClient;
bool m_bAborted;
- QObject *m_blockingCommand;
+ int m_jobAcquisitionCount;
QList<CommandExecutor*> m_availableProcesses;
QList<CommandExecutor*> m_processes;
+ DescriptionBlock *m_nextTarget;
bool m_allCommandsSuccessfullyExecuted;
};