Commit Graph

161 Commits

Author SHA1 Message Date
hjk
001b3ab626 Utils: Remove now-unused Environment::findAllInPath
Change-Id: I562309c292ab0c5ae317593e40e5105bbcf89bf8
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-05-25 11:21:48 +00:00
hjk
2d32fe4b57 Utils: Remove Environment::searchInDirectories
Was functionally replaced by FilePath::searchInDirectories.

Change-Id: I8808cbdb114fb9b6b4e1f94e13aa9e67b9c56d6a
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-05-25 09:00:37 +00:00
Leena Miettinen
c124e837c5 Doc: Add docs for Utils::Environment::systemEnvironment()
Because we link to it from the Utils namespace docs.

Change-Id: I4d320b34687e7a6304cbedcbf7e2e5d3a43642b6
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-05-24 08:26:34 +00:00
Alessandro Portale
1e1befd9eb Proliferate pathListSeparator()
Change-Id: I546107af6a88ad5901659a0a64485e4ebca3a164
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2023-05-05 15:17:10 +00:00
hjk
6e276b0a00 Utils: Add a way to provide fall-back entries in an environment
These are used if a (presumably fully-expanded) environment does
not have a value for a certain key. Currently this works only for
fully-known environments, but this can at least be delayed until
the environment is needed, not when it is set up.

Change-Id: I9baaa2d23002ddd574101741a91d5f872e6b0314
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-24 12:53:15 +00:00
hjk
2766b4004b Utils: Continue Environment/EnvironmentChange consolidation
Make Environment a stack of changes that gets "expanded" to
a full environment before things are actively accessed.

Later this expansion should be done lazily if possible.

Task-number: QTCREATORBUG-28357
Change-Id: If1c7bfdb9f58b81e71c51ed87ee75d6964a47019
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-24 07:45:35 +00:00
hjk
ae86a6a4bc Utils: Remove some iterator bases accessed to Environment
Now unused.

Change-Id: I21bce9218662d9cb8acc18e5c2ede6dfbb8962bb
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-03-06 06:45:20 +00:00
hjk
3e5d14b020 Utils: Replace Environment::find iterator use
Task-number: QTCREATORBUG-28357
Change-Id: I2723ffd6b7842f88009701eccea9aacac8cbf516
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-03-02 16:02:41 +00:00
hjk
4b93f47565 Utils: Iterate environment via callback
Iterators expose the underlying datastructure and get
in the way of moving towards "env as stack of changes"

Task-number: QTCREATORBUG-28357
Change-Id: I69e3b53e62ed4c9ab394779e97afbc6fd1986838
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2023-03-02 13:28:46 +00:00
Marcus Tillmanns
a62c5cf89a Utils: Cleanup searchInX functions
Also move some often used types into new file "utiltypes.h"

Change-Id: I3f152d1dc2f96ba0259ad6c098d9ac5ee03a59f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-02-24 15:13:32 +00:00
Marcus Tillmanns
1523f49e5c Utils: Add PathFilter to FilePath::searchInPath
Change-Id: Iccbecc7401f17208487113f89e49ed7103acf9d6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: hjk <hjk@qt.io>
2023-02-09 11:56:28 +00:00
hjk
dab859e776 Utils: Replace Environment.isValid() with .hasChanges()
That's closer to the intended semantics. The "other" use in docker
will be changed to an optional<Environment> as follow-up to
keep this here mechanical.

Change-Id: I43ef9da6c9c7731b28f9d6fab6413ce9c4f428b4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-27 12:37:35 +00:00
hjk
5f359a1dff Utils: Start Environment/EnvironmentChange consolidation
The plan is now to keep 'Environment' as the concept name, but
have what is currently 'EnvironmentChange' as implementation,
as keeping a full env vs env change(set) distiction gets messy.

First step is to cut the direct dependency of EnvironmentChange
from a (current) Environment that causes circularity when moving
the implementation.

Change-Id: Id8b512b311071611b750b27af59549ce7c2ce8e6
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2023-01-27 11:24:36 +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
7e1fb3aaaa Utils: Use std::variant for environment changes
Change-Id: Ibdac141c5ef2dc2fa4c163e059f746dfb6f9625d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-12-20 08:25:57 +00:00
Marcus Tillmanns
d3487b1bde Utils: Fix FilePath::searchInPath remotely
Change-Id: I49bd7fd96427b55d28743eab277c72710a2ac6c0
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-12-09 14:00:09 +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
hjk
3e941652e1 Utils: Reduce scope of Environment::appendExeExtensions()
The general idea is to use FilePath as entry point for this
kind of functionality.

Change-Id: Id6ade8809229d119eb6af44baa7d4e473676f6f9
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-11-22 08:42:43 +00:00
Jarek Kobus
e23e5faa82 Environment: Make systemEnvironment() thread safe
Fixes: QTCREATORBUG-26805
Change-Id: I839995699ffd25579a6a77405331a9802edaf7f1
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-10-20 14:00:13 +00:00
Marcus Tillmanns
a22d62e57d Utils: Add FilePath::isSameFile()
FilePath::isSameFile() checks if two files are the same file.
It first checks if its on the same device. If it is, it will
try to read the fileId of the files and compare them.

