1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-27 14:29:39 +00:00

return unchanged if linker result is same

This commit is contained in:
Steven Hugg 2018-06-27 21:26:23 -06:00
parent 2f2e469110
commit 0ca98f5e7f
3 changed files with 31 additions and 13 deletions

View File

@ -91,6 +91,7 @@ window methods:
- global symbols - global symbols
- pixel editor / find comment (openBitmapEditorAtCursor) - pixel editor / find comment (openBitmapEditorAtCursor)
- update debug window (200 ms) - update debug window (200 ms)
- inspect variable
file store mirrors that on worker file store mirrors that on worker

View File

@ -6,7 +6,6 @@ function installErrorHandler() {
window.onerror = function (msgevent, url, line, col, error) { window.onerror = function (msgevent, url, line, col, error) {
console.log(msgevent, url, line, col); console.log(msgevent, url, line, col);
console.log(error); console.log(error);
//$("#editor").hide();
if (window.location.host.endsWith('8bitworkshop.com')) { if (window.location.host.endsWith('8bitworkshop.com')) {
ga('send', 'exception', { ga('send', 'exception', {
'exDescription': msgevent + " " + url + " " + " " + line + ":" + col + ", " + error, 'exDescription': msgevent + " " + url + " " + " " + line + ":" + col + ", " + error,
@ -388,12 +387,6 @@ function updateSelector() {
sel.off('change').change(function(e) { sel.off('change').change(function(e) {
gotoPresetNamed($(this).val()); gotoPresetNamed($(this).val());
}); });
$("#preset_prev").off('click').click(function() {
gotoPresetAt(current_preset_index - 1);
});
$("#preset_next").off('click').click(function() {
gotoPresetAt(current_preset_index + 1);
});
} }
function loadFileDependencies(text, callback) { function loadFileDependencies(text, callback) {
@ -493,6 +486,7 @@ function setCompileOutput(data) {
current_output = null; current_output = null;
} else { } else {
// load ROM // load ROM
// TODO: don't have to compare anymore; worker does it
var rom = data.output; var rom = data.output;
var rom_changed = false; var rom_changed = false;
if (rom && rom.code) if (rom && rom.code)
@ -1256,6 +1250,7 @@ var qs = (function (a) {
return b; return b;
})(window.location.search.substr(1).split('&')); })(window.location.search.substr(1).split('&'));
// TODO: what if multiple files/tools?
function preloadWorker(fileid) { function preloadWorker(fileid) {
var tool = platform.getToolForFilename(fileid); var tool = platform.getToolForFilename(fileid);
if (tool) worker.postMessage({preload:tool, platform:platform_id}); if (tool) worker.postMessage({preload:tool, platform:platform_id});

View File

@ -131,8 +131,9 @@ function endtime(msg) { _t2 = new Date(); console.log(msg, _t2.getTime() - _t1.g
/// working file store and build steps /// working file store and build steps
var buildsteps = []; var buildsteps = [];
var buildstartseq = 0;
var workfs = {}; var workfs = {};
var workerseq = 1; var workerseq = 0;
function compareData(a,b) { function compareData(a,b) {
if (a.length != b.length) return false; if (a.length != b.length) return false;
@ -151,12 +152,23 @@ function putWorkFile(path, data) {
var encoding = (typeof data === 'string') ? 'utf8' : 'binary'; var encoding = (typeof data === 'string') ? 'utf8' : 'binary';
var entry = workfs[path]; var entry = workfs[path];
if (!entry || !compareData(entry.data, data) || entry.encoding != encoding) { if (!entry || !compareData(entry.data, data) || entry.encoding != encoding) {
workfs[path] = entry = {path:path, data:data, encoding:encoding, ts:workerseq++}; workfs[path] = entry = {path:path, data:data, encoding:encoding, ts:++workerseq};
console.log('+++', entry.path, entry.encoding, entry.data.length, entry.ts); console.log('+++', entry.path, entry.encoding, entry.data.length, entry.ts);
} }
return entry; return entry;
} }
// returns true if file changed during this build step
function wasChanged(entry) {
return entry.ts > buildstartseq;
}
/*function anyFilesChanged() {
for (var key in workfs)
if (wasChanged(workfs[key])) return true;
return false;
}*/
function populateEntry(fs, path, entry) { function populateEntry(fs, path, entry) {
fs.writeFile(path, entry.data, {encoding:entry.encoding}); fs.writeFile(path, entry.data, {encoding:entry.encoding});
fs.utime(path, entry.ts, entry.ts); fs.utime(path, entry.ts, entry.ts);
@ -207,6 +219,7 @@ function populateFiles(step, fs, options) {
function staleFiles(step, targets) { function staleFiles(step, targets) {
if (!step.maxts) throw "call populateFiles() first"; if (!step.maxts) throw "call populateFiles() first";
// see if any target files are more recent than inputs
for (var i=0; i<targets.length; i++) { for (var i=0; i<targets.length; i++) {
var entry = workfs[targets[i]]; var entry = workfs[targets[i]];
if (!entry || step.maxts > entry.ts) if (!entry || step.maxts > entry.ts)
@ -606,6 +619,12 @@ function linkLD65(step) {
var aout = FS.readFile("main", {encoding:'binary'}); var aout = FS.readFile("main", {encoding:'binary'});
var mapout = FS.readFile("main.map", {encoding:'utf8'}); var mapout = FS.readFile("main.map", {encoding:'utf8'});
var viceout = FS.readFile("main.vice", {encoding:'utf8'}); var viceout = FS.readFile("main.vice", {encoding:'utf8'});
putWorkFile("main", aout);
putWorkFile("main.map", mapout);
putWorkFile("main.vice", viceout);
// return unchanged if no files changed
if (!staleFiles(step, ["main", "main.map", "main.vice"]))
return;
// parse symbol map (TODO: omit segments, constants) // parse symbol map (TODO: omit segments, constants)
var symbolmap = {}; var symbolmap = {};
for (var s of viceout.split("\n")) { for (var s of viceout.split("\n")) {
@ -629,9 +648,6 @@ function linkLD65(step) {
}; };
} }
} }
putWorkFile("main", aout);
putWorkFile("main.map", mapout);
putWorkFile("main.vice", viceout);
return { return {
output:aout, //.slice(0), output:aout, //.slice(0),
listings:listings, listings:listings,
@ -811,6 +827,12 @@ function linkSDLDZ80(step)
execMain(step, LDZ80, args); execMain(step, LDZ80, args);
var hexout = FS.readFile("main.ihx", {encoding:'utf8'}); var hexout = FS.readFile("main.ihx", {encoding:'utf8'});
var mapout = FS.readFile("main.noi", {encoding:'utf8'}); var mapout = FS.readFile("main.noi", {encoding:'utf8'});
putWorkFile("main.ihx", hexout);
putWorkFile("main.noi", mapout);
// return unchanged if no files changed
if (!staleFiles(step, ["main.ihx", "main.noi"]))
return;
var listings = {}; var listings = {};
for (var fn of step.files) { for (var fn of step.files) {
if (fn.endsWith('.lst')) { if (fn.endsWith('.lst')) {
@ -834,7 +856,6 @@ function linkSDLDZ80(step)
symbolmap[toks[1]] = parseInt(toks[2], 16); symbolmap[toks[1]] = parseInt(toks[2], 16);
} }
} }
putWorkFile("main.ihx", hexout);
return { return {
output:parseIHX(hexout, params.rom_start?params.rom_start:params.code_start, params.rom_size), output:parseIHX(hexout, params.rom_start?params.rom_start:params.code_start, params.rom_size),
listings:listings, listings:listings,
@ -1218,6 +1239,7 @@ var TOOL_PRELOADFS = {
} }
function executeBuildSteps() { function executeBuildSteps() {
buildstartseq = workerseq;
while (buildsteps.length) { while (buildsteps.length) {
var step = buildsteps.shift(); // get top of array var step = buildsteps.shift(); // get top of array
var code = step.code; var code = step.code;