Commit Graph

251 Commits

Author SHA1 Message Date
Marcus Tillmanns
a1e960a27c Utils: Fix iterateWithFind
The change of runInShell to take QString + QStringList meant
that the caller was no longer able to fine tune the argument
escaping. This lead to "find -exec ... \;" being escaped incorrectly.

Changing back to CommandLine fixes this.

Change-Id: I55b09bd745c09912a2a0b4e43432824a99c0dd4e
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-10-14 12:52:03 +00:00
Marcus Tillmanns
22c4e9318a Docker: Remove unused function
Change-Id: I683de49c08411087e47be84265cbab62d4d0738e
Reviewed-by: hjk <hjk@qt.io>
2022-10-14 12:06:41 +00:00
Marcus Tillmanns
359ad56e17 Docker: combine escapeMountPath function
Change-Id: Ib04f8245d2da096a9d9fdbdf9b5243ca80d52bfa
Reviewed-by: hjk <hjk@qt.io>
2022-10-14 09:52:22 +00:00
Marcus Tillmanns
9aa1d56f56 Docker: Fix isValidMountInfo
Improves checking if a requested mount is actually valid.

Change-Id: I37638d26ddd46776e6375481cf1d73ed0ad24210
Reviewed-by: hjk <hjk@qt.io>
2022-10-14 09:49:58 +00:00
hjk
1fa3255242 Utils: Split off file access interface from IDevice
The file accessing functions form now a class hierarchy by themselves,
the devices return a suitable point.

The previous implementation was mildly confusing by the special handling
of the DesktopDevice, fallbacks and remote cases in the same function
leading to unnecessary boilerplate when adding new functions and
codepaths that sometimes passed the FilePath API twice.

Implemented are a "DesktopDeviceFileAccess" taking care of the
previous !needsDevice() branches and a "UnixDeviceFileAccess"
covering the current docker and RL uses.

As a side-effect this unifies to a large degree the current docker
and RL code paths with were occasionally deviating from each other
while they shouldn't.

Change-Id: I4ff59d4be2a07d13e2ca5e9ace26a84160a87c9d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-10-13 10:38:35 +00:00
hjk
b1471fe61f Utils: Combine some of the iterateWithFind overloads
Change-Id: I668447d0049f2e35cd0c76d2c5708779196167ec
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2022-10-12 08:59:32 +00:00
Marcus Tillmanns
bcadbe666b Docker: Fix mount arguments
Previously when trying to mount paths that contained spaces or colons
docker create would fail as the -v/--volume syntax does not support
these.

Switching to "--mount" and using the "type=bind" syntax allows to
escape the necessary characters.

Change-Id: If969173505dbf1b36a67dc8b398c58b78941519a
Reviewed-by: hjk <hjk@qt.io>
2022-10-11 12:24:29 +00:00
Marcus Tillmanns
ae58d373b0 Add FSEngine FilePath Cache
To speed up file dialogs we introduce a 1 minute cache for
the FilePathInfo.

A new version of "IDevice::iterateDirectories" allows implementations to
provide the FilePathInfo directly.

DockerDevice implements fetching the filePathInfo during
iterateDirectories which greatly improves the speed again.

Change-Id: I24ac16adb2478cbf16a22012e72fcb8910dcdac5
Reviewed-by: hjk <hjk@qt.io>
2022-10-11 08:53:02 +00:00
hjk
2e38cb6848 Utils: Add an offset parameter to the content writing FilePath function
Use QFile::seek to implement locally and a dd seek based poor man's
implementation on RL and docker.

Change-Id: I241d1c34c00e991845d132ad8edefa1377ba1311
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-10 16:08:28 +00:00
hjk
5dde520a43 Utils: Return a bit more data from DeviceShell::runInShell
Pass on stderr data and exit code to the caller, it's typically
in a better condition to handle errors.

Use it to notify the user about non-available 'find' arguments
and fix the fallback to ls-based operation.

Change-Id: I535535de2ffa09cad1dd6e9b07eb69f807dbae2f
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-10-10 08:39:55 +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
hjk
714e6f5c8f Utils: Make more unix find code re-usable
Change-Id: I8fe95158ed77c8f9fb8c86a8e813b5c5de425b8a
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-07 11:08:52 +00:00
hjk
a234443bee Docker: Use new FileFilter::asFindArguments function
Change-Id: I7a4e02740f27cdb72d3a876985b0941ffedc1ff2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-10-07 10:58:58 +00:00
hjk
5ff70b6f99 ProjectExplorer: Introduce an IDevice::usableAsBuildDevice
Better approach than whitelisting ids from leaf plugins.

Change-Id: Ida7e23d7ea02eb76d7de4049737f2cb0fad2b9d7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-09-30 14:38:47 +00:00
Marcus Tillmanns
34dc092642 Docker: Improve File contents read speed
Change-Id: Ic94715d2c362ac3aa75dabf4f95c74737abd6264
Reviewed-by: hjk <hjk@qt.io>
2022-09-30 12:13:52 +00:00
Eike Ziller
a254a9ba54 Merge remote-tracking branch 'origin/master' into work
Change-Id: I2235a55a599aaeca5d2b5377300a044b66c17da9
2022-09-29 12:03:13 +02:00
Marcus Tillmanns
736f778e6d Dockerdevice: Make sure that container is started
When a QtcProcess is the first thing using a dockerdevice
the container was not started and the call would fail.

Adding updateContainerAccess to withDockerExecCmd
makes sure that the container is started.

Change-Id: I7e05df1aa5e05dc55606970214109b13b142181e
Reviewed-by: hjk <hjk@qt.io>
2022-09-29 07:33:42 +00:00
Marcus Tillmanns
5f62488761 Device: Add prepareForBuild()
Change-Id: I505c4e660838bc94dcdc83ba91ec225910b8f60d
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2022-09-27 09:19:34 +00:00
Marcus Tillmanns
e42021bb09 DockerDevice: Do not change the containers entrypoint
Some containers may use their entrypoint to setup their environment.
Simply overwriting it from our side would disable such setup and
make the containers useless.

Change-Id: I3385858c49aa8217c3191acdb85343ffd6163cf9
Reviewed-by: hjk <hjk@qt.io>
2022-09-26 09:49:58 +00:00
Marcus Tillmanns
090dfb7ca5 DockerDevice: Fix debug-dumpers not found
Since the dumper path was changed after the first "startContainer"
call, subsequent startContainer calls would set the wrong source
directory.

Change-Id: I6e8304c080b4b55fc67eda0a9544a1b8f34ab7a1
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-26 09:49:44 +00:00
Marcus Tillmanns
33abca1c0b DockerDevice: Implements ensureReachable
Change-Id: I2c479b1cf7a61021f27222e2e936903a9f39e1d8
Reviewed-by: hjk <hjk@qt.io>
2022-09-26 09:49:29 +00:00
Marcus Tillmanns
bf6914a704 Docker: Don't directly access Private data in DockerDevice
Consolidating private data access

Change-Id: I8c8353bdd62606c3b0286d2ffaf3b5e634943b59
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-09-26 09:17:00 +00:00
Eike Ziller
3011548066 Merge remote-tracking branch 'origin/8.0'
Conflicts:
	src/libs/utils/deviceshell.cpp
	src/plugins/clangcodemodel/clangdclient.cpp
	src/plugins/qmldesigner/components/materialbrowser/materialbrowserview.cpp
	src/plugins/remotelinux/linuxdevice.cpp

Change-Id: Idc2edf428c98e9cbc891f1833b271ce2def9a835
2022-09-21 11:16:29 +02:00
Marcus Tillmanns
5ebb467cc6 Deviceshell: Cleanup shellProcess destruction
Change-Id: I71507d9e74979fca461784575257e7bafd1b4838
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-09-21 08:51:47 +00:00
Marcus Tillmanns
e363f27288 dockerdevice: Only try to kill if pid is valid
Change-Id: I844c8e50437b331925f9baa6862c19208edb4599
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-09-19 13:49:04 +00:00
hjk
b3200b7730 Utils: Move 'isWindowsHost' test to startsWithDriveLetter callers
"Fixes" one Q_SKIP and makes the implementation OS-agnostic.