Change-Id: I83668955cacd4e5ed03d43a3fee2be29e9d0a6f0
Reviewed-by: hjk <hjk@qt.io>
2022-10-13 11:25:48 +00:00
Jarek Kobus
d1e521d223 Utils: Limit the usage of qMakePair
Change-Id: I93eba395ddc580950a7eeb908555736ff48a3e3d
Reviewed-by: hjk <hjk@qt.io>
2022-09-30 10:17:56 +00:00
Eike Ziller
04e50438eb Utils: Remove Utils::optional
Since we are now requiring macOS 10.14 we can remove our local
implementation of optional and use std::optional for macOS too.

Change-Id: I2bd018261b68da64f7f031a812045dd7784697e1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2022-09-01 06:58:04 +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
c0a0daf588 Environment: Add convenience wrappers similar to qEnvironmentVariable*
Adds corresponding wrappers that work on
Environment::systemEnvironment(), which can be different to the
environment that Qt Creator currently runs in, depending on the settings
in Preferences > Environment > System > Environment.

Change-Id: Ib1db37d2828b686d9a3233d170612beea9d12946
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-08-24 06:46:29 +00:00
hjk
d76458a8b6 Utils: Replace Environment::size() check by some isValid() function
More descriptive, and later implementable without full expansion.

Change-Id: Ic3b17ea0b07273f292827a7b63e7695b4bd1cf23
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-06-03 09:42:26 +00:00
hjk
6bbddf115c Utils: Retain more high level information on EnvironmentChange::Item
Change-Id: I78df3cf7ae767d6baeed46f03587ee21875c8315
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-06-02 12:49:43 +00:00
hjk
5de18c67f0 Utils: Make Environment has-a NameValueDictory instead of is-a
We need a somewhat more wholistic approach on how to communicate
environment data and changes in the code, a single fixed map
doesn't cut it.

Change-Id: Ifbed254e7e0f4a76f8627e77030889c326f551d4
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-06-02 10:55:56 +00:00
Jarek Kobus
4b9545fe7f Utils: Drop unused headers [A-H]
Round 2 - focus on sources.
For classes with initial in range [A-H].
Try to keep the same separators between different kind of headers.

Change-Id: I838a8324ddd5b4d8d5a51b8f30605f783c663813
Reviewed-by: hjk <hjk@qt.io>
2022-05-25 07:47:09 +00:00
Jarek Kobus
2853660a59 Utils: More forward declarations / drop unused headers [D-G]
Round 1 - focus on headers.
For classes with initial in range [D-G].
Try to keep the same separators between different kind of headers.

Change-Id: Id42cd7b3743a816f75cecb6b576c0e37cb057473
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-05-25 07:13:52 +00:00
Jarek Kobus
0a8dbaf153 Utils lib: Remove unneeded includes from cpp files
It's a result of a team work consisting of yellow triangle and me.

Change-Id: I8b4812766da70e0785ae71bf0cb71357379e2514
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2022-05-19 12:37:20 +00:00
hjk
51d00709a5 Utils: Drop [Qt::]SkipEmptyParts from porting.h
Not needed anymore after 7c942cfd18.

Change-Id: I5e6021cb64a399fa3bc3067b2fcd60ab48587daa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-03-10 12:59:39 +00:00
hjk
3fd1122759 Utils: Rename FilePath::deviceLocalPath() to nativePath()
Change-Id: Id2b2b7d54a536d569c6dc717365ee28421e2b56b
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-12 09:02:45 +00:00
hjk
652b9844e6 Utils: FilePathify Environment::{ap,pre}pendOrSetPath etc
Change-Id: Idfa5ec247337570936b0236cab9d3a5669792ca0
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-11-10 07:26:31 +00:00
hjk
2a0d09bdac Utils: Drop unneeded env parameter in searchInDirectoryHelper
Change-Id: I8134fe3f9306d8826b409771f60db36851613954
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-10-06 15:02:44 +00:00
hjk
3a02e03729 Utils: Add an Environment::searchInDirectories
And use it in the local branch for FilePath::searchInDirectory which
so far erroneously also looked into the system environment's path.

Change-Id: I60316831b74a55dee84fbf4b54c0eecc49dd8dde
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-10-04 11:24:26 +00:00
hjk
6418eb2dda Utils: Use EnvironmentChange instead of Environment in several places
For path choosers this makes it easier to change the actual base retrospectively
based on the device for the file path entered by the user.

In other cases "end user code" only knows that something needs to
be added to PATH to get a proper environment. This here lets this
code to specify the change alone without bothering about the base
environment this might be applied to.

Change-Id: I726aaa2fd2feb0bee7158f601aac660b0ac6327b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2021-08-11 13:33:52 +00:00
Christian Stenger
98ae0d44e6 Utils: Reduce need for resolving of symlinks
Be more strict when checking whether two files might be the
same executable.

