Interface data storage in PROGMEM (#71)
Adds a webpack plugin to package interface as PROGMEM into a header file in the framework. Adds a build flag to optionally enable serving from PROGMEM or SPIFFS as required Adds documentation changes to describe changes
This commit is contained in:
36
scripts/build_interface.py
Normal file
36
scripts/build_interface.py
Normal file
@ -0,0 +1,36 @@
|
||||
from pathlib import Path
|
||||
from shutil import copytree
|
||||
from shutil import rmtree
|
||||
from subprocess import check_output, Popen, PIPE, STDOUT, CalledProcessError
|
||||
from os import chdir
|
||||
|
||||
Import("env")
|
||||
|
||||
def flagExists(flag):
|
||||
buildFlags = env.ParseFlags(env["BUILD_FLAGS"])
|
||||
for define in buildFlags.get("CPPDEFINES"):
|
||||
if (define == flag or (isinstance(define, list) and define[0] == flag)):
|
||||
return True
|
||||
|
||||
def buildWeb():
|
||||
chdir("interface")
|
||||
print("Building interface with npm")
|
||||
try:
|
||||
env.Execute("npm install")
|
||||
env.Execute("npm run build")
|
||||
buildPath = Path("build")
|
||||
wwwPath = Path("../data/www")
|
||||
if wwwPath.exists() and wwwPath.is_dir():
|
||||
rmtree(wwwPath)
|
||||
if not flagExists("PROGMEM_WWW"):
|
||||
print("Copying interface to data directory")
|
||||
copytree(buildPath, wwwPath)
|
||||
finally:
|
||||
chdir("..")
|
||||
|
||||
if (len(BUILD_TARGETS) == 0 or "upload" in BUILD_TARGETS):
|
||||
buildWeb()
|
||||
else:
|
||||
print("Skipping build interface step for target(s): " + ", ".join(BUILD_TARGETS))
|
||||
|
||||
|
40
scripts/timelib_fix.py
Normal file
40
scripts/timelib_fix.py
Normal file
@ -0,0 +1,40 @@
|
||||
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
|
||||
|
||||
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)
|
||||
|
||||
# old lib deps directory
|
||||
deleteTimeHeader(os.path.join(env.subst("$PROJECT_DIR"), ".piolibdeps"))
|
||||
|
||||
# pre 4.x lib deps directory
|
||||
deleteTimeHeader(os.path.join(env.subst("$PROJECTLIBDEPS_DIR"), env.subst("$PIOENV")))
|
||||
|
||||
# >4.x lib deps directory
|
||||
deleteTimeHeader(os.path.join(env.subst("$PROJECT_LIBDEPS_DIR"), env.subst("$PIOENV")))
|
Reference in New Issue
Block a user