Skip to content

Commit b4c1624

Browse files
committed
Fix env_setup.sh script for use on windows.
1 parent bc6d0e0 commit b4c1624

File tree

3 files changed

+65
-14
lines changed

3 files changed

+65
-14
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
.cache
33

44
# Python virtualenv
5-
.pyenv
5+
.venv
66

77
# Prerequisites
88
*.d

tools/env_setup.sh

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,75 @@
11
#!/bin/bash
2+
#
3+
# FreeRTOS STM32 Reference Integration
4+
#
5+
# Copyright (C) 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
8+
# this software and associated documentation files (the "Software"), to deal in
9+
# the Software without restriction, including without limitation the rights to
10+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11+
# the Software, and to permit persons to whom the Software is furnished to do so,
12+
# subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23+
#
24+
# https://www.FreeRTOS.org
25+
# https://github.com/FreeRTOS
26+
#
27+
#
28+
if [ -n "${BASH_SOURCE[0]}" ]; then
29+
TOOLS_PATH=$( realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")" || return; pwd )" )
30+
else
31+
TOOLS_PATH=$( realpath "$(cd "$(dirname "${0}")" || return; pwd )" )
32+
fi
33+
echo "TOOLS_PATH: ${TOOLS_PATH}"
234

3-
which python3 || alias python3=python
35+
VENV_PATH=$(realpath "${TOOLS_PATH}/..")/.venv
36+
echo "VENV_PATH: ${VENV_PATH}"
37+
echo
38+
39+
which python > /dev/null 2>&1 || alias python=python3
40+
which python > /dev/null 2>&1 || {
41+
echo "Failed to find a validate python installation."
42+
return 1
43+
}
444

545
load_venv()
646
{
7-
if [ -e ${PWD}/.venv/Scripts ]; then
8-
source ${PWD}/.venv/Scripts/activate
9-
elif [ -e ${PWD}/.venv/bin ]; then
10-
source ${PWD}/.venv/bin/activate
47+
if [ -e "${VENV_PATH}"/Scripts ]; then
48+
source "${VENV_PATH}"/Scripts/activate
49+
elif [ -e "${VENV_PATH}"/bin ]; then
50+
source "${VENV_PATH}"/bin/activate
1151
else
1252
echo "Error. Could not find python virtual environment activation script."
13-
exit -1
53+
return 1
1454
fi
55+
56+
echo "Adding tools directory to path."
57+
export PATH="${TOOLS_PATH}:${PATH}"
1558
}
1659

17-
[ -e ${PWD}/.venv ] || {
60+
if [ ! -d "${VENV_PATH}" ]; then
1861
echo "Setting up python virtual environment"
19-
python3 -m virtualenv ${PWD}/.venv || exit -1
20-
load_venv || exit -1
21-
pip3 install -r $(dirname "$0")/requirements.txt || rm -rf ${PWD}/.venv
22-
}
62+
python -m virtualenv "${VENV_PATH}" || return 1
63+
64+
echo "Activating vritual environment."
65+
load_venv || return 1
2366

24-
load_venv || exit -1
67+
pip3 install -r "${TOOLS_PATH}"/requirements.txt || {
68+
rm -rf "${VENV_PATH}"
69+
echo "Error while installing requried python packages. Removing incomplete virtual environment."
70+
return 1
71+
}
72+
else
73+
load_venv || return 1
74+
fi
75+
echo "Done."

tools/provision.py

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!python3
1+
#!python
22
#
33
# FreeRTOS STM32 Reference Integration
44
#

0 commit comments

Comments
 (0)