Skip to content

Commit 52ee4d4

Browse files
authored
Swift: add devcontainer setup
1 parent 2936e1a commit 52ee4d4

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

.devcontainer/swift/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.236.0/containers/cpp/.devcontainer/base.Dockerfile
2+
3+
# [Choice] Debian / Ubuntu version (use Debian 11, Ubuntu 18.04/22.04 on local arm64/Apple Silicon): debian-11, debian-10, ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
4+
ARG VARIANT="bullseye"
5+
FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}
6+
7+
ARG BAZELISK_VERSION=v1.10.1
8+
ARG BAZELISK_DOWNLOAD_SHA=dev-mode
9+
USER root
10+
ADD root.sh /tmp/root.sh
11+
RUN bash /tmp/root.sh && rm /tmp/root.sh

.devcontainer/swift/devcontainer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"extensions": [
3+
"github.vscode-codeql",
4+
"hbenl.vscode-test-explorer",
5+
"ms-vscode.test-adapter-converter",
6+
"slevesque.vscode-zipexplorer",
7+
"ms-vscode.cpptools"
8+
],
9+
"settings": {
10+
"files.watcherExclude": {
11+
"**/target/**": true
12+
},
13+
"codeQL.runningQueries.memory": 2048
14+
},
15+
"build": {
16+
"dockerfile": "Dockerfile",
17+
"args": {
18+
"VARIANT": "ubuntu-20.04"
19+
}
20+
},
21+
"runArgs": [
22+
"--cap-add=SYS_PTRACE",
23+
"--security-opt",
24+
"seccomp=unconfined"
25+
],
26+
"remoteUser": "vscode",
27+
"onCreateCommand": ".devcontainer/swift/user.sh"
28+
}

.devcontainer/swift/root.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
set -xe
2+
3+
apt-get update
4+
export DEBIAN_FRONTEND=noninteractive
5+
apt-get -y install --no-install-recommends \
6+
zlib1g-dev \
7+
uuid-dev \
8+
python3-distutils
9+
10+
# Install Bazel
11+
curl -fSsL -o /usr/local/bin/bazelisk https://github.com/bazelbuild/bazelisk/releases/download/${BAZELISK_VERSION}/bazelisk-linux-amd64
12+
([ "${BAZELISK_DOWNLOAD_SHA}" = "dev-mode" ] || echo "${BAZELISK_DOWNLOAD_SHA} */usr/local/bin/bazelisk" | sha256sum --check - )
13+
chmod 0755 /usr/local/bin/bazelisk
14+
ln -s bazelisk /usr/local/bin/bazel

.devcontainer/swift/user.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
set -xe
2+
3+
# add the workspace to the codeql search path
4+
mkdir -p /home/vscode/.config/codeql
5+
echo "--search-path /workspaces/codeql" > /home/vscode/.config/codeql/config
6+
7+
# create a swift extractor pack with the current state
8+
cd /workspaces/codeql
9+
bazel run swift/create-extractor-pack
10+
11+
cat >> $HOME/.bashrc << EOF
12+
13+
# have the codeql binary installed by vscode automatically in PATH
14+
bin=\$(ls \$HOME/.vscode-remote/data/User/globalStorage/github.vscode-codeql/*/codeql/codeql -t 2>/dev/null | head -1)
15+
if [[ -n \$bin ]]; then
16+
export PATH=\$PATH:$(dirname "\$bin")
17+
fi
18+
EOF

0 commit comments

Comments
 (0)