Explorar el Código

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 `<gmock/gmock.h>` and `<benchmark/benchmark.h>` 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.
Vitalii hace 3 años
padre
commit
4872f49ce7
Se han modificado 3 ficheros con 32 adiciones y 55 borrados
  1. 12 44
      .devcontainer/Dockerfile
  2. 19 10
      .devcontainer/devcontainer.json
  3. 1 1
      docs/project/contribution_tools.md

+ 12 - 44
.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

+ 19 - 10
.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"
+      ]
+    }
+  }
 }

+ 1 - 1
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);
     <br> Visual Studio Code detects the new files and opens a message box
     saying: