1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2025-01-11 08:30:02 +00:00

refactoring; fixed unchanged targets

This commit is contained in:
Steven Hugg 2018-06-27 22:57:06 -06:00
parent 4772f80e50
commit 03bf70041d
3 changed files with 44 additions and 32 deletions

View File

@ -34,9 +34,6 @@ if (window.Javatari) Javatari.AUTO_START = false;
var PRESETS; // presets array var PRESETS; // presets array
var platform_id; var platform_id;
var platform; // platform object var platform; // platform object
var originalFileID;
var originalText;
var userPaused;
var toolbar = $("#controls_top"); var toolbar = $("#controls_top");
@ -80,6 +77,19 @@ var TOOL_TO_SOURCE_STYLE = {
} }
var worker = new Worker("./src/worker/workermain.js"); var worker = new Worker("./src/worker/workermain.js");
var disasmview = CodeMirror(document.getElementById('disassembly'), {
mode: 'z80',
theme: 'cobalt',
tabSize: 8,
readOnly: true,
styleActiveLine: true
});
var originalFileID;
var originalText;
var userPaused;
var editor; var editor;
var current_output; var current_output;
var current_preset_entry; var current_preset_entry;
@ -92,13 +102,6 @@ var compparams;
var trace_pending_at_pc; var trace_pending_at_pc;
var store; var store;
var pendingWorkerMessages = 0; var pendingWorkerMessages = 0;
var disasmview = CodeMirror(document.getElementById('disassembly'), {
mode: 'z80',
theme: 'cobalt',
tabSize: 8,
readOnly: true,
styleActiveLine: true
});
//scrollProfileView(disasmview); //scrollProfileView(disasmview);
var currentDebugLine; var currentDebugLine;
@ -107,7 +110,15 @@ var lastDebugState;
var memorylist; var memorylist;
function deleteEditor() {
if (editor) {
$("#editor").empty();
editor = null;
}
}
function newEditor(mode) { function newEditor(mode) {
deleteEditor();
var isAsm = mode=='6502' || mode =='z80' || mode=='verilog' || mode=='gas'; // TODO var isAsm = mode=='6502' || mode =='z80' || mode=='verilog' || mode=='gas'; // TODO
editor = CodeMirror(document.getElementById('editor'), { editor = CodeMirror(document.getElementById('editor'), {
theme: 'mbo', theme: 'mbo',
@ -188,8 +199,8 @@ function loadFile(fileid, filename, preset) {
if (text) { if (text) {
loadCode(text, fileid); loadCode(text, fileid);
} else if (!text && preset) { } else if (!text && preset) {
if (filename.indexOf('.') <= 0) if (platform_id == 'vcs' && filename.indexOf('.') <= 0)
filename += ".a"; // TODO? filename += ".a"; // legacy stuff
console.log("Loading preset", fileid, filename, preset); console.log("Loading preset", fileid, filename, preset);
if (text.length == 0) { if (text.length == 0) {
console.log("Fetching", filename); console.log("Fetching", filename);
@ -215,9 +226,10 @@ function loadFile(fileid, filename, preset) {
}); });
} }
// can pass integer or string id
function loadPreset(preset_id) { function loadPreset(preset_id) {
// TODO preloadWorker(preset_id); // TODO: what if multiple files
var index = parseInt(preset_id+""); var index = parseInt(preset_id+""); // might fail -1
for (var i=0; i<PRESETS.length; i++) for (var i=0; i<PRESETS.length; i++)
if (PRESETS[i].id == preset_id) if (PRESETS[i].id == preset_id)
index = i; index = i;
@ -231,13 +243,7 @@ function loadPreset(preset_id) {
} }
} }
function gotoPresetAt(index) { function reloadPresetNamed(id) {
var index = (index + PRESETS.length) % PRESETS.length;
qs['file'] = PRESETS[index].id;
gotoNewLocation();
}
function gotoPresetNamed(id) {
qs['platform'] = platform_id; qs['platform'] = platform_id;
qs['file'] = id; qs['file'] = id;
gotoNewLocation(); gotoNewLocation();
@ -385,7 +391,7 @@ function updateSelector() {
populateExamples(sel); populateExamples(sel);
// set click handlers // set click handlers
sel.off('change').change(function(e) { sel.off('change').change(function(e) {
gotoPresetNamed($(this).val()); reloadPresetNamed($(this).val());
}); });
} }
@ -1299,7 +1305,6 @@ function startPlatform() {
PRESETS = platform.getPresets(); PRESETS = platform.getPresets();
if (qs['file']) { if (qs['file']) {
// start platform and load file // start platform and load file
preloadWorker(qs['file']);
platform.start(); platform.start();
setupDebugControls(); setupDebugControls();
loadPreset(qs['file']); loadPreset(qs['file']);
@ -1311,7 +1316,7 @@ function startPlatform() {
// try to load last file (redirect) // try to load last file (redirect)
var lastid = localStorage.getItem("__lastid_"+platform_id) || localStorage.getItem("__lastid"); var lastid = localStorage.getItem("__lastid_"+platform_id) || localStorage.getItem("__lastid");
localStorage.removeItem("__lastid"); localStorage.removeItem("__lastid");
gotoPresetNamed(lastid || PRESETS[0].id); reloadPresetNamed(lastid || PRESETS[0].id);
return false; return false;
} }
} }

View File

@ -163,12 +163,6 @@ function wasChanged(entry) {
return entry.ts > buildstartseq; 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);
@ -229,6 +223,18 @@ function staleFiles(step, targets) {
return false; return false;
} }
function anyTargetChanged(step, targets) {
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++) {
var entry = workfs[targets[i]];
if (!entry || entry.ts > step.maxts)
return true;
}
console.log("unchanged", step.maxts, targets);
return false;
}
function execMain(step, mod, args) { function execMain(step, mod, args) {
starttime(); starttime();
mod.callMain(args); mod.callMain(args);
@ -623,7 +629,7 @@ function linkLD65(step) {
putWorkFile("main.map", mapout); putWorkFile("main.map", mapout);
putWorkFile("main.vice", viceout); putWorkFile("main.vice", viceout);
// return unchanged if no files changed // return unchanged if no files changed
if (!staleFiles(step, ["main", "main.map", "main.vice"])) if (!anyTargetChanged(step, ["main", "main.map", "main.vice"]))
return; return;
// parse symbol map (TODO: omit segments, constants) // parse symbol map (TODO: omit segments, constants)
var symbolmap = {}; var symbolmap = {};
@ -830,7 +836,7 @@ function linkSDLDZ80(step)
putWorkFile("main.ihx", hexout); putWorkFile("main.ihx", hexout);
putWorkFile("main.noi", mapout); putWorkFile("main.noi", mapout);
// return unchanged if no files changed // return unchanged if no files changed
if (!staleFiles(step, ["main.ihx", "main.noi"])) if (!anyTargetChanged(step, ["main.ihx", "main.noi"]))
return; return;
var listings = {}; var listings = {};

View File

@ -165,6 +165,7 @@ describe('Worker', function() {
]; ];
doBuild(msgs, done, 8192, [1,1], 0); doBuild(msgs, done, 8192, [1,1], 0);
}); });
// TODO: doesn't fail
it('should not build unchanged files with CC65', function(done) { it('should not build unchanged files with CC65', function(done) {
var m = { var m = {
"updates":[ "updates":[