From 05f746cfd029c0232bb5880c50d0b0d7d17f0cc5 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Wed, 19 Feb 2020 17:01:41 +0100 Subject: [PATCH 1/5] Add script for building external plugins for packaging Also turn off PCH for building Qt Creator and add some more options for local testing. Change-Id: Ic05099ef1dd8e8c78b174d7cd07a83b2f4a9cbb5 Reviewed-by: Eike Ziller --- scripts/build.py | 45 +++++++------- scripts/build_plugin.py | 130 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 155 insertions(+), 20 deletions(-) create mode 100755 scripts/build_plugin.py diff --git a/scripts/build.py b/scripts/build.py index 3c481362395..a58a688dcac 100755 --- a/scripts/build.py +++ b/scripts/build.py @@ -83,6 +83,10 @@ def get_arguments(): action='store_true', default=(not common.is_windows_platform())) parser.add_argument('--no-docs', help='Skip documentation generation', action='store_true', default=False) + parser.add_argument('--no-dmg', help='Skip disk image creation (macOS)', + action='store_true', default=False) + parser.add_argument('--no-zip', help='Skip creation of 7zip files for install and developer package', + action='store_true', default=False) return parser.parse_args() def build_qtcreator(args, paths): @@ -124,8 +128,7 @@ def build_qtcreator(args, paths): '-DPYTHON_INCLUDE_DIR=' + os.path.join(args.python_path, 'include')] # TODO this works around a CMake bug https://gitlab.kitware.com/cmake/cmake/issues/20119 - if common.is_linux_platform(): - cmake_args += ['-DBUILD_WITH_PCH=OFF'] + cmake_args += ['-DBUILD_WITH_PCH=OFF'] ide_revision = common.get_commit_SHA(paths.src) if ide_revision: @@ -191,30 +194,32 @@ def deploy_qt(args, paths): paths.build) def package_qtcreator(args, paths): - common.check_print_call(['7z', 'a', '-mmt2', os.path.join(paths.result, 'qtcreator.7z'), '*'], - paths.install) - common.check_print_call(['7z', 'a', '-mmt2', - os.path.join(paths.result, 'qtcreator_dev.7z'), '*'], - paths.dev_install) - if common.is_windows_platform(): + if not args.no_zip: + common.check_print_call(['7z', 'a', '-mmt2', os.path.join(paths.result, 'qtcreator.7z'), '*'], + paths.install) common.check_print_call(['7z', 'a', '-mmt2', - os.path.join(paths.result, 'wininterrupt.7z'), '*'], - paths.wininterrupt_install) - if not args.no_cdb: + os.path.join(paths.result, 'qtcreator_dev.7z'), '*'], + paths.dev_install) + if common.is_windows_platform(): common.check_print_call(['7z', 'a', '-mmt2', - os.path.join(paths.result, 'qtcreatorcdbext.7z'), '*'], - paths.qtcreatorcdbext_install) + os.path.join(paths.result, 'wininterrupt.7z'), '*'], + paths.wininterrupt_install) + if not args.no_cdb: + common.check_print_call(['7z', 'a', '-mmt2', + os.path.join(paths.result, 'qtcreatorcdbext.7z'), '*'], + paths.qtcreatorcdbext_install) if common.is_mac_platform(): if args.keychain_unlock_script: common.check_print_call([args.keychain_unlock_script], paths.install) - common.check_print_call(['python', '-u', - os.path.join(paths.src, 'scripts', 'makedmg.py'), - 'qt-creator.dmg', - 'Qt Creator', - paths.src, - paths.install], - paths.result) + if not args.no_dmg: + common.check_print_call(['python', '-u', + os.path.join(paths.src, 'scripts', 'makedmg.py'), + 'qt-creator.dmg', + 'Qt Creator', + paths.src, + paths.install], + paths.result) def get_paths(args): Paths = collections.namedtuple('Paths', diff --git a/scripts/build_plugin.py b/scripts/build_plugin.py new file mode 100755 index 00000000000..45c16765d3d --- /dev/null +++ b/scripts/build_plugin.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python +############################################################################# +## +## Copyright (C) 2020 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the release tools of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:GPL-EXCEPT$ +## Commercial License Usage +## Licensees holding valid commercial Qt licenses may use this file in +## accordance with the commercial license agreement provided with the +## Software or, alternatively, in accordance with the terms contained in +## a written agreement between you and The Qt Company. For licensing terms +## and conditions see https://www.qt.io/terms-conditions. For further +## information use the contact form at https://www.qt.io/contact-us. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU +## General Public License version 3 as published by the Free Software +## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +## included in the packaging of this file. Please review the following +## information to ensure the GNU General Public License requirements will +## be met: https://www.gnu.org/licenses/gpl-3.0.html. +## +## $QT_END_LICENSE$ +## +############################################################################# + +# import the print function which is used in python 3.x +from __future__ import print_function + +import argparse +import collections +import os + +import common + +def get_arguments(): + parser = argparse.ArgumentParser(description='Build Qt Creator for packaging') + parser.add_argument('--name', help='Name to use for build results', required=True) + parser.add_argument('--src', help='Path to sources', required=True) + parser.add_argument('--build', help='Path that should be used for building', required=True) + parser.add_argument('--qt-path', help='Path to Qt', required=True) + parser.add_argument('--qtc-path', + help='Path to Qt Creator installation including development package', + required=True) + parser.add_argument('--output-path', help='Output path for resulting 7zip files') + parser.add_argument('--add-path', help='Adds a CMAKE_PREFIX_PATH to the build', + action='append', dest='prefix_paths', default=[]) + parser.add_argument('--deploy', help='Installs the "Dependencies" component of the plugin.', + action='store_true', default=False) + parser.add_argument('--debug', help='Enable debug builds', action='store_true', default=False) + return parser.parse_args() + +def build(args, paths): + if not os.path.exists(paths.build): + os.makedirs(paths.build) + if not os.path.exists(paths.result): + os.makedirs(paths.result) + prefix_paths = [paths.qt, paths.qt_creator] + [os.path.abspath(fp) for fp in args.prefix_paths] + build_type = 'Debug' if args.debug else 'Release' + cmake_args = ['cmake', + '-DCMAKE_PREFIX_PATH=' + ';'.join(prefix_paths), + '-DCMAKE_BUILD_TYPE=' + build_type, + '-DCMAKE_INSTALL_PREFIX=' + paths.install, + '-G', 'Ninja'] + + # force MSVC on Windows, because it looks for GCC in the PATH first, + # even if MSVC is first mentioned in the PATH... + # TODO would be nicer if we only did this if cl.exe is indeed first in the PATH + if common.is_windows_platform(): + cmake_args += ['-DCMAKE_C_COMPILER=cl', + '-DCMAKE_CXX_COMPILER=cl'] + + # TODO this works around a CMake bug https://gitlab.kitware.com/cmake/cmake/issues/20119 + cmake_args += ['-DBUILD_WITH_PCH=OFF'] + + ide_revision = common.get_commit_SHA(paths.src) + if ide_revision: + cmake_args += ['-DQTC_PLUGIN_REVISION=' + ide_revision] + with open(os.path.join(paths.result, args.name + '.7z.git_sha'), 'w') as f: + f.write(ide_revision) + + common.check_print_call(cmake_args + [paths.src], paths.build) + common.check_print_call(['cmake', '--build', '.'], paths.build) + common.check_print_call(['cmake', '--install', '.', '--prefix', paths.install, '--strip'], + paths.build) + if args.deploy: + common.check_print_call(['cmake', '--install', '.', '--prefix', paths.install, + '--component', 'Dependencies'], + paths.build) + common.check_print_call(['cmake', '--install', '.', '--prefix', paths.dev_install, + '--component', 'Devel'], + paths.build) + +def package(args, paths): + if not os.path.exists(paths.result): + os.makedirs(paths.result) + common.check_print_call(['7z', 'a', '-mmt2', os.path.join(paths.result, args.name + '.7z'), '*'], + paths.install) + if os.path.exists(paths.dev_install): # some plugins might not provide anything in Devel + common.check_print_call(['7z', 'a', '-mmt2', + os.path.join(paths.result, args.name + '_dev.7z'), '*'], + paths.dev_install) + +def get_paths(args): + Paths = collections.namedtuple('Paths', + ['qt', 'src', 'build', 'qt_creator', + 'install', 'dev_install', 'result']) + build_path = os.path.abspath(args.build) + install_path = os.path.join(build_path, 'install') + result_path = os.path.abspath(args.output_path) if args.output_path else build_path + return Paths(qt=os.path.abspath(args.qt_path), + src=os.path.abspath(args.src), + build=os.path.join(build_path, 'build'), + qt_creator=os.path.abspath(args.qtc_path), + install=os.path.join(install_path, args.name), + dev_install=os.path.join(install_path, args.name + '-dev'), + result=result_path) + +def main(): + args = get_arguments() + paths = get_paths(args) + + build(args, paths) + package(args, paths) + +if __name__ == '__main__': + main() From 425977231456f031331e47e8bcdc6884befefa08 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 21 Apr 2020 10:46:21 -0700 Subject: [PATCH 2/5] Fix deprecation against QProcess::start splitting overload Change-Id: I9709abb1c3734e10a7defffd1607e6d198bbf964 Reviewed-by: hjk --- src/plugins/fakevim/fakevimhandler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 743e511248e..601377ed69d 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -776,7 +776,13 @@ static QString fromLocalEncoding(const QByteArray &data) static QString getProcessOutput(const QString &command, const QString &input) { QProcess proc; +#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) + QStringList arguments = QProcess::splitCommand(command); + QString executable = arguments.takeFirst(); + proc.start(executable, arguments); +#else proc.start(command); +#endif proc.waitForStarted(); proc.write(toLocalEncoding(input)); proc.closeWriteChannel(); From 91f696b3f30e4748f2abbe405939b9fba12fc795 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Tue, 28 Apr 2020 13:01:42 +0200 Subject: [PATCH 3/5] Doc: Fix the new project template's group name Task-number: QTCREATORBUG-23858 Fixes: QTCREATORBUG-23858 Change-Id: If4493b9c5e3b017097c52797f14f3bc507275e61 Reviewed-by: Leena Miettinen --- doc/qtcreator/src/mcu/creator-mcu-dev.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/qtcreator/src/mcu/creator-mcu-dev.qdoc b/doc/qtcreator/src/mcu/creator-mcu-dev.qdoc index dd0ab2f4387..69f7dd8aa6e 100644 --- a/doc/qtcreator/src/mcu/creator-mcu-dev.qdoc +++ b/doc/qtcreator/src/mcu/creator-mcu-dev.qdoc @@ -176,7 +176,7 @@ \list 1 \li Select \uicontrol File > \uicontrol {New File or Project} > - \uicontrol {Application (Qt Quick)} > + \uicontrol {Application (Qt for MCU)} > \uicontrol {MCU Support Application} > \uicontrol Choose. \li Follow the instructions of the wizard to create the project. \li Select \uicontrol Projects > \uicontrol {Build & Run}, and then From c01fef0a78e61cbf11b044ef342e5fb9d4e2b150 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Tue, 28 Apr 2020 13:42:46 +0200 Subject: [PATCH 4/5] QmlDesigner: Fix bindings in metainfo file Since the parser update the string is not escaped anymore. Which to me is the more correct behavior. We have to remove the escape characters ourselves. Task-number: QDS-2019 Change-Id: I5d03e99ab87b27bfcb22170138b96e50f646e5e4 Reviewed-by: Miikka Heikkinen Reviewed-by: Thomas Hartmann --- .../designercore/metainfo/metainforeader.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp b/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp index 66aa3313b5e..8ad521f6ff1 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/metainforeader.cpp @@ -258,6 +258,22 @@ void MetaInfoReader::readItemLibraryEntryProperty(const QString &name, const QVa } } +inline QString deEscape(const QString &value) +{ + QString result = value; + + result.replace(QStringLiteral("\\\""), QStringLiteral("\"")); + result.replace(QStringLiteral("\\\\"), QStringLiteral("\\")); + + return result; +} + +inline QVariant deEscapeVariant(const QVariant &value) +{ + if (value.canConvert()) + return deEscape(value.toString()); + return value; +} void MetaInfoReader::readPropertyProperty(const QString &name, const QVariant &value) { if (name == QStringLiteral("name")) { @@ -265,7 +281,7 @@ void MetaInfoReader::readPropertyProperty(const QString &name, const QVariant &v } else if (name == QStringLiteral("type")) { m_currentPropertyType = value.toString(); } else if (name == QStringLiteral("value")) { - m_currentPropertyValue = value; + m_currentPropertyValue = deEscapeVariant(value); } else { addError(tr("Unknown property for Property %1").arg(name), currentSourceLocation()); setParserState(Error); From 662c224bab0e2e9a8054cf58671ff0d350713f82 Mon Sep 17 00:00:00 2001 From: Vikas Pachdha Date: Tue, 28 Apr 2020 22:05:05 +0200 Subject: [PATCH 5/5] Fix crash with sorting library items Strict weak ordering relation for the comparison was not followed. Using shared_ptr and removing QSharedData. The entry data is shared between instances Task-number: QDS-2011 Change-Id: Idfcd23b2d458f9c7cada47180cb6ab3b4b090416 Reviewed-by: Thomas Hartmann --- .../itemlibrary/itemlibrarymodel.cpp | 2 +- .../itemlibrary/itemlibrarysectionmodel.cpp | 2 +- .../designercore/include/itemlibraryinfo.h | 9 +++----- .../designercore/metainfo/itemlibraryinfo.cpp | 21 +------------------ 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp index 020369708ae..57f0d7ee944 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarymodel.cpp @@ -289,7 +289,7 @@ void ItemLibraryModel::sortSections() int nullPointerSectionCount = m_sections.removeAll(QPointer()); QTC_ASSERT(nullPointerSectionCount == 0,;); auto sectionSort = [](ItemLibrarySection *first, ItemLibrarySection *second) { - return QString::localeAwareCompare(first->sortingName(), second->sortingName()) < 1; + return QString::localeAwareCompare(first->sortingName(), second->sortingName()) < 0; }; std::sort(m_sections.begin(), m_sections.end(), sectionSort); diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarysectionmodel.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarysectionmodel.cpp index 6f7e57763c3..413ef7f3e8c 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibrarysectionmodel.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibrarysectionmodel.cpp @@ -91,7 +91,7 @@ void ItemLibrarySectionModel::sortItems() int nullPointerSectionCount = m_itemList.removeAll(QPointer()); QTC_ASSERT(nullPointerSectionCount == 0,;); auto itemSort = [](ItemLibraryItem *first, ItemLibraryItem *second) { - return QString::localeAwareCompare(first->itemName(), second->itemName()) < 1; + return QString::localeAwareCompare(first->itemName(), second->itemName()) < 0; }; std::sort(m_itemList.begin(), m_itemList.end(), itemSort); diff --git a/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h b/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h index 6e70169a6af..58d24137870 100644 --- a/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h +++ b/src/plugins/qmldesigner/designercore/include/itemlibraryinfo.h @@ -29,7 +29,7 @@ #include "propertycontainer.h" #include -#include +#include namespace QmlDesigner { @@ -55,7 +55,7 @@ class QMLDESIGNERCORE_EXPORT ItemLibraryEntry public: ItemLibraryEntry(); - ~ItemLibraryEntry(); + ~ItemLibraryEntry() = default; QString name() const; TypeName typeName() const; @@ -69,9 +69,6 @@ public: QString qmlSource() const; QString requiredImport() const; - ItemLibraryEntry(const ItemLibraryEntry &other); - ItemLibraryEntry& operator=(const ItemLibraryEntry &other); - using Property = QmlDesigner::PropertyContainer; QList properties() const; @@ -89,7 +86,7 @@ public: void addHints(const QHash &hints); private: - QSharedDataPointer m_data; + std::shared_ptr m_data; }; class QMLDESIGNERCORE_EXPORT ItemLibraryInfo : public QObject diff --git a/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp index 7b3059247f3..e76fe609f07 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/itemlibraryinfo.cpp @@ -35,12 +35,9 @@ namespace QmlDesigner { namespace Internal { -class ItemLibraryEntryData : public QSharedData +class ItemLibraryEntryData { public: - ItemLibraryEntryData() - {} - QString name; TypeName typeName; QString category; @@ -57,20 +54,6 @@ public: } // namespace Internal -// -// ItemLibraryEntry -// - -ItemLibraryEntry::ItemLibraryEntry(const ItemLibraryEntry &other) = default; - -ItemLibraryEntry& ItemLibraryEntry::operator=(const ItemLibraryEntry &other) -{ - if (this !=&other) - m_data = other.m_data; - - return *this; -} - void ItemLibraryEntry::setTypeIcon(const QIcon &icon) { m_data->typeIcon = icon; @@ -96,8 +79,6 @@ ItemLibraryEntry::ItemLibraryEntry() : m_data(new Internal::ItemLibraryEntryData m_data->name.clear(); } -ItemLibraryEntry::~ItemLibraryEntry() = default; - QString ItemLibraryEntry::name() const { return m_data->name;