Skip to content

Commit 886d7e8

Browse files
committed
feat: add dev container
1 parent 91d887e commit 886d7e8

File tree

6 files changed

+97
-0
lines changed

6 files changed

+97
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
3+
{
4+
"name": "Existing Dockerfile",
5+
"build": {
6+
// Sets the run context to one level up instead of the .devcontainer folder.
7+
"context": "..",
8+
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9+
"dockerfile": "../Dockerfile.dev"
10+
},
11+
"features": {
12+
"ghcr.io/devcontainers/features/rust:1": {
13+
"version": "latest",
14+
"profile": "minimal"
15+
}
16+
}
17+
18+
// Features to add to the dev container. More info: https://containers.dev/features.
19+
// "features": {},
20+
21+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
22+
// "forwardPorts": [],
23+
24+
// Uncomment the next line to run commands after the container is created.
25+
// "postCreateCommand": "cat /etc/os-release",
26+
27+
// Configure tool-specific properties.
28+
// "customizations": {},
29+
30+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
31+
// "remoteUser": "devcontainer"
32+
}

.devcontainer/first-run-notice.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
👋 Welcome to Codespaces! You are on our Pivot-Lang's dev image.
2+
3+
You need to run `make devlinux && source ~/.bashrc` on the project root before start developing.
4+
5+
For any cargo build issues, please try `cargo clean`, and rerun the build command.

Dockerfile.dev

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
FROM mcr.microsoft.com/devcontainers/base:ubuntu AS runner
2+
COPY ./.devcontainer/first-run-notice.txt /tmp/scripts/
3+
RUN mv -f /tmp/scripts/first-run-notice.txt /usr/local/etc/vscode-dev-containers/
4+
COPY ./setup-llvm.sh .
5+
RUN apt-get update && apt-get install -y gnupg2 software-properties-common cmake
6+
RUN apt-get update && apt-get install -y lsb-release wget && apt-get clean all
7+
RUN ./setup-llvm.sh
8+
RUN apt update
9+
RUN apt install -y git libxml2 build-essential libunwind-dev

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ vm:
1313
@cd vm && cargo build --release
1414

1515
vmdebug:
16+
@mkdir -p target/release
1617
@cd vm && cargo build
1718
@cp target/debug/libvm.a target/release/libvm.a
1819

book/src/dev-prepare.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,16 @@ make test
4646
如果上方命令都成功执行,那么恭喜你,你已经成功配置了开发环境
4747

4848

49+
## 使用github codespace 进行开发
50+
51+
使用github codespace进行开发的环境配置较为简单,但是请注意费用问题。
52+
53+
54+
点击以下链接即可创建一个包含pl开发环境的codespace
55+
56+
[create codespace](https://github.com/codespaces/new?machine=standardLinux32gb&repo=535925143&ref=master&devcontainer_path=.devcontainer%2Fdevcontainer.json&location=SouthEastAsia)
57+
58+
创建完毕后,建议使用本地vscode打开codespace中的项目进行开发
59+
60+
61+

setup-llvm.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# This script install the correct LLVM release for Debian & Ubuntu distros.
4+
5+
set -eux
6+
7+
LLVM_VERSION=14
8+
DISTRO=$(lsb_release -is)
9+
VERSION=$(lsb_release -sr)
10+
DIST_VERSION="${DISTRO}_${VERSION}"
11+
12+
# Find the right repository name for the distro and version
13+
case "$DIST_VERSION" in
14+
Debian_9* ) REPO_NAME="deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-$LLVM_VERSION main" ;;
15+
Debian_10* ) REPO_NAME="deb http://apt.llvm.org/buster/ llvm-toolchain-buster-$LLVM_VERSION main" ;;
16+
Debian_unstable ) REPO_NAME="deb http://apt.llvm.org/unstable/ llvm-toolchain-$LLVM_VERSION main" ;;
17+
Debian_testing ) REPO_NAME="deb http://apt.llvm.org/unstable/ llvm-toolchain-$LLVM_VERSION main" ;;
18+
Ubuntu_16.04 ) REPO_NAME="deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-$LLVM_VERSION main" ;;
19+
Ubuntu_18.04 ) REPO_NAME="deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-$LLVM_VERSION main" ;;
20+
Ubuntu_18.10 ) REPO_NAME="deb http://apt.llvm.org/cosmic/ llvm-toolchain-cosmic-$LLVM_VERSION main" ;;
21+
Ubuntu_19.04 ) REPO_NAME="deb http://apt.llvm.org/disco/ llvm-toolchain-disco-$LLVM_VERSION main" ;;
22+
Ubuntu_19.10 ) REPO_NAME="deb http://apt.llvm.org/eoan/ llvm-toolchain-eoan-$LLVM_VERSION main" ;;
23+
Ubuntu_20.04 ) REPO_NAME="deb http://apt.llvm.org/focal/ llvm-toolchain-focal-$LLVM_VERSION main" ;;
24+
Ubuntu_22.04 ) REPO_NAME="deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-$LLVM_VERSION main" ;;
25+
Ubuntu_22.10 ) REPO_NAME="deb http://apt.llvm.org/kinetic/ llvm-toolchain-kinetic-$LLVM_VERSION main" ;;
26+
* )
27+
echo "Distribution '$DISTRO' in version '$VERSION' is not supported by this script (${DIST_VERSION})."
28+
exit 2
29+
esac
30+
31+
# Add the right repository for the distro
32+
wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
33+
add-apt-repository "${REPO_NAME}"
34+
apt-get update
35+
36+
# Install required packages
37+
apt-get install -y llvm-$LLVM_VERSION llvm-$LLVM_VERSION-* liblld-$LLVM_VERSION* libpolly-$LLVM_VERSION-dev

0 commit comments

Comments
 (0)