Skip to content

Commit c4f4ce3

Browse files
committed
Test example run scripts
1 parent 52e00bd commit c4f4ce3

File tree

2 files changed

+44
-14
lines changed

2 files changed

+44
-14
lines changed

tools/docker/run.ps1

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,31 @@
1-
$ARDUINO_DIR = $args[0] -replace '\\', '/'
2-
if (-not $ARDUINO_DIR) {
3-
$ARDUINO_DIR = (Get-Location).Path + '/../'
1+
# This is an example of how to run the docker container.
2+
# This script is not part of the container, it is meant to be run on the host machine.
3+
# Usage: ./run.ps1 <path_to_arduino_esp32>
4+
5+
if (-not (Test-Path -Path (Get-Command docker).Source)) {
6+
Write-Host "ERROR: Docker is not installed! Please install docker first."
7+
exit 1
8+
}
9+
10+
if ($args.Count -gt 0) {
11+
$ARDUINO_DIR = $args[0] -replace '\\', '/'
12+
} else {
13+
$ARDUINO_DIR = ''
414
}
515

6-
$ARDUINO_DIR = (Get-Item -Path $ARDUINO_DIR).FullName
716
$DOCKER_ARGS = @()
817
$DOCKER_ARGS += '-it'
9-
$DOCKER_ARGS += '-v', "$ARDUINO_DIR:/arduino-esp32"
1018
$DOCKER_ARGS += '-e', 'TERM=xterm-256color'
11-
$DOCKER_ARGS += '-e', "HOST_UID=$env:UID"
19+
20+
if ((Test-Path $ARDUINO_DIR)) {
21+
$DOCKER_ARGS += '-v', "$ARDUINO_DIR:/arduino-esp32"
22+
} else {
23+
Write-Output "Warning: Invalid arduino directory: '$ARDUINO_DIR'. Ignoring it."
24+
}
1225

1326
if ($env:LIBBUILDER_GIT_SAFE_DIR) {
1427
$DOCKER_ARGS += '-e', "LIBBUILDER_GIT_SAFE_DIR=$env:LIBBUILDER_GIT_SAFE_DIR"
1528
}
1629

17-
Write-Output "Running: docker run $($DOCKER_ARGS -join ' ') lucassvaz/esp32-arduino-lib-builder:latest"
18-
docker run @($DOCKER_ARGS) lucassvaz/esp32-arduino-lib-builder:latest python3 tools/config_editor/app.py
30+
Write-Output "Running: docker run $($DOCKER_ARGS -join ' ') lucassvaz/esp32-arduino-lib-builder"
31+
#docker run @($DOCKER_ARGS) lucassvaz/esp32-arduino-lib-builder

tools/docker/run.sh

+23-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
11
#!/usr/bin/env bash
22

3-
ARDUINO_DIR=${1:-$PWD/../}
3+
# This is an example of how to run the docker container.
4+
# This script is not part of the container, it is meant to be run on the host machine.
5+
# Usage: ./run.sh <path_to_arduino_esp32>
6+
7+
if ! [ -x "$(command -v docker)" ]; then
8+
echo "ERROR: Docker is not installed! Please install docker first."
9+
exit 1
10+
fi
11+
12+
if [ -n "$1" ]; then
13+
ARDUINO_DIR=$(realpath "$1")
14+
else
15+
ARDUINO_DIR=""
16+
fi
17+
418
DOCKER_ARGS=()
519

6-
ARDUINO_DIR=$(echo $(cd $ARDUINO_DIR; pwd))
720
DOCKER_ARGS+=(-it)
8-
DOCKER_ARGS+=(-v $ARDUINO_DIR:/arduino-esp32)
921
DOCKER_ARGS+=(-e TERM=xterm-256color)
10-
DOCKER_ARGS+=(-e HOST_UID=$UID)
22+
23+
if [ -d "$ARDUINO_DIR" ]; then
24+
DOCKER_ARGS+=(-v $ARDUINO_DIR:/arduino-esp32)
25+
else
26+
echo "Warning: Invalid arduino directory: '$ARDUINO_DIR'. Ignoring it."
27+
fi
1128

1229
if [ -n "$LIBBUILDER_GIT_SAFE_DIR" ]; then
1330
DOCKER_ARGS+=(-e LIBBUILDER_GIT_SAFE_DIR=$LIBBUILDER_GIT_SAFE_DIR)
1431
fi
1532

16-
echo "Running: docker run ${DOCKER_ARGS[@]} lucassvaz/esp32-arduino-lib-builder:latest"
17-
docker run ${DOCKER_ARGS[@]} lucassvaz/esp32-arduino-lib-builder:latest python3 tools/config_editor/app.py
33+
echo "Running: docker run ${DOCKER_ARGS[@]} lucassvaz/esp32-arduino-lib-builder"
34+
docker run ${DOCKER_ARGS[@]} lucassvaz/esp32-arduino-lib-builder

0 commit comments

Comments
 (0)