Commit Graph

234 Commits

Author SHA1 Message Date
Christian Kandeler
077de5aab6 ProjectExplorer: Handle registering of auto-created bundle toolchains
... in the bundle itself, whenever possible.
It's very annoying to have to add this stanza in all places where
bundling takes place, and it's also easily forgotten, introducing memory
leaks.
This also nicely self-documents the expectations of the calling code as
to whether new toolchains can or cannot be created in the given context
as a side effect of bundling.

Change-Id: I78d2d4cdfc1010568f61f201b0d930b01f79a88b
Reviewed-by: hjk <hjk@qt.io>
2024-08-08 14:34:47 +00:00
Christian Kandeler
020883c47f ProjectExplorer: Stop pretending that C and C++ compilers are unrelated
Motivation:
  a) It was ridiculous that when users wanted to manually
     add a new toolchain, they had to do the entire setup twice.
  b) It was equally weird that users had to take care to choose
     matching toolchains when setting up a kit, or indeed that it was
     even possible to mix random toolchains in the first place.

User-visible changes:
  - The "C" and "C++" categories in the toolchain settings page have
    been merged into a single "C/C++" category.
  - When adding a new toolchain, the "C" and "C++" sub-menus are gone.
    Instead, the toolchain config widget offers two path choosers if
    the respective toolchain type supports C and C++ compilers.
  - By default, the C++ compiler file path is derived from the C
    compiler file path automatically, so the user usually has
    to enter only the former.
  - In the kit settings page, the "C" and "C++" toolchain combo boxes
    have been replaced by a single "C/C++" combo box, relieving the user
    of the responsibility to choose two matching toolchains.

Implementation:
The notion that a Toolchain object corresponds to a single compiler is so
deeply engrained in the code that it cannot realistically be changed in
the short term. We therefore introduce the concept of a "toolchain
bundle" as an additional layer that groups matching C and C++ toolchains
together. This way, most code dealing with toolchains stays unchanged,
and only the presentation layer (i.e. the toolchain and kit settings
pages) needed to be rewritten. Once set up in a bundle, toolchains stay
implicitly linked together so the matching only needs to be done once.

In follow-up patches, we will make use of toolchain bundles in all the
places where kits are auto-created, eliminating the risk of mixing
incompatible toolchains in a kit.

Change-Id: Ie6c5add9963e7c1096268dd77acd624671b2674f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2024-08-05 15:35:48 +00:00
Christian Kandeler
e75b9f32a9 ProjectExplorer: Make custom toolchains C/C++ only
That's what they were intended for. There appears to be no use case for
them to represent e.g. a nim compiler.

Change-Id: I8070fb837fe411c3e2b6e5a335e642497437896d
Reviewed-by: hjk <hjk@qt.io>
2024-07-30 11:42:12 +00:00
Christian Kandeler
9d0c144892 ProjectExplorer: Let toolchains be (de)registered in bulk
When some code adds or removes a bunch of toolchains at once, that
should be made explicit and also be reflected by the respective signal
emissions.
Fix some leaks and typos along the way.

Change-Id: I4a1f12a2378316c5faf70e85a88adc467f076caf
Reviewed-by: hjk <hjk@qt.io>
2024-07-19 14:44:47 +00:00
Christian Kandeler
2ddb7f66a8 PE: Add convenience function for retrieving a toolchain's factory
Change-Id: I76839ea04576b5a2c6252c09dea7955883e7ad9a
Reviewed-by: hjk <hjk@qt.io>
2024-07-16 08:11:47 +00:00
Christian Kandeler
ec5e055a90 ProjectExplorer: Add function for retrieving toolchain factory by type
Change-Id: I0968738c50e7fce56a016c4801054131a1ea33c9
Reviewed-by: hjk <hjk@qt.io>
2024-07-12 12:47:22 +00:00
David Schulz
9e73dc1f09 ProjectExplorer: add async toolchain autodetection
Change-Id: I82c6d0b22a9d36674c58561ef654d7ffde8574da
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2024-01-23 08:28:55 +00:00
hjk
ddf39cd0dc ProjectExplorer: Rename various items in the Toolchain class
Change-Id: I544763d3b4d521f6bbed0dc5a767c15c49055a19
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-12-04 15:10:08 +00:00
hjk
b5937836f4 ProjectExplorer: Rename ToolChainManager to ToolchainManager
Plus the private and some comments.

Change-Id: I95d72d77f25cb1c969a1a6148e7186150a697d1f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-11-27 16:33:34 +00:00
hjk
c28fb1fdbe ProjectExplorer: Rename ToolChain to Toolchain
Change-Id: Ibb520f14ff3e2a6147ca5d419b9351c50c141063
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-11-24 15:18:24 +00:00
hjk
2d4867e73f ProjectExplorer: Rename Tool{C,h}ainFactory
Also adapt derived classes.

