From 4872f49ce72f29a1c1b68e7e64d7a56933d8d28a Mon Sep 17 00:00:00 2001 From: Vitalii <56548624+beryll1um@users.noreply.github.com> Date: Sat, 30 Jul 2022 19:54:45 +0200 Subject: [PATCH] Rework of .devcontainer (#1816) (#1817) > The only issue that I currently have with this one is that the `clangd` extension is having some hiccups, not being able to find includes like `` and `` and thus showing extra errors. However, this only affects the VSCode extension and bazel seems to work fine. This might be an issue with the compilation database: you might try ./scripts/create_compdb.py to help. --- .devcontainer/Dockerfile | 56 +++++++----------------------- .devcontainer/devcontainer.json | 29 ++++++++++------ docs/project/contribution_tools.md | 2 +- 3 files changed, 32 insertions(+), 55 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 9886d9f116e1..a55e13062540 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -2,51 +2,19 @@ # Exceptions. See /LICENSE for license information. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -FROM centos:centos7.9.2009 +ARG TAG=3.5.6 +FROM homebrew/brew:${TAG} -# install -RUN yum -y install which zlib zlib-devel curl perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker gcc gcc-c++ curl-devel expat-devel gettext-devel openssl-devel expect make wget gettext zip unzip scl-utils \ - && yum -y install centos-release-scl \ - && yum -y install devtoolset-7-gcc* \ - && mkdir -p /data/App \ - && cd /data/App \ - && wget https://github.com/git/git/archive/refs/tags/v2.37.1.tar.gz \ - && tar -zxvf v2.37.1.tar.gz \ - && wget https://curl.haxx.se/download/curl-7.70.0.tar.gz --no-check-certificate \ - && tar -zxvf curl-7.70.0.tar.gz \ - && rm *.tar.gz +# Install libxcrypt using Homebrew. +RUN brew install libxcrypt --overwrite -RUN source /opt/rh/devtoolset-7/enable \ - && gcc --version \ - && cd /data/App/git-2.37.1 \ - && make prefix=/usr/local/git all \ - && make prefix=/usr/local/git install \ - && cd ../curl-7.70.0 \ - && ./configure --prefix=/usr/local/curl \ - && make && make install \ - && cd .. \ - && export PATH=/usr/local/git/bin:/usr/local/curl/bin:$PATH \ - && NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" \ - && echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /root/.bash_profile \ - && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" +# Install all other dependencies using Homebrew. +RUN brew install bazelisk node python@3.9 -RUN export PATH=/home/linuxbrew/.linuxbrew/bin/:/home/linuxbrew/.linuxbrew/opt/llvm/bin:/usr/local/git/bin:/usr/local/curl/bin:$PATH \ - && export HOMEBREW_GIT_PATH=/usr/local/git/bin/git \ - && export HOMEBREW_CURL_PATH=/usr/local/curl/bin/curl \ - && brew update \ - && brew install bazelisk \ - && brew install libxcrypt --overwrite \ - && brew install --force-bottle --only-dependencies llvm \ - && brew install --force-bottle --force --verbose llvm \ - && brew info llvm \ - && brew install node \ - && brew install python@3.9 \ - && pip3 install -U pip \ - && pip3 install pre-commit \ - && pip3 install black \ - && pip3 install codespell +# Install all python dependencies modules using Pip. +RUN pip3 install -U pip +RUN pip3 install pre-commit black codespell -ENV LANG=en_US.UTF-8 \ - HOMEBREW_GIT_PATH=/usr/local/git/bin/git \ - HOMEBREW_CURL_PATH=/usr/local/curl/bin/curl \ - PATH=/home/linuxbrew/.linuxbrew/opt/llvm/bin:/home/linuxbrew/.linuxbrew/bin/:/home/linuxbrew/.linuxbrew/Cellar/llvm/14.0.6_1.reinstall/bin:/usr/local/git/bin:/usr/local/curl/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +# Install Clang/LLVM using Homebrew. +# Many Clang/LLVM releases aren't built with options we rely on. +RUN brew install llvm diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index ff2b2163535a..f56941204fe9 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,21 @@ { - "name": "dev environment", - "dockerFile": "Dockerfile", - "extensions": [ - "bazelbuild.vscode-bazel", - "bierner.github-markdown-preview", - "daohong-emilio.yash", - "esbenp.prettier-vscode", - "llvm-vs-code-extensions.vscode-clangd", - "ms-python.python" - ] + "name": "carbon-lang", + "build": { + "dockerfile": "Dockerfile", + "args": { + "TAG": "3.5.6" + } + }, + "customizations": { + "vscode": { + "extensions": [ + "bazelbuild.vscode-bazel", + "bierner.github-markdown-preview", + "daohong-emilio.yash", + "esbenp.prettier-vscode", + "llvm-vs-code-extensions.vscode-clangd", + "ms-python.python" + ] + } + } } diff --git a/docs/project/contribution_tools.md b/docs/project/contribution_tools.md index 6ecce0869341..6aa21a25a026 100644 --- a/docs/project/contribution_tools.md +++ b/docs/project/contribution_tools.md @@ -408,7 +408,7 @@ provide VSCode `DevContainer`. - Install VSCode and Docker; - Install the plugin `ms-vscode-remote.remote-containers` under VSCode; -- Open `Carban` project folder in +- Open `Carbon` project folder in [VSCode](https://docs.microsoft.com/en-us/azure-sphere/app-development/container-build-vscode#build-and-debug-the-project);
Visual Studio Code detects the new files and opens a message box saying: