Commit Graph

100 Commits

Author SHA1 Message Date
Christian Stenger
eef0769d7a Docker: Remove unused lambda captures
Avoids warnings.

Change-Id: I9bf836ff24fa6524571d0303e544189340dede32
Reviewed-by: hjk <hjk@qt.io>
2021-06-30 07:18:37 +00:00
Christian Stenger
8e1032b83c Docker: Do not use hard-coded /tmp
Amends 8c7b6a7549.

Change-Id: Ie702c7ccc5ac897920f1b8eda00dd90378a2d80b
Reviewed-by: hjk <hjk@qt.io>
2021-06-30 04:55:15 +00:00
hjk
eb7b5ea34e Docker: Improve logging a bit
Most logged items span more than one line, so be generous with extra
newlines.

Also, complain only about when host-local read access into the
docker device ist not possible, writing is generally done only
in the separately mounted places after re-mapping to host-local paths
in the host file system.

Change-Id: I5525749dfb880d4dc3547f86de43314567e92b4d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 13:48:13 +00:00
hjk
1afe21d41e Docker: Make mounted volumes user-configurable
Still use the so-far hardcoded "/opt" and "/data" as default, i.e.
not the intended final setup which should at least pick up
the source and build dirs automatically.

Change-Id: If632f3f5a6e824a952938c97336df8ff58b39d67
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 13:48:05 +00:00
hjk
b8e6d05ded Utils: Also pass Sort flag to FilePath::dirEntries
Change-Id: Ic21c2ba3ef59c6bb3e19552904187b3c6a096d80
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 13:16:46 +00:00
hjk
1e1c556bc8 Utils: Add a FilePath::ensureExistingFile
Essentially a kind of 'touch', to be used in the CMake file API.

Change-Id: Iaae62b441c0006b39d4bef5f06420e798c28c2a5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 12:34:43 +00:00
hjk
4271b3a299 Docker: Bark if there is no container before trying to run on it
Change-Id: I64bee9901a515d46aa18e35d5e4a26f9105519ea
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 10:34:12 +00:00
Christian Stenger
75ffccad0b Docker: Make usage of UID and GID configurable
Make it optional to use UID and GID of the current user.

Change-Id: I1a7eeaba0cfae204b05f0ab4d409d965b8fc09ef
Reviewed-by: hjk <hjk@qt.io>
2021-06-29 10:21:36 +00:00
hjk
5ead2afeeb Utils: Implement FilePath::removeRecursively
Sprinkle a few QTC_ASSERT to make sure we are in a known
context.

Cmake's FileApiReader uses this before moving directories
as QFile::rename does not do anything if the target exists.

Change-Id: I555f99e81a9fe7d93ae66145eeebfa9d5880bc51
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 09:34:28 +00:00
hjk
b26fb834a8 Docker: Use categorized logging for DockerDeviceOperation
Change-Id: Ib9aa32c65bd38b4b72b356603182e84ce5672e91
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 08:35:32 +00:00
Christian Stenger
acec1a3a03 Docker: Pass on working directory only if provided
Change-Id: I9ae62b441c0006b39d4bef5f06420e798c28c2a5
Reviewed-by: hjk <hjk@qt.io>
2021-06-29 07:34:48 +00:00
Christian Stenger
ca1ce3a1ba Docker: Silence assert
We query the device with executables that may or may not exist.
So, expect the call to fail if the image does not contain the
respective executable in PATH.

Change-Id: Iff43879c72155de8a8a9276e26085d03ead61f2f
Reviewed-by: hjk <hjk@qt.io>
2021-06-29 07:34:41 +00:00
Christian Stenger
8c7b6a7549 Docker: Use directory commonly existing
Trying to use /tmp on Windows ends up in a failing process call
as this directory usually does not exist.

Change-Id: I80a5e45c474d3fe6ff6f2ede67837722cb59078a
Reviewed-by: hjk <hjk@qt.io>
2021-06-29 07:34:33 +00:00
hjk
9f29b9e31b Docker: Use id of current user to run the container
This ensures typical files created in the build process are
accessible and removable(!) by the user outside.

Downside is that some commands (e.g. whoami) won't work well
within the container as that user typically is not listed in
/etc/passwd etc. inside the container. Buildsteps requiring
them won't work until the container image is (re-)created with
this data in place.

In general, there seems to be no silver bullet for this problem.
An extensive discussion of pros and cons can be found at
https://jtreminio.com/blog/running-docker-containers-as-current-host-user

Change-Id: I0421e031324ffe3d64b9aeede289a43357c46e3d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-29 07:30:09 +00:00
hjk
54b4022987 Utils: Implement FilePath::rename()
And uses it in CMake's fileapi reader.

