2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2009-03-10 14:20:07 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
|
#include "genericprojectplugin.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
#include "genericbuildconfiguration.h"
|
2009-03-12 17:53:25 +01:00
|
|
|
#include "genericprojectwizard.h"
|
2009-03-16 11:08:07 +01:00
|
|
|
#include "genericprojectconstants.h"
|
|
|
|
|
#include "genericprojectfileseditor.h"
|
2009-03-18 13:33:00 +01:00
|
|
|
#include "genericmakestep.h"
|
2011-06-20 11:57:20 +02:00
|
|
|
#include "genericproject.h"
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
2011-06-20 11:57:20 +02:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2011-06-20 11:57:20 +02:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2017-03-03 18:16:34 +01:00
|
|
|
#include <projectexplorer/projectmanager.h>
|
2015-01-13 15:50:37 +01:00
|
|
|
#include <projectexplorer/projecttree.h>
|
2013-08-24 23:10:17 +02:00
|
|
|
#include <projectexplorer/selectablefilesmodel.h>
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2015-11-03 13:03:39 +01:00
|
|
|
#include <utils/algorithm.h>
|
|
|
|
|
#include <utils/fileutils.h>
|
2015-02-04 09:32:46 +01:00
|
|
|
|
2017-02-28 16:31:07 +01:00
|
|
|
#include <QAction>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
|
|
|
|
#include <QDebug>
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2014-08-20 00:58:38 +02:00
|
|
|
using namespace Core;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
namespace GenericProjectManager {
|
|
|
|
|
namespace Internal {
|
2009-03-10 14:20:07 +01:00
|
|
|
|
|
|
|
|
bool GenericProjectPlugin::initialize(const QStringList &, QString *errorMessage)
|
|
|
|
|
{
|
2015-02-04 09:32:46 +01:00
|
|
|
Q_UNUSED(errorMessage)
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2017-03-03 18:16:34 +01:00
|
|
|
ProjectManager::registerProjectType<GenericProject>(Constants::GENERICMIMETYPE);
|
|
|
|
|
|
2014-08-20 00:58:38 +02:00
|
|
|
addAutoReleasedObject(new ProjectFilesFactory);
|
ProjectExplorer/all: Re-organize BuildSteps/{Deploy,Build}Config setup
This follow the rough pattern of recent *RunConfigurationFactory changes
for build and deploy configurations.
- Collapse the two lines of constructors similar to what
890c1906e6fb2ec did for RunConfigurations
* Deploy* was purely mechanical
* Build* ctors are split in connects() in the ctor body
to create "empty shell for clone" etc
and build step additions in initialize() functions which
are only used in the create() case.
-- Allows to collapse the shared 'ctor()' functions, too.
- Move FooBuildConfigurationFactory::create() implementations
to FooBuildConfiguration() constructor. That was a strange
and unneeded ping-pong between factories and objects, and
furthermore allows one level less of indirection (and for a
later, left out here, some reduction of the
FooBuildConfiguration interfaces that were only used to
accommodate the *Factory::create() functions.
- Most {Build,Deploy}Configuration{,Factory} classes had a canHandle(),
but there wasn't one in the base classses. Have one there.
- Most canHandle() functions were checking simple restrictions on
e.g. project or target types, specify those by setters in the
constructors instead and check them in the base canHandle()
- clone() is generally replaced by a creation of a "shell object"
and a fromMap(source->toMap()), implemented in the base, there
are two cases left for Android and Qbs that needed(?) some extra
polish
- generally use canHandle() in base implementation, instead
of doing that in all Derived::canFoo()
- as a result, canCreate/create/canClone/clone reimplementations
are not needed anymore, keep the base implementation for
now (could be inlined into their only users later), but
de-virtualize them.
- Combine Ios{Preset,DSym}BuildStepFactory. There was only one
'dsym' build step they could create.
- Split the 'mangled' id into the ProjectConfiguration subtype
specific constant identifier, and a QString extraId() bit.
Only maintain the mangled id in saved settings.
- Make ProjectConfiguration::m_id a constant member, adapt
all constructors of derived classe.
Not done in this patch:
- Finish possible cosmetic changes on top
- Add a way to specify restrictions to supported Qt versions
(used in Android/Ios), as the base implementation does not
depend on the qtsupport plugin
- Combine the QList<X> availableFoo() + createFoo(X) function
pairs to somthing like a direct
QList<struct { X; std::function<X()>; }> fooCreators()
to avoid e.g. the baseId.withSuffix() <-> id.suffixAfter(base)
pingpong
- Remove the *Factories from the global object pool
- Do something about priority(). Falling back to plain
qmake in android+qmake setup is not helpful.
Change-Id: I2be7d88d554c5aa8b7db8edf5b93278e1ae0112a
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-11-29 12:28:40 +01:00
|
|
|
addAutoReleasedObject(new GenericMakeAllStepFactory);
|
|
|
|
|
addAutoReleasedObject(new GenericMakeCleanStepFactory);
|
2012-04-24 15:49:09 +02:00
|
|
|
addAutoReleasedObject(new GenericBuildConfigurationFactory);
|
2009-03-10 14:20:07 +01:00
|
|
|
|
2015-05-22 17:16:36 +02:00
|
|
|
IWizardFactory::registerFactoryCreator([]() { return QList<IWizardFactory *>() << new GenericProjectWizard; });
|
|
|
|
|
|
2013-08-30 16:38:57 +02:00
|
|
|
ActionContainer *mproject =
|
|
|
|
|
ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT);
|
2012-08-14 15:37:38 +02:00
|
|
|
|
2014-08-20 00:58:38 +02:00
|
|
|
auto editFilesAction = new QAction(tr("Edit Files..."), this);
|
|
|
|
|
Command *command = ActionManager::registerAction(editFilesAction,
|
|
|
|
|
"GenericProjectManager.EditFiles", Context(Constants::PROJECTCONTEXT));
|
2013-08-30 16:38:57 +02:00
|
|
|
command->setAttribute(Command::CA_Hide);
|
2011-06-20 11:57:20 +02:00
|
|
|
mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_FILES);
|
|
|
|
|
|
2015-01-30 10:19:13 +01:00
|
|
|
connect(editFilesAction, &QAction::triggered, this, &GenericProjectPlugin::editFiles);
|
2011-06-20 11:57:20 +02:00
|
|
|
|
2014-08-20 00:58:38 +02:00
|
|
|
return true;
|
2011-06-20 11:57:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GenericProjectPlugin::editFiles()
|
|
|
|
|
{
|
2015-07-14 13:10:18 +02:00
|
|
|
auto genericProject = qobject_cast<GenericProject *>(ProjectTree::currentProject());
|
|
|
|
|
if (!genericProject)
|
|
|
|
|
return;
|
2016-04-06 17:38:39 +02:00
|
|
|
SelectableFilesDialogEditFiles sfd(genericProject->projectDirectory(),
|
2017-12-06 10:27:27 +01:00
|
|
|
genericProject->files(Project::AllFiles),
|
2015-11-03 13:03:39 +01:00
|
|
|
ICore::mainWindow());
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (sfd.exec() == QDialog::Accepted)
|
2015-11-03 13:03:39 +01:00
|
|
|
genericProject->setFiles(Utils::transform(sfd.selectedFiles(), &Utils::FileName::toString));
|
2011-06-20 11:57:20 +02:00
|
|
|
}
|
|
|
|
|
|
2012-08-14 15:37:38 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace GenericProjectManager
|