From 77771aa807bce97e37968bf43d89a601e2602c5b Mon Sep 17 00:00:00 2001 From: Rick Watson Date: Sun, 14 Jul 2019 22:14:22 +0100 Subject: [PATCH] add fix for latest platformio build changes --- .gitignore | 1 + timelib_fix.py | 31 ++++++++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 765844d..cc9b44a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.pio .pioenvs .piolibdeps .clang_complete diff --git a/timelib_fix.py b/timelib_fix.py index 84c0ec1..aa7233f 100644 --- a/timelib_fix.py +++ b/timelib_fix.py @@ -15,17 +15,22 @@ def findSubDirectoryFiles(root, subDirectoryPattern, fileName): result.append(candidateFile) return result -# lib deps directory -libDepsDir = os.path.join(env.subst('$PROJECT_DIR'), '.piolibdeps') -timeHeaderFile = "Time.h" -timeLibDirectoryPattern = "Time(_ID[0-9]+)?" +def deleteTimeHeader(libDepsDir): + timeHeaderFile = "Time.h" + timeLibDirectoryPattern = "Time(_ID[0-9]+)?" -# delete the file, as long as we only find one -if os.path.isdir(libDepsDir) : - deletionCandidates = findSubDirectoryFiles(libDepsDir, timeLibDirectoryPattern, timeHeaderFile) - numDeletionCandidates = len(deletionCandidates) - if numDeletionCandidates == 1: - os.remove(deletionCandidates[0]) - elif numDeletionCandidates > 1: - os.write(2, 'Can\'t delete Time.h, more than one instance found:\n' + '\n'.join(deletionCandidates)) - sys.exit(1) + # delete the file, as long as we only find one + if os.path.isdir(libDepsDir) : + deletionCandidates = findSubDirectoryFiles(libDepsDir, timeLibDirectoryPattern, timeHeaderFile) + numDeletionCandidates = len(deletionCandidates) + if numDeletionCandidates == 1: + os.remove(deletionCandidates[0]) + elif numDeletionCandidates > 1: + os.write(2, 'Can\'t delete Time.h, more than one instance found:\n' + '\n'.join(deletionCandidates)) + sys.exit(1) + +# old lib deps directory +deleteTimeHeader(os.path.join(env.subst('$PROJECT_DIR'), '.piolibdeps')) + +# new lib deps directory +deleteTimeHeader(os.path.join(env.subst('$PROJECTLIBDEPS_DIR'), env.subst('$PIOENV')))