Fork of the excellent esp8266-react - https://github.com/rjwats/esp8266-react
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

  1. from pathlib import Path
  2. from shutil import copytree
  3. from shutil import rmtree
  4. from subprocess import check_output, Popen, PIPE, STDOUT, CalledProcessError
  5. from os import chdir
  6. Import("env")
  7. def flagExists(flag):
  8. buildFlags = env.ParseFlags(env["BUILD_FLAGS"])
  9. for define in buildFlags.get("CPPDEFINES"):
  10. if (define == flag or (isinstance(define, list) and define[0] == flag)):
  11. return True
  12. def buildWeb():
  13. chdir("interface")
  14. print("Building interface with npm")
  15. try:
  16. env.Execute("npm install")
  17. env.Execute("npm run build")
  18. buildPath = Path("build")
  19. wwwPath = Path("../data/www")
  20. if wwwPath.exists() and wwwPath.is_dir():
  21. rmtree(wwwPath)
  22. if not flagExists("PROGMEM_WWW"):
  23. print("Copying interface to data directory")
  24. copytree(buildPath, wwwPath)
  25. finally:
  26. chdir("..")
  27. if (len(BUILD_TARGETS) == 0 or "upload" in BUILD_TARGETS):
  28. buildWeb()
  29. else:
  30. print("Skipping build interface step for target(s): " + ", ".join(BUILD_TARGETS))