Commit Graph

55 Commits

Author SHA1 Message Date
Tobias Hunger
55a4a62797 CMake: Speed up server-mode
Use a QSet to avoid having to search in a QList.

Change-Id: I2261a83acd3924a8483495e1f03322c7574a78a8
Reviewed-by: hjk <hjk@qt.io>
2017-03-24 15:55:10 +00:00
Tobias Hunger
572ea47e97 CMake: Fix project tree getting lost during reparsing
Fix the project tree getting lost after changing a cmake file. This is
due to the old set of files being used for deduplication, so no CMakeLists.txt
files got added to the tree, and then nothing could be added to those later.

Change-Id: I46989e0b802ab2a030d1922282361359837c41a4
Reviewed-by: hjk <hjk@qt.io>
2017-03-23 15:09:55 +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
1621aaa26e CMake: Fix some more SOFT-ASSERTS in CMake server-mode
Fix two more SOFT-ASSERTs in CMake server-mode that could be triggered
by complex projects.

Move and simplify search functionality into FolderNode and use that instead
of hand-crafting a custom tree search in CMake.

Change-Id: If4bde5c4a7ff84c7d5dba4f595e99b39f54ac8aa
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-15 10:23:14 +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
Tobias Hunger
b8417e0f0c CMake: Fix projects with complex CMakeLists.txt layouts
This fixes soft assserts in e.g. Musescore.

Change-Id: I860c8c184161e53918fb901d66b89cffb0c09e23
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-15 10:22:24 +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
Tobias Hunger
98505427d3 CMake: forward dirty signal in server-mode
This fixes auto-running cmake on changes to the project files.

Change-Id: I652b48b243b5decb6927b1619c47527af83d7f03
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-03-13 16:27:01 +00:00
Tobias Hunger
86fde306d1 CMake: Get better FileType in servermode reader
Change-Id: I8713043a625b17532ab33a72867aa0a20aa4cb3c
Reviewed-by: hjk <hjk@qt.io>
2017-03-10 16:44:35 +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
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
568130da70 ProjectExplorer: Add FolderNode::compress
Add a method to FolderNode that compresses a tree of folders like
A/B/C/file.txt into one FolderNode (A/B/C) and a FileNode (file.txt)

Change-Id: I5efa038c33b91ea01017269daa048ba101085d01
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-14 15:39:36 +00:00
hjk
cbe30a1cca CMakeProjectManager: Add some soft asserts
The actual problem is fixed by 1f540c6c9, this is to make sure we
don't crash if this regresses again.

Change-Id: Id081ce9a9c3602c3a90216f53d63535097fabd2d
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-13 08:47:51 +00:00
Konstantin Podsvirov
1f540c6c9d CMakeProjectManager: Fix findCMakeNode function
Via CMake project we can add subdirectory like:

> add_subdirectory("subdir/subsubdir" "enotherdir")

Where "subdir" my not contain "CMakeLists.txt" file.

And intermediate directory can contain CMakeLists.txt file
that is not a part of the root node.

This change fix it.

Task-number: QTCREATORBUG-17721
Change-Id: Ice9fba1ca5a979955ec8f44324f75f3bc16ee198
Reviewed-by: hjk <hjk@qt.io>
2017-02-10 14:50:41 +00:00
hjk
04a525877b ProjectExplorer: Merge FolderNode's m_{file,folder}Node fields
One step closer to direct use of Utils::TreeNode.

Change-Id: Icd0dfd2fa4d12c2572a68f61ae43c5e906956a0e
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-02-09 12:15:23 +00:00
Tobias Hunger
0e25c08942 CMake server-mode: Use more robust logic
Use a more robust logic to find existing CMakeListsNodes again.

