Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
34 changes: 34 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/ubuntu/.devcontainer/base.Dockerfile

# [Choice] Ubuntu version (use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon): ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
ARG VARIANT="jammy"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

SHELL ["/bin/bash", "-c"]

ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Install all packages for c/c++ development
RUN apt-get update --fix-missing && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends --fix-missing \
build-essential \
cmake \
doxygen \
clang-tidy \
clang-format

RUN apt-get update --fix-missing && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends --fix-missing \
mesa-common-dev \
libxi-dev \
libxcursor-dev \
libxinerama-dev \
libxrandr-dev \
libx11-dev \
xvfb \
xorg

# [Optional] Uncomment this section to install additional OS packages.
#RUN apt-get update --fix-missing && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends --fix-missing \
# some more packages
48 changes: 48 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.241.1/containers/ubuntu
{
"name": "Ubuntu",
"build": {
"dockerfile": "Dockerfile",
// Update 'VARIANT' to pick an Ubuntu version: jammy / ubuntu-22.04, focal / ubuntu-20.04, bionic /ubuntu-18.04
// Use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon.
"args": {
"VARIANT": "ubuntu-22.04"
}
},
"containerEnv": {
"DISPLAY": "${localEnv:DISPLAY}",
"XAUTHORITY": "${localEnv:XAUTHORITY}"
},
"runArgs": [
"--network=host"
],
"mounts": [
"source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached",
"source=${localEnv:XAUTHORITY},target=${localEnv:XAUTHORITY},type=bind,consistency=cached"
],
"customizations": {
"vscode": {
"extensions": [
"llvm-vs-code-extensions.vscode-clangd",
"matepek.vscode-catch2-test-adapter",
"twxs.cmake",
"vadimcn.vscode-lldb",
"jeff-hykin.better-cpp-syntax",
"xaver.clang-format",
"eamodio.gitlens",
"rreverser.llvm",
"cschlosser.doxdocgen"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/meaningful-ooo/devcontainer-features/fish:1": {}
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ Makefile
build/
tools/*svg
docs/doxygen
.cache
compile_commands.json
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build and Run",
"type": "shell",
"command": "./tools/buildscript.sh all",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
79 changes: 79 additions & 0 deletions tools/buildscript.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/bin/bash

WD=$PWD

findWorkDirectory () {
## The `-d` test command option see if FILE exists and is a directory ##
[ -d "testapp" ] && (return 0) || (echo "Script is NOT called from base directory" ; cd ..)

[ -d "testapp" ] && ( WD=$PWD ; return 0) || (echo "Cannot find base directory, please start script from project root!" ; exit 1)

}

findWorkDirectory

clean () {
echo "=== Cleaning build folder ==="
rm -rf compile_commands.json 2> /dev/null
cd testapp || (exit 1 ; echo "testapp folder not found")
rm -rf build/
cd $WD || (exit 1 ; echo "work directory not found")
}

config () {
echo "=== Configuring build folder ==="
cd testapp || (exit 1 ; echo "Testapp folder not found")
mkdir build || (exit 1 ; echo "Build folder already exists, clean first!")
cd build || (exit 1 ; echo "Build folder not found")
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .. || (exit 1 ; echo "Config failed")
mv compile_commands.json $WD/compile_commands.json || (echo "Move compile_commands.json failed")
cd $WD || (exit 1 ; echo "Work directory not found")
}

compile () {
echo "=== Compiling Project ==="
cd testapp || (exit 1 ; echo "Testapp folder not found")
cd build || (exit 1 ; echo "Build folder not found, please run config first!")
cmake --build . || (exit 1 ; echo "Compile failed!")
cd $WD || (exit 1 ; echo "Work directory not found")
}

test () {
echo "=== Testing App ==="
cd testapp || (exit 1 ; echo "Testapp folder not found")
cd build || (exit 1 ; echo "Build folder not found, please run config first!")
./bots2dtest || (exit 1 ; echo "Can not execute or find binary!")
cd $WD || (exit 1 ; echo "Work directory not found")
}

case $1 in
all)
[ ! -d "testapp/build" ] && (clean ; config)
compile
test
;;
clean)
clean
;;
config)
[ -d "testapp/build" ] && (clean ; config ; exit)
config
;;
c | compile | b | build)
compile
;;
t | test | r | run)
test
;;
*)
if [ $1 ]; then
echo "Unknown argument: $1"
fi
echo "Please provide one of the following arguments:"
echo " clean Deletes the build folder"
echo " config Creates build folder and configures build System"
echo " c | compile | b | build Compiles the Project"
echo " t | test Test and Run the test app."
exit
;;
esac