FilePath::osType() actually depends on the host system for not fully
qualified file paths, and that doesn't seem to be the right thing to do
in all cases. The caller may actually have more context to decide
whether this is needed (e.g. in pathchooser.cpp in the context of
"return value from a GUI element, i.e. 'host' implied).

Change-Id: Iff80c17094d2deec79d34d0527223fbcf8294935
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-09-19 13:14:58 +00:00
Eike Ziller
e7ddd8a5b7 FilePath: Return optional bytearray from device hooks
For differentiating between "error" and "empty file".

Change-Id: I1806bb7386f5e7db28489f9f7e685648bfc20110
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-09-15 11:28:18 +00:00
Marcus Tillmanns
0cb3459c71 Terminal: Improve error message for start errors
Also fixes an issue where "Open Shell In Container" would fail if
the container has not been started yet.

Previously only "An Error occurred" was displayed to the user if
starting the terminal failed.

With this fix it gives more info about what went wrong, and a
specific error message is created if the openTerminal.py script
is not executable.

Change-Id: I49ae0d9b2aa7d5a27a9b100830b4fdefa5a279b8
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-09-08 05:39:48 +00:00
Marcus Tillmanns
9eef925133 docker: Improve Docker Device Wizard
* Added Sorting of Images
* Added "Double-click to accept"
* Added "disable list until sucessful"
* Added "Show unnamed Images" option
* Added Loading indicator

Change-Id: I9bb822753ffc8af1d2e54f5279a6884cb5c4f1b0
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-06 10:56:05 +00:00
Marcus Tillmanns
d4e385de06 Deviceshell: Base64 not found fallback
If no base64 is installed on the target, the shell script
cannot work. Previously this would lead to the shell functions
being unavailable.

This change adds a fallback path. In case no base64 is found,
the shell will create a process for each run request instead.

This is much slower than the shell script, but acceptable as
a fallback.

Change-Id: I70591d7e610c4e1c3c258a8e4bef354221d05cb9
Reviewed-by: hjk <hjk@qt.io>
2022-09-01 13:30:46 +00:00
hjk
7cfc3d26bc Utils: Replace FilePath part setters
... by a combined version. This will make it easier to store the parts
in one QString object.

Change-Id: Ie85a77e3957c78a30e49998fe2e617af35a8ad17
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-09-01 07:59:29 +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
hjk
11648298c8 Utils: Port some FilePath part accessors to QStringView
Change-Id: Ib5cc262e44c73880b6538eed714365e3d685870a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-08-22 13:27:56 +00:00
Marcus Tillmanns
3462bc67be filesystem: Add QFSEngine for filepaths
Change-Id: Ibd0c88c69863c0877138d8cc45541530c359bd9c
Reviewed-by: hjk <hjk@qt.io>
2022-07-21 13:14:01 +00:00
hjk
57ce33bc4e Docker: Move to Tr::tr
There were no strings in the .ts files yet.

Change-Id: I86e7edace45db796fc3cc80d2735d1a80b897c85
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-07-14 12:40:57 +00:00
hjk
9894c6eaf0 Debugger: Convert to Tr::tr
Change-Id: I5d2475c790851c68f9997ac6af72b5eaca58482d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-07-08 12:32:38 +00:00
Marcus Tillmanns
6003fe9b36 docker: Fix StringAspect default value handling
The StringAspect needs to return a possible default value if
no value was set by the user. Otherwise it would write an
empty string when ::apply was called.

Also a small improvement for docker error logging is added

Change-Id: I85f80253894d2c3e726da714616e5275039febcc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
2022-07-07 13:09:02 +00:00
Marcus Tillmanns
15c7f08e4a docker: Change Settings to single owner
We change DockerSettings to have a single owner.
Since DockerDevices are destroyed after the plugin
is unloaded, we have to make sure to remove the
settings from devices during plugin teardown.

For this we store a list of created devices in
the factory, and call their shutdown function when
the plugin unloads.

Change-Id: Ic9c7d8ad9437c48d68f20c9a8f8ad7449b3cb972
Reviewed-by: hjk <hjk@qt.io>
2022-07-05 09:42:07 +00:00
Marcus Tillmanns
8a7a4fce6c docker: Add dockercli setting
Change-Id: I46fada555d697007042d823ef1cad0658be98e22
Reviewed-by: hjk <hjk@qt.io>
2022-07-04 12:21:00 +00:00
Marcus Tillmanns
2d82f2173d Ssh: Use DeviceShell in LinuxDevice
Change-Id: I165f888dbb1e7072c35ec88ce5fd8a7ae4562139
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2022-06-30 10:55:43 +00:00
Jarek Kobus
3b0add4b16 DeviceShell: Merge done() and errorOccurred() signals into one
Don't connect to QtcProcess::errorOccurred() signal, as it's going
to be removed soon. Rely on done() signal instead.

Change-Id: I28260f8eb77911a23de80512881cf7220f1bc1fc
Reviewed-by: hjk <hjk@qt.io>
2022-06-20 13:07:32 +00:00
David Schulz
153ff77a6b Utils: use cleaned stdout all over the place again
Amends 5ee880ce5e

Change-Id: Ie0202db7d8455372c3697087d9571db6706b45a1
Reviewed-by: hjk <hjk@qt.io>
2022-06-17 13:04:42 +00:00
David Schulz
a91043d8ba Docker: assert on starting process in non device working dir
Change-Id: I7dd1040c77b3a7f7378b5567b7b5568af5f57848
Reviewed-by: hjk <hjk@qt.io>
2022-06-15 12:59:48 +00:00
Jarek Kobus
0b2899215f Introduce ProcessBlockingInterface
This replaces the ProcessInterface::waitFor...() methods.
It's not obligatory to provide this interface when
implementing ProcessInterface subclass. In this case
generic blocking implementation will be used.

The generic implementation usually isn't as efficient as
the custom one, however, for some sophisticated implementations
of process interface, like e.g. SshProcessInterface, providing
custom implementation is really difficult and error prone.

That's why we try to keep a balance: we provide two custom
implementations for QProcessImpl and for ProcessLauncherImpl,
as they are relatively easy to implement, and rely on
generic implementation for others.

Change-Id: Ifc8bd354479ec67b2e8f74f1510f8de8883e9b94
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2022-06-14 09:45:28 +00:00
hjk
6674e5f267 Docker: Remove DockerBuildStep
That was part of the initial Proof of Concept and is not needed anymore,
the normal build steps can nowadays be remote.

Change-Id: Ic69ff89ebdcf8e6aef73d71954a48501c68c60ff
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2022-06-10 12:25:28 +00:00
hjk
e3bb14d0d2 Docker/RemoteLinux Fix file size and permission retrieval
When a file path is a link, give the result of the dereferenced
link. This is what QFileInfo does locally.

Change-Id: I26ca1fb70d3391da77f2a5845e5f0a2c0fb73d53
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
2022-06-10 08:18:06 +00:00
Jarek Kobus
493573b879 QtcProcess: Make reaper timeout customizable
Add a setter and getter for reaper timeout. This makes it
possible to customize the timeout for the reaper after which it
should call kill() when previous terminate() was unsuccessful.

This setting is also used for QtcProcess::stop().

Change-Id: I653a3ad107ae4173bb8254c85cfc07886bf6a9c6
Reviewed-by: hjk <hjk@qt.io>
2022-06-08 11:21:42 +00:00
Marcus Tillmanns
0135c47849 device: Use multiplex script to allow multithread support
Previously the runInShell and outputForRunInShell methods were
exclusively processed single threaded, meaning all calls
were processed sequentially. With the multiplexed
helper script we can now run multiple processes simultaneously.
( see tst_manual_deviceshell )

Additionally the new script allows us to capture both
stdout and stderr from commands which was not possible previously.

Change-Id: I52f4fb46d872dc274edb9c11872d2f6543741b34
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-06-07 09:22:14 +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
6ea8a76e44 Utils: Consolidate port parsing methods
Change-Id: I137e9faa2c5f18e9ade0e2c59d73811d682abf13
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2022-05-16 08:43:16 +00:00