Change-Id: Id26031c1164eb6271b74ccf39071219938b285fc
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-09 10:08:13 +00:00
Tobias Hunger
c20ae42e20 CMake: Show all headers below an included directory in server-mode
Change-Id: I2ff0018a3c92ccb55eca957624cc44f941ec866c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-09 10:08:07 +00:00
Tobias Hunger
bc598ec480 CMake: Fix project name selection
Change-Id: I03740045d817762ef91cf6399ac449c5af67b278
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-02-09 10:07:57 +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
1ce6cfd809 CMakeProjectManager: Simplify creation of virtual folders
Change-Id: I781c0f6551ca01feaf1cc0fc1148a151777f91bf
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-27 08:40:50 +00:00
hjk
87304b3ce0 ProjectExplorer: Introduce some FolderNode convenience functions
... and use them.

Change-Id: I9f5237e5eac30715c2effbd3301dd2a70516d2a9
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-27 08:40:20 +00:00
hjk
f12fb1496f CMakeProject: Simplify tree generation helper function
The sets of used nodes are not needed anymore.

Change-Id: I308fa140779f8a108fa23907f0959cf35100d67f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-26 15:25:55 +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
Tobias Hunger
26878aacaa CMake: Cancel running tasks on crash of cmake server
Change-Id: I5bf36a5ebb9d6a80278b9b83a14788a171f9c14f
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-23 15:38:25 +00:00
Tobias Hunger
01e80b264b CMake: Put cmake server-mode socket into a temporary directory
Do not put the cmake server-mode socket into the build directory, but
put it into a temporary directory instead.

This makes sure it will not stick around and also avoids polluting the
build directory with Qt Creator specific files.

Task-number: QTCREATORBUG-17320
Change-Id: Id849b1a80d7cba07c026cc2ecd7030435c401884
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-20 12:21:20 +00:00
Tobias Hunger
0f7d75ccf5 CMake server-mode: Keep settings
Keep settings when switching from the temporary build directory to the
real one using cmake with server-mode.

Task-number: QTCREATORBUG-17360
Change-Id: If36489cb2584dc5e0b021430e5d860e146fd8a86
Reviewed-by: Florian Apolloner <florian@apolloner.eu>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-01-19 16:04:19 +00:00
Alexander Drozdov
3ff3a19207 CMake: fix definition composing in ServerModeReader
CMake uses definitions with assign operator notation, so, we should
replace first assign operator with space to omit parser damage.

Change-Id: I795c4371a1fdd534a42eb01bdcbe852534ce2bcf
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-16 11:31:36 +00:00
Tobias Hunger
8f885a5b2e CMake: Fix WS in servermode reader
Change-Id: I797d3c7025ee43f722ed137d911c58acb4b8e1f0
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2016-12-21 15:25:23 +00:00
Tobias Hunger
b11726bf05 CMake: Do not list <Build Directory> twice
Do not list <Build Directory> twice when switching from a temporary
build folder to the real one.

Change-Id: Id7d5f4a4b48d6c63dd4c7da2932b6a857ff0c7f7
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2016-12-21 15:25:19 +00:00
Tobias Hunger
c41404728a CMake: Always list CMakeLists.txt files
Always list CMakeLists.txt files, even if CMake thinks they are part
of its own modules. This unbreaks opening the cmake project with
a cmake built from those sources.

Change-Id: Ia7245aa0fa39854fe228cdff75b2256115545b39
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-12-21 14:21:06 +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
Tobias Hunger
45ad669a88 CMake: Return empty tree on errors in server-mode
This triggers the fallback mechanism which will make sure the CMakeLists.txt
file will be displayed.

This used to fail since one empty folder was left over in the project.

Task-number: QTCREATORBUG-17383
Change-Id: I867fd9039bc5df805ff5174ec49084bbcf688824
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-12-05 16:21:30 +00:00
Tobias Hunger
183cdbc91f CMake: Emit errorOccurred on errors in server-mode
Change-Id: I0dd262ccaad3704c70dedff5e0b102032c46d2df
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-12-05 09:22:41 +00:00
Tobias Hunger
e545f8a105 CMake: Work-around first config argument getting skipped by cmake
Work-around the first configure argument getting ignored by cmake 3.7.0
and CMake 3.7.1.