Change-Id: Iebf654c974730333c42b6994269ad1a4d5f7f428
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-11-24 13:55:25 +00:00
hjk
4d2f3e8b01 ProjectExplorer: Merge GccToolChainFactories further
This replaces the four classes from the GccToolChainFactories
hierarchy by a single (parametrized) GccToolChainFactory, but
makes the "RealGcc" one responsible for all autodetection.

This is a hack to move closer to a "scan only once" setup, and
temporarily necessary as there is currently one factory creates
one type of toolchain, so we need four factories for the current
four gcc-ish toolchain types.

Change-Id: Icbecb1be6e89cf5efad76baf92ef38ac63be074f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-09-26 09:26:59 +00:00
David Schulz
726cc7f5cd PE: Make GccToolChainFactory::autoDetectToolchains static
In preparation of running it in another thread.

Change-Id: I2cbac1bd45885416f8ee0dfdc95a4998e87d2f8e
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-09-20 12:02:32 +00:00
hjk
23149b27ab Utils: Introduce variantFromStore and storeFromVariant
These are functional replacements for
  QVariant::fromValue(QVariantMap) (or QVariant::fromValue(Store)) and
  QVariant::toMap() (or QVariant::toValue<Store>())

We will have a few code paths in the end that need to explicitly
operarate on both QVariantMap and Store (e.g. actual reading/writing
to keep format compatibility etc), so these can't in the end be
simple to/fromValue(OneType) but need an internal 'if' or such.

Change-Id: I954f3cb24fa8fe123162b72bbd25d891dd19b768
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-08-28 11:16:40 +00:00
hjk
b9f9d2574e Utils/ProjectExplorer: More Key and Store
Change-Id: Ic9cc3a36b320c7413c362d1a1cdf024298d25027
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-08-25 07:33:53 +00:00
hjk
6c2864bd4b ProjectExplorer: And more Key and Store
Change-Id: Id5787890bdb46bfeef8e3f37923e6dc26cb56c31
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-08-24 11:20:25 +00:00
hjk
6e307be365 Utils: Rename the new Storage to Store
Apparently that's what the young people on the web use for such a thing.

Change-Id: I75d5396ff3cb3c26efd6008b5f2261354c4f7896
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2023-08-24 05:56:57 +00:00
hjk
dc6b40a5c0 Use Utils::Storage instead of QVariantMap in a few places
Change-Id: I02833cf2bc3caaadc22ff93ae530e4aebe4c3868
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-08-23 14:30:50 +00:00
hjk
62969fe567 ProjectExplorer: Remove unneeded #include
Change-Id: Ib835409781ad1ebf8efa184e69c5adf20436b6ad
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-08-17 06:36:36 +00:00
Jarek Kobus
8d8e60436d ProjectExplorer: Simplify return statements
Change-Id: Ifef006cd2dcc567097ce16376eab9ccedb092f04
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-08-02 11:08:25 +00:00
hjk
c558896594 ProjectExplorer: Replace the fromMap error return value for toolchains
... by some out-of-band mechanism, keeping previous functionality.

The driving reason is to get the same fromMap signature as in the
AspectContainer base.

Change-Id: Ife7fbf4d0e0f78d88729021eb5220ec4a8ddb2ec
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-07-24 10:17:36 +00:00
hjk
32850e7fcc ProjectEplorer: Base ToolChain on AspectContainer
Similar approach as done with ProjectConfiguration

Change-Id: Ia5e1d464b7c5c64d7a12ee12c7673ff453f24390
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-07-20 15:27:07 +00:00
hjk
c1309f9417 ProjectExplorer: Change ToolChain::toMap() signature
... to something similar to AspectContainer::toMap() as
preparation for later aspectification.

Change-Id: Ic60060ad1a7eb1aba58ded01221b016c684db073
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2023-07-20 15:01:52 +00:00
hjk
6f17409b53 ProjectExplorer: Code cosmetics in toolchain.cpp
Mostly namespaces, but also centralize access to the factory list
for better debugging.

Change-Id: Ic8b19b8c110dc925e0f7ae27af1da2b9e1ec6086
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-07-07 15:25:29 +00:00
hjk
cacc4aeede ProjectExplorer: Run toolchain autodetection on startup
... explicitly only for the Desktop device. This was implicitly done in
some cases by assuming 'no device' == 'desktop'. Make that explicit now.

