Merge remote-tracking branch 'origin/8.0'

Conflicts:
	src/plugins/todo/optionsdialog.cpp
	src/plugins/todo/todoprojectsettingswidget.cpp

Change-Id: I24ca90c2fc2cd707df901d42694df6d0e27d696d
This commit is contained in:
Eike Ziller
2022-07-20 11:53:36 +02:00
77 changed files with 917 additions and 227 deletions

View File

@@ -62,8 +62,11 @@ finalOutput() {
local fileInputBuffer
while read fileInputBuffer
do
if test -f "$fileInputBuffer.err"; then
cat $fileInputBuffer.err
fi
cat $fileInputBuffer
rm $fileInputBuffer
rm -f $fileInputBuffer.err $fileInputBuffer
done
}
@@ -117,7 +120,7 @@ executeAndMark()
# Mark the app's output streams
readAndMark $PID 'O' < "$stdoutenc" >> $TMPFILE &
readAndMark $PID 'E' < "$stderrenc" >> $TMPFILE &
readAndMark $PID 'E' < "$stderrenc" >> $TMPFILE.err &
# Start the app ...
if [ -z "$INDATA" ]

View File

@@ -151,7 +151,8 @@ signals:
void append(const QString &text);
void appendSilently(const QString &text);
void appendError(const QString &text);
void appendCommand(const FilePath &workingDirectory, const CommandLine &command);
// TODO: remove Utils:: scope when support for Qt5 is dropped (Creator 9.0)
void appendCommand(const Utils::FilePath &workingDirectory, const Utils::CommandLine &command);
void appendMessage(const QString &text);
void executedAsync(const QFuture<void> &future);

View File

