Skip to content

Commit 14b2708

Browse files
committed
Add devcontainer
1 parent cd94912 commit 14b2708

File tree

4 files changed

+134
-0
lines changed

4 files changed

+134
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
FROM ubuntu:22.04
2+
3+
RUN apt update
4+
RUN apt install -y --no-install-recommends \
5+
ca-certificates \
6+
nano \
7+
git \
8+
openssh-client \
9+
make \
10+
gcc \
11+
python3 \
12+
python3-pip \
13+
curl \
14+
wget \
15+
xz-utils \
16+
pkg-config \
17+
libgmp-dev \
18+
zlib1g-dev \
19+
zsh
20+
21+
# Default powerline10k theme, no plugins installed
22+
RUN sh -c "$(wget -O- https://github.com/deluan/zsh-in-docker/releases/download/v1.2.1/zsh-in-docker.sh)" -- \
23+
-t ys \
24+
-a 'CASE_SENSITIVE="true"' \
25+
-p git \
26+
-p ssh-agent \
27+
-p zsh-autosuggestions \
28+
-p zsh-autosuggestions \
29+
-p zsh-syntax-highlighting

.devcontainer/Makefile

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
2+
CURL_ARGS = -C - --retry 5 --retry-delay 2 --retry-connrefused -L -o
3+
4+
export PATH := $(PATH):/opt/sail/bin:/workspaces/sail-riscv/c_emulator:/opt/riscv32/riscv/bin:/opt/riscv64/riscv/bin
5+
6+
setup: setup-ctg setup-isac setup-riscof setup-sail-riscv setup-rv32 setup-rv64
7+
8+
CTG := $(shell command -v riscv_ctg 2> /dev/null)
9+
setup-ctg:
10+
ifndef CTG
11+
pip install --editable ./riscv-ctg
12+
endif
13+
echo "riscv-ctg install"
14+
15+
ISAC := $(shell command -v riscv_isac 2> /dev/null)
16+
setup-isac:
17+
ifndef ISAC
18+
pip install --editable ./riscv-isac
19+
endif
20+
echo "riscv-isac install"
21+
22+
RISCOF := $(shell command -v riscof 2> /dev/null)
23+
setup-riscof:
24+
ifndef RISCOF
25+
pip install riscof
26+
endif
27+
echo "riscof install"
28+
29+
SAIL := $(shell command -v sail 2> /dev/null)
30+
_setup-sail:
31+
ifndef SAIL
32+
curl $(CURL_ARGS) /opt/sail.tar.gz https://github.com/rems-project/sail/releases/download/0.18-linux-binary/sail.tar.gz
33+
tar xzf /opt/sail.tar.gz -C /opt/
34+
sail -v
35+
echo 'export PATH="$$PATH:/opt/sail/bin"' >> ~/.zshrc
36+
endif
37+
echo "sail install"
38+
39+
SAIL_RISCV := $(shell command -v riscv_sim_RV64 2> /dev/null)
40+
setup-sail-riscv: _setup-sail
41+
ifndef SAIL
42+
cd .. && git clone https://github.com/riscv/sail-riscv.git
43+
cd sail-riscv
44+
ARCH=RV32 make -j$(nproc)
45+
ARCH=RV64 make -j$(nproc)
46+
riscv_sim_RV32 --help
47+
riscv_sim_RV64 --help
48+
echo 'export PATH="$$PATH:/workspaces/sail-riscv/c_emulator"' >> ~/.zshrc
49+
endif
50+
echo "sail-riscv install"
51+
52+
RV32 := $(shell command -v riscv32-unknown-elf-gcc 2> /dev/null)
53+
setup-rv32:
54+
ifndef RV32
55+
curl $(CURL_ARGS) /opt/riscv32.tar.xz https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2024.11.22/riscv32-elf-ubuntu-22.04-gcc-nightly-2024.11.22-nightly.tar.xz
56+
mkdir -p /opt/riscv32
57+
tar xf /opt/riscv32.tar.xz -C /opt/riscv32
58+
riscv32-unknown-elf-gcc --version
59+
echo 'export PATH="$$PATH:/opt/riscv32/riscv/bin"' >> ~/.zshrc
60+
endif
61+
echo "rv64 toolchain install"
62+
63+
RV64 := $(shell command -v riscv64-unknown-elf-gcc 2> /dev/null)
64+
setup-rv64:
65+
ifndef RV64
66+
curl $(CURL_ARGS) /opt/riscv64.tar.xz https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/2024.11.22/riscv64-elf-ubuntu-22.04-gcc-nightly-2024.11.22-nightly.tar.xz
67+
mkdir -p /opt/riscv64
68+
tar xf /opt/riscv64.tar.xz -C /opt/riscv64
69+
riscv64-unknown-elf-gcc --version
70+
echo 'export PATH="$$PATH:/opt/riscv64/riscv/bin"' >> ~/.zshrc
71+
endif
72+
echo "rv64 toolchain install"
73+
74+
clean_zip:
75+
rm /opt/sail.tar.gz
76+
rm /opt/riscv32.tar.xz
77+
rm /opt/riscv64.tar.xz

.devcontainer/devcontainer.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "RISC-V UnifiedDB Dev",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"onCreateCommand": "${containerWorkspaceFolder}/.devcontainer/onCreateCommand.sh",
7+
"remoteEnv": {
8+
"DISPLAY": ":0"
9+
},
10+
// vscode extensions
11+
"customizations": {
12+
"vscode": {
13+
"settings": {
14+
"files.exclude": {},
15+
"files.watcherExclude": {}
16+
},
17+
"extensions": [
18+
"charliermarsh.ruff",
19+
"redhat.vscode-yaml",
20+
"zhwu95.riscv"
21+
]
22+
}
23+
},
24+
"forwardPorts": [
25+
// 8080
26+
]
27+
}

.devcontainer/onCreateCommand.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
git config --global --add safe.directory /workspaces/riscv-arch-test

0 commit comments

Comments
 (0)