Commit Graph

40 Commits

Author SHA1 Message Date
hjk
cf8a05fbec CMake: Use FilePath in FileApi{Reader,Parser}
Helps docker.

Change-Id: I2e1eba61be983340260211bbee6c1bab8a59f883
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-06-16 07:21:08 +00:00
Eike Ziller
2f7f645983 Merge remote-tracking branch 'origin/4.15'
Conflicts:
	cmake/QtCreatorIDEBranding.cmake
	qbs/modules/qtc/qtc.qbs
	qtcreator_ide_branding.pri

Change-Id: Ibd07b5b5ff7c3282134b062ed28b1c4951061c97
2021-06-11 14:20:21 +02:00
Cristian Adam
7a074608b6 CMakePM: Do not emit error signal in destructor while project is parsed
Do not emit error occurred in the fileapireader destructor
if it's parsing. This will cause the fallback file system view
tree to be generated just before the parsing will be stopped.

This can lead to crashes.

Task-number: QTCREATORBUG-25837
Change-Id: Ic7a2dfc394ed8e259da3366727a3c5fa65d98776
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-06-10 14:29:09 +00:00
Cristian Adam
0e613918b6 CMakePM: Always create build directories
Having two configurations for a project, one in /tmp and one in the
right build directory is confusing and for big projects can take some
time.

Fixes: QTCREATORBUG-25532
Change-Id: Ib0dad267117b3c025d668646ef076b0f77bff166
Reviewed-by: hjk <hjk@qt.io>
2021-06-10 13:42:14 +00:00
hjk
d254cf5845 CMake: Use Utils::FilePath in fileapi parser and reader
It still relies on local host execution in some places.

Change-Id: I36adfeb93ea26b285bbf6da2aee7e0fac64a7d94
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-06-09 12:15:02 +00:00
Jarek Kobus
150cc88db1 Don't leave m_rootProjectNode in moved-out state
After calling FileApiReader::generateProjectTree(), the
m_rootProjectNode was left in a moved-out state, meaning
that it was in a corrupted state. However, it was still
possible, that later FileApiReader::resetData() was called
for the same instance of FileApiReader, so a call to
m_rootProjectNode.reset() was executed on an invalid object.
This might lead to a crash.

The fix is to use std::exchange instead and we are leaving
the m_rootProjectNode in a valid, default-constructed state.

We do the same for other members, for consistency.

Task-number: QTCREATORBUG-25837
Change-Id: I5812e410d11c8a3fd5a7c9db002d2ef244ae89cd
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-06-09 11:38:08 +00:00
Eike Ziller
8650e42be8 Merge remote-tracking branch 'origin/4.15'
Change-Id: I07ac7113947cae2e7c3e51b8fa95563fe02b3dc8
2021-06-09 09:03:41 +02:00
hjk
bc2af18a41 CMake: Simplify CMakeProcess::finished signature
The parameters were never used, and start to look alien in the
presence of QtcProcess::result().

Change-Id: Ie2d6a051b439b5e9161d565b84efb78dbe17487f
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2021-06-08 12:38:42 +00:00
Cristian Adam
80d18c1e57 CMakePM: Do backup/restore configuration for all cases
When "Auto create build directories" is not checked, then the first
configuration is done in /tmp, which is covered by workDirectory.

Change-Id: Iad65b4776433ce296bd2561195fcf1bb6f8ace1d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-06-08 09:35:22 +00:00
Cristian Adam
1b3a4e1fc6 CMakePM: Clear and setup file watcher before and after backup configuration
Qt Creator 4.15 will do a backup of the CMake file-api, but the file watcher
that triggers a reparsing was not cleared up before the backup.

This could lead to unnecesary file-api rescans.

Task-number: QTCREATORBUG-25783
Change-Id: Id91379ea85c8a91e03d952c5c66b0371ebff943f
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-06-08 09:34:00 +00:00
Eike Ziller
58d03f3f2f CMake: cancel file api parsing
Change-Id: Ie59370fa4329f92dd28bf3e147b2828cbd75330b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-06-01 12:35:25 +00:00
Cristian Adam
392bda1160 CMakePM: Save cmake parameters in qtcsettings.cmake also for initial run
This way projects can have access to all CMake parameters that were
issued from Qt Creator.

Previously the initial run was skipped, only the subsequent changes
were picked up.

Change-Id: I7a2262cdb9754ff666f78fd2e39663466f494f5f
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-06-01 09:22:41 +00:00
Eike Ziller
fbeaa774b5 CMakePM: stop file api reader future on stop()
The future that would trigger the result of a cmake api file parsing
would not be removed if the stop parsing would be triggered.

This could be triggered by fast switching between build configurations.

It could also lead to forever parsing states having the project's
wheel always spinning.

Fixes: QTCREATORBUG-25588
Fixes: QTCREATORBUG-25287
Change-Id: I4f92806ebdb703b4910952cd8db1e52816daf9cf
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-05-31 13:58:26 +00:00
Cristian Adam
f7d729f0b5 CMakePM: Treat empty build as empty when importing CMake builds
Qt Creator 4.15 with the CMake multi-config support it parses the
correct CMAKE_BUILD_TYPE file-api json export.

With the empty build Qt Creator was giving it a name: Build, which
was not part of the file-api json export.

Fixes: QTCREATORBUG-25387
Change-Id: Id0b5f1077f6473fa5aef09397a8257b253557597
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-03-10 10:29:55 +00:00
Cristian Adam
8c9faaf3e5 CMakePM: Do not issue error message when CMakeCache.txt is missing
Only do the backup of the CMakeCache.txt and the file-api json
reply directory when they exist.

Change-Id: I0fe1098968c5b6b3a8285745452d5a24d7ded638
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-03-05 11:36:54 +00:00
Cristian Adam
fc411cd0d1 CMakeProjectManager: Make backup of CMake configuration before starting CMake
CMake's fileapi functionality will save the project structure in json
files in the .cmake/api/v1/reply directory.

When issuing a cmake command with -D variables CMake will update its
CMakeCache.txt file even if cmake will fail.

This commit will rename .cmake/api/v1/reply as .cmake/api/v1/reply.prev
and make a copy of CMakeCache.txt before starting CMake, and if
something fails, replace the existing files with the previous values.

Also make sure the changed values are not dissappearing when the
old .cmake/api/v1/reply gets parsed.

Fixes: QTCREATORBUG-24593
Change-Id: I82141786fea7068699e0f761a8978ba1f3203e47
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-02-18 13:21:11 +00:00
Cristian Adam
6cbdae8070 CMakeProjectManager: Support for multi-config generators
CMake has multi-config generators like:

  * Visual Studio
  * Xcode
  * Ninja Multi-Config

The first two have different special targets for "all", "install",
"package", "test" namely: "ALL_BUILD", "INSTALL", "PACKAGE",
"RUN_TESTS".

All of them need to get the build type passed via "--config <build-
type>" and not via "CMAKE_BUILD_TYPE".

The multi-config generators will use only one build directory.

Fixes: QTCREATORBUG-24984
Change-Id: I8aa7ff73ce2af1e163b21a6504d26fcf95530edf
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-01-21 09:31:30 +00:00
Christian Stenger
617a8aee2b CMakePM: Start integrating ctest
Gather some more information of a CMake based project to be
able to provide this later on to the AutoTest plugin.

Task-number: QTCREATORBUG-23332
Change-Id: I2beaf0a6456d57871dcf65832f0a79f37fe5fddc
Reviewed-by: David Schulz <david.schulz@qt.io>
2020-11-09 11:02:37 +00:00
Dmitriy Purgin
53115259ba CMakeProjectManager: Add File System virtual folder
If a CMake project cannot be parsed by CMake, it is practically unusable in
Qt Creator. According to discussion in QTCREATORBUG-24677, a virtual
folder with the project's file system view is added to the project
manager as a convenience feature.

Fixes: QTCREATORBUG-24677
Change-Id: I48775bb89c704d3f7e5bb21ec6481bd5cc0f4b6c
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-11-09 10:48:14 +00:00
Tobias Hunger
01b0d4f8f5 CMake: Remove magic configuration from CMake
Get rid of magic configuration handling in the CMakeProjectManager.

* Use CMakeCache.txt as the sole source of truth, do not keep
  a shadow copy of configuration in the .user file
* Have initial CMake arguments that are easy to edit in batch
  (Fixes: QTCREATORBUG-18179) used whenever no CMakeCache.txt
  file is in the build directory. These allow for any thing that
  can be passed to CMake on the command line.
  (Fixes: QTCREATORBUG-16296)
* Ask when changes to CMake configuration were not applied
  (Fixes: QTCREATORBUG-18504)
* Run cmake with arguments effecting its configuration only when
  the CMake settings are changed in the UI, run CMake without any
  special arguments in all other cases.
* Get rid of the confusing dialog used to keep settings in sync between
  what is in CMakeCache.txt and Creator (Fixes: QTCREATORBUG-23218)

Change-Id: I26d55be7df733f084f5691ecf7d7b4352f58b8e7
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-06-09 16:34:00 +00:00
Tobias Hunger
7c985c14ad CMake: Move notification on outside cmake runs into FileApiReader
Move the detection of outside cmake runs into FileApiReader and
make the FileApiParser non-interactive.

Change-Id: I70afc1df35fcfe90e88822569579154aabbdb1cd
Fixes: QTCREATORBUG-24015
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-05-15 08:36:50 +00:00
Tobias Hunger
517cb05db0 CMake: Clean up API of FileApiParser
Clean up the API of FileApiParser in preparation of moving
the FileSystemWatcher out of that class and into FileApiReader.

Change-Id: I5618252dd98a39f6a70f56b50fb50327e8b43e84
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-05-15 08:36:37 +00:00
Tobias Hunger
59473389b9 CMake: Remove BuildDirManager
The BuildDirManager was used to switch between different
BuildDirReaders. Now that only the FileApiReader is left, that
infrastructure is no longer needed.

Change-Id: I2d339a3407bb633cff6a8f7502b7b09094f63fef
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-04-30 12:08:08 +00:00
Tobias Hunger
902b1c3b9e CMake: Disable switching between different readers
Remove the code that switches between different types of
readers based on what the different CMake binaries support.

This is no longer needed since only file-api is supported now.

Change-Id: Ia86d143f5e2cecc2bcd68ab7d62503915a32d223
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2020-04-30 08:06:18 +00:00
Tobias Hunger
5350288e45 CMake: Fix includes all over the CMake plugin
Keep internals internal, remove some unnecessary includes, add
some that should have been there.

This reduces the number of files that get rebuild when working
on CMake internals from over 1000 to about 200.

This patch also moves some code around that ended up being
in the wrong file.

Change-Id: Icd7366ac760dc85031040720418fbb16336dce9b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-04-20 10:05:24 +00:00
Tobias Hunger
5de0e81d8b CMake: Fix typo in symbol names
I can't spell occurred:-/

Similar typos in 3rd party code (sqlite) has been left in place.

Change-Id: I7cfa9911fc434d42ce3df8e9c7ccb83dc00401e8
Reviewed-by: hjk <hjk@qt.io>
2020-03-19 17:50:21 +00:00
hjk
b0b50257ec ProjectExplorer: Pass extra project files as QSet
They are available in some cases as such, and consumed as such.

Change-Id: I9866c7d7bd817fb19a8b11a0efbe583ed55fe393
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2020-03-03 09:17:20 +00:00
Cristian Adam
f65f260c91 CMakeBuildSystem: Don't re-update code model on CMakeLists.txt saves
Currently if you edit a CMakeLists.txt and then press save, the code
model will be reindexed.

On projects like Qt Creator this operation is quite significant.

Note that the code model is updated after CMake has run on the project,
which is what I would expect.

Saving the CMakeLists.txt and not running CMake has no effect on the
project, and the code model shoudn't be reindexed.

