WordClockESP/scripts/build_interface.py
rjwats ced5b74ba1
NTP Timezone & Enable/Disable Setting (#80)
* quick and dirty WIP to investigate timezones, currently only building under esp8266 platform
much of the status stuff has been stripped for now, to test the concepts

* support set of common features across ESP32/ESP8266 WRT timezone and sntp
return dates as ISO format strings

* remove time library, and timelib fix which is no longer required

* fix the icons

* remove temporary changes to demo project
2020-01-20 11:14:46 +00:00

35 lines
1.1 KiB
Python

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))