From 168a018b00b6581a2bcd10583393ecace877a838 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 30 Jan 2024 15:15:32 +0000 Subject: [PATCH] update firmwaremaker to use new pretokenisation --- bin/firmwaremaker_c.js | 27 +++++++++++++++++++++++---- core | 2 +- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/bin/firmwaremaker_c.js b/bin/firmwaremaker_c.js index bd1e1f564..b932f0b84 100755 --- a/bin/firmwaremaker_c.js +++ b/bin/firmwaremaker_c.js @@ -13,6 +13,7 @@ var path = require('path'); var fs = require("fs"); var ROOTDIR = path.join(__dirname, '..'); var OUTFILE, APPS; +var JSUTILS = path.join(ROOTDIR, '../Espruino/src/jsutils.h'); if (DEVICEID=="BANGLEJS") { var OUTFILE = path.join(ROOTDIR, '../Espruino/libs/banglejs/banglejs1_storage_default.c'); @@ -34,9 +35,18 @@ if (DEVICEID=="BANGLEJS") { } console.log("Device = ",DEVICEID); +// Search for version String +var VERSION = "2v10"; +var m = require("fs").readFileSync(JSUTILS).toString().match(/#define\s*JS_VERSION\s*([^\n]*)/); +if (m) { + VERSION = JSON.parse(m[1]); +} +console.log("Using version "+VERSION); + var apploader = require("../core/lib/apploader.js"); apploader.init({ - DEVICEID : DEVICEID + DEVICEID : DEVICEID, + VERSION : VERSION, }); @@ -79,11 +89,13 @@ var appfiles = []; // If file should be evaluated, try and do it... function evaluateFile(file) { + var content = file.content.trim(); var hsStart = 'require("heatshrink").decompress(atob("'; var hsEnd = '"))'; - if (file.content.startsWith(hsStart) && file.content.endsWith(hsEnd)) { + if (content.startsWith(hsStart) && content.endsWith(hsEnd)) { + console.log("heatshrink"); var heatshrink = require(ROOTDIR+"/webtools/heatshrink.js"); - var b64 = file.content.slice(hsStart.length, -hsEnd.length); + var b64 = content.slice(hsStart.length, -hsEnd.length); var decompressed = heatshrink.decompress(atob(b64)); file.content = ""; for (var i=0;i { files.forEach(f => { var existing = appfiles.find(a=> a.name==f.name); if (existing) { - if (existing.content !== f.content) + if (existing.content !== f.content) { + console.log("========================================="); + console.log(`Duplicate file ${f.name} is different`); + console.log("EXISTING", existing.content); + console.log("NEW", f.content); throw new Error(`Duplicate file ${f.name} is different`) + } } else { appfiles.push(f); } diff --git a/core b/core index bdcc79ac2..364b2c1b0 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit bdcc79ac2155b8eae6ce9ec4cc1065495e99ac8c +Subproject commit 364b2c1b00de17ffbbee87fb1d91e79b513b9127