diff options
author | Jake Petroules <jake.petroules@petroules.com> | 2014-01-08 14:36:16 -0500 |
---|---|---|
committer | Jake Petroules <jake.petroules@petroules.com> | 2014-01-14 17:41:47 +0100 |
commit | 49a051bd4b320aff32066181932dc27a4eea63c5 (patch) | |
tree | a8f5c6e56bb275d2ae8c83179065623385d1395a /src/lib/corelib/buildgraph | |
parent | cf706560d394e582a897d2a69e79ce5740d2459d (diff) |
Prepare for using QT_NO_CAST_FROM/TO_ASCII.
Change-Id: Ib39e49e896cbddf5a5bd851088500991d962355a
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Diffstat (limited to 'src/lib/corelib/buildgraph')
-rw-r--r-- | src/lib/corelib/buildgraph/artifactcleaner.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/automoc.cpp | 10 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/buildgraph.cpp | 14 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/command.cpp | 82 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/executor.cpp | 10 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/inputartifactscanner.cpp | 13 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/jscommandexecutor.cpp | 2 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/processcommandexecutor.cpp | 12 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/projectbuilddata.cpp | 6 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/rulesapplicator.cpp | 56 | ||||
-rw-r--r-- | src/lib/corelib/buildgraph/transformer.cpp | 19 |
11 files changed, 133 insertions, 93 deletions
diff --git a/src/lib/corelib/buildgraph/artifactcleaner.cpp b/src/lib/corelib/buildgraph/artifactcleaner.cpp index 98fed728e..a1e91cdaf 100644 --- a/src/lib/corelib/buildgraph/artifactcleaner.cpp +++ b/src/lib/corelib/buildgraph/artifactcleaner.cpp @@ -166,7 +166,7 @@ void ArtifactCleaner::cleanup(const TopLevelProjectPtr &project, if (dir.startsWith(project->buildDirectory) && FileInfo(dir).exists()) removeEmptyDirectories(dir, options); if (dir != project->buildDirectory) { - const QString parentDir = QDir::cleanPath(dir + "/.."); + const QString parentDir = QDir::cleanPath(dir + QLatin1String("/..")); if (parentDir != project->buildDirectory && !dirList.contains(parentDir)) dirList << parentDir; } diff --git a/src/lib/corelib/buildgraph/automoc.cpp b/src/lib/corelib/buildgraph/automoc.cpp index 5dcb6ec9f..38db3b83c 100644 --- a/src/lib/corelib/buildgraph/automoc.cpp +++ b/src/lib/corelib/buildgraph/automoc.cpp @@ -59,7 +59,7 @@ void AutoMoc::setScanResultCache(ScanResultCache *scanResultCache) void AutoMoc::apply(const ResolvedProductPtr &product) { if (cppScanners().isEmpty() || hppScanners().isEmpty()) - throw ErrorInfo("C++ scanner cannot be loaded."); + throw ErrorInfo(Tr::tr("C++ scanner cannot be loaded.")); Artifact *pluginMetaDataFile = 0; Artifact *pchFile = 0; @@ -159,10 +159,11 @@ QString AutoMoc::generateMocFileName(Artifact *artifact, FileType fileType) case UnknownFileType: break; case HppFileType: - mocFileName = "moc_" + FileInfo::baseName(artifact->filePath()) + ".cpp"; + mocFileName = QLatin1String("moc_") + FileInfo::baseName(artifact->filePath()) + + QLatin1String(".cpp"); break; case CppFileType: - mocFileName = FileInfo::baseName(artifact->filePath()) + ".moc"; + mocFileName = FileInfo::baseName(artifact->filePath()) + QLatin1String(".moc"); break; } return mocFileName; @@ -229,7 +230,8 @@ void AutoMoc::scan(Artifact *artifact, FileType fileType, bool &hasQObjectMacro, foreach (const ScanResultCache::Dependency &dependency, scanResult.deps) { const QString &includedFilePath = dependency.filePath(); - if (includedFilePath.startsWith("moc_") && includedFilePath.endsWith(".cpp")) { + if (includedFilePath.startsWith(QLatin1String("moc_")) && + includedFilePath.endsWith(QLatin1String(".cpp"))) { if (m_logger.traceEnabled()) m_logger.qbsTrace() << "[AUTOMOC] finds included file: " << includedFilePath; includedMocCppFiles += includedFilePath; diff --git a/src/lib/corelib/buildgraph/buildgraph.cpp b/src/lib/corelib/buildgraph/buildgraph.cpp index 542d083c9..af723cff7 100644 --- a/src/lib/corelib/buildgraph/buildgraph.cpp +++ b/src/lib/corelib/buildgraph/buildgraph.cpp @@ -67,7 +67,8 @@ public: setProduct(depfunc, product.data()); QScriptValue descriptor = m_engine->newObject(); descriptor.setProperty(QLatin1String("get"), depfunc); - descriptor.setProperty(QLatin1String("set"), m_engine->evaluate("(function(){})")); + descriptor.setProperty(QLatin1String("set"), + m_engine->evaluate(QLatin1String("(function(){})"))); descriptor.setProperty(QLatin1String("enumerable"), true); m_engine->defineProperty(productScriptValue, QLatin1String("dependencies"), descriptor); } @@ -124,7 +125,8 @@ private: depfunc.setData(engine->toScriptValue(propMap.value(QLatin1String("modules")))); QScriptValue descriptor = engine->newObject(); descriptor.setProperty(QLatin1String("get"), depfunc); - descriptor.setProperty(QLatin1String("set"), engine->evaluate("(function(){})")); + descriptor.setProperty(QLatin1String("set"), + engine->evaluate(QLatin1String("(function(){})"))); descriptor.setProperty(QLatin1String("enumerable"), true); engine->defineProperty(moduleScriptValue, QLatin1String("dependencies"), descriptor); moduleScriptValue.setProperty(QLatin1String("type"), QLatin1String("module")); @@ -324,7 +326,7 @@ QString relativeArtifactFileName(const Artifact *artifact) QString str = artifact->filePath(); if (str.startsWith(buildDir)) str.remove(0, buildDir.count()); - if (str.startsWith('/')) + if (str.startsWith(QLatin1Char('/'))) str.remove(0, 1); return str; } @@ -397,12 +399,12 @@ void insertArtifact(const ResolvedProductPtr &product, Artifact *artifact, const if (lookupArtifact(otherProduct, artifact->filePath())) { if (artifact->artifactType == Artifact::Generated) { QString pl; - pl.append(QString(" - %1 \n").arg(product->name)); + pl.append(QString::fromLatin1(" - %1 \n").arg(product->name)); foreach (const ResolvedProductConstPtr &p, product->project->products) { if (lookupArtifact(p, artifact->filePath())) - pl.append(QString(" - %1 \n").arg(p->name)); + pl.append(QString::fromLatin1(" - %1 \n").arg(p->name)); } - throw ErrorInfo(QString ("BUG: already inserted in this project: %1\n%2") + throw ErrorInfo(QString::fromLatin1("BUG: already inserted in this project: %1\n%2") .arg(artifact->filePath()).arg(pl), CodeLocation(), true); } } diff --git a/src/lib/corelib/buildgraph/command.cpp b/src/lib/corelib/buildgraph/command.cpp index 8e30906ee..60ec93907 100644 --- a/src/lib/corelib/buildgraph/command.cpp +++ b/src/lib/corelib/buildgraph/command.cpp @@ -70,9 +70,9 @@ bool AbstractCommand::equals(const AbstractCommand *other) const void AbstractCommand::fillFromScriptValue(const QScriptValue *scriptValue, const CodeLocation &codeLocation) { - m_description = scriptValue->property("description").toString(); - m_highlight = scriptValue->property("highlight").toString(); - m_silent = scriptValue->property("silent").toBool(); + m_description = scriptValue->property(QLatin1String("description")).toString(); + m_highlight = scriptValue->property(QLatin1String("highlight")).toString(); + m_silent = scriptValue->property(QLatin1String("silent")).toBool(); m_codeLocation = codeLocation; } @@ -90,9 +90,12 @@ static QScriptValue js_CommandBase(QScriptContext *context, QScriptEngine *engin { QScriptValue cmd = context->thisObject(); QBS_ASSERT(context->isCalledAsConstructor(), cmd = engine->newObject()); - cmd.setProperty("description", engine->toScriptValue(AbstractCommand::defaultDescription())); - cmd.setProperty("highlight", engine->toScriptValue(AbstractCommand::defaultHighLight())); - cmd.setProperty("silent", engine->toScriptValue(AbstractCommand::defaultIsSilent())); + cmd.setProperty(QLatin1String("description"), + engine->toScriptValue(AbstractCommand::defaultDescription())); + cmd.setProperty(QLatin1String("highlight"), + engine->toScriptValue(AbstractCommand::defaultHighLight())); + cmd.setProperty(QLatin1String("silent"), + engine->toScriptValue(AbstractCommand::defaultIsSilent())); return cmd; } @@ -110,16 +113,24 @@ static QScriptValue js_Command(QScriptContext *context, QScriptEngine *engine) if (arguments.isUndefined()) arguments = engine->toScriptValue(commandPrototype.arguments()); QScriptValue cmd = js_CommandBase(context, engine); - cmd.setProperty("className", engine->toScriptValue(QString("Command"))); - cmd.setProperty("program", program); - cmd.setProperty("arguments", arguments); - cmd.setProperty("workingDir", engine->toScriptValue(commandPrototype.workingDir())); - cmd.setProperty("maxExitCode", engine->toScriptValue(commandPrototype.maxExitCode())); - cmd.setProperty("stdoutFilterFunction", engine->toScriptValue(commandPrototype.stdoutFilterFunction())); - cmd.setProperty("stderrFilterFunction", engine->toScriptValue(commandPrototype.stderrFilterFunction())); - cmd.setProperty("responseFileThreshold", engine->toScriptValue(commandPrototype.responseFileThreshold())); - cmd.setProperty("responseFileUsagePrefix", engine->toScriptValue(commandPrototype.responseFileUsagePrefix())); - cmd.setProperty("environment", engine->toScriptValue(commandPrototype.environment().toStringList())); + cmd.setProperty(QLatin1String("className"), + engine->toScriptValue(QString::fromLatin1("Command"))); + cmd.setProperty(QLatin1String("program"), program); + cmd.setProperty(QLatin1String("arguments"), arguments); + cmd.setProperty(QLatin1String("workingDir"), + engine->toScriptValue(commandPrototype.workingDir())); + cmd.setProperty(QLatin1String("maxExitCode"), + engine->toScriptValue(commandPrototype.maxExitCode())); + cmd.setProperty(QLatin1String("stdoutFilterFunction"), + engine->toScriptValue(commandPrototype.stdoutFilterFunction())); + cmd.setProperty(QLatin1String("stderrFilterFunction"), + engine->toScriptValue(commandPrototype.stderrFilterFunction())); + cmd.setProperty(QLatin1String("responseFileThreshold"), + engine->toScriptValue(commandPrototype.responseFileThreshold())); + cmd.setProperty(QLatin1String("responseFileUsagePrefix"), + engine->toScriptValue(commandPrototype.responseFileUsagePrefix())); + cmd.setProperty(QLatin1String("environment"), + engine->toScriptValue(commandPrototype.environment().toStringList())); return cmd; } @@ -128,7 +139,7 @@ void ProcessCommand::setupForJavaScript(QScriptValue targetObject) { QBS_CHECK(targetObject.isObject()); QScriptValue ctor = targetObject.engine()->newFunction(js_Command, 2); - targetObject.setProperty("Command", ctor); + targetObject.setProperty(QLatin1String("Command"), ctor); } ProcessCommand::ProcessCommand() @@ -169,14 +180,18 @@ bool ProcessCommand::equals(const AbstractCommand *otherAbstractCommand) const void ProcessCommand::fillFromScriptValue(const QScriptValue *scriptValue, const CodeLocation &codeLocation) { AbstractCommand::fillFromScriptValue(scriptValue, codeLocation); - m_program = scriptValue->property("program").toString(); - m_arguments = scriptValue->property("arguments").toVariant().toStringList(); - m_workingDir = scriptValue->property("workingDirectory").toString(); - m_maxExitCode = scriptValue->property("maxExitCode").toInt32(); - m_stdoutFilterFunction = scriptValue->property("stdoutFilterFunction").toString(); - m_stderrFilterFunction = scriptValue->property("stderrFilterFunction").toString(); - m_responseFileThreshold = scriptValue->property("responseFileThreshold").toInt32(); - m_responseFileUsagePrefix = scriptValue->property("responseFileUsagePrefix").toString(); + m_program = scriptValue->property(QLatin1String("program")).toString(); + m_arguments = scriptValue->property(QLatin1String("arguments")).toVariant().toStringList(); + m_workingDir = scriptValue->property(QLatin1String("workingDirectory")).toString(); + m_maxExitCode = scriptValue->property(QLatin1String("maxExitCode")).toInt32(); + m_stdoutFilterFunction = + scriptValue->property(QLatin1String("stdoutFilterFunction")).toString(); + m_stderrFilterFunction = + scriptValue->property(QLatin1String("stderrFilterFunction")).toString(); + m_responseFileThreshold = scriptValue->property(QLatin1String("responseFileThreshold")) + .toInt32(); + m_responseFileUsagePrefix = scriptValue->property(QLatin1String("responseFileUsagePrefix")) + .toString(); QStringList envList = scriptValue->property(QLatin1String("environment")).toVariant() .toStringList(); getEnvironmentFromList(envList); @@ -218,13 +233,15 @@ static QScriptValue js_JavaScriptCommand(QScriptContext *context, QScriptEngine return context->throwError(Tr::tr("JavaScriptCommand constructor called without new.")); if (Q_UNLIKELY(context->argumentCount() != 0)) { return context->throwError(QScriptContext::SyntaxError, - "JavaScriptCommand c'tor doesn't take arguments."); + QLatin1String("JavaScriptCommand c'tor doesn't take arguments.")); } static JavaScriptCommand commandPrototype; QScriptValue cmd = js_CommandBase(context, engine); - cmd.setProperty("className", engine->toScriptValue(QString("JavaScriptCommand"))); - cmd.setProperty("sourceCode", engine->toScriptValue(commandPrototype.sourceCode())); + cmd.setProperty(QLatin1String("className"), + engine->toScriptValue(QString::fromLatin1("JavaScriptCommand"))); + cmd.setProperty(QLatin1String("sourceCode"), + engine->toScriptValue(commandPrototype.sourceCode())); return cmd; } @@ -232,7 +249,7 @@ void JavaScriptCommand::setupForJavaScript(QScriptValue targetObject) { QBS_CHECK(targetObject.isObject()); QScriptValue ctor = targetObject.engine()->newFunction(js_JavaScriptCommand, 0); - targetObject.setProperty("JavaScriptCommand", ctor); + targetObject.setProperty(QLatin1String("JavaScriptCommand"), ctor); } JavaScriptCommand::JavaScriptCommand() @@ -252,13 +269,14 @@ bool JavaScriptCommand::equals(const AbstractCommand *otherAbstractCommand) cons void JavaScriptCommand::fillFromScriptValue(const QScriptValue *scriptValue, const CodeLocation &codeLocation) { AbstractCommand::fillFromScriptValue(scriptValue, codeLocation); - QScriptValue sourceCode = scriptValue->property("sourceCode"); + QScriptValue sourceCode = scriptValue->property(QLatin1String("sourceCode")); if (sourceCode.isFunction()) - m_sourceCode = "(" + sourceCode.toString() + ")()"; + m_sourceCode = QLatin1String("(") + sourceCode.toString() + QLatin1String(")()"); else m_sourceCode = sourceCode.toString(); static QSet<QString> predefinedProperties = QSet<QString>() - << "description" << "highlight" << "silent" << "className" << "sourceCode"; + << QLatin1String("description") << QLatin1String("highlight") << QLatin1String("silent") + << QLatin1String("className") << QLatin1String("sourceCode"); QScriptValueIterator it(*scriptValue); while (it.hasNext()) { diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp index fe546c97b..3938e961b 100644 --- a/src/lib/corelib/buildgraph/executor.cpp +++ b/src/lib/corelib/buildgraph/executor.cpp @@ -505,7 +505,7 @@ void Executor::buildArtifact(Artifact *artifact) Artifact *output = *it; QDir outDir = QFileInfo(output->filePath()).absoluteDir(); if (!outDir.exists()) - outDir.mkpath("."); + outDir.mkpath(QLatin1String(".")); } } @@ -547,7 +547,7 @@ void Executor::buildArtifact(Artifact *artifact) m_processingJobs.insert(job, artifact); Q_ASSERT_X(artifact->product, Q_FUNC_INFO, - qPrintable(QString("Generated artifact '%1' belongs to no product.") + qPrintable(QString::fromLatin1("Generated artifact '%1' belongs to no product.") .arg(QDir::toNativeSeparators(artifact->filePath())))); job->run(artifact->transformer.data(), artifact->product); @@ -724,7 +724,7 @@ void Executor::addExecutorJobs(int jobNumber) for (int i = 1; i <= jobNumber; i++) { ExecutorJob *job = new ExecutorJob(m_logger, this); job->setMainThreadScriptEngine(m_evalContext->engine()); - job->setObjectName(QString(QLatin1String("J%1")).arg(i)); + job->setObjectName(QString::fromLatin1("J%1").arg(i)); m_availableJobs.append(job); connect(job, SIGNAL(reportCommandDescription(QString,QString)), this, SIGNAL(reportCommandDescription(QString,QString)), Qt::QueuedConnection); @@ -744,7 +744,7 @@ void Executor::runAutoMoc() throw ErrorInfo(Tr::tr("Build canceled%1.").arg(configString())); // HACK call the automoc thingy here only if we have use Qt/core module foreach (const ResolvedModuleConstPtr &m, product->modules) { - if (m->name == "Qt/core") { + if (m->name == QLatin1String("Qt/core")) { autoMocApplied = true; m_autoMoc->apply(product); break; @@ -817,7 +817,7 @@ void Executor::finish() m_logger.qbsInfo() << Tr::tr("Build done%1.").arg(configString()); } else { m_error.append(Tr::tr("The following products could not be built%1: %2.") - .arg(configString(), unbuiltProductNames.join(", "))); + .arg(configString(), unbuiltProductNames.join(QLatin1String(", ")))); } if (m_explicitlyCanceled) diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.cpp b/src/lib/corelib/buildgraph/inputartifactscanner.cpp index d5a0fabb6..ba646c54f 100644 --- a/src/lib/corelib/buildgraph/inputartifactscanner.cpp +++ b/src/lib/corelib/buildgraph/inputartifactscanner.cpp @@ -62,12 +62,14 @@ static void collectIncludePaths(const QVariantMap &modules, QSet<QString> *colle QMapIterator<QString, QVariant> iterator(modules); while (iterator.hasNext()) { iterator.next(); - if (iterator.key() == "cpp") { - QVariant includePathsVariant = iterator .value().toMap().value("includePaths"); + if (iterator.key() == QLatin1String("cpp")) { + QVariant includePathsVariant = + iterator.value().toMap().value(QLatin1String("includePaths")); if (includePathsVariant.isValid()) collectedPaths->unite(QSet<QString>::fromList(includePathsVariant.toStringList())); } else { - collectIncludePaths(iterator.value().toMap().value("modules").toMap(), collectedPaths); + collectIncludePaths(iterator.value().toMap().value(QLatin1String("modules")).toMap(), + collectedPaths); } } } @@ -184,7 +186,8 @@ void InputArtifactScanner::scan() if (cacheHit) { includePaths = cacheItem.includePaths; } else { - includePaths = collectIncludePaths(inputArtifact->properties->value().value("modules").toMap()); + includePaths = collectIncludePaths(inputArtifact->properties->value() + .value(QLatin1String("modules")).toMap()); cacheItem.includePaths = includePaths; cacheItem.valid = true; } @@ -212,7 +215,7 @@ void InputArtifactScanner::scanForFileDependencies(ScannerPlugin *scannerPlugin, { if (m_logger.debugEnabled()) { m_logger.qbsDebug() << QString::fromLocal8Bit("scanning %1 [%2]\n from %3") - .arg(inputArtifact->filePath()).arg(scannerPlugin->fileTag) + .arg(inputArtifact->filePath()).arg(QLatin1String(scannerPlugin->fileTag)) .arg(m_artifact->filePath()); } diff --git a/src/lib/corelib/buildgraph/jscommandexecutor.cpp b/src/lib/corelib/buildgraph/jscommandexecutor.cpp index 5de52e581..b51dd6475 100644 --- a/src/lib/corelib/buildgraph/jscommandexecutor.cpp +++ b/src/lib/corelib/buildgraph/jscommandexecutor.cpp @@ -172,7 +172,7 @@ void JsCommandExecutor::onJavaScriptCommandFinished() if (!result.success) { logger().qbsDebug() << "JS context:\n" << jsCommand()->properties(); logger().qbsDebug() << "JS code:\n" << jsCommand()->sourceCode(); - QString msg = "Error while executing JavaScriptCommand:\n"; + QString msg = tr("Error while executing JavaScriptCommand:\n"); msg += result.errorMessage; emit error(ErrorInfo(msg, result.errorLocation)); } diff --git a/src/lib/corelib/buildgraph/processcommandexecutor.cpp b/src/lib/corelib/buildgraph/processcommandexecutor.cpp index 8887cc99f..3c435fcde 100644 --- a/src/lib/corelib/buildgraph/processcommandexecutor.cpp +++ b/src/lib/corelib/buildgraph/processcommandexecutor.cpp @@ -77,7 +77,7 @@ ProcessCommandExecutor::ProcessCommandExecutor(const Logger &logger, QObject *pa static QString commandArgsToString(const QStringList &args) { QString result; - QRegExp ws("\\s"); + QRegExp ws(QLatin1String("\\s")); foreach (const QString &arg, args) { result += QLatin1Char(' '); @@ -131,7 +131,7 @@ void ProcessCommandExecutor::doStart() // We need to delete the file manually, later. QTemporaryFile responseFile; responseFile.setAutoRemove(false); - responseFile.setFileTemplate(QDir::tempPath() + "/qbsresp"); + responseFile.setFileTemplate(QDir::tempPath() + QLatin1String("/qbsresp")); if (!responseFile.open()) { emit error(ErrorInfo(Tr::tr("Cannot create response file '%1'.") .arg(responseFile.fileName()))); @@ -171,7 +171,9 @@ QString ProcessCommandExecutor::filterProcessOutput(const QByteArray &_output, if (filterFunctionSource.isEmpty()) return output; - QScriptValue filterFunction = scriptEngine()->evaluate("var f = " + filterFunctionSource + "; f"); + QScriptValue filterFunction = scriptEngine()->evaluate(QLatin1String("var f = ") + + filterFunctionSource + + QLatin1String("; f")); if (!filterFunction.isFunction()) { emit error(ErrorInfo(Tr::tr("Error in filter function: %1.\n%2") .arg(filterFunctionSource, filterFunction.toString()))); @@ -285,8 +287,8 @@ QString ProcessCommandExecutor::findProcessCommandInPath() if (logger().traceEnabled()) logger().qbsTrace() << "[EXEC] looking for executable in PATH " << fullProgramPath; const QProcessEnvironment &buildEnvironment = product->buildEnvironment; - QStringList pathEnv = buildEnvironment.value("PATH").split(HostOsInfo::pathListSeparator(), - QString::SkipEmptyParts); + QStringList pathEnv = buildEnvironment.value(QLatin1String("PATH")) + .split(HostOsInfo::pathListSeparator(), QString::SkipEmptyParts); if (HostOsInfo::isWindowsHost()) pathEnv.prepend(QLatin1String(".")); for (int i = 0; i < pathEnv.count(); ++i) { diff --git a/src/lib/corelib/buildgraph/projectbuilddata.cpp b/src/lib/corelib/buildgraph/projectbuilddata.cpp index d671a029b..5c2188753 100644 --- a/src/lib/corelib/buildgraph/projectbuilddata.cpp +++ b/src/lib/corelib/buildgraph/projectbuilddata.cpp @@ -328,7 +328,8 @@ void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &produc foreach (const QString &inputFileName, rtrafo->inputs) { Artifact *artifact = lookupArtifact(product, inputFileName); if (Q_UNLIKELY(!artifact)) - throw ErrorInfo(QString("Can't find artifact '%0' in the list of source files.").arg(inputFileName)); + throw ErrorInfo(Tr::tr("Can't find artifact '%0' in the list of source files.") + .arg(inputFileName)); inputArtifacts += artifact; } TransformerPtr transformer = Transformer::create(); @@ -369,7 +370,8 @@ void BuildDataResolver::resolveProductBuildData(const ResolvedProductPtr &produc ScriptEngine::argumentList(transformer->rule->prepareScript->argumentNames, prepareScriptContext)); if (Q_UNLIKELY(transformer->commands.isEmpty())) - throw ErrorInfo(QString("There's a transformer without commands."), rtrafo->transform->location); + throw ErrorInfo(Tr::tr("There's a transformer without commands."), + rtrafo->transform->location); } // Handle Transformer.explicitlyDependsOn after all transformer outputs have been created. diff --git a/src/lib/corelib/buildgraph/rulesapplicator.cpp b/src/lib/corelib/buildgraph/rulesapplicator.cpp index 8a60c709e..e5b5621da 100644 --- a/src/lib/corelib/buildgraph/rulesapplicator.cpp +++ b/src/lib/corelib/buildgraph/rulesapplicator.cpp @@ -100,8 +100,9 @@ void RulesApplicator::doApply(const ArtifactList &inputArtifacts, evalContext()->checkForCancelation(); if (m_logger.debugEnabled()) { - m_logger.qbsDebug() << "[BG] apply rule " << m_rule->toString() << " " - << toStringList(inputArtifacts).join(",\n "); + m_logger.qbsDebug() << QString::fromLatin1("[BG] apply rule ") << m_rule->toString() + << QString::fromLatin1(" ") + << toStringList(inputArtifacts).join(QLatin1String(",\n ")); } QList<QPair<const RuleArtifact *, Artifact *> > ruleArtifactArtifactMap; @@ -171,22 +172,25 @@ void RulesApplicator::doApply(const ArtifactList &inputArtifacts, Artifact *outputArtifact = ruleArtifactArtifactMap.at(i).second; outputArtifact->properties = outputArtifact->properties->clone(); - scope().setProperty("fileName", engine()->toScriptValue(outputArtifact->filePath())); - scope().setProperty("fileTags", + scope().setProperty(QLatin1String("fileName"), + engine()->toScriptValue(outputArtifact->filePath())); + scope().setProperty(QLatin1String("fileTags"), toScriptValue(engine(), outputArtifact->fileTags.toStringList())); - QVariantMap artifactModulesCfg = outputArtifact->properties->value().value("modules").toMap(); + QVariantMap artifactModulesCfg = outputArtifact->properties->value() + .value(QLatin1String("modules")).toMap(); for (int i=0; i < ra->bindings.count(); ++i) { const RuleArtifact::Binding &binding = ra->bindings.at(i); scriptValue = engine()->evaluate(binding.code); if (Q_UNLIKELY(engine()->hasErrorOrException(scriptValue))) { QString msg = QLatin1String("evaluating rule binding '%1': %2"); - throw ErrorInfo(msg.arg(binding.name.join(QLatin1String(".")), scriptValue.toString()), binding.location); + throw ErrorInfo(msg.arg(binding.name.join(QLatin1String(".")), + scriptValue.toString()), binding.location); } setConfigProperty(artifactModulesCfg, binding.name, scriptValue.toVariant()); } QVariantMap outputArtifactConfig = outputArtifact->properties->value(); - outputArtifactConfig.insert("modules", artifactModulesCfg); + outputArtifactConfig.insert(QLatin1String("modules"), artifactModulesCfg); outputArtifact->properties->setValue(outputArtifactConfig); } if (!ruleArtifactArtifactMap.isEmpty()) @@ -196,7 +200,8 @@ void RulesApplicator::doApply(const ArtifactList &inputArtifacts, m_transformer->createCommands(m_rule->prepareScript, evalContext(), ScriptEngine::argumentList(m_rule->prepareScript->argumentNames, prepareScriptContext)); if (Q_UNLIKELY(m_transformer->commands.isEmpty())) - throw ErrorInfo(QString("There's a rule without commands: %1.").arg(m_rule->toString()), m_rule->prepareScript->location); + throw ErrorInfo(Tr::tr("There's a rule without commands: %1.") + .arg(m_rule->toString()), m_rule->prepareScript->location); } void RulesApplicator::setupScriptEngineForArtifact(Artifact *artifact) @@ -217,13 +222,13 @@ void RulesApplicator::setupScriptEngineForArtifact(Artifact *artifact) // expose per file properties we want to use in an Artifact within a Rule QScriptValue scriptValue = engine()->newObject(); ModuleProperties::init(scriptValue, artifact); - scriptValue.setProperty("fileName", inFileName); - scriptValue.setProperty("baseName", inBaseName); - scriptValue.setProperty("completeBaseName", inCompleteBaseName); - scriptValue.setProperty("baseDir", basedir); + scriptValue.setProperty(QLatin1String("fileName"), inFileName); + scriptValue.setProperty(QLatin1String("baseName"), inBaseName); + scriptValue.setProperty(QLatin1String("completeBaseName"), inCompleteBaseName); + scriptValue.setProperty(QLatin1String("baseDir"), basedir); - scope().setProperty("input", scriptValue); - Q_ASSERT_X(scriptValue.strictlyEquals(engine()->evaluate("input")), + scope().setProperty(QLatin1String("input"), scriptValue); + Q_ASSERT_X(scriptValue.strictlyEquals(engine()->evaluate(QLatin1String("input"))), "BG", "The input object is not in current scope."); } @@ -232,9 +237,11 @@ Artifact *RulesApplicator::createOutputArtifact(const RuleArtifactConstPtr &rule { QScriptValue scriptValue = engine()->evaluate(ruleArtifact->fileName); if (Q_UNLIKELY(engine()->hasErrorOrException(scriptValue))) - throw ErrorInfo("Error in Rule.Artifact fileName: " + scriptValue.toString()); + throw ErrorInfo(Tr::tr("Error in Rule.Artifact fileName: ") + scriptValue.toString()); QString outputPath = scriptValue.toString(); - outputPath.replace("..", "dotdot"); // don't let the output artifact "escape" its build dir + + // Don't let the output artifact "escape" its build dir + outputPath.replace(QLatin1String(".."), QLatin1String("dotdot")); outputPath = resolveOutPath(outputPath); Artifact *outputArtifact = lookupArtifact(m_product, outputPath); @@ -252,18 +259,21 @@ Artifact *RulesApplicator::createOutputArtifact(const RuleArtifactConstPtr &rule m_transformer->inputs.unite(inputArtifacts); if (Q_UNLIKELY(m_transformer->inputs.count() > 1 && !m_rule->multiplex)) { - QString th = "[" + outputArtifact->fileTags.toStringList().join(", ") + "]"; - QString e = Tr::tr("Conflicting rules for producing %1 %2 \n").arg(outputArtifact->filePath(), th); - th = "[" + m_rule->inputs.toStringList().join(", ") - + "] -> [" + outputArtifact->fileTags.toStringList().join(", ") + "]"; - - e += QString(" while trying to apply: %1:%2:%3 %4\n") + QString th = QLatin1Char('[') + outputArtifact->fileTags.toStringList() + .join(QLatin1String(", ")) + QLatin1Char(']'); + QString e = Tr::tr("Conflicting rules for producing %1 %2 \n") + .arg(outputArtifact->filePath(), th); + th = QLatin1Char('[') + m_rule->inputs.toStringList().join(QLatin1String(", ")) + + QLatin1String("] -> [") + outputArtifact->fileTags.toStringList() + .join(QLatin1String(", ")) + QLatin1Char(']'); + + e += QString::fromLatin1(" while trying to apply: %1:%2:%3 %4\n") .arg(m_rule->prepareScript->location.fileName()) .arg(m_rule->prepareScript->location.line()) .arg(m_rule->prepareScript->location.column()) .arg(th); - e += QString(" was already defined in: %1:%2:%3 %4\n") + e += QString::fromLatin1(" was already defined in: %1:%2:%3 %4\n") .arg(outputArtifact->transformer->rule->prepareScript->location.fileName()) .arg(outputArtifact->transformer->rule->prepareScript->location.line()) .arg(outputArtifact->transformer->rule->prepareScript->location.column()) diff --git a/src/lib/corelib/buildgraph/transformer.cpp b/src/lib/corelib/buildgraph/transformer.cpp index 5c095f9db..87bc45527 100644 --- a/src/lib/corelib/buildgraph/transformer.cpp +++ b/src/lib/corelib/buildgraph/transformer.cpp @@ -96,14 +96,14 @@ void Transformer::setupInputs(QScriptEngine *scriptEngine, QScriptValue targetSc { const QString &defaultModuleName = rule->module->name; QScriptValue scriptValue = translateInOutputs(scriptEngine, inputs, defaultModuleName); - targetScriptValue.setProperty("inputs", scriptValue); + targetScriptValue.setProperty(QLatin1String("inputs"), scriptValue); if (inputs.count() == 1) { Artifact *input = *inputs.begin(); const FileTags &fileTags = input->fileTags; QBS_ASSERT(!fileTags.isEmpty(), return); QScriptValue inputsForFileTag = scriptValue.property(fileTags.begin()->toString()); QScriptValue inputScriptValue = inputsForFileTag.property(0); - targetScriptValue.setProperty("input", inputScriptValue); + targetScriptValue.setProperty(QLatin1String("input"), inputScriptValue); } else { targetScriptValue.setProperty(QLatin1String("input"), scriptEngine->undefinedValue()); } @@ -113,14 +113,14 @@ void Transformer::setupOutputs(QScriptEngine *scriptEngine, QScriptValue targetS { const QString &defaultModuleName = rule->module->name; QScriptValue scriptValue = translateInOutputs(scriptEngine, outputs, defaultModuleName); - targetScriptValue.setProperty("outputs", scriptValue); + targetScriptValue.setProperty(QLatin1String("outputs"), scriptValue); if (outputs.count() == 1) { Artifact *output = *outputs.begin(); const FileTags &fileTags = output->fileTags; QBS_ASSERT(!fileTags.isEmpty(), return); QScriptValue outputsForFileTag = scriptValue.property(fileTags.begin()->toString()); QScriptValue outputScriptValue = outputsForFileTag.property(0); - targetScriptValue.setProperty("output", outputScriptValue); + targetScriptValue.setProperty(QLatin1String("output"), outputScriptValue); } else { targetScriptValue.setProperty(QLatin1String("output"), scriptEngine->undefinedValue()); } @@ -132,10 +132,10 @@ static AbstractCommand *createCommandFromScriptValue(const QScriptValue &scriptV if (scriptValue.isUndefined() || !scriptValue.isValid()) return 0; AbstractCommand *cmdBase = 0; - QString className = scriptValue.property("className").toString(); - if (className == "Command") + QString className = scriptValue.property(QLatin1String("className")).toString(); + if (className == QLatin1String("Command")) cmdBase = new ProcessCommand; - else if (className == "JavaScriptCommand") + else if (className == QLatin1String("JavaScriptCommand")) cmdBase = new JavaScriptCommand; if (cmdBase) cmdBase->fillFromScriptValue(&scriptValue, codeLocation); @@ -157,14 +157,15 @@ void Transformer::createCommands(const ScriptFunctionConstPtr &script, propertiesRequestedFromArtifactInPrepareScript = engine->propertiesRequestedFromArtifact(); engine->clearRequestedProperties(); if (Q_UNLIKELY(engine->hasErrorOrException(scriptValue))) - throw ErrorInfo("evaluating prepare script: " + engine->uncaughtException().toString(), + throw ErrorInfo(Tr::tr("evaluating prepare script: ") + + engine->uncaughtException().toString(), CodeLocation(script->location.fileName(), script->location.line() + engine->uncaughtExceptionLineNumber() - 1)); qDeleteAll(commands); commands.clear(); if (scriptValue.isArray()) { - const int count = scriptValue.property("length").toInt32(); + const int count = scriptValue.property(QLatin1String("length")).toInt32(); for (qint32 i = 0; i < count; ++i) { QScriptValue item = scriptValue.property(i); if (item.isValid() && !item.isUndefined()) { |