Commit Graph

148 Commits

Author SHA1 Message Date
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
Christian Kandeler
4d71c0f13e Let users disable environment entries
It's helpful to be able to temporarily disable environment variables, as
opposed to having to remove (and then re-add) them entirely.

Fixes: QTCREATORBUG-20984
Change-Id: Ib0d287035b9357507c4c19faaf3a1517382506b5
Reviewed-by: hjk <hjk@qt.io>
2019-07-22 14:31:01 +00:00
David Schulz
5da5116cb1 Utils: Add path search function to environment
In contrast to Environment::searchInPath This function
returns _all_ executables found in the path variable.

Change-Id: Ic62b8f70d0690ff9a3261db3ead2c919a2486c89
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2019-07-15 13:01:25 +00:00
Christian Kandeler
f7520b7d99 Make the project managers tell the code model about include paths
... from the environment.

Fixes: QTCREATORBUG-17985
Change-Id: I9b54e550121cfcc0684a6e173337d59d235c6107
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
2019-07-12 09:13:42 +00:00
Marco Bubke
4bae5de36b Enable macro editing for the Clang indexer
Refactor much of the code from Environment* classes to NameValue* classes
to share it with the preprocessor macro settings.

Change-Id: Ica4ee817aa338230c422b30d91240d266248d226
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2019-06-13 16:51:48 +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
9433b8a7e7 ProjectExplorer: Use Utils::FileName in ProcessParameters
For the command and the working directory.

Change-Id: Ia69dc7100aeb57bb6e1b35f4dd4f3cf3763d8cda
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-05-15 12:55:22 +00:00
Orgad Shaneh
24ec0b7708 Utils: Detect hardlinks also on Windows
Believe it or not, they exist :)

Git for Windows installs all its exectables as hardlinks for instance.

Logic copied from qfilesystemengine_{win,unix}.cpp in Qt.

This amends commit 118f713eb4.

Change-Id: Iafc64be4b2150378c7f9676fda0e01a43cd8b7cf
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-04-30 09:43:45 +00:00
Alessandro Portale
7ef62eb869 Utils: Fix "unreferenced formal parameter" warnings
environment.cpp:438: warning: C4100: 'file2': unreferenced formal
parameter

Change-Id: I6543c1304307826543ef9d8a9eb860df652ae73b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2019-04-05 08:26:12 +00:00
Christian Kandeler
118f713eb4 Utils: Make Environment::isSameExecutable also detect hard links
Change-Id: I64041a60febf9f5724028c488b535c5ec7b1f6a0
Reviewed-by: hjk <hjk@qt.io>
2019-04-04 15:38:00 +00:00
Eike Ziller
d69470c15c Allow external tools to use build or run environment
Add mechanism for registering environment providers, since just
registering the environment as a prefix variable in the macro expander
doesn't really fit the use case of using more than an individual
variable.

Project explorer registers providers for the current build and run
environments.

External tools can refer to a provider by id and then use that as base
environment.

Task-number: QTCREATORBUG-18394
Task-number: QTCREATORBUG-19892
Change-Id: I19fc4dfa8286b2f1e4679c6406f285dcc9514ba3
Reviewed-by: hjk <hjk@qt.io>
2018-09-26 09:41:34 +00:00
Tobias Hunger
bfc76b4cd8 Environment: Do not allow keys containing '='
Those keys will cause trouble later, so do not allow them.

Change-Id: Ib2f51a469253d9df21c6a77faa47e6e88feadc07
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-09-05 11:40:49 +00:00
Eike Ziller
d35638df56 Do not modify environment for user applications
We used to set QT_OPENGL, currently set LD_LIBRARY_PATH when qtcreator.sh
is used, and might set other variables in the future,
but these environment modifications should not be passed on
to user applications or when we run tools that are not shipped with
Qt Creator.

For LD_LIBRARY_PATH there already was a hack for
Environment::systemEnvironment.

For environment variables that we might set in main()
in the future, this patch caches the system environment for
Environment::systemEnvironment early before any modifications are made.

The previous hack for LD_LIBRARY_PATH no longer works, since it
used QCoreApplication::applicationDirPath() which cannot be used at that
point in time (before the QApplication has been created). Instead pass
the correct user LD_LIBRARY_PATH directly from qtcreator.sh to
Qt Creator through a command line option, which is cleaner anyhow.

Task-number: QTCREATORBUG-20808
Change-Id: I6674a5e0537e1b37fd7dcbff371b542fa24bce69
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2018-08-21 08:48:21 +00:00
Eike Ziller
847787f146 Merge remote-tracking branch 'origin/4.7'
Conflicts:
	src/plugins/debugger/debuggerruncontrol.cpp

Change-Id: I72882df605bc3fc8a8d20118fd4e49207ac92664
2018-08-07 09:42:02 +02:00