Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM ubuntu:22.04
Comment thread
dariusarnold marked this conversation as resolved.
Outdated

# Install dependencies
ARG DEBIAN_FRONTEND=noninteractive
ARG NODE_MAJOR=20
RUN apt-get update -qq && \
apt-get install -y \
curl \
cmake \
ccache \
libsdl2-dev \
g++ \
git \
libpng-dev \
ninja-build \
sudo \
python3-pip \
python3-venv \
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/* \
&& curl -sL https://deb.nodesource.com/setup_${NODE_MAJOR}.x -o nodesource_setup.sh \
&& bash nodesource_setup.sh \
Comment thread
dariusarnold marked this conversation as resolved.
&& apt-get install -y nodejs \
&& npm install -g lv_font_conv@1.5.2 \
&& pip install wheel Pillow

# Add the infinitime user with sudo password "it" for developing in devcontainer
RUN adduser infinitime && echo "infinitime:it" | chpasswd && usermod -aG sudo infinitime

# Persist bash history across container rebuilds
# Reference: https://code.visualstudio.com/remote/advancedcontainers/persist-bash-history
ARG USERNAME=infinitime
RUN SNIPPET="export PROMPT_COMMAND='history -a' && export HISTFILE=/commandhistory/.bash_history" \
&& mkdir /commandhistory \
&& touch /commandhistory/.bash_history \
&& chown -R $USERNAME /commandhistory \
&& echo "$SNIPPET" >> "/home/$USERNAME/.bashrc"

USER infinitime

# Section for interactive compilation during docker run

WORKDIR /sources
# Directory if InfiniTime source code
Comment thread
dariusarnold marked this conversation as resolved.
ENV INFITIME_DIR="/sources/InfiniTime"
Comment thread
dariusarnold marked this conversation as resolved.
Outdated
# Passed to CMake generate step
ENV GENERATE_ARGS=""
# Passed to CMake build step
ENV BUILD_ARGS=""
# Build directory
ENV BUILD_DIRECTORY="build"

CMD ["bash", "-c", "cmake -S . -B ${BUILD_DIRECTORY} -G Ninja -DInfiniTime_DIR=${INFITIME_DIR} ${GENERATE_ARGS} && cmake --build ${BUILD_DIRECTORY} ${BUILD_ARGS}"]
32 changes: 32 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json.
{
"name": "InfiniSim Dev Container",
"build": {
"dockerfile": "Dockerfile"
},

// Configure tool-specific properties.
"customizations": {
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"marus25.cortex-debug",
Comment thread
dariusarnold marked this conversation as resolved.
Outdated
"notskm.clang-tidy",
"mjohns.clang-format",
"timonwong.shellcheck"
]
}
},

"mounts": [
// Local volume to store bash history across rebuilds
"source=projectname-bashhistory,target=/commandhistory,type=volume"
Comment thread
dariusarnold marked this conversation as resolved.
Outdated
// Uncomment and modify path to mount external InfiniTime source into the container
//,"source=/home/example/git/InfiniTime,target=/workspaces/InfiniTime,type=bind,consistency=cached"
],

// Sudo password "it"
"remoteUser": "infinitime"
}
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,30 @@ The following configuration settings can be added to the first `cmake -S . -B bu
Ex: `-DENABLE_USERAPPS="Apps::Timer, Apps::Alarm"`.
The default list of user applications will be selected if this variable is not set.

### Build with Docker

You can also build the simulator using Docker. This is useful if you don't want to install all the dependencies on your system.
Comment thread
dariusarnold marked this conversation as resolved.
Outdated
First build the Docker image:
```sh
docker build -t infinisim-build .devcontainer
```

Afterwards you can build the simulator with:
```sh
docker run --rm -it -v ${PWD}:/sources infinisim-build
```

By default this builds the InfiniTime from the submodule in your ${PWD}. If you want to use a different repository, you got to mount it and pass the path to the `INFITIME_DIR` variable:
Comment thread
dariusarnold marked this conversation as resolved.
Outdated
```sh
docker run --rm -it -v ${PWD}:/sources -v ${PWD}/../InfiniTime:/infinitime -e INFITIME_DIR=/infinitime infinisim-build
Comment thread
dariusarnold marked this conversation as resolved.
Outdated
```

Other CMake generation and build arguments can be passed to the GENERATE_ARGS and BUILD_ARGS variables:
Comment thread
dariusarnold marked this conversation as resolved.
Outdated
```sh
docker run --rm -it -v ${PWD}:/sources -e GENERATE_ARGS=-DENABLE_USERAPPS="Apps::Timer,Apps::Alarm" -e BUILD_ARGS=-j16 infinisim-build
```


## Run Simulator

When the build was successful the simulator binary can be started with
Expand Down