@@ -267,11 +267,15 @@ bool AndroidAvdManager::startAvdAsync(const QString &avdName) const
{
QFileInfo info(m_config.emulatorToolPath().toString());
if (!info.exists()) {
QMessageBox::critical(Core::ICore::dialogParent(),
tr("Emulator Tool Is Missing"),
tr("Install the missing emulator tool (%1) to the"
" installed Android SDK.")
.arg(m_config.emulatorToolPath().toString()));
const QString emulatorToolPath = m_config.emulatorToolPath().toUserOutput();
QMetaObject::invokeMethod(Core::ICore::mainWindow(), [emulatorToolPath] {
QMessageBox::critical(Core::ICore::dialogParent(),
AndroidAvdManager::tr("Emulator Tool Is Missing"),
AndroidAvdManager::tr(
"Install the missing emulator tool (%1) to the"
" installed Android SDK.")
.arg(emulatorToolPath));
});
return false;
}
@@ -283,10 +287,13 @@ bool AndroidAvdManager::startAvdAsync(const QString &avdName) const
avdProcess->setProcessChannelMode(QProcess::MergedChannels);
QObject::connect(avdProcess, &QtcProcess::done, avdProcess, [avdProcess] {
if (avdProcess->exitCode()) {
const QString title = QCoreApplication::translate("Android::Internal::AndroidAvdManager",
"AVD Start Error");
QMessageBox::critical(Core::ICore::dialogParent(), title,
QString::fromLatin1(avdProcess->readAllStandardOutput()));
const QString errorOutput = QString::fromLatin1(avdProcess->readAllStandardOutput());
QMetaObject::invokeMethod(Core::ICore::mainWindow(), [errorOutput] {
const QString title
= QCoreApplication::translate("Android::Internal::AndroidAvdManager",
"AVD Start Error");
QMessageBox::critical(Core::ICore::dialogParent(), title, errorOutput);
});
}
avdProcess->deleteLater();
});

View File

@@ -146,14 +146,14 @@ ClangdFollowSymbol::ClangdFollowSymbol(ClangdClient *client, const QTextCursor &
openInSplit))
{
// Abort if the user does something else with the document in the meantime.
connect(document, &TextDocument::contentsChanged, this, &ClangdFollowSymbol::emitDone,
connect(document, &TextDocument::contentsChanged, this, [this] { emitDone(); },
Qt::QueuedConnection);
if (editorWidget) {
connect(editorWidget, &CppEditorWidget::cursorPositionChanged,
this, &ClangdFollowSymbol::emitDone, Qt::QueuedConnection);
this, [this] { emitDone(); }, Qt::QueuedConnection);
}
d->focusChangedConnection = connect(qApp, &QApplication::focusChanged,
this, &ClangdFollowSymbol::emitDone, Qt::QueuedConnection);
this, [this] { emitDone(); }, Qt::QueuedConnection);
// Step 1: Follow the symbol via "Go to Definition". At the same time, request the
// AST node corresponding to the cursor position, so we can find out whether
@@ -195,6 +195,7 @@ ClangdFollowSymbol::~ClangdFollowSymbol()
d->client->cancelRequest(id);
for (const MessageId &id : qAsConst(d->pendingGotoDefRequests))
d->client->cancelRequest(id);
delete d;
}
void ClangdFollowSymbol::clear()
@@ -205,12 +206,14 @@ void ClangdFollowSymbol::clear()
d->pendingGotoDefRequests.clear();
}
void ClangdFollowSymbol::emitDone()
void ClangdFollowSymbol::emitDone(const Link &link)
{
if (d->done)
return;
d->done = true;
if (link.hasValidTarget())
d->callback(link);
emit done();
}
@@ -246,14 +249,12 @@ void ClangdFollowSymbol::Private::handleDocumentInfoResults()
// If something went wrong, we just follow the original link.
if (symbolsToDisplay.isEmpty()) {
callback(defLink);
q->emitDone();
q->emitDone(defLink);
return;
}
if (symbolsToDisplay.size() == 1) {
callback(symbolsToDisplay.first().second);
q->emitDone();
q->emitDone(symbolsToDisplay.first().second);
return;
}
@@ -382,8 +383,7 @@ void ClangdFollowSymbol::Private::handleGotoDefinitionResult()
// No dis-ambiguation necessary. Call back with the link and finish.
if (!defLinkIsAmbiguous()) {
callback(defLink);
q->emitDone();
q->emitDone(defLink);
return;
}
@@ -416,8 +416,7 @@ void ClangdFollowSymbol::Private::handleGotoImplementationResult(
// We didn't find any further candidates, so jump to the original definition link.
if (allLinks.size() == 1 && pendingGotoImplRequests.isEmpty()) {
callback(allLinks.first());
q->emitDone();
q->emitDone(allLinks.first());
return;
}

View File

@@ -55,7 +55,7 @@ signals:
void done();
private:
void emitDone();
void emitDone(const Utils::Link &link = {});
class VirtualFunctionAssistProcessor;
class VirtualFunctionAssistProvider;

View File

@@ -67,6 +67,7 @@ void ClangToolRunner::init(const FilePath &outputDirPath, const Environment &env
QTC_CHECK(!m_outputDirPath.isEmpty());
m_process.setEnvironment(environment);
m_process.setUseCtrlCStub(true);
m_process.setWorkingDirectory(m_outputDirPath); // Current clang-cl puts log file into working dir.
connect(&m_process, &QtcProcess::done, this, &ClangToolRunner::onProcessDone);
}

View File

@@ -1058,10 +1058,12 @@ void DebuggerEngine::setRunId(const QString &id)
void DebuggerEngine::setRunTool(DebuggerRunTool *runTool)
{
d->m_device = runTool->device();
QTC_ASSERT(d->m_device, d->m_device = DeviceManager::deviceForPath(
d->m_runParameters.inferior.command.executable()));
if (QTC_GUARD(d->m_device))
d->m_runParameters.dumperPath = d->m_device->debugDumperPath();
IDevice::ConstPtr debuggerDevice =
DeviceManager::deviceForPath(d->m_runParameters.debugger.command.executable());
if (QTC_GUARD(debuggerDevice))
d->m_runParameters.dumperPath = debuggerDevice->debugDumperPath();
d->m_terminalRunner = runTool->terminalRunner();
validateRunParameters(d->m_runParameters);

View File

@@ -274,7 +274,7 @@ GitLabOptionsPage::GitLabOptionsPage(GitLabParameters *p, QObject *parent)
: Core::IOptionsPage{parent}
, m_parameters(p)
{
setId("GitLab");
setId(Constants::GITLAB_SETTINGS);
setDisplayName(tr("GitLab"));
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
}

View File

@@ -39,6 +39,10 @@ QT_END_NAMESPACE
namespace GitLab {
namespace Constants {
const char GITLAB_SETTINGS[] = "GitLab";
} // namespace Constants
class GitLabServerWidget : public QWidget
{
public:

View File

@@ -136,6 +136,7 @@ GitLabProjectSettingsWidget::GitLabProjectSettingsWidget(ProjectExplorer::Projec
{
setUseGlobalSettingsCheckBoxVisible(false);
setUseGlobalSettingsLabelVisible(true);
setGlobalSettingsId(Constants::GITLAB_SETTINGS);
// setup ui
auto verticalLayout = new QVBoxLayout(this);
verticalLayout->setContentsMargins(0, 0, 0, 0);

View File

@@ -606,8 +606,10 @@ void AppOutputPane::stopRunControl()
QTC_ASSERT(rc, return);
if (rc->isRunning()) {
if (optionallyPromptToStop(rc))
if (optionallyPromptToStop(rc)) {
rc->initiateStop();
enableButtons(rc);
}
} else {
QTC_CHECK(false);
rc->forceStop();

View File

@@ -201,7 +201,6 @@ BuildConfiguration::BuildConfiguration(Target *target, Utils::Id id)
tr("Variables in the build configuration's environment"),
[this](const QString &var) { return environment().expandedValueForKey(var); });
updateCacheAndEmitEnvironmentChanged();
connect(Core::ICore::instance(), &Core::ICore::systemEnvironmentChanged,
this, &BuildConfiguration::updateCacheAndEmitEnvironmentChanged);
connect(target, &Target::kitChanged,
@@ -292,6 +291,8 @@ void BuildConfiguration::addConfigWidgets(const std::function<void(NamedWidget *
void BuildConfiguration::doInitialize(const BuildInfo &info)
{
updateCacheAndEmitEnvironmentChanged();
setDisplayName(info.displayName);
setDefaultDisplayName(info.displayName);
setBuildDirectory(info.buildDirectory);

View File

@@ -164,6 +164,8 @@ MaterialBrowserWidget::MaterialBrowserWidget()
m_qmlSourceUpdateShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_F8), this);
connect(m_qmlSourceUpdateShortcut, &QShortcut::activated, this, &MaterialBrowserWidget::reloadQmlSource);
QmlDesignerPlugin::trackWidgetFocusTime(this, Constants::EVENT_MATERIALBROWSER_TIME);
reloadQmlSource();
}

View File

@@ -31,18 +31,17 @@
#include "materialeditortransaction.h"
#include "assetslibrarywidget.h"
#include <qmldesignerconstants.h>
#include <qmltimeline.h>
#include <bindingproperty.h>
#include <metainfo.h>
#include <nodeinstanceview.h>
#include <nodelistproperty.h>
#include <nodemetainfo.h>
#include <nodeproperty.h>
#include <nodelistproperty.h>
#include <nodeinstanceview.h>
#include <metainfo.h>
#include <rewritingexception.h>
#include <variantproperty.h>
#include <bindingproperty.h>
#include <qmldesignerconstants.h>
#include <qmldesignerplugin.h>
#include <qmltimeline.h>
#include <theme.h>
@@ -86,6 +85,7 @@ MaterialEditorView::MaterialEditorView(QWidget *parent)
m_stackedWidget->setStyleSheet(Theme::replaceCssColors(
QString::fromUtf8(Utils::FileReader::fetchQrc(":/qmldesigner/stylesheet.css"))));
m_stackedWidget->setMinimumWidth(250);
QmlDesignerPlugin::trackWidgetFocusTime(m_stackedWidget, Constants::EVENT_MATERIALEDITOR_TIME);
}
MaterialEditorView::~MaterialEditorView()

View File

@@ -112,12 +112,13 @@ public:
ModelNode createModelNode(const TypeName &typeName);
ModelNode createModelNode(const TypeName &typeName,
int majorVersion,
int minorVersion,
const PropertyListType &propertyList = PropertyListType(),
const PropertyListType &auxPropertyList = PropertyListType(),
const QString &nodeSource = QString(),
ModelNode::NodeSourceType nodeSourceType = ModelNode::NodeWithoutSource);
int majorVersion,
int minorVersion,
const PropertyListType &propertyList = PropertyListType(),
const PropertyListType &auxPropertyList = PropertyListType(),
const QString &nodeSource = {},
ModelNode::NodeSourceType nodeSourceType = ModelNode::NodeWithoutSource,
const QString &behaviorPropertyName = {});
ModelNode rootModelNode() const;
ModelNode rootModelNode();

View File

@@ -238,6 +238,7 @@ public:
bool isComponent() const;
bool isSubclassOf(const TypeName &typeName, int majorVersion = -1, int minorVersion = -1) const;
QIcon typeIcon() const;
QString behaviorPropertyName() const;
friend void swap(ModelNode &first, ModelNode &second) noexcept
{

View File

@@ -1050,7 +1050,8 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
nodeMetaType,
nodeFlags);
instanceContainerList.append(container);
if (instance.modelNode().behaviorPropertyName().isEmpty())
instanceContainerList.append(container);
}
QVector<ReparentContainer> reparentContainerList;

View File

@@ -78,6 +78,15 @@ using PropertyInfo = QPair<PropertyName, TypeName>;
QVector<PropertyInfo> getObjectTypes(const ObjectValue *ov, const ContextPtr &context, bool local = false, int rec = 0);
static QByteArray getUnqualifiedName(const QByteArray &name)
{
const QList<QByteArray> nameComponents = name.split('.');
if (nameComponents.size() < 2)
return name;
return nameComponents.constLast();
}
static TypeName resolveTypeName(const ASTPropertyReference *ref, const ContextPtr &context, QVector<PropertyInfo> &dotProperties)
{
TypeName type = "unknown";
@@ -765,22 +774,49 @@ NodeMetaInfoPrivate::NodeMetaInfoPrivate(Model *model, TypeName type, int maj, i
} else {
m_isFileComponent = true;
const Imports *imports = context()->imports(document());
const ImportInfo importInfo = imports->info(lookupNameComponent().constLast(), context().data());
const ImportInfo importInfo = imports->info(lookupNameComponent().constLast(),
context().data());
if (importInfo.isValid()) {
if (importInfo.type() == ImportType::Library) {
m_majorVersion = importInfo.version().majorVersion();
m_minorVersion = importInfo.version().minorVersion();
}
bool prepandName = (importInfo.type() == ImportType::Library || importInfo.type() == ImportType::Directory)
&& !m_qualfiedTypeName.contains('.');
bool prepandName = (importInfo.type() == ImportType::Library
|| importInfo.type() == ImportType::Directory)
&& !m_qualfiedTypeName.contains('.');
if (prepandName)
m_qualfiedTypeName.prepend(importInfo.name().toUtf8() + '.');
m_qualfiedTypeName.prepend(importInfo.name().toUtf8() + '.');
}
}
m_objectValue = objectValue;
m_defaultPropertyName = context()->defaultPropertyName(objectValue).toUtf8();
m_isValid = true;
setupPrototypes();
} else {
// Special case for aliased types for the rewriter
const Imports *imports = context()->imports(document());
const ImportInfo importInfo = imports->info(QString::fromUtf8(m_qualfiedTypeName),
context().data());
if (importInfo.isValid()) {
if (importInfo.type() == ImportType::Library) {
m_majorVersion = importInfo.version().majorVersion();
m_minorVersion = importInfo.version().minorVersion();
}
m_qualfiedTypeName = getUnqualifiedName(m_qualfiedTypeName);
bool prepandName = (importInfo.type() == ImportType::Library
|| importInfo.type() == ImportType::Directory);
if (prepandName)
m_qualfiedTypeName.prepend(importInfo.name().toUtf8() + '.');
}
m_objectValue = getObjectValue();
m_defaultPropertyName = context()->defaultPropertyName(objectValue).toUtf8();
m_isValid = true;
setupPrototypes();
}
}
}
@@ -1009,14 +1045,6 @@ bool NodeMetaInfoPrivate::isPropertyEnum(const PropertyName &propertyName) const
return qmlObjectValue->getEnum(QString::fromUtf8(propertyType(propertyName))).isValid();
}
static QByteArray getUnqualifiedName(const QByteArray &name)
{
const QList<QByteArray> nameComponents = name.split('.');
if (nameComponents.size() < 2)
return name;
return nameComponents.constLast();
}
static QByteArray getPackage(const QByteArray &name)
{
QList<QByteArray> nameComponents = name.split('.');

View File

@@ -97,14 +97,15 @@ ModelNode AbstractView::createModelNode(const TypeName &typeName)
}
ModelNode AbstractView::createModelNode(const TypeName &typeName,
int majorVersion,
int minorVersion,
const QList<QPair<PropertyName, QVariant> > &propertyList,
const QList<QPair<PropertyName, QVariant> > &auxPropertyList,
const QString &nodeSource,
ModelNode::NodeSourceType nodeSourceType)
int majorVersion,
int minorVersion,
const QList<QPair<PropertyName, QVariant>> &propertyList,
const QList<QPair<PropertyName, QVariant>> &auxPropertyList,
const QString &nodeSource,
ModelNode::NodeSourceType nodeSourceType,
const QString &behaviorPropertyName)
{
return ModelNode(model()->d->createNode(typeName, majorVersion, minorVersion, propertyList, auxPropertyList, nodeSource, nodeSourceType), model(), this);
return ModelNode(model()->d->createNode(typeName, majorVersion, minorVersion, propertyList, auxPropertyList, nodeSource, nodeSourceType, behaviorPropertyName), model(), this);
}

View File

@@ -389,5 +389,15 @@ void InternalNode::setNodeSourceType(int i)
m_nodeSourceType = i;
}
QString InternalNode::behaviorPropertyName() const
{
return m_behaviorPropertyName;
}
void InternalNode::setBehaviorPropertyName(const QString &name)
{
m_behaviorPropertyName = name;
}
}
}

View File

@@ -123,6 +123,9 @@ public:
int nodeSourceType() const;
void setNodeSourceType(int i);
QString behaviorPropertyName() const;
void setBehaviorPropertyName(const QString &name);
protected:
Pointer internalPointer() const;
void setInternalWeakPointer(const Pointer &pointer);
@@ -149,6 +152,8 @@ private:
QString m_nodeSource;
int m_nodeSourceType = 0;
QString m_behaviorPropertyName;
};
size_t qHash(const InternalNodePointer& node);

View File

@@ -97,9 +97,11 @@ ModelPrivate::ModelPrivate(Model *model)
0,
PropertyListType(),
PropertyListType(),
QString(),
{},
ModelNode::NodeWithoutSource,
{},
true);
m_currentStateNode = m_rootInternalNode;
m_currentTimelineNode = m_rootInternalNode;
}
@@ -250,6 +252,7 @@ InternalNodePointer ModelPrivate::createNode(const TypeName &typeName,
const QList<QPair<PropertyName, QVariant>> &auxPropertyList,
const QString &nodeSource,
ModelNode::NodeSourceType nodeSourceType,
const QString &behaviorPropertyName,
bool isRootNode)
{
if (typeName.isEmpty())
@@ -263,6 +266,8 @@ InternalNodePointer ModelPrivate::createNode(const TypeName &typeName,
InternalNodePointer newNode = InternalNode::create(typeName, majorVersion, minorVersion, internalId);
newNode->setNodeSourceType(nodeSourceType);
newNode->setBehaviorPropertyName(behaviorPropertyName);
using PropertyPair = QPair<PropertyName, QVariant>;
for (const PropertyPair &propertyPair : propertyList) {
@@ -400,7 +405,7 @@ void ModelPrivate::notifyNodeInstanceViewLast(Callable call)
resetModel = true;
}
for (QPointer<AbstractView> view : enabledViews()) {
for (const QPointer<AbstractView> &view : enabledViews()) {
if (!view->isBlockingNotifications())
call(view.data());
}
@@ -429,7 +434,7 @@ void ModelPrivate::notifyNormalViewsLast(Callable call)
if (nodeInstanceView() && !nodeInstanceView()->isBlockingNotifications())
call(nodeInstanceView());
for (QPointer<AbstractView> view : enabledViews()) {
for (const QPointer<AbstractView> &view : enabledViews()) {
if (!view->isBlockingNotifications())
call(view.data());
}
@@ -441,7 +446,7 @@ void ModelPrivate::notifyNormalViewsLast(Callable call)
template<typename Callable>
void ModelPrivate::notifyInstanceChanges(Callable call)
{
for (QPointer<AbstractView> view : enabledViews()) {
for (const QPointer<AbstractView> &view : enabledViews()) {
if (!view->isBlockingNotifications())
call(view.data());
}

View File

@@ -104,6 +104,7 @@ public:
const QList<QPair<PropertyName, QVariant> > &auxPropertyList,
const QString &nodeSource,
ModelNode::NodeSourceType nodeSourceType,
const QString &behaviorPropertyName,
bool isRootNode = false);

View File

@@ -197,7 +197,8 @@ static bool isIdToAvoid(const QString& id)
"shaderInfo",
"sprite",
"spriteSequence",
"baseState"
"baseState",
"rect"
};
return ids.contains(id);
@@ -1435,4 +1436,12 @@ QIcon ModelNode::typeIcon() const
return QIcon(QStringLiteral(":/ItemLibrary/images/item-invalid-icon.png"));
}
QString ModelNode::behaviorPropertyName() const
{
if (m_internalNode.isNull())
return {};
return m_internalNode->behaviorPropertyName();
}
}

View File

@@ -218,6 +218,10 @@ QString QmlTextGenerator::toQml(const ModelNode &node, int indentDepth) const
result = alias + '.';
result += type;
if (!node.behaviorPropertyName().isEmpty()) {
result += " on " + node.behaviorPropertyName();
}
result += QStringLiteral(" {\n");
const int propertyIndentDepth = indentDepth + m_tabSettings.m_indentSize;

View File

@@ -276,7 +276,7 @@ bool RemoveNodeRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePosi
QString RemoveNodeRewriteAction::info() const
{
return QLatin1String("RemoveNodeRewriteAction");
return QLatin1String("RemoveNodeRewriteAction") + QString::number(m_node.internalId());
}
bool RemovePropertyRewriteAction::execute(QmlRefactoring &refactoring, ModelNodePositionStorage &positionStore)

View File

@@ -40,6 +40,7 @@
#include "propertyparser.h"
#include "rewriterview.h"
#include "variantproperty.h"
#include <rewritingexception.h>
#include <enumeration.h>
@@ -435,13 +436,14 @@ class ReadingContext
{
public:
ReadingContext(const Snapshot &snapshot, const Document::Ptr &doc,
const ViewerContext &vContext)
const ViewerContext &vContext, Model *model)
: m_doc(doc)
, m_context(
Link(snapshot, vContext, ModelManagerInterface::instance()->builtins(doc))
(doc, &m_diagnosticLinkMessages))
, m_scopeChain(doc, m_context)
, m_scopeBuilder(&m_scopeChain)
, m_model(model)
{
}
@@ -507,6 +509,36 @@ public:
typeName.prepend(name + QLatin1Char('.'));
}
}
{
TypeName fullTypeName;
for (AST::UiQualifiedId *iter = astTypeNode; iter; iter = iter->next)
if (!iter->name.isEmpty())
fullTypeName += iter->name.toUtf8() + '.';
if (fullTypeName.endsWith('.'))
fullTypeName.chop(1);
NodeMetaInfo metaInfo = m_model->metaInfo(fullTypeName);
bool ok = metaInfo.typeName() == typeName.toUtf8()
&& metaInfo.majorVersion() == majorVersion
&& metaInfo.minorVersion() == minorVersion;
if (!ok) {
qDebug() << Q_FUNC_INFO;
qDebug() << astTypeNode->name.toString() << typeName;
qDebug() << metaInfo.isValid() << metaInfo.typeName();
qDebug() << metaInfo.directSuperClass().typeName();
if (!typeName.startsWith("..."))
throw RewritingException(__LINE__, __FUNCTION__, __FILE__, "test", "test");
}
typeName = QString::fromUtf8(metaInfo.typeName());
majorVersion = metaInfo.majorVersion();
minorVersion = metaInfo.minorVersion();
}
}
/// When something is changed here, also change Check::checkScopeObjectMember in
@@ -759,6 +791,7 @@ private:
ContextPtr m_context;
ScopeChain m_scopeChain;
ScopeBuilder m_scopeBuilder;
Model *m_model;
};
} // namespace Internal
@@ -1127,7 +1160,7 @@ bool TextToModelMerger::load(const QString &data, DifferenceHandler &differenceH
m_vContext = ModelManagerInterface::instance()->projectVContext(Dialect::Qml, m_document);
ReadingContext ctxt(snapshot, m_document, m_vContext);
ReadingContext ctxt(snapshot, m_document, m_vContext, m_rewriterView->model());
m_scopeChain = QSharedPointer<const ScopeChain>(
new ScopeChain(ctxt.scopeChain()));
@@ -1188,6 +1221,15 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
ReadingContext *context,
DifferenceHandler &differenceHandler)
{
auto binding = AST::cast<AST::UiObjectBinding *>(astNode);
const bool hasOnToken = binding && binding->hasOnToken;
QString onTokenProperty;
if (hasOnToken)
onTokenProperty = toString(binding->qualifiedId);
AST::UiQualifiedId *astObjectType = qualifiedTypeNameId(astNode);
AST::UiObjectInitializer *astInitializer = initializerOfObject(astNode);
@@ -1224,10 +1266,10 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
bool isImplicitComponent = modelNode.hasParentProperty() && propertyIsComponentType(modelNode.parentProperty(), typeName, modelNode.model());
if (modelNode.type() != typeName //If there is no valid parentProperty //the node has just been created. The type is correct then.
|| modelNode.majorVersion() != majorVersion
|| modelNode.minorVersion() != minorVersion) {
if (modelNode.type()
!= typeName //If there is no valid parentProperty //the node has just been created. The type is correct then.
|| modelNode.majorVersion() != majorVersion || modelNode.minorVersion() != minorVersion
|| modelNode.behaviorPropertyName() != onTokenProperty) {
const bool isRootNode = m_rewriterView->rootModelNode() == modelNode;
differenceHandler.typeDiffers(isRootNode, modelNode, typeName,
majorVersion, minorVersion,
@@ -1294,7 +1336,8 @@ void TextToModelMerger::syncNode(ModelNode &modelNode,
} else if (auto binding = AST::cast<AST::UiObjectBinding *>(member)) {
const QString astPropertyName = toString(binding->qualifiedId);
if (binding->hasOnToken) {
// skip value sources
// Store Behaviours in the default property
defaultPropertyItems.append(member);
} else {
const Value *propertyType = nullptr;
const ObjectValue *containingObject = nullptr;
@@ -1690,6 +1733,13 @@ ModelNode TextToModelMerger::createModelNode(const TypeName &typeName,
{
QString nodeSource;
auto binding = AST::cast<AST::UiObjectBinding *>(astNode);
const bool hasOnToken = binding && binding->hasOnToken;
QString onTokenProperty;
if (hasOnToken)
onTokenProperty = toString(binding->qualifiedId);
AST::UiQualifiedId *astObjectType = qualifiedTypeNameId(astNode);
@@ -1721,7 +1771,8 @@ ModelNode TextToModelMerger::createModelNode(const TypeName &typeName,
PropertyListType(),
PropertyListType(),
nodeSource,
nodeSourceType);
nodeSourceType,
onTokenProperty);
syncNode(newNode, astNode, context, differenceHandler);
return newNode;

View File

@@ -131,6 +131,8 @@ const char EVENT_ITEMLIBRARY_TIME[] = "itemLibrary";
const char EVENT_TRANSLATIONVIEW_TIME[] = "translationView";
const char EVENT_NAVIGATORVIEW_TIME[] = "navigatorView";
const char EVENT_DESIGNMODE_TIME[] = "designMode";
const char EVENT_MATERIALEDITOR_TIME[] = "materialEditor";
const char EVENT_MATERIALBROWSER_TIME[] = "materialBrowser";
const char PROPERTY_EDITOR_CLASSNAME_PROPERTY[] = "__classNamePrivateInternal";

View File

@@ -90,11 +90,14 @@ void generateMenuEntry(QObject *parent)
Core::Command *cmd = Core::ActionManager::registerAction(action, "QmlProject.CreateCMakeLists");
menu->addAction(cmd, Core::Constants::G_FILE_EXPORT);
action->setEnabled(ProjectExplorer::SessionManager::startupProject() != nullptr);
action->setEnabled(false);
QObject::connect(ProjectExplorer::SessionManager::instance(),
&ProjectExplorer::SessionManager::startupProjectChanged, [action]() {
action->setEnabled(ProjectExplorer::SessionManager::startupProject() != nullptr);
});
&ProjectExplorer::SessionManager::startupProjectChanged,
[action]() {
auto qmlProject = qobject_cast<QmlProject *>(
ProjectExplorer::SessionManager::startupProject());
action->setEnabled(qmlProject != nullptr);
});
}
void onGenerateCmakeLists()

View File

@@ -379,7 +379,8 @@ bool QmlProjectPlugin::initialize(const QStringList &, QString *errorMessage)
}
GenerateCmake::generateMenuEntry(this);
GenerateCmake::CmakeProjectConverter::generateMenuEntry(this);
if (QmlProject::isQtDesignStudio())
GenerateCmake::CmakeProjectConverter::generateMenuEntry(this);
return true;
}

View File

@@ -7504,7 +7504,7 @@ QMimeData *TextEditorWidget::createMimeDataFromSelection() const
tempCursor.setCharFormat(range.format);
}
} else {
const int startPosition = current.position() - start.position()
const int startPosition = current.position() - selectionStart
- removedCount;
int endPosition = startPosition + current.text().count();
if (current != last)

View File

@@ -31,6 +31,8 @@
namespace Todo {
namespace Constants {
const char TODO_SETTINGS[] = "TodoSettings";
// Settings entries
const char SETTINGS_GROUP[] = "TodoPlugin";
const char SCANNING_SCOPE[] = "ScanningScope";

View File

@@ -26,8 +26,9 @@
#include "optionsdialog.h"
#include "keyworddialog.h"
#include "constants.h"
#include "keyword.h"
#include "keyworddialog.h"
#include "settings.h"
#include "todotr.h"
@@ -267,7 +268,7 @@ void OptionsDialog::apply()
TodoOptionsPage::TodoOptionsPage(Settings *settings, const std::function<void ()> &onApply)
{
setId("TodoSettings");
setId(Constants::TODO_SETTINGS);
setDisplayName(Tr::tr("To-Do"));
setCategory("To-Do");
setDisplayCategory(Tr::tr("To-Do"));

View File

@@ -71,8 +71,11 @@ TodoProjectSettingsWidget::TodoProjectSettingsWidget(ProjectExplorer::Project *p
}.attachTo(this);
setExcludedPatternsButtonsEnabled();
connect(addExcludedPatternButton, &QPushButton::clicked,
this, &TodoProjectSettingsWidget::addExcludedPatternButtonClicked);
setGlobalSettingsId(Constants::TODO_SETTINGS);
connect(addExcludedPatternButton,
&QPushButton::clicked,
this,
&TodoProjectSettingsWidget::addExcludedPatternButtonClicked);
connect(m_removeExcludedPatternButton, &QPushButton::clicked,
this, &TodoProjectSettingsWidget::removeExcludedPatternButtonClicked);
connect(m_excludedPatternsList, &QListWidget::itemChanged,

View File

@@ -33,7 +33,7 @@
# but it is only necessary on the end-user side. It is not necessary to create conan
# packages, in fact it shouldn't be use for that. Check the project documentation.
# version: 0.16.0-dev
# version: 0.18.1
include(CMakeParseArguments)
@@ -55,23 +55,14 @@ function(_get_msvc_ide_version result)
set(${result} 15 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930)
set(${result} 16 PARENT_SCOPE)
elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1940)
set(${result} 17 PARENT_SCOPE)
else()
message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]")
endif()
endfunction()
function(conan_cmake_settings result)
#message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER})
#message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID})
#message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION})
#message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS})
#message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
#message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE})
#message(STATUS "GENERATOR " ${CMAKE_GENERATOR})
#message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64})
message(STATUS "Conan: Automatic detection of conan settings from cmake")
macro(_conan_detect_build_type)
conan_parse_arguments(${ARGV})
if(ARGUMENTS_BUILD_TYPE)
@@ -92,10 +83,9 @@ function(conan_cmake_settings result)
elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "MINSIZEREL")
set(_CONAN_SETTING_BUILD_TYPE "MinSizeRel")
endif()
endmacro()
if(ARGUMENTS_ARCH)
set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH})
endif()
macro(_conan_check_system_name)
#handle -s os setting
if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic")
#use default conan os setting if CMAKE_SYSTEM_NAME is not defined
@@ -115,7 +105,9 @@ function(conan_cmake_settings result)
message(FATAL_ERROR "cmake system ${CONAN_SYSTEM_NAME} is not supported by conan. Use one of ${CONAN_SUPPORTED_PLATFORMS}")
endif()
endif()
endmacro()
macro(_conan_check_language)
get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES)
if (";${_languages};" MATCHES ";CXX;")
set(LANGUAGE CXX)
@@ -126,6 +118,19 @@ function(conan_cmake_settings result)
else ()
message(FATAL_ERROR "Conan: Neither C or C++ was detected as a language for the project. Unabled to detect compiler version.")
endif()
endmacro()
macro(_conan_detect_compiler)
conan_parse_arguments(${ARGV})
if(ARGUMENTS_ARCH)
set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH})
endif()
if(USING_CXX)
set(_CONAN_SETTING_COMPILER_CPPSTD ${CMAKE_CXX_STANDARD})
endif()
if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU)
# using GCC
@@ -143,6 +148,17 @@ function(conan_cmake_settings result)
conan_cmake_detect_unix_libcxx(_LIBCXX)
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
endif ()
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Intel)
string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
list(GET VERSION_LIST 0 MAJOR)
list(GET VERSION_LIST 1 MINOR)
set(COMPILER_VERSION ${MAJOR}.${MINOR})
set(_CONAN_SETTING_COMPILER intel)
set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION})
if (USING_CXX)
conan_cmake_detect_unix_libcxx(_LIBCXX)
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
endif ()
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL AppleClang)
# using AppleClang
string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
@@ -154,7 +170,10 @@ function(conan_cmake_settings result)
conan_cmake_detect_unix_libcxx(_LIBCXX)
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
endif ()
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang)
elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang
AND NOT "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"
AND NOT "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC")
string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION})
list(GET VERSION_LIST 0 MAJOR)
list(GET VERSION_LIST 1 MINOR)
@@ -174,7 +193,11 @@ function(conan_cmake_settings result)
conan_cmake_detect_unix_libcxx(_LIBCXX)
set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX})
endif ()
elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC)
elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC
OR (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang
AND "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC"
AND "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC"))
set(_VISUAL "Visual Studio")
_get_msvc_ide_version(_VISUAL_VERSION)
if("${_VISUAL_VERSION}" STREQUAL "")
@@ -197,7 +220,7 @@ function(conan_cmake_settings result)
endif()
endif()
conan_cmake_detect_vs_runtime(_vs_runtime)
conan_cmake_detect_vs_runtime(_vs_runtime ${ARGV})
message(STATUS "Conan: Detected VS runtime: ${_vs_runtime}")
set(_CONAN_SETTING_COMPILER_RUNTIME ${_vs_runtime})
@@ -206,10 +229,34 @@ function(conan_cmake_settings result)
elseif(CMAKE_VS_PLATFORM_TOOLSET AND (CMAKE_GENERATOR STREQUAL "Ninja"))
set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET})
endif()
else()
else()
message(FATAL_ERROR "Conan: compiler setup not recognized")
endif()
endmacro()
function(conan_cmake_settings result)
#message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER})
#message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID})
#message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION})
#message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS})
#message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE})
#message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE})
#message(STATUS "GENERATOR " ${CMAKE_GENERATOR})
#message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64})
message(STATUS "Conan: Automatic detection of conan settings from cmake")
conan_parse_arguments(${ARGV})
_conan_detect_build_type(${ARGV})
_conan_check_system_name()
_conan_check_language()
_conan_detect_compiler(${ARGV})
# If profile is defined it is used
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARGUMENTS_DEBUG_PROFILE)
set(_APPLIED_PROFILES ${ARGUMENTS_DEBUG_PROFILE})
@@ -346,7 +393,19 @@ function(conan_cmake_detect_unix_libcxx result)
endfunction()
function(conan_cmake_detect_vs_runtime result)
string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
conan_parse_arguments(${ARGV})
if(ARGUMENTS_BUILD_TYPE)
set(build_type "${ARGUMENTS_BUILD_TYPE}")
elseif(CMAKE_BUILD_TYPE)
set(build_type "${CMAKE_BUILD_TYPE}")
else()
message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)")
endif()
if(build_type)
string(TOUPPER "${build_type}" build_type)
endif()
set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS)
foreach(variable ${variables})
if(NOT "${${variable}}" STREQUAL "")
@@ -367,17 +426,39 @@ function(conan_cmake_detect_vs_runtime result)
endif()
endfunction()
function(_collect_settings result)
set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version
compiler.runtime compiler.libcxx compiler.toolset
compiler.cppstd)
foreach(ARG ${ARGUMENTS_PROFILE_AUTO})
string(TOUPPER ${ARG} _arg_name)
string(REPLACE "." "_" _arg_name ${_arg_name})
if(_CONAN_SETTING_${_arg_name})
set(detected_setings ${detected_setings} ${ARG}=${_CONAN_SETTING_${_arg_name}})
endif()
endforeach()
set(${result} ${detected_setings} PARENT_SCOPE)
endfunction()
function(conan_cmake_autodetect detected_settings)
_conan_detect_build_type(${ARGV})
_conan_check_system_name()
_conan_check_language()
_conan_detect_compiler(${ARGV})
_collect_settings(collected_settings)
set(${detected_settings} ${collected_settings} PARENT_SCOPE)
endfunction()
macro(conan_parse_arguments)
set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS OUTPUT_QUIET NO_IMPORTS SKIP_STD)
set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER CONAN_COMMAND)
set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER OUTPUT_FOLDER CONAN_COMMAND)
set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE
PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO
INSTALL_ARGS CONFIGURATION_TYPES PROFILE_BUILD)
INSTALL_ARGS CONFIGURATION_TYPES PROFILE_BUILD BUILD_REQUIRES)
cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
endmacro()
function(conan_cmake_install)
function(old_conan_cmake_install)
# Calls "conan install"
# Argument BUILD is equivalant to --build={missing, PkgName,...} or
# --build when argument is 'BUILD all' (which builds all packages from source)
@@ -428,6 +509,10 @@ function(conan_cmake_install)
if(ARGUMENTS_INSTALL_FOLDER)
set(CONAN_INSTALL_FOLDER -if=${ARGUMENTS_INSTALL_FOLDER})
endif()
set(CONAN_OUTPUT_FOLDER "")
if(ARGUMENTS_OUTPUT_FOLDER)
set(CONAN_OUTPUT_FOLDER -of=${ARGUMENTS_OUTPUT_FOLDER})
endif()
foreach(ARG ${ARGUMENTS_GENERATORS})
set(CONAN_GENERATORS ${CONAN_GENERATORS} -g=${ARG})
endforeach()
@@ -457,6 +542,220 @@ function(conan_cmake_install)
endfunction()
function(conan_cmake_install)
if(DEFINED CONAN_COMMAND)
set(CONAN_CMD ${CONAN_COMMAND})
else()
conan_check(REQUIRED)
endif()
set(installOptions UPDATE NO_IMPORTS OUTPUT_QUIET ERROR_QUIET)
set(installOneValueArgs PATH_OR_REFERENCE REFERENCE REMOTE LOCKFILE LOCKFILE_OUT LOCKFILE_NODE_ID INSTALL_FOLDER OUTPUT_FOLDER)
set(installMultiValueArgs GENERATOR BUILD ENV ENV_HOST ENV_BUILD OPTIONS_HOST OPTIONS OPTIONS_BUILD PROFILE
PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD)
cmake_parse_arguments(ARGS "${installOptions}" "${installOneValueArgs}" "${installMultiValueArgs}" ${ARGN})
foreach(arg ${installOptions})
if(ARGS_${arg})
set(${arg} ${${arg}} ${ARGS_${arg}})
endif()
endforeach()
foreach(arg ${installOneValueArgs})
if(DEFINED ARGS_${arg})
if("${arg}" STREQUAL "REMOTE")
set(flag "--remote")
elseif("${arg}" STREQUAL "LOCKFILE")
set(flag "--lockfile")
elseif("${arg}" STREQUAL "LOCKFILE_OUT")
set(flag "--lockfile-out")
elseif("${arg}" STREQUAL "LOCKFILE_NODE_ID")
set(flag "--lockfile-node-id")
elseif("${arg}" STREQUAL "INSTALL_FOLDER")
set(flag "--install-folder")
elseif("${arg}" STREQUAL "OUTPUT_FOLDER")
set(flag "--output-folder")
endif()
set(${arg} ${${arg}} ${flag} ${ARGS_${arg}})
endif()
endforeach()
foreach(arg ${installMultiValueArgs})
if(DEFINED ARGS_${arg})
if("${arg}" STREQUAL "GENERATOR")
set(flag "--generator")
elseif("${arg}" STREQUAL "BUILD")
set(flag "--build")
elseif("${arg}" STREQUAL "ENV")
set(flag "--env")
elseif("${arg}" STREQUAL "ENV_HOST")
set(flag "--env:host")
elseif("${arg}" STREQUAL "ENV_BUILD")
set(flag "--env:build")
elseif("${arg}" STREQUAL "OPTIONS")
set(flag "--options")
elseif("${arg}" STREQUAL "OPTIONS_HOST")
set(flag "--options:host")
elseif("${arg}" STREQUAL "OPTIONS_BUILD")
set(flag "--options:build")
elseif("${arg}" STREQUAL "PROFILE")
set(flag "--profile")
elseif("${arg}" STREQUAL "PROFILE_HOST")
set(flag "--profile:host")
elseif("${arg}" STREQUAL "PROFILE_BUILD")
set(flag "--profile:build")
elseif("${arg}" STREQUAL "SETTINGS")
set(flag "--settings")
elseif("${arg}" STREQUAL "SETTINGS_HOST")
set(flag "--settings:host")
elseif("${arg}" STREQUAL "SETTINGS_BUILD")
set(flag "--settings:build")
endif()
list(LENGTH ARGS_${arg} numargs)
foreach(item ${ARGS_${arg}})
if(${item} STREQUAL "all" AND ${arg} STREQUAL "BUILD")
set(${arg} "--build")
break()
endif()
set(${arg} ${${arg}} ${flag} ${item})
endforeach()
endif()
endforeach()
if(DEFINED UPDATE)
set(UPDATE --update)
endif()
if(DEFINED NO_IMPORTS)
set(NO_IMPORTS --no-imports)
endif()
set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} ${OUTPUT_FOLDER}
${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD}
${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD})
string(REPLACE ";" " " _install_args "${install_args}")
message(STATUS "Conan executing: ${CONAN_CMD} ${_install_args}")
if(ARGS_OUTPUT_QUIET)
set(OUTPUT_OPT OUTPUT_QUIET)
endif()
if(ARGS_ERROR_QUIET)
set(ERROR_OPT ERROR_QUIET)
endif()
execute_process(COMMAND ${CONAN_CMD} ${install_args}
RESULT_VARIABLE return_code
${OUTPUT_OPT}
${ERROR_OPT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(NOT "${return_code}" STREQUAL "0")
if (ARGS_ERROR_QUIET)
message(WARNING "Conan install failed='${return_code}'")
else()
message(FATAL_ERROR "Conan install failed='${return_code}'")
endif()
endif()
endfunction()
function(conan_cmake_lock_create)
if(DEFINED CONAN_COMMAND)
set(CONAN_CMD ${CONAN_COMMAND})
else()
conan_check(REQUIRED)
endif()
set(lockCreateOptions UPDATE BASE OUTPUT_QUIET ERROR_QUIET)
set(lockCreateOneValueArgs PATH REFERENCE REMOTE LOCKFILE LOCKFILE_OUT)
set(lockCreateMultiValueArgs BUILD ENV ENV_HOST ENV_BUILD OPTIONS_HOST OPTIONS OPTIONS_BUILD PROFILE
PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD)
cmake_parse_arguments(ARGS "${lockCreateOptions}" "${lockCreateOneValueArgs}" "${lockCreateMultiValueArgs}" ${ARGN})
foreach(arg ${lockCreateOptions})
if(ARGS_${arg})
set(${arg} ${${arg}} ${ARGS_${arg}})
endif()
endforeach()
foreach(arg ${lockCreateOneValueArgs})
if(DEFINED ARGS_${arg})
if("${arg}" STREQUAL "REMOTE")
set(flag "--remote")
elseif("${arg}" STREQUAL "LOCKFILE")
set(flag "--lockfile")
elseif("${arg}" STREQUAL "LOCKFILE_OUT")
set(flag "--lockfile-out")
endif()
set(${arg} ${${arg}} ${flag} ${ARGS_${arg}})
endif()
endforeach()
foreach(arg ${lockCreateMultiValueArgs})
if(DEFINED ARGS_${arg})
if("${arg}" STREQUAL "BUILD")
set(flag "--build")
elseif("${arg}" STREQUAL "ENV")
set(flag "--env")
elseif("${arg}" STREQUAL "ENV_HOST")
set(flag "--env:host")
elseif("${arg}" STREQUAL "ENV_BUILD")
set(flag "--env:build")
elseif("${arg}" STREQUAL "OPTIONS")
set(flag "--options")
elseif("${arg}" STREQUAL "OPTIONS_HOST")
set(flag "--options:host")
elseif("${arg}" STREQUAL "OPTIONS_BUILD")
set(flag "--options:build")
elseif("${arg}" STREQUAL "PROFILE")
set(flag "--profile")
elseif("${arg}" STREQUAL "PROFILE_HOST")
set(flag "--profile:host")
elseif("${arg}" STREQUAL "PROFILE_BUILD")
set(flag "--profile:build")
elseif("${arg}" STREQUAL "SETTINGS")
set(flag "--settings")
elseif("${arg}" STREQUAL "SETTINGS_HOST")
set(flag "--settings:host")
elseif("${arg}" STREQUAL "SETTINGS_BUILD")
set(flag "--settings:build")
endif()
list(LENGTH ARGS_${arg} numargs)
foreach(item ${ARGS_${arg}})
if(${item} STREQUAL "all" AND ${arg} STREQUAL "BUILD")
set(${arg} "--build")
break()
endif()
set(${arg} ${${arg}} ${flag} ${item})
endforeach()
endif()
endforeach()
if(DEFINED UPDATE)
set(UPDATE --update)
endif()
if(DEFINED BASE)
set(BASE --base)
endif()
set(lock_create_Args lock create ${PATH} ${REFERENCE} ${UPDATE} ${BASE} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER}
${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD}
${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD})
string(REPLACE ";" " " _lock_create_Args "${lock_create_Args}")
message(STATUS "Conan executing: ${CONAN_CMD} ${_lock_create_Args}")
if(ARGS_OUTPUT_QUIET)
set(OUTPUT_OPT OUTPUT_QUIET)
endif()
if(ARGS_ERROR_QUIET)
set(ERROR_OPT ERROR_QUIET)
endif()
execute_process(COMMAND ${CONAN_CMD} ${lock_create_Args}
RESULT_VARIABLE return_code
${OUTPUT_OPT}
${ERROR_OPT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
if(NOT "${return_code}" STREQUAL "0")
if (ARGS_ERROR_QUIET)
message(WARNING "Conan lock create failed='${return_code}'")
else()
message(FATAL_ERROR "Conan lock create failed='${return_code}'")
endif()
endif()
endfunction()
function(conan_cmake_setup_conanfile)
conan_parse_arguments(${ARGV})
@@ -466,26 +765,64 @@ function(conan_cmake_setup_conanfile)
configure_file(${ARGUMENTS_CONANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk COPYONLY)
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk)
else()
conan_cmake_generate_conanfile(${ARGV})
conan_cmake_generate_conanfile(ON ${ARGV})
endif()
endfunction()
function(conan_cmake_generate_conanfile)
# Generate, writing in disk a conanfile.txt with the requires, options, and imports
# specified as arguments
# This will be considered as temporary file, generated in CMAKE_CURRENT_BINARY_DIR)
conan_parse_arguments(${ARGV})
set(_FN "${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt")
function(conan_cmake_configure)
conan_cmake_generate_conanfile(OFF ${ARGV})
endfunction()
file(WRITE ${_FN} "[generators]\ncmake\n\n[requires]\n")
foreach(ARG ${ARGUMENTS_REQUIRES})
file(APPEND ${_FN} ${ARG} "\n")
endforeach()
# Generate, writing in disk a conanfile.txt with the requires, options, and imports
# specified as arguments
# This will be considered as temporary file, generated in CMAKE_CURRENT_BINARY_DIR)
function(conan_cmake_generate_conanfile DEFAULT_GENERATOR)
conan_parse_arguments(${ARGV})
set(_FN "${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt")
file(WRITE ${_FN} "")
if(DEFINED ARGUMENTS_REQUIRES)
file(APPEND ${_FN} "[requires]\n")
foreach(REQUIRE ${ARGUMENTS_REQUIRES})
file(APPEND ${_FN} ${REQUIRE} "\n")
endforeach()
endif()
if (DEFAULT_GENERATOR OR DEFINED ARGUMENTS_GENERATORS)
file(APPEND ${_FN} "[generators]\n")
if (DEFAULT_GENERATOR)
file(APPEND ${_FN} "cmake\n")
endif()
if (DEFINED ARGUMENTS_GENERATORS)
foreach(GENERATOR ${ARGUMENTS_GENERATORS})
file(APPEND ${_FN} ${GENERATOR} "\n")
endforeach()
endif()
endif()
if(DEFINED ARGUMENTS_BUILD_REQUIRES)
file(APPEND ${_FN} "[build_requires]\n")
foreach(BUILD_REQUIRE ${ARGUMENTS_BUILD_REQUIRES})
file(APPEND ${_FN} ${BUILD_REQUIRE} "\n")
endforeach()
endif()
if(DEFINED ARGUMENTS_IMPORTS)
file(APPEND ${_FN} "[imports]\n")
foreach(IMPORTS ${ARGUMENTS_IMPORTS})
file(APPEND ${_FN} ${IMPORTS} "\n")
endforeach()
endif()
if(DEFINED ARGUMENTS_OPTIONS)
file(APPEND ${_FN} "[options]\n")
foreach(OPTION ${ARGUMENTS_OPTIONS})
file(APPEND ${_FN} ${OPTION} "\n")
endforeach()
endif()
file(APPEND ${_FN} ${ARG} "\n[imports]\n")
foreach(ARG ${ARGUMENTS_IMPORTS})
file(APPEND ${_FN} ${ARG} "\n")
endforeach()
endfunction()
@@ -537,12 +874,12 @@ macro(conan_cmake_run)
foreach(CMAKE_BUILD_TYPE ${ARGUMENTS_CONFIGURATION_TYPES})
set(ENV{CONAN_IMPORT_PATH} ${CMAKE_BUILD_TYPE})
conan_cmake_settings(settings ${ARGV})
conan_cmake_install(SETTINGS ${settings} ${ARGV})
old_conan_cmake_install(SETTINGS ${settings} ${ARGV})
endforeach()
set(CMAKE_BUILD_TYPE)
else()
conan_cmake_settings(settings ${ARGV})
conan_cmake_install(SETTINGS ${settings} ${ARGV})
old_conan_cmake_install(SETTINGS ${settings} ${ARGV})
endif()
endif()
@@ -584,10 +921,17 @@ macro(conan_check)
message(STATUS "Conan: Found program ${CONAN_CMD}")
endif()
execute_process(COMMAND ${CONAN_CMD} --version
RESULT_VARIABLE return_code
OUTPUT_VARIABLE CONAN_VERSION_OUTPUT
ERROR_VARIABLE CONAN_VERSION_OUTPUT)
if(NOT "${return_code}" STREQUAL "0")
message(FATAL_ERROR "Conan --version failed='${return_code}'")
endif()
if(NOT CONAN_DETECT_QUIET)
message(STATUS "Conan: Version found ${CONAN_VERSION_OUTPUT}")
string(STRIP "${CONAN_VERSION_OUTPUT}" _CONAN_VERSION_OUTPUT)
message(STATUS "Conan: Version found ${_CONAN_VERSION_OUTPUT}")
endif()
if(DEFINED CONAN_VERSION)
@@ -617,14 +961,18 @@ function(conan_add_remote)
if(DEFINED CONAN_COMMAND)
set(CONAN_CMD ${CONAN_COMMAND})
else()
conan_check(REQUIRED)
conan_check(REQUIRED DETECT_QUIET)
endif()
set(CONAN_VERIFY_SSL_ARG "True")
if(DEFINED CONAN_VERIFY_SSL)
set(CONAN_VERIFY_SSL_ARG ${CONAN_VERIFY_SSL})
endif()
message(STATUS "Conan: Adding ${CONAN_NAME} remote repository (${CONAN_URL}) verify ssl (${CONAN_VERIFY_SSL_ARG})")
execute_process(COMMAND ${CONAN_CMD} remote add ${CONAN_NAME} ${CONAN_INDEX_ARG} -f ${CONAN_URL} ${CONAN_VERIFY_SSL_ARG})
execute_process(COMMAND ${CONAN_CMD} remote add ${CONAN_NAME} ${CONAN_INDEX_ARG} -f ${CONAN_URL} ${CONAN_VERIFY_SSL_ARG}
RESULT_VARIABLE return_code)
if(NOT "${return_code}" STREQUAL "0")
message(FATAL_ERROR "Conan remote failed='${return_code}'")
endif()
endfunction()
macro(conan_config_install)
@@ -637,37 +985,42 @@ macro(conan_config_install)
set(multiValueArgs ARGS)
cmake_parse_arguments(CONAN "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
find_program(CONAN_CMD conan)
if(NOT CONAN_CMD AND CONAN_REQUIRED)
message(FATAL_ERROR "Conan executable not found!")
if(DEFINED CONAN_COMMAND)
set(CONAN_CMD ${CONAN_COMMAND})
else()
conan_check(REQUIRED)
endif()
if(DEFINED CONAN_VERIFY_SSL)
set(CONAN_VERIFY_SSL_ARG "--verify-ssl=${CONAN_VERIFY_SSL}")
set(CONAN_VERIFY_SSL_ARG "--verify-ssl=${CONAN_VERIFY_SSL}")
endif()
if(DEFINED CONAN_TYPE)
set(CONAN_TYPE_ARG "--type=${CONAN_TYPE}")
set(CONAN_TYPE_ARG "--type=${CONAN_TYPE}")
endif()
if(DEFINED CONAN_ARGS)
set(CONAN_ARGS_ARGS "--args=\"${CONAN_ARGS}\"")
set(CONAN_ARGS_ARGS "--args=\"${CONAN_ARGS}\"")
endif()
if(DEFINED CONAN_SOURCE)
set(CONAN_SOURCE_ARGS "--source-folder=${CONAN_SOURCE}")
set(CONAN_SOURCE_ARGS "--source-folder=${CONAN_SOURCE}")
endif()
if(DEFINED CONAN_TARGET)
set(CONAN_TARGET_ARGS "--target-folder=${CONAN_TARGET}")
set(CONAN_TARGET_ARGS "--target-folder=${CONAN_TARGET}")
endif()
set (CONAN_CONFIG_INSTALL_ARGS ${CONAN_VERIFY_SSL_ARG}
${CONAN_TYPE_ARG}
${CONAN_ARGS_ARGS}
${CONAN_SOURCE_ARGS}
${CONAN_TARGET_ARGS})
set (CONAN_CONFIG_INSTALL_ARGS ${CONAN_VERIFY_SSL_ARG}
${CONAN_TYPE_ARG}
${CONAN_ARGS_ARGS}
${CONAN_SOURCE_ARGS}
${CONAN_TARGET_ARGS})
message(STATUS "Conan: Installing config from ${CONAN_ITEM}")
execute_process(COMMAND ${CONAN_CMD} config install ${CONAN_ITEM} ${CONAN_CONFIG_INSTALL_ARGS})
execute_process(COMMAND ${CONAN_CMD} config install ${CONAN_ITEM} ${CONAN_CONFIG_INSTALL_ARGS}
RESULT_VARIABLE return_code)
if(NOT "${return_code}" STREQUAL "0")
message(FATAL_ERROR "Conan config failed='${return_code}'")
endif()
endmacro()