Commit Graph

63 Commits

Author SHA1 Message Date
hjk
4098be05b2 Utils: Extract a CommandLine structure from a QtcProcess
We regularly pass around strings or filenames or pairs of strings
or filenames and stringlist etc the in the end will be used
as a kind of "command line", with quite a bit of ad-hoc user
code and QtcProcess::addArg etc to set them up and manipulate them.

Let's have a class for that concept.

Change-Id: I288ab939d853b32c717135a65242c584c2beab50
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-29 14:36:46 +00:00
Alessandro Portale
0933c20de8 connect() to ambiguous signals/slots: Replace static_cast with QOverload
Change-Id: I473d7a2a16509cee944a2a21b022a3f6f02cfd8d
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-28 14:07:03 +00:00
hjk
473a741c9f Utils: Rename FileName to FilePath
More in line with QFileInfo terminonlogy which appears to be
best-of-breed within Qt.

Change-Id: I1d051ff1c8363ebd4ee56376451df45216c4c9ab
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-28 12:23:26 +00:00
hjk
24560d8830 CMake: Avoid a temporary QFileInfo
Change-Id: Ifaf8ecb3601881003b739027e81c0216744be5f5
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2019-05-28 05:51:08 +00:00
Christian Stenger
411678048d CMake: Set the correct build system target to the project part
The internal build target key had changed again. Adapt and use
a more error proof pattern to be hopefully safe if it may
change again.
The wrong build target key led inside the AutoTest plugin to a
wrong comparison of build target of the project parts vs. the
build target of the run configuration which in turn ended up
in always deducing the run configuration for the test runner.

Change-Id: I32df578df85cc0206c2b8fdac00acc3a798f0d73
Reviewed-by: hjk <hjk@qt.io>
2019-05-27 11:35:52 +00:00
hjk
0595e67c82 More FileName::pathAppended()
Change-Id: Ie20ec34ea9712b3ec49e6233b23cef84c2019f03
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-20 14:37:13 +00:00
hjk
36daca80f3 Utils: Make FileName::canonicalPath a member
Change-Id: I8d7450dec5c4c14ae3e007d1d66f1a9c3c98f807
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-20 11:06:12 +00:00
hjk
f4c9e5e5c4 More FileName::appendPath() -> .pathAppended()
Change-Id: I403d34e4f52f758339c158efc7a11fd329e3e043
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-05-17 11:55:04 +00:00
hjk
09372918c1 ProjectExplorer: Remove FileNode's isGenerated constructor bool
Use setter of base class, similar to setListInProject() before.

Change-Id: Id620f0084a5dec0410f29c80f8f6393a6bcd5050
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-02-25 12:23:31 +00:00
Bernhard Beschow
693e2649a4 CMakeProject: Prefer assignment to out parameter
Also change method names from update...() to create...() and mark as
const. This communicates that the objects the methods are called on are
neither altered nor updated.

Change-Id: I29e84dc398ded3ffcbf90741227362c6b4be2bf9
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-01-27 12:13:45 +00:00
Alessandro Portale
17f169c291 CMakeProjectManager: Modernize
modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using

Change-Id: I6a272bc3b75835840b3d6cbe83be6f50f94bbedb
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2018-11-25 07:50:15 +00:00
Ivan Donchevskii
0bd095aa45 ProjectExplorer: Rename compiler includes from System to BuiltIn
System include are those used with -isystem keyword, built-in
includes on the other hand come from compiler and always
follow in the end of the include list (after system includes).

Change-Id: I95c2fec36d2e5b43f014fe0a88d59c6769edfa1f
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2018-09-17 11:24:32 +00:00
Marco Bubke
3abaf647d0 Add system include path to HeaderPath and merge ProjectPartHeaderPath
System include paths are appended after other includes by the compiler. So
we should set them as system includes and not as normal includes. Otherwise
we change the include order. Headers in system include paths are not
cluttering the screen with unwanted warning and by the way improve
performance too.

ProjectPartHeaderPath was a dopperganger of HeaderPath, so we merged them.

Change-Id: I7c394b4098b697de79761499ffcd5913cc02d652
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-09-10 09:31:32 +00:00
Eike Ziller
c8c6b28e22 Merge remote-tracking branch 'origin/4.7'
Conflicts:
	src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.h

Change-Id: I192b9e88f967182f3275b4b98abed1220c26daac
2018-05-28 16:10:23 +02:00
Eike Ziller
6e66b2a078 Remove some lambdas from Utils::transform calls
It is often possible to user (member) functions or members directly.
That improves readablility and potentially reduces the total number of
symbols.
Also use qobject_container_cast at places where it is appropriate.