Change-Id: I2ce86702a9b5b795fb4832301a11a8c8b40e77ea
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-04-17 16:08:42 +00:00
hjk
2704f8ff0b ProjectExplorer: Proliferate FilePath a bit
Change-Id: Ia671a1de17b9e58764375c5f64cc47b053b0725a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-03-15 09:57:02 +00:00
hjk
66c08a824d Utils: Rename most FilePath::{from,to}Variant uses to {from,to}Settings
Specifies the main purpose more clearly. The remaining ones a "true"
(internal) variants in models and as action data.

Change-Id: I8dd3c846e419f29d88283c2f48268ef6685b19fe
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-10 09:00:30 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
hjk
c7c6ddb8b0 Utils: Replace Environment::isSameExecutable()
... by FilePath::isSameExecutable().

The only non-mechanical case is the use inside QmakeBuildSystem::testToolChain
using a build environment instead of the FilePath's device environment.

This make a difference in theory due to the use of PATHEXT in the actual
check, but I believe the case that someone creates a 'qmake.foo' and
a 'qmake.bar', adds .foo and .bar to PATHEXT and then complains that
there's a warning missing about not-matching mkspecs has zero
likelihood in reality (and will break other places in Creator anyway).

Change-Id: Id6a8d1e4dc2eb74ca81610ccb1c4ee94c6f47e12
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-23 08:07:08 +00:00
Orgad Shaneh
b81e295f58 Toolchain: Support also concatenated syntax for MSVC included file
For example: /FIC:/Projects/test/config.h

Change-Id: I18dcda6593effa58ece019ce40bca7860cebfc8c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-11 11:32:46 +00:00
Marc Mutz
8eb4d52342 Port from qAsConst() to std::as_const()
We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
2022-10-07 13:47:53 +00:00
Jarek Kobus
898053533a ProjectExplorer: Limit the usage of qMakePair
Make the code less verbose.

Change-Id: If9fe08a6a7538d34c80ca97a2aec21a2bd6e5d22
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-04 09:02:22 +00:00
Jarek Kobus
50f2f57f6a ProjectExplorer: Limit the usage of std::make_pair
Make the code less verbose.

Change-Id: I4d671a49a6b8097d4a324bdd9f6a2c9dbdb225cc
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-10-04 09:02:18 +00:00
Marcus Tillmanns
8d67bc36a7 ToolChain: Cache validity
Checking the validity of a toolchain can involve a call to
a remote device.

We cache the status now to speed up places that repeatedly
check the validity like opening the Toolchain Settings Page

Change-Id: I2b1d8aeba99fb9761d60d4710806bf4b767eaac9
Reviewed-by: hjk <hjk@qt.io>
2022-09-30 12:13:43 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Eike Ziller
948f0070fa macOS: Fix importing command line builds with CMake
When configuring a CMake project on the command line, CMake will
(correctly) find and use the compiler from the current developer
directory, usually somewhere in
/Applications/Xcode.app/Contents/Developer

But Qt Creator auto-detects and sets up the compiler /usr/bin/clang(++)
for desktop kits. This leads to a compiler mismatch between kits and the
imported build, and to new kits registered in Qt Creator for the import.

Since /usr/bin/clang(++) is just a thin wrapper that resolves to the
compiler in the current developer directory, resolve that in Qt Creator
with "xcrun -f <command>" too (caching the result), and include that
when comparing toolchains for importing builds.

Fixes: QTCREATORBUG-27591
Change-Id: I301e2a4e267450b488b49d0c32d4ce89001bb5ec
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2022-06-13 10:03:16 +00:00
Eike Ziller
3211d064e0 Merge remote-tracking branch 'origin/7.0'
Change-Id: I3da1b663a570682201afbe644d6f9299019aae21
2022-04-26 15:22:35 +02:00
Orgad Shaneh
48f01f503f ProjectExplorer: Only strip L from cplusplus macro if it exists
Old GCC versions have #define __cplusplus 1

Change-Id: I71286656df8f9925c2e0ccc46d32546037423268
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-04-26 06:59:42 +00:00
Jarek Kobus
7fadaff5d4 IDevice: Make it possible to forward declare Ptr and ConstPtr
Most inclusions of idevice.h inside other headers are
required just because of IDevice::Ptr or IDevice::ConstPtr
was used there. Unfortunately, since these "using"
are defined inside a IDevice class, we just can't
forward declare IDevice::Ptr nor IDevice::ConstPtr.

Instead, create a separate header that defines
IDevicePtr and IDeviceConstPtr while having IDevice
forward declared. Redefine IDevice::Ptr/ConstPtr
inside IDevice to use IDevicePtr/IDeviceConstPtr.

