Browse Source

Clean up builder files

pull/963/head
Xose Pérez 6 years ago
parent
commit
52ca64eded
3 changed files with 44 additions and 44 deletions
  1. +0
    -5
      code/build.sh
  2. +43
    -38
      code/gulpfile.js
  3. +1
    -1
      code/ota.py

+ 0
- 5
code/build.sh View File

@ -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..."


+ 43
- 38
code/gulpfile.js View File

@ -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<data.length; i++) {
if (0 === (i % 20)) {
wstream.write('\n');
}
wstream.write('0x' + ('00' + data[i].toString(16)).slice(-2));
if (i < (data.length - 1)) {
wstream.write(',');
var data = fs.readFileSync(file.path);
wstream.write('#define ' + safename + '_len ' + data.length + '\n');
wstream.write('const uint8_t ' + safename + '[] PROGMEM = {');
for (var i=0; i<data.length; i++) {
if (0 === (i % 20)) {
wstream.write('\n');
}
wstream.write('0x' + ('00' + data[i].toString(16)).slice(-2));
if (i < (data.length - 1)) {
wstream.write(',');
}
}
}
wstream.write('\n};');
wstream.end();
wstream.write('\n};');
wstream.end();
};
var fstat = fs.statSync(file.path);
log("Created '" + filename + "' size: " + fstat.size + " bytes");
cb(0, destination);
});
}
var htmllintReporter = function(filepath, issues) {
if (issues.length > 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']);

+ 1
- 1
code/ota.py View File

@ -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)


Loading…
Cancel
Save