Change-Id: I9e719aa4b253eaca17c6b304eab5e7268fcfab29
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-28 13:03:32 +00:00
hjk
6d26f4f5b0 CMake: Allow autodetected tools to associate themselves with kits
Change-Id: I5b48ddf36ba1b9c4eb6476017be63c4d43b60627
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-25 13:57:36 +00:00
hjk
f295021d98 Docker: Give created devices an deterministic id
Change-Id: I451f37065b69da26000cb21ba92b070e6b5698d5
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-24 14:07:26 +00:00
hjk
430e81facd All: Replace most SynchronousProcess by QtcProcess
Change-Id: I0bf22fef2cd4a7297ef5a1e9aa9c3e2b9348ba42
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-23 07:55:31 +00:00
David Schulz
6902ddc535 Utils: add FilePath::isWritableFile
Change-Id: Ic6ced87fcee92deadf5a117ea7e987f1c877f83a
Reviewed-by: hjk <hjk@qt.io>
2021-06-23 06:21:46 +00:00
Christian Stenger
0e57baf784 Docker: Raise number of iterations when starting container
On Windows this call takes way longer to write to the cidfile.
Beside this, read only from file if it could be opened to
silence some Qt internal warnings.

Change-Id: Iec5f631aaf871995c1903289d7a0a24abc2f8e05
Reviewed-by: hjk <hjk@qt.io>
2021-06-22 12:07:20 +00:00
hjk
c721242be8 Docker: Automatically remove the container when it exits
Change-Id: I167dfadc79e892807f47332f79f2a5226ffdbe1a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-22 10:34:27 +00:00
hjk
76cf6ce983 Utils: Add a QtcProcess flag to keep stdin open
Needed to run e.g. gdb on-device.

Change-Id: I5a98df575478f18adf1540ced44f6808bdba0b76
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-22 07:48:36 +00:00
David Schulz
6af287fa2d Docker: fix is<Writable/Readable>Directory
Change-Id: I63093a1aeb3bc2b87592f93900f26b44305b5e85
Reviewed-by: hjk <hjk@qt.io>
2021-06-22 04:54:30 +00:00
hjk
aca55dce58 Docker: Auto-detect debugger binaries in docker devices
Change-Id: Iec7c2b16277ea626520372603ae769418e9efd12
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-21 12:14:29 +00:00
hjk
f558323bac Docker: Actually run 'env' on the docker device to get the environment
Change-Id: Ice31b4f7cfd6c699a78da1518405d8d6bb6e3611
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-21 12:14:14 +00:00
hjk
faf1296345 Docker: Be a bit more flexible when searching Qt versions
Change-Id: I8611a0ad05cbbca79589f1defc8c1ed1399615e1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-21 11:05:19 +00:00
hjk
645c7f8379 Docker: Make CMake autodetection a bit more flexible
Search in build device path instead of two hardcoded locations.

Change-Id: I91e047aa48eb6566353e3ba090070c2a00b3dd06
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-21 09:39:57 +00:00
hjk
c533e5c43c Docker: Use a variable to list directories to mount
Baby step on the path from hard coded to user defined.

Change-Id: I2536924c5ba07dadcbe3c94304d55db25f876987
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-18 09:34:18 +00:00
hjk
e3c03fd3c5 Utils: Implement FilePath::writeFileContents()
Including a docker version of it.

Change-Id: Ib2ac6073cc2b39818fb77a7d9d608386f9d17285
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-16 09:00:37 +00:00
hjk
a5b16f8137 Utils: Support remote FilePath::{lastModified,{remove,copy}File}
And implement the Docker variant.

Change-Id: Iee7cd0aaaf3d5c7dbb4ff995ac6889f31cb2f505
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-14 11:19:31 +00:00
hjk
c9ffce8e50 Docker: Make device creation dialog a bit more verbose
Some more visible logging since toolchain detection takes long.

Change-Id: I565a5b0051f485ddf18c2cb034283287d6185190
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-14 06:51:08 +00:00
hjk
71db2d9c4f Docker: Warn if file access through merged dir is impossible
Even when the fallbacks via 'docker exec' work this will cause a
significant performance hit. Better inform the user.

Change-Id: If369dcc498bffa2ef422dab3e69325c4122b45ad
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-11 10:37:04 +00:00
hjk
18245dcf10 Utils/ProjectExplorer: Add IDevice::searchInPath
Change-Id: Ibc7cc7bd6bf3a7776681f7cd2fff051525b19f60
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-10 05:05:58 +00:00
hjk
18a9df8b4a Docker: De-register some auto-detected items on device removal
Kit and QtVersion for now, ToolChains seem to lack easy access.

