Skip to content

Commit

Permalink
Merge pull request #102 from sidoh/embedded_web
Browse files Browse the repository at this point in the history
Embed website in firmware rather than storing it separately in SPIFFS
  • Loading branch information
sidoh authored Jul 24, 2017
2 parents cc0b0ea + a5aeed9 commit 36a3432
Show file tree
Hide file tree
Showing 34 changed files with 1,247 additions and 3,092 deletions.
34 changes: 34 additions & 0 deletions .build_web.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from shutil import copyfile
from subprocess import check_output
import sys
import os
import platform
import subprocess

Import("env")

def is_tool(name):
cmd = "where" if platform.system() == "Windows" else "which"
try:
check_output([cmd, name])
return True
except:
return False;

def pre_build(source, target, env):
if is_tool("npm"):
os.chdir("web")
print("Attempting to build webpage...")
try:
print check_output(["npm", "install"])
print check_output(["node_modules/.bin/gulp"])
copyfile("build/index.html.gz.h", "../dist/index.html.gz.h")

except Exception as e:
print "Encountered error building webpage: ", e
print "WARNING: Failed to build web package. Using pre-built page."
pass
finally:
os.chdir("..");

env.Execute(pre_build)
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.piolibdeps
.clang_complete
.gcc-flags.json
/dist
/web/node_modules
/web/build
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ sudo: false
cache:
directories:
- "~/.platformio"
env:
- NODE_VERSION="6"
before_install:
- nvm install $NODE_VERSION
install:
- pip install -U platformio
- platformio lib install
- cd web && npm install && cd ..
script:
- platformio run
before_deploy:
Expand Down
Loading

0 comments on commit 36a3432

Please sign in to comment.