mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Provide a `.devcontainer` definition, following the Dev Container Specification, to give contributors a ready-made Linux environment with the tools needed to build CMake, run its test suite, build its documentation, and satisfy its style rules. Base the container on Ubuntu, which offers the broadest ecosystem of packages and tooling for development, including a recent `cmake` and the `clang-format` version our style rules require, exactly. Mirror the package lists of the Debian image our CI infrastructure uses, section by section, so that the dependencies available closely match the ones against which merge requests are tested. Build the image the way the images under `.gitlab/ci/docker/` are built: bind mount the package lists and the installation script rather than copying them in, and cache the package lists and downloaded archives so that a rebuild fetches only what has changed. Run optional `.devcontainer/hooks/root.sh` and `.devcontainer/hooks/user.sh` scripts, both ignored by Git, so that developers may customize the container without modifying tracked files. Document usage in a new `Help/dev/devcontainer.rst`. Fixes: #28043
28 lines
1.1 KiB
Bash
Executable File
28 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Install the packages listed in `deps_packages.lst` and `dev_packages.lst`.
|
|
# See `Help/dev/devcontainer.rst`.
|
|
|
|
set -e
|
|
|
|
# Install without asking questions, e.g. the time zone `tzdata` wants.
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Unlike our CI images, keep the documentation that packages carry: the base
|
|
# image excludes man pages and the like, which is not what one wants in a
|
|
# development environment. Packages already installed in the base image
|
|
# remain without their documentation; `unminimize` restores that.
|
|
rm -f /etc/dpkg/dpkg.cfg.d/excludes
|
|
|
|
apt-get update
|
|
apt-get install -y $(grep -h '^[^#]\+$' /root/deps_packages.lst /root/dev_packages.lst)
|
|
|
|
# Add locales, the way our CI images do, for the tests that need them.
|
|
sed -i -E '/^# en_US[ .](ISO-8859-1|UTF-8)( |$)/ s/^# //' /etc/locale.gen
|
|
dpkg-reconfigure --frontend=noninteractive locales
|
|
|
|
# `Utilities/Scripts/clang-format.bash` finds `clang-format-18` by name, but
|
|
# make the unversioned name resolve to version 18 as well so that tools
|
|
# looking for it get the version our style rules require.
|
|
ln -s "$(command -v clang-format-18)" /usr/local/bin/clang-format
|