Change-Id: I657cb075dd3b4f6fd8ebfd3d6d20b1cdd4dce831
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-06-09 12:00:22 +00:00
hjk
a7cd9bda3a ProjectExplorer: Implement (Docker)Device::exists(filePath)
While the original plan was to use more specific functions like
'isReadableFile' to cut down the number of accesses, it is
unrealistic to re-write all occurrences in reasonable time.
So make the basic building blocks accessible, too.

Change-Id: I2586ebd19e1e7ae2c884fd2a4180869421293e3a
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-07 12:16:38 +00:00
hjk
accb1e6e08 Utils: Make QtcProcess::{setW,w}orkingDirectory use FilePath
But keep the old setter for a while to ease transition.

Change-Id: If02b79b1fcd31fbf8b06ef26876c41af891127f9
Reviewed-by: hjk <hjk@qt.io>
2021-06-03 10:31:13 +00:00
hjk
08040e4e94 Utils: Move QProcess base to QtcProcessPrivate
Change-Id: I4c6811d42e051fadfcf32edb664ff3bc09e692e6
Reviewed-by: David Schulz <david.schulz@qt.io>
2021-06-02 13:21:08 +00:00
hjk
a490745ae0 Docker: Remove some toUrl/path indirection in FilePath access
Change-Id: I8528f28fe64c99d251b20d486438fcd594b55824
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-06-01 06:01:42 +00:00
hjk
9ba5d9d8a8 Docker: Fix indentation
Change-Id: Ice8634c7de27a10dcb4ad7d25fdc3c5933146815
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-31 09:29:23 +00:00
hjk
e8286088b1 Docker: Implement DockerDevice::systemEnvironment() function
For synchronous retrieval of the system environment of the device.

Change-Id: I057f9591866b72e37733d495a2a6b203fae91ac4
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-05-27 11:28:36 +00:00
hjk
984d992abf Docker: Fix DockerDevice::runProcess again
We need the on-device path in "docker exec", not the global version of it.

This was not visible earlier as some more places used local paths,
accidentally matching the on-device path.

Change-Id: If1d7e94d2cf0730e85e5a89972d7eaa309743fa6
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-25 12:59:26 +00:00
hjk
bc58589dee Docker: Use new FilePath API directly
No need to take the QUrl detour.

Change-Id: Ia8245f671411f58729834777413b4749f14b128e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-20 09:29:09 +00:00
hjk
83ae140e8c Docker: Create a partial kit on device creation
Device, Toolchain, and Qt; no Debugger, cmake, ...

Change-Id: Icca660aef62470dda638050fddb74fb1a3032af2
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-19 08:10:13 +00:00
hjk
8ffeecc633 Docker: Simple Auto-detection for cmake binaries
Change-Id: Ia7e6f648c99c87786604cb8801c1408b9e231d3d
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-19 08:10:03 +00:00
hjk
ad5b34ab3e Utils: Remove QtcProcess::{is,set}Synchronous
This reverts a bit of fe8fbf1a4a which was over-shooting API-wise.

Change-Id: Iac4c2b9fa550f7ec0b0aa8deea8c3fc6b6ddcfba
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-11 12:49:08 +00:00
hjk
d71c725453 Utils: Delete QtcProcess::{setP,p}rocessEnvironment
Enforces the use of {setE,e}nvironment for better control.

Change-Id: Iffd9ee4604a6735ee886ecc7623a58729ecd245a
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-07 07:49:04 +00:00
hjk
43636e3cb3 Docker: Suppress a warning if logging is not enabled
Change-Id: Ifad1dd0b720d910cf0fc0c200517563f3ba0897c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-05-05 12:54:22 +00:00
hjk
fe8fbf1a4a Utils: Add a synchronous property to QtcProcess interface
Use it to avoid IDevice interface clutter.

Change-Id: I4a04f04e2c343593d937a402060e56ef94fcabf1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-30 09:16:12 +00:00
hjk
ba36cbfdaa Docker: Implement some DockerDevice functions
Container file system accesses are primarily done through the host
file system by prepending the appropriate path.

This is Linux-only, and only in case the volumes are mounted to
the same relative location in the container.

As a fallback, provide the functionality also via 'docker exec'.
This is, however, too slow to be used in the future.

Change-Id: I23185ae45184cb7b1de7c723a01ab96fe9c0801e
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2021-04-30 09:15:08 +00:00
hjk
ef108d7a06 Docker: Add DockerDevice and a simple run config
The "Docker Container" runconfig executes 'docker run <image>' without
further attributes, and "works" with docker's hello-world example image.

Change-Id: Ib9417d238ac0757db16be1fc21af40c81db02f05
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2021-04-13 08:54:17 +00:00