Change-Id: Ia2591bca356591e001e2c53eeebcf753e5bc3c37
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2018-05-28 13:45:20 +00:00
Tobias Hunger
88b065db3f CMake: Do not crash when deleting cmake tools
Do not crash when the cmake tool that was used to parse the project
gets removed.

Change-Id: Ieda3ae2025dbcfb1f90d9bd01c5f0ed960756c6a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2018-05-28 12:36:33 +00:00
Tobias Hunger
887d1f17a1 CMake: Do not sort nodes
The project tree will sort the nodes as needed, so there is no
need to sort the list beforehand.

Change-Id: I1ee71100aba003117c918c5295224ec1253dc807
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2018-05-04 09:03:30 +00:00
Tobias Hunger
bdd2dd371e ProjectExplorer: Add FolderNode::addNestedNodes taking unique_ptrs
Use that in CMake's tealeafreader.

Change-Id: Id1c372b083df380d0d930668cf7eec4ee89060c2
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2018-05-04 09:02:56 +00:00
hjk
bc698d4ce6 ProjectExplorer: Consolidate RunConfiguration identifications
The previously per-Project/RunConfiguration changing meanings of
BuildTargetInfo::buildTarget have by now been split
into separate values in BuildTargetInfo:
  - buildKey     a handle to one item in Target::applicationTargetList
  - displayName  a user-visible string in the run settings page

The buildKey was tweaked to coincide with the previous 'extraId',
i.e. the non-RunConfiguration-type part of the project configuration
id that (still) use id mangling.

This allows replacing the cases of locally stored seven different
versions of buildKey(-ish) data by one RunConfiguration::m_buildKey,
and do all remaining extraId handling in RC::{from,to}Map only,
i.e. remove the base ProjectConfiguration::extraId() virtual and
remove the "re-try fromMap with mangled id" hack entirely.

The id mangling is still used to temporarily maintain .user file
compatibility in some cases for now, but should be replaced by
storing the build key and the RunConfiguration type soon. Qbs
already changes in here to only use the uniqueProductName as
buildKey, without the previously added display name which is
stored as part of the ProjectConfiguration already.

It turns out that RunConfiguration::buildSystemTarget was intended
and used to retrieve an item from the Target::applicationTargetList
for some configurations, coinciding with what buildKey does always.
So use that insteand and drop RunConfiguration::buildSystemTarget.

There is clearly is further consolidation potential left.

handling of (default)displayNames is still a per-runconfiguration
mess and there is further consolidation potential left.

Change-Id: I448ed30f1b562fb91b970e328a42fa5f6fb2e43e
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-04-12 12:11:45 +00:00
Tobias Hunger
7a7a12cef2 CMake: Fix build directory
Fix use of build directory vs. workdirectory in tealeafreader and servermode
reader.

Change-Id: I593579f7ad4facd64cf201368cacc4d3a8414fbf
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2017-10-27 09:07:10 +00:00
Tobias Hunger
02533e61cf CMake: Fix project parsing notification
This builds on top of 08677c0b01 and
fixes one more code path to go through a common entry/exit point.

Change-Id: I1d00fa9242f247028e5d3b0ef3b5fe1d3f4cb03d
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-10-06 09:53:40 +00:00
Christian Stenger
e255baaa8f CppTools: Add target type information to project part
Let project managers store information whether a project part
belongs to an executable or a library and use this information
inside the AutoTest plugin.
This information will help to determine which targets are
relevant for the execution of tests.

