.build_web.py 790 B

1234567891011121314151617181920212223242526272829303132
  1. from shutil import copyfile
  2. from subprocess import check_output
  3. import sys
  4. import os
  5. import platform
  6. import subprocess
  7. Import("env")
  8. def is_tool(name):
  9. cmd = "where" if platform.system() == "Windows" else "which"
  10. try:
  11. check_output([cmd, name])
  12. return True
  13. except:
  14. return False;
  15. if is_tool("npm"):
  16. os.chdir("web")
  17. print("Attempting to build webpage...")
  18. try:
  19. print check_output(["npm", "install"])
  20. print check_output(["node_modules/.bin/gulp"])
  21. copyfile("build/index.html.gz.h", "../dist/index.html.gz.h")
  22. except Exception as e:
  23. print "Encountered error building webpage: ", e
  24. print "WARNING: Failed to build web package. Using pre-built page."
  25. pass
  26. finally:
  27. os.chdir("..");