Change-Id: I61289fda60752ef002cf3625d339d4fcaf144d1b
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2020-02-20 15:41:28 +00:00
Alessandro Portale
9904464074 Make various Q_LOGGING_CATEGORY's static
Change-Id: I43d3a198b0863d85a7fb305c7cb768f68acbd139
Reviewed-by: hjk <hjk@qt.io>
2020-01-15 14:54:10 +00:00
Tobias Hunger
97855766bd CMake: Fix build directory location in fileapi and tealeaf reader
Sorry, this was wrong in 196b0da08a

Change-Id: Id2d6a5fb180ccc74c6fea0559466f8e390de69e8
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-10-18 14:33:46 +00:00
Tobias Hunger
196b0da08a CMake: Write creators settings into build directory
Write a file qtcsettings.cmake into the build directory. This
file contains all applicable CMake configuration settings that
creator wants to set.

Use "cmake -C qtcsettings.cmake .." to reconfigure on the command
line to make use of this file.

Change-Id: I4a69d082c50bb66e60b4eec1b3155df53e00734d
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2019-10-18 14:11:13 +00:00
Tobias Hunger
faa9eabe48 CMake: Reset process in fileapi reader once it is done
This is what made "Run CMake" only work every second attempt.

Change-Id: If539941138072504225fa6461379f92a0991deac
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-10-08 14:42:47 +00:00
Eike Ziller
9cc45fe1fb CppTools: Move RawProjectPart to ProjectExplorer
Doesn't have any dependencies into CppTools anymore, therefore moving it
reduces the dependencies of the project managers to CppTools as well.

Change-Id: Ibe728abe59eb88a8877943dca1f48a85163e27ac
Reviewed-by: hjk <hjk@qt.io>
2019-09-11 06:22:12 +00:00
hjk
c343d98215 CMakeProjectManager: Work around deprecation warning
Change-Id: I2e2281395ca030ba76334fba8a574c145bc1dbf5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-08-30 07:07:10 +00:00
Tobias Hunger
b8be7da158 CMake: Simplify based on Project::projectFileIsDirty signal
Delegate all the necessary file watching to Project and connect
to the relevant signal.

Server-mode insists on watching files itself, so that may not
report extra project files.

Change-Id: If821c54a7b0f8b72beed53dd1c83f255973faf3e
Reviewed-by: hjk <hjk@qt.io>
2019-08-16 12:43:39 +00:00
Tobias Hunger
87f496d091 CMake: More logging of cmake parsing flags
Add more logging of cmake parsing flags as cmake runs are requested
in the plugin.

Change-Id: I5231bd29dfeb6521218dc28c26a5b658ccb4059b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-08-09 11:52:26 +00:00
Tobias Hunger
eab0df22f9 CMake: Make fileapi not race against its own reply file detection
Fix broken logic to prevent CMake fileapi from detecting the change
its own cmake run triggered via file watching.

Remember the last file that was parsed and do not attempt to parse
this again. Remember the file on a per-project basis, too:-)

Change-Id: Ia6e155b65d77994f6e3d2a3677f770a4ba53539d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2019-07-25 13:32:21 +00:00
Tobias Hunger
09ae77d0a9 CMake: Update code to decide whether to run cmake in fileapi mode
Change-Id: Iea841bb49876a580abc80cc7ea21a88b153cc224
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-07-23 11:11:30 +00:00
Tobias Hunger
c61c499970 CMake: Add an option to override cmake reader type
Add an option to override the cmake reader type that is going to
be used.

By default the reader type is "auto" for autodetection, but that can
get changed in the cmaketools.xml settings file. Other supported options
are "tealeaf", "servermode" or "fileapi" and that will force that reader.

You can also set QTC_CMAKE_IGNORE_FILEAPI=1 in your environment to force
creator to ignore the existence of fileapi support in all cmake tools.

Change-Id: I2006616312090ce2909154dc1966f7a8eaa2949a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-06-20 13:42:02 +00:00
Tobias Hunger
a95eb53d3b CMake: Add initial fileapireader class
Change-Id: I620cba7cc1c2a5ac56789fa9770dce573c6b19cd
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-06-20 12:25:36 +00:00