Change-Id: I93b42797bf55225425398dc83aecea3c99eea290
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2017-09-18 10:01:30 +00:00
Marco Bubke
b6e12f4a1c Convert macros from plain QByteArray to a vector of structs
The old code model expected the macros as C++ formatted text
("#define Foo 42) but newer targets like the Clang codemodel expect key
value arguments like "-DFoo=42". So instead of parsing the text again and
again we use an abstract data description.

Task-number: QTCREATORBUG-17915
Change-Id: I0179fd13c48a581e91ee79bba9d42d501c26f19f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-09-14 15:23:56 +00:00
Ulf Hermann
47886969cc Drop unused variables and lambda captures
Also, add context to connect() expressions where we are or were
capturing "this".

Change-Id: I6e006ba6f83d532478018550d148ee93eca59605
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2017-09-08 09:06:53 +00:00
Christian Stenger
27cb331b4b AutoTest: Avoid guessing run configuration
Base the selection of the run configuration on the executable
we have gotten already from the BuildTargetInfo and take
deployment information into account.

This also reverts cce1e130 partially and avoids
stuffing unrelated information into the buildsystemtarget.

Change-Id: I3de6e910a5fd1092d428ec4afc33c4ca62daaa25
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-07-31 06:11:35 +00:00
Claus Steuer
bf10378992 CMake: Fix cmake config can't be changed by user in tealeaf mode
Changes to the cmake configuration (via projects page) are not applied
in tealeaf mode.
The tealeafreader::parse method passes changed config parameters to
cmake only if the .cpb file does not exist. Since that file always
exists after project initialization the user can't change the cmake
config anymore.

Make tealeaf reader pass changed config parameters to cmake when
a reparse is forced. This restores the behavior from 4.2.2

Change-Id: I31ffad32d176e6290064b55758e4df96d2ffe6bc
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-07-19 04:30:38 +00:00
Claus Steuer
13bcdf700d CMake: Set project file location in tealeaf mode
The tealeafreader creates a RawProjectPart for each cmake build target.
However, the location of the CMakeLists.txt is not set/added to
RawProjectPart::projectFile and RawProjectPart::buildSystemTarget.
Both properties are required by the AutoTest plugin to map
run configurations to test configurations.

Make tealeafreader use the same code as the servermodereader
to determine the location of the CMakeLists.txt.

Change-Id: Ia35444799bcd3c46f84ad897044cae56c1aa16ac
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-07-19 04:30:19 +00:00
Tobias Hunger
64c5f960e8 CMake: Return an empty project tree if parsing failed
This triggers the logic in Project to show the top level project
file in the project tree.

Remove similar logic in CMake.

Change-Id: I2bfdd3f5e3d4126910a3feb480cec5ef689954ed
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Florian Apolloner <florian@apolloner.eu>
2017-06-23 09:56:07 +00:00
Claus Steuer
523439d71b CMake: The first build of a cmake project always fails in tealeaf mode
The TeaLeafReader tries to parse the CMakeCache.txt before cmake is
executed for the first time.

The error is signaled to the CMakeBuildStep which reports the build as a
failure.

Make TeaLeafReader::takeParsedConfiguration return an empty
CMakeConfig object if the CMakeCache.txt file does not exist instead,
but do not report an error.

Task-number: QTCREATORBUG-18290
Change-Id: Ibfc43858938477ae7479029e8fe6786c77823014
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-06-20 13:37:17 +00:00
Christian Stenger
cce1e130d7 AutoTest: Fix handling of multiple build targets
If project files are not mapped 1:1 to targets the result
of the chosen executable was more or less random.
Try to handle multiple targets as correct as possible by
checking for build targets already where we still know
which files are part of the respective test cases.

Task-number: QTCREATORBUG-17783
Task-number: QTCREATORBUG-18357
Change-Id: I82dcc26bf52c9918e2727b439a719af08879ef49
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-06-19 08:14:55 +00:00
Tobias Hunger
6886b59fe6 CMake: Filter duplicate files from tree in tealeaf mode
Task-number: QTCREATORBUG-17955
Change-Id: Ibd19c7a0d398f3f26d63983ec024722933485513
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-05-19 08:01:50 +00:00
Tobias Hunger
175643fd7e ProjectNodes: Do not define a copy constructor for FileNode
Nodes are QObjects (still), so they should not have a copy constructor.

Change-Id: I1b20663ee0ec121cda4d39ced7a9f204fb4621a1
Reviewed-by: hjk <hjk@qt.io>
2017-05-04 09:16:27 +00:00
Tobias Hunger
802eff3485 CppTools: Add target information to ProjectPart
This is important to be able to map sources to actual things that are
going to be built.

Change-Id: I1aef940767d60192642ed79a1703cff8dfdad9e1
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-03-15 11:03:45 +00:00
Tobias Hunger
6e91fe5046 CMake: Use a CMakeProjectNode as top level cmake node
Change-Id: I6e68b971cf490b9b064a2866bd99865a7f4a7bd9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-15 10:23:09 +00:00
hjk
4d8352a6c1 ProjectExplorer: Add a FolderNode::addNestedNode() function
Also, rename buildTree() to addNestedNodes(), it's really
adding things, not recompletely (re-)building the subtree.

Use it whenever possible to avoid intermediate lists of items
to insert.

Change-Id: I5fde41e5b164a8a292410bd381a85f5efadf3471
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-03-14 12:26:22 +00:00
Nikolai Kosjar
8a076e3f4b CppTools: De-duplicate and rename function in ProjectPart
Change-Id: I675ce4c9059d8ae4046f6a13aa7c04b88141d443
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-03-09 14:35:29 +00:00
hjk
8b5b1f1de7 CMake: Move CMakeProjectManager::findCbpFile to tealeafreader.cpp
That's the the only user of that code.

Change-Id: Iabc6a1fa9a4ad05c467e8ed64386d3185de25f02
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-28 11:59:07 +00:00
Nikolai Kosjar
8c90998fff CppTools/ProjectManagers: Reduce ui blocking when loading projects
${AnyProject}::updateCppCodeModel() did two potentially not that cheap
operations in the ui thread:
 (1) Querying the MimeDatabase for the mime type for the source files of
     the project. In 99.9% of the cases no files need to be read for
     this as the file extension will resolve the type. The expensiveness
     comes from the sheer number of files that can occur.
 (2) Calling compilers with the "(sub)project's compiler command line"
     to determine the macros. While the caches avoid redundant calls,
     the number of the unique compiler calls makes this still a
     ui-freezing experience.

These two operations are moved into a worker thread. For this, the
expensive compiler calls are encapsulated in thread safe lambdas
("runners") in order to keep the "mutexed" data minimal. The original
API calls of the toolchains are implemented in terms of the runners.

While adapting the project managers, remove also the calls to
setProjectLanguage(). These are redundant because all of the project
managers already set a proper value in the constructor. Also, currently
there is no need (client) to report back detection of C sources in
project parts. This also keeps CppProjectUpdater simple.

There is still room for improvement:
 * Run the compiler calls in parallel instead of sequence.
 * Ensure that the mime type for a file is determined exactly once.

Change-Id: I2efc4e132ee88e3c8f264012ec8fafe3d86c404f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-20 09:18:13 +00:00
Tobias Hunger
c09b3709b9 CMake: Reimplement CMakeCache.txt parsing in BuildDirManager
The CMakeProjectImporter will need that in addition to the tealeafreader.

Change-Id: I453a7a124b5303e163e9c85bc3fc215215617119
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-10 10:33:56 +00:00
hjk
30bf801629 ProjectExplorer: Further tree node related simplification
Drop the list sorting and difference generation which is not
needed in the "build from scratch" setup.

This also removes some of the intermediately introduced
convienience functions and fixes a regression that led to
missing project files.

Change-Id: I39d1966324917f466fb347da3a52552393ca4a01
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2017-01-30 07:56:05 +00:00
Tobias Hunger
36a49ed103 CMake: Set project file information (when available)
Change-Id: I854a0207bd8568bc8f324840cba52dfb3ca880e9
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-27 14:53:06 +00:00
hjk
beaba559a5 ProjectExplorer: Slim down user side ProjectNode handling
Change-Id: If727ff6cd09cc127e031c49c47f61ffda631a80e
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-26 15:24:57 +00:00
Filippo Cucchetto
4b1f8f3609 ProjectExplorer: Added support for registering custom languages
Change-Id: I728a2ed1ef7d9f44d7c2b59d27d6e23444cd3bb5
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-23 11:19:11 +00:00
Tobias Hunger
1b2fc1c815 CMake: Pass const QList<const FileNode *> to Directory Readers
This makes sure they need to copy whatever they need.

Change-Id: I767ac0c5f54ca1f9f46acdefe4bd7fea35657312
Reviewed-by: Alexander Drozdov <adrozdoff@gmail.com>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-12-21 14:19:36 +00:00
Christian Stenger
95fa59dd6c Cmake: Fix regular expression
Change-Id: Ibcd5f62ace4adb4516ecaeba987eb8747996ba04
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-12-13 05:44:44 +00:00
Tobias Hunger
4f8769d844 CMake: Tealeafreader: Emit start signal before actually starting
This way we will get the start signal before the done signal if something
fails early.

Change-Id: I015017fdba16dd84f830b2e1fe2742eb0bec02a0
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-12-05 09:22:50 +00:00
Tobias Hunger
63c0fbc4e4 CMake: Cache cmake configuration only once
This fixes saves memory and fixes some update issues with the cmake
configuration, where the three layers of caches used to interfere
with each other.

Task-number: QTCREATORBUG-17360
Change-Id: I5564bbe46ca8de6b38dd710100bfc18fad98eac5
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-12-02 12:00:09 +00:00
Tobias Hunger
49e255c4d5 CMake: Check result of file open
Change-Id: Ia4a11359f7cb08ee3fa55c77dc54d42890f37845
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-11-30 14:24:55 +00:00
Alexander Drozdov
651460cd8d CMake: separate processing C and C++ flags in TeaLeafReader
C and C++ flags holds at the different variables/compiler settings in
the generated Make and Ninja files.

Currently only C++ Flags processed and assumes that same one uses for
C lang. But now QtC core can handle C and C++ separatelly, so just
add processing for that flags and use it for code model.

Change-Id: If1f71a2c58284a46324f04e962fc120cc316b0fb
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-11-25 13:59:20 +00:00
Tobias Hunger
591d693d0d CMake: Move code to read CMakeCache.txt into CMakeItem class
Change-Id: Ie5d76a2b50007c80d68b2e97d3339a582afce469
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-17 13:10:47 +00:00