Merge branch 'master' into ft_user_security

This commit is contained in:
Rick Watson 2019-06-02 16:07:23 +01:00
commit 9da0888d7d
2 changed files with 33 additions and 0 deletions

View File

@ -12,6 +12,8 @@
platform = espressif32
board = node32s
extra_scripts = pre:timelib_fix.py
framework = arduino
monitor_speed = 115200

31
timelib_fix.py Normal file
View File

@ -0,0 +1,31 @@
import os
import sys
import re
Import("env")
# Find files under 'root' of a given 'fileName' in directories matching 'subDirectoryPattern'
# This will allow us to safely find the offending Time.h file for removal prior to building
def findSubDirectoryFiles(root, subDirectoryPattern, fileName):
subDirectories = os.listdir(root)
subDirectories = filter(lambda d: re.match(subDirectoryPattern, d), subDirectories)
result = []
for subDirectory in subDirectories:
candidateFile = os.path.join(root, subDirectory, fileName)
if os.path.isfile(candidateFile):
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]+)?"
# 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)