From 52ca64edede27c080af42083795edac1de4498cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Thu, 21 Jun 2018 00:38:13 +0200 Subject: [PATCH] Clean up builder files --- code/build.sh | 5 --- code/gulpfile.js | 81 +++++++++++++++++++++++++----------------------- code/ota.py | 2 +- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/code/build.sh b/code/build.sh index 5b1fd86d..51fec76b 100755 --- a/code/build.sh +++ b/code/build.sh @@ -54,11 +54,6 @@ revision=${revision:0:7} cp espurna/config/version.h espurna/config/version.h.original sed -i -e "s/APP_REVISION \".*\"/APP_REVISION \"$revision\"/g" espurna/config/version.h -# Recreate web interface -echo "--------------------------------------------------------------" -echo "Building web interface..." -node node_modules/gulp/bin/gulp.js || exit - # Build all the required firmware images echo "--------------------------------------------------------------" echo "Building firmware images..." diff --git a/code/gulpfile.js b/code/gulpfile.js index 8ce50eea..d915d899 100644 --- a/code/gulpfile.js +++ b/code/gulpfile.js @@ -40,40 +40,56 @@ const csslint = require('gulp-csslint'); const crass = require('gulp-crass'); const replace = require('gulp-replace'); const remover = require('gulp-remove-code'); +const map = require('map-stream'); const dataFolder = 'espurna/data/'; const staticFolder = 'espurna/static/'; -var toHeader = function(filename) { +var buildHeaderFile = function() { - var source = dataFolder + filename; - var destination = staticFolder + filename + '.h'; - var safename = filename.split('.').join('_'); + String.prototype.replaceAll = function(search, replacement) { + var target = this; + return target.split(search).join(replacement); + }; - var wstream = fs.createWriteStream(destination); - wstream.on('error', function (err) { - log.error(err); - }); + return map(function(file, cb) { - var data = fs.readFileSync(source); + var parts = file.path.split("/"); + var filename = parts[parts.length - 1]; + var destination = staticFolder + filename + ".h"; + var safename = filename.replaceAll('.', '_'); - wstream.write('#define ' + safename + '_len ' + data.length + '\n'); - wstream.write('const uint8_t ' + safename + '[] PROGMEM = {'); + var wstream = fs.createWriteStream(destination); + wstream.on('error', function (err) { + log.error(err); + }); - for (var i=0; i 0) { @@ -92,8 +108,8 @@ var htmllintReporter = function(filepath, issues) { }; gulp.task('build_certs', function() { - toHeader('server.cer'); - toHeader('server.key'); + gulp.src(dataFolder + 'server.*'). + pipe(buildHeaderFile()); }); gulp.task('csslint', function() { @@ -103,7 +119,8 @@ gulp.task('csslint', function() { }); gulp.task('buildfs_embeded', ['buildfs_inline'], function() { - toHeader('index.html.gz'); + gulp.src(dataFolder + 'index.*'). + pipe(buildHeaderFile()); }); gulp.task('buildfs_inline', function() { @@ -126,7 +143,7 @@ gulp.task('buildfs_inline', function() { } } } - log.info("Modules: " + JSON.stringify(remover_config)); + log.info("Modules " + JSON.stringify(remover_config)); return gulp.src('html/*.html'). pipe(htmllint({ @@ -155,16 +172,4 @@ gulp.task('buildfs_inline', function() { pipe(gulp.dest(dataFolder)); }); - -gulp.task('test', function() { - return gulp.src('html/custom.js'). - pipe(remover({ - sensor: false, - light: false, - rfbridge: false - })). - pipe(gulp.dest('/home/xose/tmp/')); -}); - - gulp.task('default', ['buildfs_embeded']); diff --git a/code/ota.py b/code/ota.py index 8f9fc219..c1c72fba 100755 --- a/code/ota.py +++ b/code/ota.py @@ -230,7 +230,7 @@ def store(device, env): def run(device, env): print("Building and flashing image over-the-air...") - command = "ESPURNA_IP=\"%s\" ESPURNA_BOARD=\"%s\" ESPURNA_AUTH=\"%s\" ESPURNA_FLAGS=\"%s\" WEBUI_MODULES=\"%s\" platformio run --environment %s -t upload" + command = "ESPURNA_IP=\"%s\" ESPURNA_BOARD=\"%s\" ESPURNA_AUTH=\"%s\" ESPURNA_FLAGS=\"%s\" WEBUI_MODULES=\"%s\" platformio run --silent --environment %s -t upload" command = command % (device['ip'], device['board'], device['auth'], device['flags'], device['modules'], env) subprocess.check_call(command, shell=True) store(device, env)