mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
Merge remote-tracking branch 'origin/v3.4' into dev
This commit is contained in:
24
scripts/build_interface.py
Executable file → Normal file
24
scripts/build_interface.py
Executable file → Normal file
@@ -1,11 +1,17 @@
|
||||
from pathlib import Path
|
||||
from shutil import copytree
|
||||
from shutil import rmtree
|
||||
from shutil import copytree, rmtree, copyfileobj
|
||||
from subprocess import check_output, Popen, PIPE, STDOUT, CalledProcessError
|
||||
from os import chdir
|
||||
import os
|
||||
import gzip
|
||||
|
||||
Import("env")
|
||||
|
||||
def gzipFile(file):
|
||||
with open(file, 'rb') as f_in:
|
||||
with gzip.open(file + '.gz', 'wb') as f_out:
|
||||
copyfileobj(f_in, f_out)
|
||||
os.remove(file)
|
||||
|
||||
def flagExists(flag):
|
||||
buildFlags = env.ParseFlags(env["BUILD_FLAGS"])
|
||||
for define in buildFlags.get("CPPDEFINES"):
|
||||
@@ -13,7 +19,7 @@ def flagExists(flag):
|
||||
return True
|
||||
|
||||
def buildWeb():
|
||||
chdir("interface")
|
||||
os.chdir("interface")
|
||||
print("Building interface with npm")
|
||||
try:
|
||||
env.Execute("npm install")
|
||||
@@ -22,10 +28,16 @@ def buildWeb():
|
||||
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)
|
||||
for currentpath, folders, files in os.walk(wwwPath):
|
||||
for file in files:
|
||||
gzipFile(os.path.join(currentpath, file))
|
||||
finally:
|
||||
chdir("..")
|
||||
os.chdir("..")
|
||||
|
||||
if (len(BUILD_TARGETS) == 0 or "upload" in BUILD_TARGETS):
|
||||
buildWeb()
|
||||
else:
|
||||
print("Skipping build interface step for target(s): " + ", ".join(BUILD_TARGETS))
|
||||
print("Skipping build interface step for target(s): " + ", ".join(BUILD_TARGETS))
|
||||
Reference in New Issue
Block a user