Change-Id: Iaf164cbf973672c1d899738a374c65ea5641132c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-12-02 15:33:55 +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
ea220ccec1 CMake: Emit necessary signal in server-mode
Change-Id: I35066deebbd0b7330cbf9864442073966af9203f
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-12-02 11:59:58 +00:00
Tobias Hunger
2d8d90bc79 CMake: Cache buildtargets in builddirmanager
No need to have the builddirreaders to so.

Change-Id: Ia7e38f6483b29d6a4f4b65baacc17bf184a3cb34
Task-number: QTCREATORBUG-17359
Reviewed-by: Florian Apolloner <florian@apolloner.eu>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-11-30 14:23:36 +00:00
Tobias Hunger
c9be75fe65 CMake: Handle executables properly in server-mode
Change-Id: Idabfc2449377d0d81cc1639ad4992d8710ec8b7d
Task-number: QTCREATORBUG-17359
Reviewed-by: Florian Apolloner <florian@apolloner.eu>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-11-30 14:23:28 +00:00
Tobias Hunger
c54fe23579 CMake: Send compact JSON output to cmake server
Change-Id: I0e02f122bdb2b1b417a70aa4933cc4246d6969c6
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-30 14:23:16 +00:00
Tobias Hunger
391284f393 CMake: Fix <Build Directory> in server-mode
Files below <Build Directory> could not be opened from the project tree
since their file path was broken. Fix that.

Task-number: QTCREATORBUG-17297
Change-Id: Id785ffa1c4d22c4dfdc0b5ecf8217d3f8bc319c4
Reviewed-by: Florian Apolloner <florian@apolloner.eu>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-25 10:23:50 +00:00
Tobias Hunger
3422e5cded CMake: Clean up more paths in server-mode
Change-Id: Ifd578cbc7516f66ad52cc13faca0ee733dbc7512
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-17 10:57:23 +00:00
Tobias Hunger
a7aeec22ce CMake: Unify names for important directories in server-mode
Unify names for important directories in the project tree of
server-mode cmake projects.

Change-Id: I6354e0a1cfb71f9038d9110438622c824deedebe
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-17 10:57:16 +00:00
Tobias Hunger
eff0768100 CMake: Fix server-mode trimming out targets every second time
Do not trim out targets every second time the project tree is generated.

Change-Id: I6ed9cd7bb6b2e88ec6dbe063f90719ffacffdd61
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-11-15 16:27:21 +00:00
Tobias Hunger
7b467cbad6 CMake: Make sure paths are clean in server-mode
Change-Id: I93c61a24e63d8920731b4197d88248d13219eb81
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2016-11-15 16:27:09 +00:00
Tobias Hunger
247a6fea93 CMake: Server-mode: Use sourceDirectory directly
Change-Id: I0929ea86e24a8f1aa4dbfc5d41421127accefe33
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-14 11:17:45 +00:00
Tobias Hunger
4b4dc9d06c CMake: Project tree for server mode data
Change-Id: Ief884a76c1b4211501dd6515b17b6e88a8e881e5
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-14 10:29:53 +00:00
Tobias Hunger
1a2f649b70 CMake: Clean out unnecessary data in server mode reader
Do not keep data around once it is used. It will not help on the next run,
especially not when the parsing fails then:-)

Change-Id: Ifa1259b74349ac172a5c9d5411c10d429085b853
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-14 09:03:44 +00:00
Tobias Hunger
269e699fd9 CMake: Pass scanned files on to builddirreaders
Change-Id: I226aeafe6800a84fe4bbf8cf6fd21b8237575a88
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-14 09:03:28 +00:00
Tobias Hunger
a7f237d17b CMake: Make future-handling in ServerModeReader more robust
Change-Id: Id2fc5487fdfb7619db2eee2439e5636afdc39add
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2016-11-07 13:25:39 +00:00