Skip to content

Commit

Permalink
Features feature is now working.
Browse files Browse the repository at this point in the history
  • Loading branch information
sierdzio committed Jun 22, 2018
1 parent 6445af1 commit 7b3dcad
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gibs/src/baseparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ bool BaseParser::parseCommand(const QString &commandString)
const QStringList arguments(startsWithComment?
QStringList(allArguments.mid(1)) : allArguments);

qDebug() << "Parsing command:" << commandString << "command is:" << command << "arguments:" << arguments;
//qDebug() << "Parsing command:" << commandString << "command is:" << command << "arguments:" << arguments;
if(command == Tags::targetCommand) {
if (arguments.at(1) == Tags::targetName) {
const QString &arg(arguments.at(2));
Expand Down
13 changes: 13 additions & 0 deletions gibs/src/fileparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ bool FileParser::parse()
block.active = block.defined;
QString source;
QCryptographicHash checksum(QCryptographicHash::Sha1);
// Cache:
int scopeFeatureCount = mScope->features().count();
int previousFeatureCount = 0;

//QTextStream in(&file);
while (!file.atEnd()) {
Expand Down Expand Up @@ -63,6 +66,16 @@ bool FileParser::parse()

// TODO: if new define was added, we should update block.active
// and block.defined here!
scopeFeatureCount = mScope->features().count();
if (scopeFeatureCount != previousFeatureCount) {
previousFeatureCount = scopeFeatureCount;
const auto &features = mScope->features().values();
for (const auto &feature : features) {
if (!block.defined.contains(feature.define)) {
block.defined.insert(feature.define, feature.enabled);
}
}
}

// Glue words together
for (int i = 0; i < w.length(); ++i) {
Expand Down
11 changes: 6 additions & 5 deletions gibs/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ int main(int argc, char *argv[]) {
<< "\n\tOrganisation:" << app.organizationName()
<< "\n\tDomain:" << app.organizationDomain()
<< "\n\tVersion:" << app.applicationVersion()
<< "\n\tSHA:" << GIT_COMMIT_ID;
<< "\n\tSHA:" << GIT_COMMIT_ID
<< "\n\tArgs:" << app.arguments();


QCommandLineParser parser;
Expand Down Expand Up @@ -143,21 +144,21 @@ int main(int argc, char *argv[]) {
}

// Extract features:
QHash<QString, Gibs::Feature> features;
if (args.length() > 1) {
const auto commands = args.mid(1);
qDebug() << "Features:" << commands;
QHash<QString, Gibs::Feature> features;
for (const auto &command: commands) {
const auto &feature = Gibs::commandLineToFeature(command);
features.insert(feature.name, feature);
qDebug() << "Feature:" << feature.name << feature.define << feature.defined << feature.enabled;
qDebug() << "Feature:" << feature.name
<< "enabled:" << feature.enabled;
}
}

ProjectManager manager(flags);
manager.loadCache();
manager.loadCommands();
// TODO: pass features to manager
manager.loadFeatures(features);
QObject::connect(&manager, &ProjectManager::finished, &app, &QCoreApplication::exit);

if (flags.clean()) {
Expand Down
11 changes: 8 additions & 3 deletions gibs/src/projectmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,13 @@ void ProjectManager::runNextProcess()

void ProjectManager::connectScope(const ScopePtr &scope)
{
connect(scope.data(), &Scope::error, this, &ProjectManager::error);
connect(scope.data(), &Scope::subproject, this, &ProjectManager::onSubproject);
connect(scope.data(), &Scope::runProcess, this, &ProjectManager::runProcess,
connect(scope.data(), &Scope::error,
this, &ProjectManager::error);
connect(scope.data(), &Scope::subproject,
this, &ProjectManager::onSubproject);
connect(scope.data(), &Scope::runProcess,
this, &ProjectManager::runProcess,
Qt::QueuedConnection);
connect(scope.data(), &Scope::feature,
this, &ProjectManager::onFeatureUpdated);
}
11 changes: 9 additions & 2 deletions gibs/src/scope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,13 @@ void Scope::onFeature(const QString &name, const bool isOn)
feat.name = name;
feat.define = Gibs::normalizeFeatureName(name);
result = feat;
emit feature(feat);
}

emit feature(result);
//qDebug() << "Processed feature:" << result.name << result.define << result.defined << result.enabled;

if (result.enabled) {
addDefines(QStringList {name});
addDefines(QStringList {result.define});
}
}

Expand Down Expand Up @@ -827,6 +829,11 @@ bool Scope::initializeMoc()
return qtIsMocInitialized();
}

QHash<QString, Gibs::Feature> Scope::features() const
{
return mFeatures;
}

void Scope::setVersion(const QVersionNumber &version)
{
mVersion = version;
Expand Down
2 changes: 2 additions & 0 deletions gibs/src/scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ class Scope : public QObject
QVersionNumber version() const;
void setVersion(const QVersionNumber &version);

QHash<QString, Gibs::Feature> features() const;

public slots:
void start(bool fromCache, bool isQuickMode);
void clean();
Expand Down
2 changes: 1 addition & 1 deletion samples/simpletest-feature/custom-test-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

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

CUSTOM_PATH=""
CUSTOM_PATH="main.cpp"
CUSTOM_ARGS="-- --my-feature"
12 changes: 6 additions & 6 deletions scripts/run-compilation-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fi

JOBS="1"
QTDIR=""
IBSEXE=""
GIBSEXE=""
QMAKEEXE=""
LOG="$PWD/compilation-summary.log"
DETAILS="$PWD/compilation-details.log"
Expand All @@ -30,7 +30,7 @@ do
;;
q) QTDIR=$OPTARG
;;
i) IBSEXE=$OPTARG
i) GIBSEXE=$OPTARG
;;
m) QMAKEEXE=$OPTARG
;;
Expand All @@ -44,7 +44,7 @@ do
done

cleanUp() {
rm -f .ibs.cache *.o moc_* .qmake* Makefile
rm -f .gibs.cache *.o moc_* .qmake* Makefile
}

# Clear log file
Expand Down Expand Up @@ -76,13 +76,13 @@ for dir in ../samples/* ; do
#echo "CUSTOM: $CUSTOM_PATH $CUSTOM_ARGS"

ts=$(date +%s%N)
$IBSEXE -j $JOBS --qt-dir $QTDIR $CUSTOM_ARGS $SOURCE/$CUSTOM_PATH >> $DETAILS 2>&1
$GIBSEXE -j $JOBS --qt-dir $QTDIR $SOURCE/$CUSTOM_PATH $CUSTOM_ARGS >> $DETAILS 2>&1
EXIT_CODE=$?
tt=$((($(date +%s%N) - $ts)/1000000))
echo "IBS: $dir/main.cpp $tt" | tee --append $LOG $DETAILS # >/dev/null
echo "GIBS: $dir/main.cpp $tt" | tee --append $LOG $DETAILS # >/dev/null

if [ "$EXIT_CODE" != "0" ]; then
echo "IBS failed with: $EXIT_CODE after $tt"
echo "GIBS failed with: $EXIT_CODE after $tt"
exit $EXIT_CODE
fi

Expand Down

0 comments on commit 7b3dcad

Please sign in to comment.