Now, instead of forward declaring a IDevice::Ptr
it's sufficient to include the idevicefwd.h.

This drops the number of files being recompiled
after touching idevice.h from ~770 to ~210.

Change-Id: Ib6f2982aa0761fb4cd6593badb9c3c0c527ea535
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-04-14 12:27:04 +00:00
hjk
a23c4ce014 Docker: Fix searching compilers in custom directories
Previously, detection (mostly) only used path.

Change-Id: If382205c2ff39cabfe21953e877e152dc952a84c
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-03-18 08:21:51 +00:00
Christian Kandeler
6cec0e2033 ProjectExplorer: Allow users to override the gcc target triple
... for the clang code model. Otherwise, it won't work with GCC
compilers for architectures clang does not know about.

Fixes: QTCREATORBUG-26913
Change-Id: I90115f2f562eae9922b90c500630ccf988542ca3
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-01-24 12:10:56 +00:00
Christian Kandeler
16ef8b6253 ProjectExplorer: Collect and remember non-functional toolchains
It's not unusual for the toolchain auto-detection procedure to encounter
binaries that turn out not to be valid toolchains only after running
them, either because they are genuinely broken or because their names
match a compiler name pattern, but they are not actually compilers.
Until now, we would re-run such executables on every start of Qt
Creator, potentially delaying start-up unnecessarily.
Now we store them in the settings and do not try to run them again.
For now, the collection of bad toolchains is done for GCC only. Follow-
up patches will add support for more toolchain types.

Change-Id: Icfa28de523737bdd88af3a2bfa8b947326c1bc70
Reviewed-by: hjk <hjk@qt.io>
2022-01-20 13:58:53 +00:00
hjk
5cfe69b049 ProjectExplorer: Use a struct for toolchain autodetection parameters
Also, make some functions const and use an alias for QList<ToolChain *>.

Change-Id: I6a1cbcb79bfaa9d252c4b69e00aa93e5d0dabe2f
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-01-18 11:25:34 +00:00
hjk
3f4d45532d ProjectExplorer: Introduce a QString Toolchain::detectionSource
Would be useful to link auto-detected items to the source of
their detection and later automatic removal when the source vanishes.

This is bit more fine grained than the existing detection() and
mimics what QtVersion, Debugger and CMake have.

Change-Id: I2fae95e7e3c2e8191e9ff4cc7f36dc3fde86cf18
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-07-13 07:22:44 +00:00
Eike Ziller
f83be6debe Merge remote-tracking branch 'origin/4.15'
Change-Id: Ia6558fc2423fd9cd84ca2282bfa60d102dff682e
2021-05-19 09:54:07 +02:00
Eike Ziller
801dbdf932 Android/Qbs: Improve startup time
At startup the Android plugin looks at the NDK(s) for tool chains, and
the for matching tool chains already registered in Qt Creator. If it
finds one, it doesn't register a new one, but simply force-marks the
found one as auto-detected.
(See AndroidToolChainFactory::autodetectToolChainsFromNdks)

Unfortunately changing the auto-detected property of a tool chain
triggers a full update down the line, which for example Qbs takes as a
hint to re-create profiles.

This simply doesn't make sense. Setting the auto-detection flag
shouldn't result in these updates.

Task-number: QTCREATORBUG-25463
Change-Id: I22a5f6fbe08124a08041bf871e683bdbda279c01
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-19 07:41:24 +00:00
Eike Ziller
b3a893e9b8 Merge remote-tracking branch 'origin/4.15'
Change-Id: I75ffc79eeb8d73296a2271a636fae48e35427947
2021-05-05 11:46:19 +02:00
Eike Ziller
ed6b3f2bcd Revert "ProjectExplorer: Remove toolchain settings compatibility with <= 4.3"
This reverts commit 6baf09bf91.

sdktool still writes the toolchains with the old settings key.
This should be changed in a follow-up commit, but since we missed
updating the key used in sdktool, we have to stay compatible with that
for a longer while still, or we break lots of existing Qt installations
out there (specifically Boot2Qt, which is the main user of the sdktool
operation).

Fixes: QTCREATORBUG-25647
Change-Id: Ie665c9db5fd5bb808f510c53fd4173b8a318bb7c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2021-04-30 12:04:52 +00:00
hjk
28bf6f98cb ProjectExplorer: Extend toolchain validity check to remote setups
Change-Id: I4843a1c1dcb8191435469bd9f1b62f9fa09e5e14
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-04-29 08:35:50 +00:00
hjk
85930c03d2 ProjectExplorer: Persist remote toolchains properly
Change-Id: I9582e9d94a4d858205e90dfe9bfa4a4fa621b191
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-04-29 08:29:22 +00:00