8000 Fix double build frozen (#102) · daq-tools/pycom-micropython@aae2981 · GitHub
[go: up one dir, main page]

Skip to content

Commit aae2981

Browse files
peter-pycomamotl
authored andcommitted
Fix double build frozen (pycom#102)
* fix double building of frozen Mpy the second build after a first (clean) build would rebuild the frozen Mpy. echo ${CURR_TS} > ${BUILD_TIMESTAMP} that doesn't work if the dir doesn't exist!
1 parent 93abd08 commit aae2981

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

esp32/tools/mpy-build-check.sh

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/bash
2+
# Check whether we should rebuild the frozen Micro Python code
3+
4+
set -e
25

36
BOARD="$1"
47
RELEASE_TYP="$2"
@@ -7,12 +10,12 @@ PY_PATH="./frozen"
710
PY_DIRS="$(ls ${PY_PATH})"
811
OS="$(uname)"
912
if [ ${VARIANT} != "BASE" ] ; then
10-
BUILD_DIR="build-${VARIANT}"
13+
BUILD_DIR="build-${VARIANT}/${BOARD}/${RELEASE_TYP}"
1114
else
12-
BUILD_DIR="build"
15+
BUILD_DIR="build/${BOARD}/${RELEASE_TYP}"
1316
fi
1417

15-
#Script Has to be called from esp32 Dir
18+
# Script has to be called from esp32 dir
1619
if ! [ $0 = "tools/mpy-build-check.sh" ]; then
1720
echo "Need to run as tools/mpy-build-check.sh!" >&2
1821
exit 1
@@ -24,32 +27,33 @@ if [ "${BOARD}" != "WIPY" -a "${BOARD}" != "SIPY" -a "${BOARD}" != "LOPY" -a "${
2427
exit 1
2528
fi
2629

27-
BUILD_TIMESTAMP=./"${BUILD_DIR}"/${BOARD}"/"${RELEASE_TYP}"/"mpy_last_build_timestamp.TS
28-
29-
#If Last mpy Build Timestamp Not avialable create it
30-
if [ ! -d ${BUILD_DIR}/${BOARD}/${RELEASE_TYP} ] ; then
31-
exit 0
32-
else
33-
if [ ! -f ${BUILD_TIMESTAMP} ] ; then
34-
$(touch ${BUILD_TIMESTAMP})
35-
fi
36-
fi
3730

38-
#Get Current Timestamp
31+
# Get current timestamp
3932
CURR_TS="$(date +"%s")"
4033

41-
MPY_PATH=./"${BUILD_DIR}"/"${BOARD}"/"${RELEASE_TYP}"/frozen_mpy
4234

35+
BUILD_TIMESTAMP="${BUILD_DIR}/mpy_last_build_timestamp.TS"
36+
37+
38+
MPY_PATH="${BUILD_DIR}/frozen_mpy"
4339
if ! [ -d ${MPY_PATH} ] ; then
44-
#Build Directory not created yet
45-
#Update Last Build Timestamp
46-
$(echo ${CURR_TS} > ${BUILD_TIMESTAMP})
40+
# Build directory does not exist
41+
# Update last build timestamp
42+
mkdir -p ${BUILD_DIR}
43+
echo ${CURR_TS} > ${BUILD_TIMESTAMP}
4744
exit 0
4845
fi
4946

50-
LAST_BUILD=$(<${BUILD_TIMESTAMP})
5147

52-
#Check if any of Frozen Directorys has been updated.. Rebuild out Mpy files
48+
# Get last build timestamp
49+
if [ ! -f ${BUILD_TIMESTAMP} ] ; then
50+
LAST_BUILD=0
51+
else
52+
LAST_BUILD=$(<${BUILD_TIMESTAMP})
53+
fi
54+
55+
56+
# Remove Mpy build directory if any of the frozen directories have been updated
5357
for dir in ${PY_DIRS}
5458
do
5559
if [[ "${dir}" =~ ^\\.* ]] ; then
@@ -65,14 +69,14 @@ do
6569

6670
if [[ ${TS} -gt ${LAST_BUILD} ]] ; then
6771
echo "Rebuilding frozen Code!" >&2
68-
#Remove all MPY out files to be rubuild again by Makefile
69-
$(rm -rf ${MPY_PATH})
70-
#Update Last Build Timestamp
71-
$(echo ${CURR_TS} > ${BUILD_TIMESTAMP})
72+
# Remove the build directory to trigger a rebuild from the Makefile
73+
rm -rf ${MPY_PATH}
74+
# Update last build timestamp
75+
echo ${CURR_TS} > ${BUILD_TIMESTAMP}
7276
exit 0
7377
fi
7478
done
7579

76-
#Update Last Build Timestamp
77-
$(echo ${CURR_TS} > ${BUILD_TIMESTAMP})
80+
# Update last build timestamp
81+
echo ${CURR_TS} > ${BUILD_TIMESTAMP}
7882
exit 0

0 commit comments

Comments
 (0)
0