-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrun.sh
executable file
·60 lines (52 loc) · 1.5 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
# Detect the operating system
OS=$(uname -s)
# Set the correct mpy-cross executable based on the OS
if [ "$OS" == "Linux" ]; then
MPY_EXEC="mpy-cross"
elif [ "$OS" == "Darwin" ]; then
MPY_EXEC="mpy-cross-macos"
elif [[ "$OS" == *_NT* ]]; then
MPY_EXEC="mpy-cross"
else
echo "Unsupported OS: $OS"
exit 1
fi
# Make the correct mpy-cross executable
if [[ ! "$OS" == *_NT* ]]; then
chmod +x build_tools/$MPY_EXEC
echo "$MPY_EXEC is now executable"
fi
# Detect the appropriate Python command
if command -v python3 &> /dev/null; then
PYTHON_CMD="python3"
elif command -v python &> /dev/null; then
PYTHON_CMD="python"
else
echo "Python is not installed or not found in PATH."
exit 1
fi
echo "Using Python command: $PYTHON_CMD"
export ARGUS_SIMULATION_FLAG=0
if [[ -z $1 ]]; then
$PYTHON_CMD build_tools/build.py
$PYTHON_CMD build_tools/move_to_board.py
elif [ "$1" == "emulate" ]; then
$PYTHON_CMD build_tools/build-emulator.py
cd build/ && $PYTHON_CMD main.py
cd -
elif [ "$1" == "emulate-profile" ]; then
$PYTHON_CMD build_tools/build-emulator.py
cd build/ && mprof run --python main.py
mprof plot -o output.png
cd -
elif [ "$1" == "simulate" ]; then
export ARGUS_SIMULATION_FLAG=1
echo "ARGUS_SIMULATION_FLAG set to 1 for simulation mode."
$PYTHON_CMD build_tools/build-emulator.py
cd build/ && $PYTHON_CMD main.py
cd -
else
$PYTHON_CMD build_tools/build.py
$PYTHON_CMD build_tools/move_to_board.py -d "$1"
fi