As side-effect this reduces the calls to symLinkTarget() a lot
and speeds up auto detection of kits.

Change-Id: I23dc697a34bf93f8bd09cbe7e9d17f829cf0d010
Reviewed-by: hjk <hjk@qt.io>
2021-07-23 11:55:20 +00:00
hjk
2bf72a6dfd Utils: Move resolveSymLinks from FileUtils to FilePath
And make it work with remote paths.

Change-Id: I1fe4548547231338284152a86c43f5d0b1eba4d6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-07-02 11:08:00 +00:00
hjk
4e30ce160e Utils: Start collecting environment changes instead of full environments
We have a couple of cases where classes need to modify environments but
have only the ability to provide complete environments without actually
knowing the full context. Starting with systemEnvironment usually works
so far, but breaks down in cases of e.g. containerized builds.

This patch here introduces the ability to collect changes to
environments, and postpones creating a full environment until the
context is clear.

As introductory example use BaseQtVersion::qmakeRunEnvironment

Change-Id: Id23c0aa80fc95b0a8a01f8e3a87adc9b1a57002a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-04 11:42:05 +00:00
hjk
77d7b24326 Utils: Make Environment::setEnglishOutput a proper member function
The previous indirection was useful as long as they were overloads
for QProcessEnvironment and QStringList, but these are gone now.

Change-Id: I5066bd2e72fd06948a5cc7bbac6dda9006db96ed
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-21 15:07:34 +00:00
hjk
f23b27ded6 Utils: Remove two of the Environment::setupEnglishOutput overloads
We standardize on Utils::Environment nowadays.

Change-Id: Icaf2fac21d237686a63cb60fdaf1b5900bf9fe1c
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-14 12:42:52 +00:00
Alessandro Portale
81f3452e1c Aggregation/Utils/ExtensionSystem: Make member functions const/static
readability-make-member-function-const finds lots of member functions
that could be made const. This change just picks getter functions that
really should be const.

readability-convert-member-functions-to-static finds non-static member
functions which do not access this. This change turns most of them
into static ones, but leaves some non static to keep the class API
consistent.

readability-static-accessed-through-instance fixes the places where
the originally non-static, now static functions were called through
instance.

Change-Id: I8cf16c01f7988a7c9d073b5f8ede6a9706b94fb0
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2020-11-27 09:16:08 +00:00
Eike Ziller
e755094480 Add option for globally changing the base environment for tools
Fixes: QTCREATORBUG-22123
Change-Id: I00a5bbdf92e5dab513cb12f3518a2abb1adbb9cd
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
2020-11-18 15:24:02 +00:00
Eike Ziller
d3c31917aa Fix build of sdktool against older Qt
Use wrapper for SkipEmptyParts, since Qt::SkipEmptyParts is only
available since Qt 5.14.

Change-Id: I26e26aaafd91c8eb002e73124d07306f21365bef
Reviewed-by: hjk <hjk@qt.io>
2020-08-18 12:46:34 +00:00
hjk
43b658e9e7 Utils: Drop Utils::SkipEmptyParts again
We require Qt 5.14 nowadays.

Change-Id: Iff245257d3cb19207007c0445ee13814e66152dd
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-07-21 12:42:27 +00:00
hjk
1c81a3b3e8 All: Use Utils::SkipEmptyParts
Task-number: QTCREATORBUG-24098
Change-Id: Iab45de9a9c17ddc39a0e343b1175d4f6cb94b098
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2020-06-17 05:55:25 +00:00
hjk
e109b731ad Utils: Rename FilePathList to simply FilePaths
The exact storage type does not really matter here.

Change-Id: Iefec40f0f5909c8e7ba3415db4a11962694e1b38
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2019-12-18 08:43:18 +00:00
Christian Kandeler
567a0db6dd Utils::Environment: Consider target OS type when sorting
That is, use case-insensitive sorting on Windows, so that e.g. "Path"
will not appear after "PROCESSOR_REVISION".

Fixes: QTCREATORBUG-22786
Change-Id: I42d469b6079037d1062dbd5b273f5aa8ade25e79
Reviewed-by: hjk <hjk@qt.io>
2019-08-22 10:29:22 +00:00
Christian Kandeler
6d3f236aab Utils::Environment: Use expanded values
The Environment class is supposed to support values with references to
other variables, but we failed to actually expand them in most places.

Fixes: QTCREATORBUG-22687
Change-Id: I108cb59d3b4571471423455240f6f4f1cf64bf05
Reviewed-by: hjk <hjk@qt.io>
2019-08-20 12:39:16 +00:00
Christian Kandeler
37a2bbe14e Utils::Environment: Remove another set of duplicate functions
More clean-up after 4bae5de36b.

Change-Id: Ia60cb868c464627b42a94d502d301b175449aa17
Reviewed-by: hjk <hjk@qt.io>
2019-08-19 13:11:01 +00:00