Skip to content

Commit

Permalink
Connect features from command line with those parsed in files.
Browse files Browse the repository at this point in the history
  • Loading branch information
sierdzio committed Jun 22, 2018
1 parent 877e872 commit 6445af1
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 9 deletions.
4 changes: 1 addition & 3 deletions gibs/src/baseparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ BaseParser::BaseParser(Scope *scope, QObject *parent) : QObject(parent),
connect(this, &BaseParser::defines, scope, &Scope::addDefines);
connect(this, &BaseParser::includes, scope, &Scope::addIncludePaths);
connect(this, &BaseParser::libs, scope, &Scope::addLibs);
connect(this, &BaseParser::feature, scope, &Scope::feature);
// ProjectManager is responsible for this
//connect(this, &BaseParser::feature, scope, &Scope::onFeature);
connect(this, &BaseParser::feature, scope, &Scope::onFeature);
}

bool BaseParser::parseCommand(const QString &commandString)
Expand Down
19 changes: 16 additions & 3 deletions gibs/src/projectmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ void ProjectManager::start()
mFlags.relativePath(),
mFlags.prefix(),
mFlags.qtDir(),
mFlags.parseWholeFiles());
mFlags.parseWholeFiles(),
mFeatures);
connectScope(scope);

if (!mGlobalScope.isNull()) {
Expand Down Expand Up @@ -209,7 +210,8 @@ void ProjectManager::loadCommands()
if (mGlobalScope.isNull()) {
mGlobalScope = ScopePtr::create(Tags::globalScope, mFlags.relativePath(),
mFlags.prefix(), mFlags.qtDir(),
mFlags.parseWholeFiles());
mFlags.parseWholeFiles(),
mFeatures);
connectScope(mGlobalScope);
mScopes.insert(mGlobalScope->id(), mGlobalScope);
}
Expand All @@ -220,6 +222,11 @@ void ProjectManager::loadCommands()
parser.parse();
}

void ProjectManager::loadFeatures(const QHash<QString, Gibs::Feature> &features)
{
mFeatures = features;
}

/*!
* Register new subproject. If current scope (\a scopeId) depends on the new
* project, it will be added to \a scopeId later.
Expand All @@ -235,7 +242,8 @@ void ProjectManager::onSubproject(const QByteArray &scopeId, const QString &path
oldScope->relativePath() + "/" + newRelativePath,
mFlags.prefix(),
mFlags.qtDir(),
mFlags.parseWholeFiles());
mFlags.parseWholeFiles(),
mFeatures);
//qDebug() << "Subproject:" << scope->name() << "STARTING!";
connectScope(scope);

Expand All @@ -262,6 +270,11 @@ void ProjectManager::onSubproject(const QByteArray &scopeId, const QString &path
});
}

void ProjectManager::onFeatureUpdated(const Gibs::Feature &feature)
{
mFeatures.insert(feature.name, feature);
}

void ProjectManager::onProcessErrorOccurred(QProcess::ProcessError _error)
{
auto process = qobject_cast<QProcess *>(sender());
Expand Down
4 changes: 4 additions & 0 deletions gibs/src/projectmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ProjectManager : public QObject

void loadCache();
void loadCommands();
void loadFeatures(const QHash<QString, Gibs::Feature> &features);

signals:
void error(const QString &error) const;
Expand All @@ -45,6 +46,7 @@ protected slots:
void onError(const QString &error);
void saveCache() const;
void onSubproject(const QByteArray &scopeId, const QString &path);
void onFeatureUpdated(const Gibs::Feature &feature);

// Process handling
void onProcessErrorOccurred(QProcess::ProcessError _error);
Expand All @@ -63,6 +65,8 @@ protected slots:

// scopeId, scope
QHash<QByteArray, ScopePtr> mScopes;
// name, Feature
QHash<QString, Gibs::Feature> mFeatures;

QVector<MetaProcessPtr> mProcessQueue;
QVector<ProcessPtr> mRunningJobs;
Expand Down
6 changes: 4 additions & 2 deletions gibs/src/scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@ Scope::Scope(const QString &name,
const QString &prefix,
const QString &qtDir,
const bool parseWholeFiles,
const QHash<QString, Gibs::Feature> &features,
QObject *parent)
: QObject(parent),
mParseWholeFiles(parseWholeFiles),
mRelativePath(relativePath),
mPrefix(prefix),
mName(name),
mId(QCryptographicHash::hash(name.toUtf8(), QCryptographicHash::Sha1)),
mQtDir(qtDir)
mQtDir(qtDir),
mFeatures(features)
{
addIncludePaths({"."});

Expand Down Expand Up @@ -622,7 +624,7 @@ void Scope::onFeature(const QString &name, const bool isOn)
feat.name = name;
feat.define = Gibs::normalizeFeatureName(name);
result = feat;
emit feature(name, isOn);
emit feature(feat);
}

if (result.enabled) {
Expand Down
3 changes: 2 additions & 1 deletion gibs/src/scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Scope : public QObject
explicit Scope(const QString &name, const QString &relativePath,
const QString &prefix, const QString &qtDir,
const bool parseWholeFiles,
const QHash<QString, Gibs::Feature> &features,
QObject *parent = nullptr);

QString name() const;
Expand Down Expand Up @@ -88,7 +89,7 @@ public slots:
void error(const QString &error) const;
void runProcess(const QString &app, const QStringList &arguments, const MetaProcessPtr &mp) const;
void subproject(const QByteArray &scopeId, const QString &path) const;
void feature(const QString &name, const bool defaultOn) const;
void feature(const Gibs::Feature &feature) const;

protected:
QString compile(const QString &file);
Expand Down
6 changes: 6 additions & 0 deletions samples/simpletest-feature/custom-test-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# This is a helper script for scripts/run-compilation-tests.sh

CUSTOM_PATH=""
CUSTOM_ARGS="-- --my-feature"

0 comments on commit 6445af1

Please sign in to comment.