Skip to content

Commit

Permalink
Merge pull request #23 from LemLib/chore/devcontainer-setup
Browse files Browse the repository at this point in the history
🧑‍💻 add devcontainer setup with sim
  • Loading branch information
ion098 authored Nov 21, 2024
2 parents 0dc0a36 + 7e00807 commit 6e70274
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 10 deletions.
62 changes: 62 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
FROM rust:1.67 as builder

RUN git clone https://github.com/vexide/vex-v5-qemu.git /vex-v5-qemu

WORKDIR /vex-v5-qemu
RUN cd packages/kernel; cargo build --target-dir /target/kernel

RUN cd packages/client-cli; cargo install --path . --root /target/client-cli

FROM mcr.microsoft.com/devcontainers/cpp:1-noble
# ------------
# Install Required Packages
# ------------
RUN sudo apt-get update
COPY ./.devcontainer/packagelist /packagelist
RUN sudo apt-get -y install $(cat /packagelist | sed 's/\r//')
RUN rm /packagelist # Cleanup image
RUN sudo apt-get clean # Cleanup image

# ------------
# Install Clangd
# ------------
RUN curl -sLo clangd.zip $( \
curl -s https://api.github.com/repos/clangd/clangd/releases/latest \
| jq -r '[.assets[] | select(.name | test ("^clangd-linux"))][0].browser_download_url' \
) \
&& unzip clangd.zip -d /usr/local/share \
&& mv /usr/local/share/clangd_*/ /usr/local/share/clangd \
&& rm clangd.zip

ENV PATH="$PATH:/usr/local/share/clangd/bin"

# ------------
# Install PROS CLI
# ------------
RUN pip install --break-system-packages pros-cli

# ------------
# Install ARM Toolchain
# ------------
COPY --from=ghcr.io/lemlib/pros-build:v2.0.2 /gcc-arm-none-eabi-10.3-2021.10 /usr/local/share/arm-none-eabi
ENV PATH="$PATH:/usr/local/share/arm-none-eabi/bin"

# Copy the simulator binary
COPY --from=builder /target/client-cli/bin/client-cli /usr/local/bin/simulator

# Clone pros kernel source so we can reference it when debugging
COPY ./project.pros /project.pros
ENV PROS_SOURCE_PATH="$HOME/.pros"
RUN git clone https://github.com/purduesigbots/pros.git $PROS_SOURCE_PATH \
--depth 1 \
--branch $(</project.pros jq -r '.["py/state"].templates.kernel.version')
RUN rm /project.pros # Cleanup image

# Copy the sim kernel, as its required to run the simulator
ENV V5_SIM_PATH="$HOME/.vex-v5-qemu"
ENV V5_SIM_KERNEL_PATH="$V5_SIM_PATH/kernel"
COPY --from=builder /target/kernel/armv7a-none-eabi/debug/kernel $V5_SIM_KERNEL_PATH

# Copy the sim source, so we can reference it when debugging
ENV V5_SIM_SOURCE_PATH="$V5_SIM_PATH/source"
COPY --from=builder /vex-v5-qemu $V5_SIM_SOURCE_PATH
27 changes: 27 additions & 0 deletions .devcontainer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
All files in the .devcontainer folder are taken from
https://github.com/darkMatter781x/HighStakes and are licensed under the MIT
license as follows.

===== BEGIN LICENSE =====

MIT License

Copyright (c) 2024 Andrew Curtis and Kairui Dai

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 20 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
{
"postCreateCommand": "chmod 777 .devcontainer/postCreateCommand.bash && .devcontainer/postCreateCommand.bash && source ~/.bashrc"
}
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"customizations": {
"vscode": {
"settings": {
"clangd.path": "/usr/local/share/clangd/bin/clangd"
},
"extensions": [
"jeff-hykin.better-cpp-syntax",
"llvm-vs-code-extensions.vscode-clangd",
"streetsidesoftware.code-spell-checker",
"cschlosser.doxdocgen",
"ms-azuretools.vscode-docker",
"vivaxy.vscode-conventional-commits"
]
}
}
}
7 changes: 7 additions & 0 deletions .devcontainer/packagelist
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
git
python3-minimal
python3-pip
pipx
qemu-system
gdb-multiarch
jq
8 changes: 0 additions & 8 deletions .devcontainer/postCreateCommand.bash

This file was deleted.

5 changes: 5 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
All files in this repository are licensed under the MIT license as follows,
unless otherwise noted in another LICENSE file

===== BEGIN LICENSE =====

MIT License

Copyright (c) 2024 Jamie Maki-Fern, Ayaan (ion098), and other contributors
Expand Down

0 comments on commit 6e70274

Please sign in to comment.