mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2026-04-20 15:16:38 +00:00
Deploying to gh-pages from @ sehugg/8bitworkshop@312cb3d025 🚀
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LibRetroRunner = void 0;
|
||||
const wasishim_1 = require("./wasishim");
|
||||
class LibRetroRunner extends wasishim_1.WASIRunner {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
getEnv() {
|
||||
return Object.assign(Object.assign({}, super.getEnv()), { retro_environment_callback: (cmd, data) => {
|
||||
console.log(`retro_environment_callback: ${cmd}, ${data}`);
|
||||
return 0;
|
||||
}, retro_video_refresh_callback: (data, width, height, pitch) => {
|
||||
console.log(`retro_video_refresh_callback: ${data}, ${width}, ${height}, ${pitch}`);
|
||||
}, retro_audio_sample_batch_callback: (data, frames) => {
|
||||
console.log(`retro_audio_sample_batch_callback: ${data}, ${frames}`);
|
||||
}, retro_audio_sample_callback: (left, right) => {
|
||||
console.log(`retro_audio_sample_callback: ${left}, ${right}`);
|
||||
return 0;
|
||||
}, retro_input_poll_callback: () => {
|
||||
console.log(`retro_input_poll_callback`);
|
||||
}, retro_input_state_callback: (port, device, index, id) => {
|
||||
console.log(`retro_input_state_callback: ${port}, ${device}, ${index}, ${id}`);
|
||||
return 0;
|
||||
} });
|
||||
}
|
||||
retro_init() {
|
||||
let errno = this.initialize();
|
||||
// TODO: if (errno) throw new Error(`retro_init failed: ${errno}`);
|
||||
this.exports().retro_init_callbacks();
|
||||
this.exports().retro_init();
|
||||
this.exports().retro_set_controller_port_device(0, 1);
|
||||
this.exports().retro_set_controller_port_device(1, 1);
|
||||
}
|
||||
retro_api_version() {
|
||||
return this.exports().retro_api_version();
|
||||
}
|
||||
load_rom(path, data) {
|
||||
const meta = '';
|
||||
this.exports().retro_load_rom(path, data, data.length, meta);
|
||||
}
|
||||
reset() {
|
||||
this.exports().retro_reset();
|
||||
}
|
||||
advance() {
|
||||
this.exports().retro_run();
|
||||
}
|
||||
}
|
||||
exports.LibRetroRunner = LibRetroRunner;
|
||||
//# sourceMappingURL=libretro.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"libretro.js","sourceRoot":"","sources":["../../../src/common/wasi/libretro.ts"],"names":[],"mappings":";;;AAAA,yCAAwC;AAExC,MAAa,cAAe,SAAQ,qBAAU;IAC1C;QACI,KAAK,EAAE,CAAC;IACZ,CAAC;IACD,MAAM;QACF,uCACO,KAAK,CAAC,MAAM,EAAE,KACjB,0BAA0B,EAAE,CAAC,GAAW,EAAE,IAAY,EAAE,EAAE;gBACtD,OAAO,CAAC,GAAG,CAAC,+BAA+B,GAAG,KAAK,IAAI,EAAE,CAAC,CAAC;gBAC3D,OAAO,CAAC,CAAC;YACb,CAAC,EACD,4BAA4B,EAAE,CAAC,IAAY,EAAE,KAAa,EAAE,MAAc,EAAE,KAAa,EAAE,EAAE;gBACzF,OAAO,CAAC,GAAG,CAAC,iCAAiC,IAAI,KAAK,KAAK,KAAK,MAAM,KAAK,KAAK,EAAE,CAAC,CAAC;YACxF,CAAC,EACD,iCAAiC,EAAE,CAAC,IAAY,EAAE,MAAc,EAAE,EAAE;gBAChE,OAAO,CAAC,GAAG,CAAC,sCAAsC,IAAI,KAAK,MAAM,EAAE,CAAC,CAAC;YACzE,CAAC,EACD,2BAA2B,EAAE,CAAC,IAAY,EAAE,KAAa,EAAE,EAAE;gBACzD,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC;gBAC9D,OAAO,CAAC,CAAC;YACb,CAAC,EACD,yBAAyB,EAAE,GAAG,EAAE;gBAC5B,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;YAC7C,CAAC,EACD,0BAA0B,EAAE,CAAC,IAAY,EAAE,MAAc,EAAE,KAAa,EAAE,EAAU,EAAE,EAAE;gBACpF,OAAO,CAAC,GAAG,CAAC,+BAA+B,IAAI,KAAK,MAAM,KAAK,KAAK,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC/E,OAAO,CAAC,CAAC;YACb,CAAC,IACJ;IACL,CAAC;IACD,UAAU;QACN,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAC9B,mEAAmE;QACnE,IAAI,CAAC,OAAO,EAAE,CAAC,oBAAoB,EAAE,CAAC;QACtC,IAAI,CAAC,OAAO,EAAE,CAAC,UAAU,EAAE,CAAC;QAC5B,IAAI,CAAC,OAAO,EAAE,CAAC,gCAAgC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;QACrD,IAAI,CAAC,OAAO,EAAE,CAAC,gCAAgC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,iBAAiB;QACb,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,iBAAiB,EAAE,CAAC;IAC9C,CAAC;IACD,QAAQ,CAAC,IAAY,EAAE,IAAgB;QACnC,MAAM,IAAI,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;IACD,KAAK;QACD,IAAI,CAAC,OAAO,EAAE,CAAC,WAAW,EAAE,CAAC;IACjC,CAAC;IACD,OAAO;QACH,IAAI,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,CAAC;IAC/B,CAAC;CACJ;AAnDD,wCAmDC"}
|
||||
@@ -6,17 +6,17 @@
|
||||
// https://github.com/WebAssembly/wasi-libc/blob/main/libc-bottom-half/sources/preopens.c
|
||||
// https://fossies.org/linux/wasm3/source/extra/wasi_core.h
|
||||
// https://wasix.org/docs/api-reference/wasi/fd_read
|
||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
};
|
||||
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
||||
if (kind === "m") throw new TypeError("Private method is not writable");
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
||||
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
||||
};
|
||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
};
|
||||
var _WASIRunner_instance, _WASIRunner_memarr8, _WASIRunner_memarr32, _WASIRunner_args, _WASIRunner_envvars;
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.WASIRunner = exports.WASIMemoryFilesystem = exports.WASIFileDescriptor = exports.WASIErrors = exports.FDOpenFlags = exports.FDFlags = exports.FDRights = exports.FDType = void 0;
|
||||
@@ -287,6 +287,9 @@ class WASIRunner {
|
||||
this.fs = new WASIMemoryFilesystem();
|
||||
this.createStdioBrowser();
|
||||
}
|
||||
exports() {
|
||||
return __classPrivateFieldGet(this, _WASIRunner_instance, "f").exports;
|
||||
}
|
||||
createStdioNode() {
|
||||
this.stdin = new WASIStreamingFileDescriptor(0, '<stdin>', FDType.CHARACTER_DEVICE, FDRights.FD_READ, process.stdin);
|
||||
this.stdout = new WASIStreamingFileDescriptor(1, '<stdout>', FDType.CHARACTER_DEVICE, FDRights.FD_WRITE, process.stdout);
|
||||
@@ -391,6 +394,10 @@ class WASIRunner {
|
||||
}
|
||||
return this.getErrno();
|
||||
}
|
||||
initialize() {
|
||||
__classPrivateFieldGet(this, _WASIRunner_instance, "f").exports._initialize();
|
||||
return this.getErrno();
|
||||
}
|
||||
getImportObject() {
|
||||
return {
|
||||
"wasi_snapshot_preview1": this.getWASISnapshotPreview1(),
|
||||
@@ -503,7 +510,9 @@ class WASIRunner {
|
||||
}
|
||||
fd_seek(fd, offset, whence, newoffset_ptr) {
|
||||
const file = this.fds[fd];
|
||||
debug("fd_seek", fd, offset, whence, file);
|
||||
if (typeof offset == 'bigint')
|
||||
offset = Number(offset);
|
||||
debug("fd_seek", fd, offset, whence, file + "");
|
||||
if (file != null) {
|
||||
file.llseek(offset, whence);
|
||||
this.poke64(newoffset_ptr, file.offset);
|
||||
@@ -623,11 +632,12 @@ class WASIRunner {
|
||||
fd_readdir() { warning("TODO: fd_readdir"); return WASIErrors.NOTSUP; },
|
||||
path_unlink_file() { warning("TODO: path_unlink_file"); return WASIErrors.NOTSUP; },
|
||||
clock_time_get() { warning("TODO: clock_time_get"); return WASIErrors.NOTSUP; },
|
||||
fd_tell() { warning("TODO: fd_tell"); return WASIErrors.NOTSUP; },
|
||||
};
|
||||
}
|
||||
getEnv() {
|
||||
return {
|
||||
__syscall_unlinkat() { warning('TODO: unlink'); return 0; },
|
||||
__syscall_unlinkat() { warning('TODO: unlink'); return WASIErrors.NOTSUP; },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
+252
-20002
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs = __importStar(require("fs"));
|
||||
const libretro_1 = require("../common/wasi/libretro");
|
||||
async function loadLibretro() {
|
||||
const wasmdata = fs.readFileSync(`./wasi/stella2014_libretro_2.wasm`);
|
||||
let shim = new libretro_1.LibRetroRunner();
|
||||
await shim.loadAsync(wasmdata);
|
||||
return shim;
|
||||
}
|
||||
/*
|
||||
describe('test WASI libretro', function () {
|
||||
it('libretro init', async function () {
|
||||
let shim = await loadLibretro();
|
||||
assert.strictEqual(1, shim.retro_api_version());
|
||||
shim.retro_init();
|
||||
let romdata = fs.readFileSync(`./test/roms/vcs/brickgame.rom`);
|
||||
shim.load_rom('brickgame.rom', romdata);
|
||||
shim.reset();
|
||||
shim.advance();
|
||||
});
|
||||
});
|
||||
*/
|
||||
//# sourceMappingURL=testlibretro.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"testlibretro.js","sourceRoot":"","sources":["../../src/test/testlibretro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,uCAAyB;AACzB,sDAAyD;AAEzD,KAAK,UAAU,YAAY;IACvB,MAAM,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,mCAAmC,CAAC,CAAC;IACtE,IAAI,IAAI,GAAG,IAAI,yBAAc,EAAE,CAAC;IAChC,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;;;;;;;EAYE"}
|
||||
@@ -0,0 +1,386 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.fixParamsWithDefines = exports.anyTargetChanged = exports.staleFiles = exports.populateExtraFiles = exports.populateFiles = exports.getPrefix = exports.gatherFiles = exports.populateEntry = exports.getWorkFileAsString = exports.putWorkFile = exports.endtime = exports.starttime = exports.builder = exports.Builder = exports.errorResult = exports.store = exports.FileWorkingStore = exports.PWORKER = void 0;
|
||||
const util_1 = require("../common/util");
|
||||
const platforms_1 = require("./platforms");
|
||||
const workertools_1 = require("./workertools");
|
||||
/// working file store and build steps
|
||||
const PSRC = "../../src/";
|
||||
exports.PWORKER = PSRC + "worker/";
|
||||
;
|
||||
///
|
||||
class FileWorkingStore {
|
||||
constructor() {
|
||||
this.workfs = {};
|
||||
this.workerseq = 0;
|
||||
this.reset();
|
||||
}
|
||||
reset() {
|
||||
this.workfs = {};
|
||||
this.newVersion();
|
||||
}
|
||||
currentVersion() {
|
||||
return this.workerseq;
|
||||
}
|
||||
newVersion() {
|
||||
let ts = new Date().getTime();
|
||||
if (ts <= this.workerseq)
|
||||
ts = ++this.workerseq;
|
||||
return ts;
|
||||
}
|
||||
putFile(path, data) {
|
||||
var encoding = (typeof data === 'string') ? 'utf8' : 'binary';
|
||||
var entry = this.workfs[path];
|
||||
if (!entry || !compareData(entry.data, data) || entry.encoding != encoding) {
|
||||
this.workfs[path] = entry = { path: path, data: data, encoding: encoding, ts: this.newVersion() };
|
||||
console.log('+++', entry.path, entry.encoding, entry.data.length, entry.ts);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
hasFile(path) {
|
||||
return this.workfs[path] != null;
|
||||
}
|
||||
getFileData(path) {
|
||||
return this.workfs[path] && this.workfs[path].data;
|
||||
}
|
||||
getFileAsString(path) {
|
||||
let data = this.getFileData(path);
|
||||
if (data != null && typeof data !== 'string')
|
||||
throw new Error(`${path}: expected string`);
|
||||
return data; // TODO
|
||||
}
|
||||
getFileEntry(path) {
|
||||
return this.workfs[path];
|
||||
}
|
||||
setItem(key, value) {
|
||||
this.items[key] = value;
|
||||
}
|
||||
}
|
||||
exports.FileWorkingStore = FileWorkingStore;
|
||||
exports.store = new FileWorkingStore();
|
||||
///
|
||||
function errorResult(msg) {
|
||||
return { errors: [{ line: 0, msg: msg }] };
|
||||
}
|
||||
exports.errorResult = errorResult;
|
||||
class Builder {
|
||||
constructor() {
|
||||
this.steps = [];
|
||||
this.startseq = 0;
|
||||
}
|
||||
// returns true if file changed during this build step
|
||||
wasChanged(entry) {
|
||||
return entry.ts > this.startseq;
|
||||
}
|
||||
async executeBuildSteps() {
|
||||
this.startseq = exports.store.currentVersion();
|
||||
var linkstep = null;
|
||||
while (this.steps.length) {
|
||||
var step = this.steps.shift(); // get top of array
|
||||
var platform = step.platform;
|
||||
var [tool, remoteTool] = step.tool.split(':', 2);
|
||||
var toolfn = workertools_1.TOOLS[tool];
|
||||
if (!toolfn) {
|
||||
throw Error(`no tool named "${tool}"`);
|
||||
}
|
||||
if (remoteTool) {
|
||||
step.tool = remoteTool;
|
||||
}
|
||||
step.params = platforms_1.PLATFORM_PARAMS[(0, util_1.getBasePlatform)(platform)];
|
||||
try {
|
||||
step.result = await toolfn(step);
|
||||
}
|
||||
catch (e) {
|
||||
console.log("EXCEPTION", e, e.stack);
|
||||
return errorResult(e + ""); // TODO: catch errors already generated?
|
||||
}
|
||||
if (step.result) {
|
||||
step.result.params = step.params; // TODO: type check
|
||||
if (step.debuginfo) {
|
||||
let r = step.result; // TODO
|
||||
if (!r.debuginfo)
|
||||
r.debuginfo = {};
|
||||
Object.assign(r.debuginfo, step.debuginfo);
|
||||
}
|
||||
// errors? return them
|
||||
if ('errors' in step.result && step.result.errors.length) {
|
||||
applyDefaultErrorPath(step.result.errors, step.path);
|
||||
return step.result;
|
||||
}
|
||||
// if we got some output, return it immediately
|
||||
if ('output' in step.result && step.result.output) {
|
||||
return step.result;
|
||||
}
|
||||
// combine files with a link tool?
|
||||
if ('linktool' in step.result) {
|
||||
// add to existing link step
|
||||
if (linkstep) {
|
||||
linkstep.files = linkstep.files.concat(step.result.files);
|
||||
linkstep.args = linkstep.args.concat(step.result.args);
|
||||
}
|
||||
else {
|
||||
linkstep = {
|
||||
tool: step.result.linktool,
|
||||
platform: platform,
|
||||
files: step.result.files,
|
||||
args: step.result.args
|
||||
};
|
||||
}
|
||||
linkstep.debuginfo = step.debuginfo; // TODO: multiple debuginfos
|
||||
}
|
||||
// process with another tool?
|
||||
if ('nexttool' in step.result) {
|
||||
var asmstep = Object.assign({ tool: step.result.nexttool, platform: platform }, step.result);
|
||||
this.steps.push(asmstep);
|
||||
}
|
||||
// process final step?
|
||||
if (this.steps.length == 0 && linkstep) {
|
||||
this.steps.push(linkstep);
|
||||
linkstep = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
async handleMessage(data) {
|
||||
this.steps = [];
|
||||
// file updates
|
||||
if (data.updates) {
|
||||
data.updates.forEach((u) => exports.store.putFile(u.path, u.data));
|
||||
}
|
||||
// object update
|
||||
if (data.setitems) {
|
||||
data.setitems.forEach((i) => exports.store.setItem(i.key, i.value));
|
||||
}
|
||||
// build steps
|
||||
if (data.buildsteps) {
|
||||
this.steps.push.apply(this.steps, data.buildsteps);
|
||||
}
|
||||
// single-file
|
||||
if (data.code) {
|
||||
this.steps.push(data); // TODO: remove cast
|
||||
}
|
||||
// execute build steps
|
||||
if (this.steps.length) {
|
||||
var result = await this.executeBuildSteps();
|
||||
return result ? result : { unchanged: true };
|
||||
}
|
||||
// TODO: cache results
|
||||
// message not recognized
|
||||
console.log("Unknown message", data);
|
||||
}
|
||||
}
|
||||
exports.Builder = Builder;
|
||||
function applyDefaultErrorPath(errors, path) {
|
||||
if (!path)
|
||||
return;
|
||||
for (var i = 0; i < errors.length; i++) {
|
||||
var err = errors[i];
|
||||
if (!err.path && err.line)
|
||||
err.path = path;
|
||||
}
|
||||
}
|
||||
function compareData(a, b) {
|
||||
if (a.length != b.length)
|
||||
return false;
|
||||
if (typeof a === 'string' && typeof b === 'string') {
|
||||
return a == b;
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
//if (a[i] != b[i]) console.log('differ at byte',i,a[i],b[i]);
|
||||
if (a[i] != b[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
exports.builder = new Builder();
|
||||
var _t1;
|
||||
function starttime() { _t1 = new Date(); }
|
||||
exports.starttime = starttime;
|
||||
function endtime(msg) { var _t2 = new Date(); console.log(msg, _t2.getTime() - _t1.getTime(), "ms"); }
|
||||
exports.endtime = endtime;
|
||||
///
|
||||
function putWorkFile(path, data) {
|
||||
return exports.store.putFile(path, data);
|
||||
}
|
||||
exports.putWorkFile = putWorkFile;
|
||||
function getWorkFileAsString(path) {
|
||||
return exports.store.getFileAsString(path);
|
||||
}
|
||||
exports.getWorkFileAsString = getWorkFileAsString;
|
||||
function populateEntry(fs, path, entry, options) {
|
||||
var data = entry.data;
|
||||
if (options && options.processFn) {
|
||||
data = options.processFn(path, data);
|
||||
}
|
||||
// create subfolders
|
||||
var toks = path.split('/');
|
||||
if (toks.length > 1) {
|
||||
for (var i = 0; i < toks.length - 1; i++)
|
||||
try {
|
||||
fs.mkdir(toks[i]);
|
||||
}
|
||||
catch (e) { }
|
||||
}
|
||||
// write file
|
||||
fs.writeFile(path, data, { encoding: entry.encoding });
|
||||
var time = new Date(entry.ts);
|
||||
fs.utime(path, time, time);
|
||||
console.log("<<<", path, entry.data.length);
|
||||
}
|
||||
exports.populateEntry = populateEntry;
|
||||
// can call multiple times (from populateFiles)
|
||||
function gatherFiles(step, options) {
|
||||
var maxts = 0;
|
||||
if (step.files) {
|
||||
for (var i = 0; i < step.files.length; i++) {
|
||||
var path = step.files[i];
|
||||
var entry = exports.store.workfs[path];
|
||||
if (!entry) {
|
||||
throw new Error("No entry for path '" + path + "'");
|
||||
}
|
||||
else {
|
||||
maxts = Math.max(maxts, entry.ts);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (step.code) {
|
||||
var path = step.path ? step.path : options.mainFilePath; // TODO: what if options null
|
||||
if (!path)
|
||||
throw Error("need path or mainFilePath");
|
||||
var code = step.code;
|
||||
var entry = putWorkFile(path, code);
|
||||
step.path = path;
|
||||
step.files = [path];
|
||||
maxts = entry.ts;
|
||||
}
|
||||
else if (step.path) {
|
||||
var path = step.path;
|
||||
var entry = exports.store.workfs[path];
|
||||
maxts = entry.ts;
|
||||
step.files = [path];
|
||||
}
|
||||
if (step.path && !step.prefix) {
|
||||
step.prefix = getPrefix(step.path);
|
||||
}
|
||||
step.maxts = maxts;
|
||||
return maxts;
|
||||
}
|
||||
exports.gatherFiles = gatherFiles;
|
||||
function getPrefix(s) {
|
||||
var pos = s.lastIndexOf('.');
|
||||
return (pos > 0) ? s.substring(0, pos) : s;
|
||||
}
|
||||
exports.getPrefix = getPrefix;
|
||||
function populateFiles(step, fs, options) {
|
||||
gatherFiles(step, options);
|
||||
if (!step.files)
|
||||
throw Error("call gatherFiles() first");
|
||||
for (var i = 0; i < step.files.length; i++) {
|
||||
var path = step.files[i];
|
||||
populateEntry(fs, path, exports.store.workfs[path], options);
|
||||
}
|
||||
}
|
||||
exports.populateFiles = populateFiles;
|
||||
function populateExtraFiles(step, fs, extrafiles) {
|
||||
if (extrafiles) {
|
||||
for (var i = 0; i < extrafiles.length; i++) {
|
||||
var xfn = extrafiles[i];
|
||||
// is this file cached?
|
||||
if (exports.store.workfs[xfn]) {
|
||||
fs.writeFile(xfn, exports.store.workfs[xfn].data, { encoding: 'binary' });
|
||||
continue;
|
||||
}
|
||||
// fetch from network
|
||||
var xpath = "lib/" + (0, util_1.getBasePlatform)(step.platform) + "/" + xfn;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.open("GET", exports.PWORKER + xpath, false); // synchronous request
|
||||
xhr.send(null);
|
||||
if (xhr.response && xhr.status == 200) {
|
||||
var data = new Uint8Array(xhr.response);
|
||||
fs.writeFile(xfn, data, { encoding: 'binary' });
|
||||
putWorkFile(xfn, data);
|
||||
console.log(":::", xfn, data.length);
|
||||
}
|
||||
else {
|
||||
throw Error("Could not load extra file " + xpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.populateExtraFiles = populateExtraFiles;
|
||||
function staleFiles(step, targets) {
|
||||
if (!step.maxts)
|
||||
throw Error("call populateFiles() first");
|
||||
// see if any target files are more recent than inputs
|
||||
for (var i = 0; i < targets.length; i++) {
|
||||
var entry = exports.store.workfs[targets[i]];
|
||||
if (!entry || step.maxts > entry.ts)
|
||||
return true;
|
||||
}
|
||||
console.log("unchanged", step.maxts, targets);
|
||||
return false;
|
||||
}
|
||||
exports.staleFiles = staleFiles;
|
||||
function anyTargetChanged(step, targets) {
|
||||
if (!step.maxts)
|
||||
throw Error("call populateFiles() first");
|
||||
// see if any target files are more recent than inputs
|
||||
for (var i = 0; i < targets.length; i++) {
|
||||
var entry = exports.store.workfs[targets[i]];
|
||||
if (!entry || entry.ts > step.maxts)
|
||||
return true;
|
||||
}
|
||||
console.log("unchanged", step.maxts, targets);
|
||||
return false;
|
||||
}
|
||||
exports.anyTargetChanged = anyTargetChanged;
|
||||
function fixParamsWithDefines(path, params) {
|
||||
var libargs = params.libargs;
|
||||
if (path && libargs) {
|
||||
var code = getWorkFileAsString(path);
|
||||
if (code) {
|
||||
var oldcfgfile = params.cfgfile;
|
||||
var ident2index = {};
|
||||
// find all lib args "IDENT=VALUE"
|
||||
for (var i = 0; i < libargs.length; i++) {
|
||||
var toks = libargs[i].split('=');
|
||||
if (toks.length == 2) {
|
||||
ident2index[toks[0]] = i;
|
||||
}
|
||||
}
|
||||
// find #defines and replace them
|
||||
var re = /^[;]?#define\s+(\w+)\s+(\S+)/gmi; // TODO: empty string?
|
||||
var m;
|
||||
while (m = re.exec(code)) {
|
||||
var ident = m[1];
|
||||
var value = m[2];
|
||||
var index = ident2index[ident];
|
||||
if (index >= 0) {
|
||||
libargs[index] = ident + "=" + value;
|
||||
console.log('Using libargs', index, libargs[index]);
|
||||
// TODO: MMC3 mapper switch
|
||||
if (ident == 'NES_MAPPER' && value == '4') {
|
||||
params.cfgfile = 'nesbanked.cfg';
|
||||
console.log("using config file", params.cfgfile);
|
||||
}
|
||||
}
|
||||
else if (ident == 'CFGFILE' && value) {
|
||||
params.cfgfile = value;
|
||||
}
|
||||
else if (ident == 'LIBARGS' && value) {
|
||||
params.libargs = value.split(',').filter((s) => { return s != ''; });
|
||||
console.log('Using libargs', params.libargs);
|
||||
}
|
||||
else if (ident == 'CC65_FLAGS' && value) {
|
||||
params.extra_compiler_args = value.split(',').filter((s) => { return s != ''; });
|
||||
console.log('Using compiler flags', params.extra_compiler_args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.fixParamsWithDefines = fixParamsWithDefines;
|
||||
//# sourceMappingURL=builder.js.map
|
||||
File diff suppressed because one or more lines are too long
+1774
-1743
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,138 @@
|
||||
"use strict";
|
||||
// test.c(6) : warning 85: in function main unreferenced local variable : 'x'
|
||||
// main.a (4): error: Unknown Mnemonic 'xxx'.
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseSourceLines = exports.parseListing = exports.re_lineoffset = exports.re_crlf = exports.extractErrors = exports.makeErrorMatcher = exports.msvcErrorMatcher = exports.re_msvc2 = exports.re_msvc = void 0;
|
||||
// at 2: warning 190: ISO C forbids an empty source file
|
||||
exports.re_msvc = /[/]*([^( ]+)\s*[(](\d+)[)]\s*:\s*(.+?):\s*(.*)/;
|
||||
exports.re_msvc2 = /\s*(at)\s+(\d+)\s*(:)\s*(.*)/;
|
||||
function msvcErrorMatcher(errors) {
|
||||
return function (s) {
|
||||
var matches = exports.re_msvc.exec(s) || exports.re_msvc2.exec(s);
|
||||
if (matches) {
|
||||
var errline = parseInt(matches[2]);
|
||||
errors.push({
|
||||
line: errline,
|
||||
path: matches[1],
|
||||
//type:matches[3],
|
||||
msg: matches[4]
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log(s);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.msvcErrorMatcher = msvcErrorMatcher;
|
||||
function makeErrorMatcher(errors, regex, iline, imsg, mainpath, ifilename) {
|
||||
return function (s) {
|
||||
var matches = regex.exec(s);
|
||||
if (matches) {
|
||||
errors.push({
|
||||
line: parseInt(matches[iline]) || 1,
|
||||
msg: matches[imsg],
|
||||
path: ifilename ? matches[ifilename] : mainpath
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log("??? " + s);
|
||||
}
|
||||
};
|
||||
}
|
||||
exports.makeErrorMatcher = makeErrorMatcher;
|
||||
function extractErrors(regex, strings, path, iline, imsg, ifilename) {
|
||||
var errors = [];
|
||||
var matcher = makeErrorMatcher(errors, regex, iline, imsg, path, ifilename);
|
||||
for (var i = 0; i < strings.length; i++) {
|
||||
matcher(strings[i]);
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
exports.extractErrors = extractErrors;
|
||||
exports.re_crlf = /\r?\n/;
|
||||
// 1 %line 16+1 hello.asm
|
||||
exports.re_lineoffset = /\s*(\d+)\s+[%]line\s+(\d+)\+(\d+)\s+(.+)/;
|
||||
function parseListing(code, lineMatch, iline, ioffset, iinsns, icycles, funcMatch, segMatch) {
|
||||
var lines = [];
|
||||
var lineofs = 0;
|
||||
var segment = '';
|
||||
var func = '';
|
||||
var funcbase = 0;
|
||||
code.split(exports.re_crlf).forEach((line, lineindex) => {
|
||||
let segm = segMatch && segMatch.exec(line);
|
||||
if (segm) {
|
||||
segment = segm[1];
|
||||
}
|
||||
let funcm = funcMatch && funcMatch.exec(line);
|
||||
if (funcm) {
|
||||
funcbase = parseInt(funcm[1], 16);
|
||||
func = funcm[2];
|
||||
}
|
||||
var linem = lineMatch.exec(line);
|
||||
if (linem && linem[1]) {
|
||||
var linenum = iline < 0 ? lineindex : parseInt(linem[iline]);
|
||||
var offset = parseInt(linem[ioffset], 16);
|
||||
var insns = linem[iinsns];
|
||||
var cycles = icycles ? parseInt(linem[icycles]) : null;
|
||||
var iscode = cycles > 0;
|
||||
if (insns) {
|
||||
lines.push({
|
||||
line: linenum + lineofs,
|
||||
offset: offset - funcbase,
|
||||
insns,
|
||||
cycles,
|
||||
iscode,
|
||||
segment,
|
||||
func
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
let m = exports.re_lineoffset.exec(line);
|
||||
// TODO: check filename too
|
||||
if (m) {
|
||||
lineofs = parseInt(m[2]) - parseInt(m[1]) - parseInt(m[3]);
|
||||
}
|
||||
}
|
||||
});
|
||||
return lines;
|
||||
}
|
||||
exports.parseListing = parseListing;
|
||||
function parseSourceLines(code, lineMatch, offsetMatch, funcMatch, segMatch) {
|
||||
var lines = [];
|
||||
var lastlinenum = 0;
|
||||
var segment = '';
|
||||
var func = '';
|
||||
var funcbase = 0;
|
||||
for (var line of code.split(exports.re_crlf)) {
|
||||
let segm = segMatch && segMatch.exec(line);
|
||||
if (segm) {
|
||||
segment = segm[1];
|
||||
}
|
||||
let funcm = funcMatch && funcMatch.exec(line);
|
||||
if (funcm) {
|
||||
funcbase = parseInt(funcm[1], 16);
|
||||
func = funcm[2];
|
||||
}
|
||||
var linem = lineMatch.exec(line);
|
||||
if (linem && linem[1]) {
|
||||
lastlinenum = parseInt(linem[1]);
|
||||
}
|
||||
else if (lastlinenum) {
|
||||
var linem = offsetMatch.exec(line);
|
||||
if (linem && linem[1]) {
|
||||
var offset = parseInt(linem[1], 16);
|
||||
lines.push({
|
||||
line: lastlinenum,
|
||||
offset: offset - funcbase,
|
||||
segment,
|
||||
func
|
||||
});
|
||||
lastlinenum = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
exports.parseSourceLines = parseSourceLines;
|
||||
//# sourceMappingURL=listingutils.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"listingutils.js","sourceRoot":"","sources":["../../src/worker/listingutils.ts"],"names":[],"mappings":";AACA,6EAA6E;AAC7E,6CAA6C;;;AAI7C,wDAAwD;AAC3C,QAAA,OAAO,GAAG,gDAAgD,CAAC;AAC3D,QAAA,QAAQ,GAAG,8BAA8B,CAAC;AAEvD,SAAgB,gBAAgB,CAAC,MAAqB;IAClD,OAAO,UAAU,CAAS;QACtB,IAAI,OAAO,GAAG,eAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,gBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClD,IAAI,OAAO,EAAE;YACT,IAAI,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;YACnC,MAAM,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;gBAChB,kBAAkB;gBAClB,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;aAClB,CAAC,CAAC;SACN;aAAM;YACH,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;SAClB;IACL,CAAC,CAAA;AACL,CAAC;AAfD,4CAeC;AAED,SAAgB,gBAAgB,CAAC,MAAqB,EAAE,KAAK,EAAE,KAAa,EAAE,IAAY,EAAE,QAAgB,EAAE,SAAkB;IAC5H,OAAO,UAAU,CAAC;QACd,IAAI,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,OAAO,EAAE;YACT,MAAM,CAAC,IAAI,CAAC;gBACR,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC;gBAC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W,EAAE;YACpB,IAAI,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE;gBACnB,IAAI,MAAM,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACpC,KAAK,CAAC,IAAI,CAAC;oBACP,IAAI,EAAE,WAAW;oBACjB,MAAM,EAAE,MAAM,GAAG,QAAQ;oBACzB,OAAO;oBACP,IAAI;iBACP,CAAC,CAAC;gBACH,WAAW,GAAG,CAAC,CAAC;aACnB;SACJ;KACJ;IACD,OAAO,KAAK,CAAC;AACjB,CAAC;AA9BD,4CA8BC"}
|
||||
@@ -0,0 +1,335 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PLATFORM_PARAMS = void 0;
|
||||
exports.PLATFORM_PARAMS = {
|
||||
'vcs': {
|
||||
arch: '6502',
|
||||
code_start: 0x1000,
|
||||
code_size: 0xf000,
|
||||
data_start: 0x80,
|
||||
data_size: 0x80,
|
||||
wiz_rom_ext: '.a26',
|
||||
wiz_inc_dir: '2600',
|
||||
cfgfile: 'atari2600.cfg',
|
||||
libargs: ['crt0.o', 'atari2600.lib'],
|
||||
extra_link_files: ['crt0.o', 'atari2600.cfg'],
|
||||
define: ['__ATARI2600__'],
|
||||
},
|
||||
'mw8080bw': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x2000,
|
||||
data_start: 0x2000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0x2400,
|
||||
},
|
||||
'vicdual': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x4020,
|
||||
data_start: 0xe400,
|
||||
data_size: 0x400,
|
||||
stack_end: 0xe800,
|
||||
},
|
||||
'galaxian': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x4000,
|
||||
data_start: 0x4000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0x4800,
|
||||
},
|
||||
'galaxian-scramble': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x5020,
|
||||
data_start: 0x4000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0x4800,
|
||||
},
|
||||
'williams': {
|
||||
arch: '6809',
|
||||
code_start: 0x0,
|
||||
rom_size: 0xc000,
|
||||
data_start: 0x9800,
|
||||
data_size: 0x2800,
|
||||
stack_end: 0xc000,
|
||||
set_stack_end: 0xc000,
|
||||
extra_link_files: ['williams.scr', 'libcmoc-crt-vec.a', 'libcmoc-std-vec.a'],
|
||||
extra_link_args: ['-swilliams.scr', '-lcmoc-crt-vec', '-lcmoc-std-vec'],
|
||||
extra_compile_files: ['assert.h', 'cmoc.h', 'stdarg.h', 'stdlib.h'],
|
||||
//extra_compile_args: ['--vectrex'],
|
||||
},
|
||||
'williams-defender': {
|
||||
arch: '6809',
|
||||
code_start: 0x0,
|
||||
rom_size: 0xc000,
|
||||
data_start: 0x9800,
|
||||
data_size: 0x2800,
|
||||
stack_end: 0xc000,
|
||||
},
|
||||
'williams-z80': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x9800,
|
||||
data_start: 0x9800,
|
||||
data_size: 0x2800,
|
||||
stack_end: 0xc000,
|
||||
},
|
||||
'vector-z80color': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0xe000,
|
||||
data_size: 0x2000,
|
||||
stack_end: 0x0,
|
||||
},
|
||||
'vector-ataricolor': {
|
||||
arch: '6502',
|
||||
define: ['__VECTOR__'],
|
||||
cfgfile: 'vector-color.cfg',
|
||||
libargs: ['crt0.o', 'none.lib'],
|
||||
extra_link_files: ['crt0.o', 'vector-color.cfg'],
|
||||
},
|
||||
'sound_williams-z80': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x4000,
|
||||
data_start: 0x4000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0x8000,
|
||||
},
|
||||
'base_z80': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0x8000,
|
||||
data_size: 0x8000,
|
||||
stack_end: 0x0,
|
||||
},
|
||||
'coleco': {
|
||||
arch: 'z80',
|
||||
rom_start: 0x8000,
|
||||
code_start: 0x8100,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0x7000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0x8000,
|
||||
extra_preproc_args: ['-I', '/share/include/coleco', '-D', 'CV_CV'],
|
||||
extra_link_args: ['-k', '/share/lib/coleco', '-l', 'libcv', '-l', 'libcvu', 'crt0.rel'],
|
||||
},
|
||||
'msx': {
|
||||
arch: 'z80',
|
||||
rom_start: 0x4000,
|
||||
code_start: 0x4000,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0xc000,
|
||||
data_size: 0x3000,
|
||||
stack_end: 0xffff,
|
||||
extra_link_args: ['crt0-msx.rel'],
|
||||
extra_link_files: ['crt0-msx.rel', 'crt0-msx.lst'],
|
||||
wiz_sys_type: 'z80',
|
||||
wiz_inc_dir: 'msx',
|
||||
},
|
||||
'msx-libcv': {
|
||||
arch: 'z80',
|
||||
rom_start: 0x4000,
|
||||
code_start: 0x4000,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0xc000,
|
||||
data_size: 0x3000,
|
||||
stack_end: 0xffff,
|
||||
extra_preproc_args: ['-I', '.', '-D', 'CV_MSX'],
|
||||
extra_link_args: ['-k', '.', '-l', 'libcv-msx', '-l', 'libcvu-msx', 'crt0-msx.rel'],
|
||||
extra_link_files: ['libcv-msx.lib', 'libcvu-msx.lib', 'crt0-msx.rel', 'crt0-msx.lst'],
|
||||
extra_compile_files: ['cv.h', 'cv_graphics.h', 'cv_input.h', 'cv_sound.h', 'cv_support.h', 'cvu.h', 'cvu_c.h', 'cvu_compression.h', 'cvu_f.h', 'cvu_graphics.h', 'cvu_input.h', 'cvu_sound.h'],
|
||||
},
|
||||
'sms-sg1000-libcv': {
|
||||
arch: 'z80',
|
||||
rom_start: 0x0000,
|
||||
code_start: 0x0100,
|
||||
rom_size: 0xc000,
|
||||
data_start: 0xc000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0xe000,
|
||||
extra_preproc_args: ['-I', '.', '-D', 'CV_SMS'],
|
||||
extra_link_args: ['-k', '.', '-l', 'libcv-sms', '-l', 'libcvu-sms', 'crt0-sms.rel'],
|
||||
extra_link_files: ['libcv-sms.lib', 'libcvu-sms.lib', 'crt0-sms.rel', 'crt0-sms.lst'],
|
||||
extra_compile_files: ['cv.h', 'cv_graphics.h', 'cv_input.h', 'cv_sound.h', 'cv_support.h', 'cvu.h', 'cvu_c.h', 'cvu_compression.h', 'cvu_f.h', 'cvu_graphics.h', 'cvu_input.h', 'cvu_sound.h'],
|
||||
},
|
||||
'nes': {
|
||||
arch: '6502',
|
||||
define: ['__NES__'],
|
||||
cfgfile: 'neslib2.cfg',
|
||||
libargs: ['crt0.o', 'nes.lib', 'neslib2.lib',
|
||||
'-D', 'NES_MAPPER=0',
|
||||
'-D', 'NES_PRG_BANKS=2',
|
||||
'-D', 'NES_CHR_BANKS=1',
|
||||
'-D', 'NES_MIRRORING=0', // horizontal mirroring
|
||||
],
|
||||
extra_link_files: ['crt0.o', 'neslib2.lib', 'neslib2.cfg', 'nesbanked.cfg'],
|
||||
wiz_rom_ext: '.nes',
|
||||
},
|
||||
'apple2': {
|
||||
arch: '6502',
|
||||
define: ['__APPLE2__'],
|
||||
cfgfile: 'apple2.cfg',
|
||||
libargs: ['--lib-path', '/share/target/apple2/drv', 'apple2.lib'],
|
||||
__CODE_RUN__: 16384,
|
||||
code_start: 0x803,
|
||||
acmeargs: ['-f', 'apple'],
|
||||
},
|
||||
'apple2-e': {
|
||||
arch: '6502',
|
||||
define: ['__APPLE2__'],
|
||||
cfgfile: 'apple2.cfg',
|
||||
libargs: ['apple2.lib'],
|
||||
acmeargs: ['-f', 'apple'],
|
||||
},
|
||||
'atari8-800xl.disk': {
|
||||
arch: '6502',
|
||||
define: ['__ATARI__'],
|
||||
cfgfile: 'atari.cfg',
|
||||
libargs: ['atari.lib'],
|
||||
fastbasic_cfgfile: 'fastbasic-cart.cfg',
|
||||
},
|
||||
'atari8-800xl': {
|
||||
arch: '6502',
|
||||
define: ['__ATARI__'],
|
||||
cfgfile: 'atari-cart.cfg',
|
||||
libargs: ['atari.lib', '-D', '__CARTFLAGS__=4'],
|
||||
fastbasic_cfgfile: 'fastbasic-cart.cfg',
|
||||
},
|
||||
'atari8-800': {
|
||||
arch: '6502',
|
||||
define: ['__ATARI__'],
|
||||
cfgfile: 'atari-cart.cfg',
|
||||
libargs: ['atari.lib', '-D', '__CARTFLAGS__=4'],
|
||||
fastbasic_cfgfile: 'fastbasic-cart.cfg',
|
||||
},
|
||||
'atari8-5200': {
|
||||
arch: '6502',
|
||||
define: ['__ATARI5200__'],
|
||||
cfgfile: 'atari5200.cfg',
|
||||
libargs: ['atari5200.lib', '-D', '__CARTFLAGS__=255'],
|
||||
fastbasic_cfgfile: 'fastbasic-cart.cfg',
|
||||
},
|
||||
'verilog': {
|
||||
arch: 'verilog',
|
||||
extra_compile_files: ['8bitworkshop.v'],
|
||||
},
|
||||
'astrocade': {
|
||||
arch: 'z80',
|
||||
code_start: 0x2000,
|
||||
rom_size: 0x2000,
|
||||
data_start: 0x4e10,
|
||||
data_size: 0x1f0,
|
||||
stack_end: 0x5000,
|
||||
},
|
||||
'astrocade-arcade': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0000,
|
||||
rom_size: 0x4000,
|
||||
data_start: 0x7de0,
|
||||
data_size: 0x220,
|
||||
stack_end: 0x8000,
|
||||
},
|
||||
'astrocade-bios': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0000,
|
||||
rom_size: 0x2000,
|
||||
data_start: 0x4fce,
|
||||
data_size: 50,
|
||||
stack_end: 0x4fce,
|
||||
},
|
||||
'atari7800': {
|
||||
arch: '6502',
|
||||
define: ['__ATARI7800__'],
|
||||
cfgfile: 'atari7800.cfg',
|
||||
libargs: ['crt0.o', 'none.lib'],
|
||||
extra_link_files: ['crt0.o', 'atari7800.cfg'],
|
||||
},
|
||||
'c64': {
|
||||
arch: '6502',
|
||||
define: ['__CBM__', '__C64__'],
|
||||
cfgfile: 'c64.cfg',
|
||||
libargs: ['c64.lib'],
|
||||
acmeargs: ['-f', 'cbm'],
|
||||
//extra_link_files: ['c64-cart.cfg'],
|
||||
},
|
||||
'vic20': {
|
||||
arch: '6502',
|
||||
define: ['__CBM__', '__VIC20__'],
|
||||
cfgfile: 'vic20.cfg',
|
||||
libargs: ['vic20.lib'],
|
||||
acmeargs: ['-f', 'cbm'],
|
||||
//extra_link_files: ['c64-cart.cfg'],
|
||||
},
|
||||
'kim1': {
|
||||
arch: '6502',
|
||||
},
|
||||
'vectrex': {
|
||||
arch: '6809',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0xc880,
|
||||
data_size: 0x380,
|
||||
stack_end: 0xcc00,
|
||||
extra_compile_files: ['assert.h', 'cmoc.h', 'stdarg.h', 'vectrex.h', 'stdlib.h', 'bios.h'],
|
||||
extra_link_files: ['vectrex.scr', 'libcmoc-crt-vec.a', 'libcmoc-std-vec.a'],
|
||||
extra_compile_args: ['--vectrex'],
|
||||
extra_link_args: ['-svectrex.scr', '-lcmoc-crt-vec', '-lcmoc-std-vec'],
|
||||
},
|
||||
'x86': {
|
||||
arch: 'x86',
|
||||
},
|
||||
'zx': {
|
||||
arch: 'z80',
|
||||
code_start: 0x5ccb,
|
||||
rom_size: 0xff58 - 0x5ccb,
|
||||
data_start: 0xf000,
|
||||
data_size: 0xfe00 - 0xf000,
|
||||
stack_end: 0xff58,
|
||||
extra_link_args: ['crt0-zx.rel'],
|
||||
extra_link_files: ['crt0-zx.rel', 'crt0-zx.lst'],
|
||||
},
|
||||
'devel-6502': {
|
||||
arch: '6502',
|
||||
cfgfile: 'devel-6502.cfg',
|
||||
libargs: ['crt0.o', 'none.lib'],
|
||||
extra_link_files: ['crt0.o', 'devel-6502.cfg'],
|
||||
},
|
||||
// https://github.com/cpcitor/cpc-dev-tool-chain
|
||||
'cpc.rslib': {
|
||||
arch: 'z80',
|
||||
code_start: 0x4000,
|
||||
rom_size: 0xb100 - 0x4000,
|
||||
data_start: 0xb100,
|
||||
data_size: 0xb100 - 0xc000,
|
||||
stack_end: 0xc000,
|
||||
extra_compile_files: ['cpcrslib.h'],
|
||||
extra_link_args: ['crt0-cpc.rel', 'cpcrslib.lib'],
|
||||
extra_link_files: ['crt0-cpc.rel', 'crt0-cpc.lst', 'cpcrslib.lib', 'cpcrslib.lst'],
|
||||
},
|
||||
// https://lronaldo.github.io/cpctelera/ (TODO)
|
||||
'cpc': {
|
||||
arch: 'z80',
|
||||
code_start: 0x4000,
|
||||
rom_size: 0xb100 - 0x4000,
|
||||
data_start: 0xb100,
|
||||
data_size: 0xb100 - 0xc000,
|
||||
stack_end: 0xc000,
|
||||
extra_compile_files: ['cpctelera.h'],
|
||||
extra_link_args: ['crt0-cpc.rel', 'cpctelera.lib'],
|
||||
extra_link_files: ['crt0-cpc.rel', 'crt0-cpc.lst', 'cpctelera.lib', 'cpctelera.lst'],
|
||||
},
|
||||
'pce': {
|
||||
arch: 'huc6280',
|
||||
define: ['__PCE__'],
|
||||
cfgfile: 'pce.cfg',
|
||||
libargs: ['pce.lib', '-D', '__CARTSIZE__=0x8000'],
|
||||
},
|
||||
};
|
||||
exports.PLATFORM_PARAMS['sms-sms-libcv'] = exports.PLATFORM_PARAMS['sms-sg1000-libcv'];
|
||||
exports.PLATFORM_PARAMS['sms-gg-libcv'] = exports.PLATFORM_PARAMS['sms-sms-libcv'];
|
||||
//# sourceMappingURL=platforms.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -9,8 +9,8 @@ const path_1 = __importDefault(require("path"));
|
||||
const child_process_1 = require("child_process");
|
||||
const workertypes_1 = require("../../common/workertypes");
|
||||
const util_1 = require("../../common/util");
|
||||
const workermain_1 = require("../workermain");
|
||||
const clang_1 = require("./clang");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const LLVM_MOS_TOOL = {
|
||||
name: 'llvm-mos',
|
||||
version: '',
|
||||
@@ -170,7 +170,7 @@ class ServerBuildEnv {
|
||||
async processErrors(step, errorData) {
|
||||
let errors = [];
|
||||
// split errorData into lines
|
||||
let errorMatcher = (0, workermain_1.makeErrorMatcher)(errors, /([^:/]+):(\d+):(\d+):\s*(.+)/, 2, 4, step.path, 1);
|
||||
let errorMatcher = (0, listingutils_1.makeErrorMatcher)(errors, /([^:/]+):(\d+):(\d+):\s*(.+)/, 2, 4, step.path, 1);
|
||||
for (let line of errorData.split('\n')) {
|
||||
errorMatcher(line);
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
+16
-14
@@ -1,7 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.assembleACME = void 0;
|
||||
const workermain_1 = require("../workermain");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
function parseACMESymbolTable(text) {
|
||||
var symbolmap = {};
|
||||
var lines = text.split("\n");
|
||||
@@ -46,24 +48,24 @@ function parseACMEReportFile(text) {
|
||||
}
|
||||
function assembleACME(step) {
|
||||
var _a;
|
||||
(0, workermain_1.loadNative)("acme");
|
||||
(0, wasmutils_1.loadNative)("acme");
|
||||
var errors = [];
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.acme" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.acme" });
|
||||
var binpath = step.prefix + ".bin";
|
||||
var lstpath = step.prefix + ".lst";
|
||||
var sympath = step.prefix + ".sym";
|
||||
if ((0, workermain_1.staleFiles)(step, [binpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [binpath])) {
|
||||
var binout, lstout, symout;
|
||||
var ACME = workermain_1.emglobal.acme({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('acme'),
|
||||
var ACME = wasmutils_1.emglobal.acme({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('acme'),
|
||||
noInitialRun: true,
|
||||
print: workermain_1.print_fn,
|
||||
printErr: (0, workermain_1.msvcErrorMatcher)(errors),
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: (0, listingutils_1.msvcErrorMatcher)(errors),
|
||||
//printErr: makeErrorMatcher(errors, /(Error|Warning) - File (.+?), line (\d+)[^:]+: (.+)/, 3, 4, step.path, 2),
|
||||
});
|
||||
var FS = ACME.FS;
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.fixParamsWithDefines)(step.path, step.params);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, builder_1.fixParamsWithDefines)(step.path, step.params);
|
||||
var args = ['--msvc', '--initmem', '0', '-o', binpath, '-r', lstpath, '-l', sympath, step.path];
|
||||
if ((_a = step.params) === null || _a === void 0 ? void 0 : _a.acmeargs) {
|
||||
args.unshift.apply(args, step.params.acmeargs);
|
||||
@@ -75,7 +77,7 @@ function assembleACME(step) {
|
||||
if (step.mainfile) {
|
||||
args.unshift.apply(args, ["-D__MAIN__=1"]);
|
||||
}
|
||||
(0, workermain_1.execMain)(step, ACME, args);
|
||||
(0, wasmutils_1.execMain)(step, ACME, args);
|
||||
if (errors.length) {
|
||||
let listings = {};
|
||||
return { errors, listings };
|
||||
@@ -83,9 +85,9 @@ function assembleACME(step) {
|
||||
binout = FS.readFile(binpath, { encoding: 'binary' });
|
||||
lstout = FS.readFile(lstpath, { encoding: 'utf8' });
|
||||
symout = FS.readFile(sympath, { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)(binpath, binout);
|
||||
(0, workermain_1.putWorkFile)(lstpath, lstout);
|
||||
(0, workermain_1.putWorkFile)(sympath, symout);
|
||||
(0, builder_1.putWorkFile)(binpath, binout);
|
||||
(0, builder_1.putWorkFile)(lstpath, lstout);
|
||||
(0, builder_1.putWorkFile)(sympath, symout);
|
||||
return {
|
||||
output: binout,
|
||||
listings: parseACMEReportFile(lstout),
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"acme.js","sourceRoot":"","sources":["../../../src/worker/tools/acme.ts"],"names":[],"mappings":";;;AACA,8CAA2O;AAG3O,SAAS,oBAAoB,CAAC,IAAY;IACtC,IAAI,SAAS,GAAG,EAAE,CAAC;IACnB,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnC,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC3B,wBAAwB;QACxB,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;QAClD,IAAI,CAAC,EAAE;YACH,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;SACxC;KACJ;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAY;IACrC,IAAI,QAAQ,GAAoB,EAAE,CAAC;IACnC,IAAI,OAAqB,CAAC;IAC1B,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnC,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC3B,gCAAgC;QAChC,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,2B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,EAAE,CAAC,sBAAsB,CAAC,CAAC,CAAC;QACnD,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;SAC9C;QACD,IAAA,oBAAQ,EAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAC3B,IAAI,MAAM,CAAC,MAAM,EAAE;YACf,IAAI,QAAQ,GAAmB,EAAE,CAAC;YAClC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;SAC/B;QACD,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QACtD,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACpD,MAAM,GAAG,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACpD,IAAA,qBAAW,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,IAAA,qBAAW,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,IAAA,qBAAW,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC7B,OAAO;YACH,MAAM,EAAE,MAAM;YACd,QAAQ,EAAE,mBAAmB,CAAC,MAAM,CAAC;YACrC,MAAM,EAAE,MAAM;YACd,SAAS,EAAE,oBAAoB,CAAC,MAAM,CAAC;SAC1C,CAAC;KACL;AACL,CAAC;AA/CD,oCA+CC"}
|
||||
+28
-26
@@ -2,42 +2,44 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.assembleVASMARM = exports.assembleARMIPS = void 0;
|
||||
const util_1 = require("../../common/util");
|
||||
const workermain_1 = require("../workermain");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
function assembleARMIPS(step) {
|
||||
(0, workermain_1.loadNative)("armips");
|
||||
(0, wasmutils_1.loadNative)("armips");
|
||||
var errors = [];
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.asm" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.asm" });
|
||||
var objpath = "main.bin";
|
||||
var lstpath = step.prefix + ".lst";
|
||||
var sympath = step.prefix + ".sym";
|
||||
//test.armips(3) error: Parse error '.arm'
|
||||
var error_fn = (0, workermain_1.makeErrorMatcher)(errors, /^(.+?)\((\d+)\)\s+(fatal error|error|warning):\s+(.+)/, 2, 4, step.path, 1);
|
||||
if ((0, workermain_1.staleFiles)(step, [objpath])) {
|
||||
var error_fn = (0, listingutils_1.makeErrorMatcher)(errors, /^(.+?)\((\d+)\)\s+(fatal error|error|warning):\s+(.+)/, 2, 4, step.path, 1);
|
||||
if ((0, builder_1.staleFiles)(step, [objpath])) {
|
||||
var args = [step.path, '-temp', lstpath, '-sym', sympath, '-erroronwarning'];
|
||||
var armips = workermain_1.emglobal.armips({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('armips'),
|
||||
var armips = wasmutils_1.emglobal.armips({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('armips'),
|
||||
noInitialRun: true,
|
||||
print: error_fn,
|
||||
printErr: error_fn,
|
||||
});
|
||||
var FS = armips.FS;
|
||||
var code = (0, workermain_1.getWorkFileAsString)(step.path);
|
||||
var code = (0, builder_1.getWorkFileAsString)(step.path);
|
||||
code = `.arm.little :: .create "${objpath}",0 :: ${code}
|
||||
.close`;
|
||||
(0, workermain_1.putWorkFile)(step.path, code);
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.execMain)(step, armips, args);
|
||||
(0, builder_1.putWorkFile)(step.path, code);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, wasmutils_1.execMain)(step, armips, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var objout = FS.readFile(objpath, { encoding: 'binary' });
|
||||
(0, workermain_1.putWorkFile)(objpath, objout);
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, [objpath]))
|
||||
(0, builder_1.putWorkFile)(objpath, objout);
|
||||
if (!(0, builder_1.anyTargetChanged)(step, [objpath]))
|
||||
return;
|
||||
var symbolmap = {};
|
||||
var segments = [];
|
||||
var listings = {};
|
||||
var lstout = FS.readFile(lstpath, { encoding: 'utf8' });
|
||||
var lines = lstout.split(workermain_1.re_crlf);
|
||||
var lines = lstout.split(listingutils_1.re_crlf);
|
||||
//00000034 .word 0x11223344 ; /vidfill.armips line 25
|
||||
var re_asmline = /^([0-9A-F]+) (.+?); [/](.+?) line (\d+)/;
|
||||
var lastofs = -1;
|
||||
@@ -45,7 +47,7 @@ function assembleARMIPS(step) {
|
||||
var m;
|
||||
if (m = re_asmline.exec(line)) {
|
||||
var path = m[3];
|
||||
var path2 = (0, workermain_1.getPrefix)(path) + '.lst'; // TODO: don't rename listing
|
||||
var path2 = (0, builder_1.getPrefix)(path) + '.lst'; // TODO: don't rename listing
|
||||
var lst = listings[path2];
|
||||
if (lst == null) {
|
||||
lst = listings[path2] = { lines: [] };
|
||||
@@ -74,7 +76,7 @@ function assembleARMIPS(step) {
|
||||
//0000000C loop2
|
||||
//00000034 .dbl:0004
|
||||
var re_symline = /^([0-9A-F]+)\s+(.+)/;
|
||||
for (var line of symout.split(workermain_1.re_crlf)) {
|
||||
for (var line of symout.split(listingutils_1.re_crlf)) {
|
||||
var m;
|
||||
if (m = re_symline.exec(line)) {
|
||||
symbolmap[m[2]] = parseInt(m[1], 16);
|
||||
@@ -91,7 +93,7 @@ function assembleARMIPS(step) {
|
||||
}
|
||||
exports.assembleARMIPS = assembleARMIPS;
|
||||
function assembleVASMARM(step) {
|
||||
(0, workermain_1.loadNative)("vasmarm_std");
|
||||
(0, wasmutils_1.loadNative)("vasmarm_std");
|
||||
/// error 2 in line 8 of "gfxtest.c": unknown mnemonic <ew>
|
||||
/// error 3007: undefined symbol <XXLOOP>
|
||||
/// TODO: match undefined symbols
|
||||
@@ -140,27 +142,27 @@ function assembleVASMARM(step) {
|
||||
}
|
||||
}
|
||||
}
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.asm" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.asm" });
|
||||
var objpath = step.prefix + ".bin";
|
||||
var lstpath = step.prefix + ".lst";
|
||||
if ((0, workermain_1.staleFiles)(step, [objpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [objpath])) {
|
||||
var args = ['-Fbin', '-m7tdmi', '-x', '-wfail', step.path, '-o', objpath, '-L', lstpath];
|
||||
var vasm = workermain_1.emglobal.vasm({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('vasmarm_std'),
|
||||
var vasm = wasmutils_1.emglobal.vasm({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('vasmarm_std'),
|
||||
noInitialRun: true,
|
||||
print: match_fn,
|
||||
printErr: match_fn,
|
||||
});
|
||||
var FS = vasm.FS;
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.execMain)(step, vasm, args);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, wasmutils_1.execMain)(step, vasm, args);
|
||||
if (errors.length) {
|
||||
return { errors: errors };
|
||||
}
|
||||
if (undefsyms.length == 0) {
|
||||
var objout = FS.readFile(objpath, { encoding: 'binary' });
|
||||
(0, workermain_1.putWorkFile)(objpath, objout);
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, [objpath]))
|
||||
(0, builder_1.putWorkFile)(objpath, objout);
|
||||
if (!(0, builder_1.anyTargetChanged)(step, [objpath]))
|
||||
return;
|
||||
}
|
||||
var lstout = FS.readFile(lstpath, { encoding: 'utf8' });
|
||||
@@ -182,7 +184,7 @@ function assembleVASMARM(step) {
|
||||
var curline = 0;
|
||||
var sections = {};
|
||||
// map file and section indices -> names
|
||||
var lines = lstout.split(workermain_1.re_crlf);
|
||||
var lines = lstout.split(listingutils_1.re_crlf);
|
||||
// parse lines
|
||||
var lstlines = [];
|
||||
for (var line of lines) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,103 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileBatariBasic = void 0;
|
||||
const builder_1 = require("../builder");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
function preprocessBatariBasic(code) {
|
||||
(0, wasmutils_1.load)("bbpreprocess");
|
||||
var bbout = "";
|
||||
function addbbout_fn(s) {
|
||||
bbout += s;
|
||||
bbout += "\n";
|
||||
}
|
||||
var BBPRE = wasmutils_1.emglobal.preprocess({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: addbbout_fn,
|
||||
printErr: wasmutils_1.print_fn,
|
||||
noFSInit: true,
|
||||
});
|
||||
var FS = BBPRE.FS;
|
||||
(0, wasmutils_1.setupStdin)(FS, code);
|
||||
BBPRE.callMain([]);
|
||||
console.log("preprocess " + code.length + " -> " + bbout.length + " bytes");
|
||||
return bbout;
|
||||
}
|
||||
function compileBatariBasic(step) {
|
||||
(0, wasmutils_1.load)("bb2600basic");
|
||||
var params = step.params;
|
||||
// stdout
|
||||
var asmout = "";
|
||||
function addasmout_fn(s) {
|
||||
asmout += s;
|
||||
asmout += "\n";
|
||||
}
|
||||
// stderr
|
||||
var re_err1 = /[(](\d+)[)]:?\s*(.+)/;
|
||||
var errors = [];
|
||||
var errline = 0;
|
||||
function match_fn(s) {
|
||||
console.log(s);
|
||||
var matches = re_err1.exec(s);
|
||||
if (matches) {
|
||||
errline = parseInt(matches[1]);
|
||||
errors.push({
|
||||
line: errline,
|
||||
msg: matches[2]
|
||||
});
|
||||
}
|
||||
}
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.bas" });
|
||||
var destpath = step.prefix + '.asm';
|
||||
if ((0, builder_1.staleFiles)(step, [destpath])) {
|
||||
var BB = wasmutils_1.emglobal.bb2600basic({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: addasmout_fn,
|
||||
printErr: match_fn,
|
||||
noFSInit: true,
|
||||
TOTAL_MEMORY: 64 * 1024 * 1024,
|
||||
});
|
||||
var FS = BB.FS;
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
// preprocess, pipe file to stdin
|
||||
var code = (0, builder_1.getWorkFileAsString)(step.path);
|
||||
code = preprocessBatariBasic(code);
|
||||
(0, wasmutils_1.setupStdin)(FS, code);
|
||||
(0, wasmutils_1.setupFS)(FS, '2600basic');
|
||||
(0, wasmutils_1.execMain)(step, BB, ["-i", "/share", step.path]);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
// build final assembly output from include file list
|
||||
var includesout = FS.readFile("includes.bB", { encoding: 'utf8' });
|
||||
var redefsout = FS.readFile("2600basic_variable_redefs.h", { encoding: 'utf8' });
|
||||
var includes = includesout.trim().split("\n");
|
||||
var combinedasm = "";
|
||||
var splitasm = asmout.split("bB.asm file is split here");
|
||||
for (var incfile of includes) {
|
||||
var inctext;
|
||||
if (incfile == "bB.asm")
|
||||
inctext = splitasm[0];
|
||||
else if (incfile == "bB2.asm")
|
||||
inctext = splitasm[1];
|
||||
else
|
||||
inctext = FS.readFile("/share/includes/" + incfile, { encoding: 'utf8' });
|
||||
console.log(incfile, inctext.length);
|
||||
combinedasm += "\n\n;;;" + incfile + "\n\n";
|
||||
combinedasm += inctext;
|
||||
}
|
||||
// TODO: ; bB.asm file is split here
|
||||
(0, builder_1.putWorkFile)(destpath, combinedasm);
|
||||
(0, builder_1.putWorkFile)("2600basic.h", FS.readFile("/share/includes/2600basic.h"));
|
||||
(0, builder_1.putWorkFile)("2600basic_variable_redefs.h", redefsout);
|
||||
}
|
||||
return {
|
||||
nexttool: "dasm",
|
||||
path: destpath,
|
||||
args: [destpath],
|
||||
files: [destpath, "2600basic.h", "2600basic_variable_redefs.h"],
|
||||
bblines: true,
|
||||
};
|
||||
}
|
||||
exports.compileBatariBasic = compileBatariBasic;
|
||||
//# sourceMappingURL=bataribasic.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"bataribasic.js","sourceRoot":"","sources":["../../../src/worker/tools/bataribasic.ts"],"names":[],"mappings":";;;AAAA,wCAAkI;AAClI,4CAAyG;AAEzG,SAAS,qBAAqB,CAAC,IAAY;IACvC,IAAA,gBAAI,EAAC,cAAc,CAAC,CAAC;IACrB,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,SAAS,WAAW,CAAC,CAAC;QAClB,KAAK,IAAI,CAAC,CAAC;QACX,KAAK,IAAI,IAAI,CAAC;IAClB,CAAC;IACD,IAAI,KAAK,GAAqB,oBAAQ,CAAC,UAAU,CAAC;QAC9C,YAAY,EAAE,IAAI;QAClB,oBAAoB;QACpB,KAAK,EAAE,WAAW;QAClB,QAAQ,EAAE,oBAAQ;QAClB,QAAQ,EAAE,IAAI;KACjB,CAAC,CAAC;IACH,IAAI,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;IAClB,IAAA,sBAAU,EAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACrB,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACnB,OAAO,CAAC,GAAG,CAAC,aAAa,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC;IAC5E,OAAO,KAAK,CAAC;AACjB,CAAC;AAED,SAAgB,kBAAkB,CAAC,IAAe;IAC9C,IAAA,gBAAI,EAAC,aAAa,CAAC,CAAC;IACpB,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACzB,SAAS;IACT,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,SAAS,YAAY,CAAC,CAAC;QACnB,MAAM,IAAI,CAAC,CAAC;QACZ,MAAM,IAAI,IAAI,CAAC;IACnB,CAAC;IACD,SAA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,CAAC,CAAC;QACnC,IAAA,qBAAW,EAAC,aAAa,EAAE,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC,CAAC;QACvE,IAAA,qBAAW,EAAC,6BAA6B,EAAE,SAAS,CAAC,CAAC;KACzD;IACD,OAAO;QACH,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,QAAQ,CAAC;QAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,aAAa,EAAE,6BAA6B,CAAC;QAC/D,OAAO,EAAE,IAAI;KAChB,CAAC;AACN,CAAC;AA3ED,gDA2EC"}
|
||||
+46
-44
@@ -2,7 +2,9 @@
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileCC65 = exports.linkLD65 = exports.assembleCA65 = void 0;
|
||||
const util_1 = require("../../common/util");
|
||||
const workermain_1 = require("../workermain");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
/*
|
||||
000000r 1 .segment "CODE"
|
||||
000000r 1 .proc _rasterWait: near
|
||||
@@ -29,7 +31,7 @@ function parseCA65Listing(asmfn, code, symbols, segments, params, dbg, listings)
|
||||
var linenum = 0;
|
||||
let curpath = asmfn || '';
|
||||
// TODO: only does .c functions, not all .s files
|
||||
for (var line of code.split(workermain_1.re_crlf)) {
|
||||
for (var line of code.split(listingutils_1.re_crlf)) {
|
||||
var dbgm = dbgLineMatch.exec(line);
|
||||
if (dbgm && dbgm[1]) {
|
||||
var dbgtype = dbgm[4];
|
||||
@@ -107,30 +109,30 @@ function parseCA65Listing(asmfn, code, symbols, segments, params, dbg, listings)
|
||||
return origlines;
|
||||
}
|
||||
function assembleCA65(step) {
|
||||
(0, workermain_1.loadNative)("ca65");
|
||||
(0, wasmutils_1.loadNative)("ca65");
|
||||
var errors = [];
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.s" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.s" });
|
||||
var objpath = step.prefix + ".o";
|
||||
var lstpath = step.prefix + ".lst";
|
||||
if ((0, workermain_1.staleFiles)(step, [objpath, lstpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [objpath, lstpath])) {
|
||||
var objout, lstout;
|
||||
var CA65 = workermain_1.emglobal.ca65({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('ca65'),
|
||||
var CA65 = wasmutils_1.emglobal.ca65({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('ca65'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: workermain_1.print_fn,
|
||||
printErr: (0, workermain_1.makeErrorMatcher)(errors, /(.+?):(\d+): (.+)/, 2, 3, step.path, 1),
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: (0, listingutils_1.makeErrorMatcher)(errors, /(.+?):(\d+): (.+)/, 2, 3, step.path, 1),
|
||||
});
|
||||
var FS = CA65.FS;
|
||||
(0, workermain_1.setupFS)(FS, '65-' + (0, util_1.getRootBasePlatform)(step.platform));
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.fixParamsWithDefines)(step.path, step.params);
|
||||
(0, wasmutils_1.setupFS)(FS, '65-' + (0, util_1.getRootBasePlatform)(step.platform));
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, builder_1.fixParamsWithDefines)(step.path, step.params);
|
||||
var args = ['-v', '-g', '-I', '/share/asminc', '-o', objpath, '-l', lstpath, step.path];
|
||||
args.unshift.apply(args, ["-D", "__8BITWORKSHOP__=1"]);
|
||||
if (step.mainfile) {
|
||||
args.unshift.apply(args, ["-D", "__MAIN__=1"]);
|
||||
}
|
||||
(0, workermain_1.execMain)(step, CA65, args);
|
||||
(0, wasmutils_1.execMain)(step, CA65, args);
|
||||
if (errors.length) {
|
||||
let listings = {};
|
||||
// TODO? change extension to .lst
|
||||
@@ -139,8 +141,8 @@ function assembleCA65(step) {
|
||||
}
|
||||
objout = FS.readFile(objpath, { encoding: 'binary' });
|
||||
lstout = FS.readFile(lstpath, { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)(objpath, objout);
|
||||
(0, workermain_1.putWorkFile)(lstpath, lstout);
|
||||
(0, builder_1.putWorkFile)(objpath, objout);
|
||||
(0, builder_1.putWorkFile)(lstpath, lstout);
|
||||
}
|
||||
return {
|
||||
linktool: "ld65",
|
||||
@@ -151,26 +153,26 @@ function assembleCA65(step) {
|
||||
exports.assembleCA65 = assembleCA65;
|
||||
function linkLD65(step) {
|
||||
var _a, _b;
|
||||
(0, workermain_1.loadNative)("ld65");
|
||||
(0, wasmutils_1.loadNative)("ld65");
|
||||
var params = step.params;
|
||||
(0, workermain_1.gatherFiles)(step);
|
||||
(0, builder_1.gatherFiles)(step);
|
||||
var binpath = "main";
|
||||
if ((0, workermain_1.staleFiles)(step, [binpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [binpath])) {
|
||||
var errors = [];
|
||||
var LD65 = workermain_1.emglobal.ld65({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('ld65'),
|
||||
var LD65 = wasmutils_1.emglobal.ld65({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('ld65'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: workermain_1.print_fn,
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: function (s) { errors.push({ msg: s, line: 0 }); }
|
||||
});
|
||||
var FS = LD65.FS;
|
||||
(0, workermain_1.setupFS)(FS, '65-' + (0, util_1.getRootBasePlatform)(step.platform));
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.populateExtraFiles)(step, FS, params.extra_link_files);
|
||||
(0, wasmutils_1.setupFS)(FS, '65-' + (0, util_1.getRootBasePlatform)(step.platform));
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateExtraFiles)(step, FS, params.extra_link_files);
|
||||
// populate .cfg file, if it is a custom one
|
||||
if (workermain_1.store.hasFile(params.cfgfile)) {
|
||||
(0, workermain_1.populateEntry)(FS, params.cfgfile, workermain_1.store.getFileEntry(params.cfgfile), null);
|
||||
if (builder_1.store.hasFile(params.cfgfile)) {
|
||||
(0, builder_1.populateEntry)(FS, params.cfgfile, builder_1.store.getFileEntry(params.cfgfile), null);
|
||||
}
|
||||
var libargs = params.libargs || [];
|
||||
var cfgfile = params.cfgfile;
|
||||
@@ -182,7 +184,7 @@ function linkLD65(step) {
|
||||
'-o', 'main',
|
||||
'-m', 'main.map'].concat(step.args, libargs);
|
||||
//console.log(args);
|
||||
(0, workermain_1.execMain)(step, LD65, args);
|
||||
(0, wasmutils_1.execMain)(step, LD65, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var aout = FS.readFile("main", { encoding: 'binary' });
|
||||
@@ -197,11 +199,11 @@ function linkLD65(step) {
|
||||
aout = newrom;
|
||||
}
|
||||
//var dbgout = FS.readFile("main.dbg", {encoding:'utf8'});
|
||||
(0, workermain_1.putWorkFile)("main", aout);
|
||||
(0, workermain_1.putWorkFile)("main.map", mapout);
|
||||
(0, workermain_1.putWorkFile)("main.vice", viceout);
|
||||
(0, builder_1.putWorkFile)("main", aout);
|
||||
(0, builder_1.putWorkFile)("main.map", mapout);
|
||||
(0, builder_1.putWorkFile)("main.vice", viceout);
|
||||
// return unchanged if no files changed
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, ["main", "main.map", "main.vice"]))
|
||||
if (!(0, builder_1.anyTargetChanged)(step, ["main", "main.map", "main.vice"]))
|
||||
return;
|
||||
// parse symbol map (TODO: omit segments, constants)
|
||||
var symbolmap = {};
|
||||
@@ -244,7 +246,7 @@ function linkLD65(step) {
|
||||
if (fn.endsWith('.lst')) {
|
||||
var lstout = FS.readFile(fn, { encoding: 'utf8' });
|
||||
lstout = lstout.split('\n\n')[1] || lstout; // remove header
|
||||
(0, workermain_1.putWorkFile)(fn, lstout);
|
||||
(0, builder_1.putWorkFile)(fn, lstout);
|
||||
//const asmpath = fn.replace(/\.lst$/, '.ca65'); // TODO! could be .s
|
||||
let isECS = ((_b = (_a = step.debuginfo) === null || _a === void 0 ? void 0 : _a.systems) === null || _b === void 0 ? void 0 : _b.Init) != null; // TODO
|
||||
if (isECS) {
|
||||
@@ -281,7 +283,7 @@ function processIncbin(code) {
|
||||
// find #embed "filename.bin" and replace with C array data
|
||||
return code.replace(re3, (m, m1) => {
|
||||
let filename = m1;
|
||||
let filedata = workermain_1.store.getFileData(filename);
|
||||
let filedata = builder_1.store.getFileData(filename);
|
||||
let bytes = (0, util_1.convertDataToUint8Array)(filedata);
|
||||
if (!bytes)
|
||||
throw new Error('#embed: file not found: "' + filename + '"');
|
||||
@@ -293,7 +295,7 @@ function processIncbin(code) {
|
||||
});
|
||||
}
|
||||
function compileCC65(step) {
|
||||
(0, workermain_1.loadNative)("cc65");
|
||||
(0, wasmutils_1.loadNative)("cc65");
|
||||
var params = step.params;
|
||||
// stderr
|
||||
var re_err1 = /(.*?):(\d+): (.+)/;
|
||||
@@ -311,19 +313,19 @@ function compileCC65(step) {
|
||||
});
|
||||
}
|
||||
}
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.c" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.c" });
|
||||
var destpath = step.prefix + '.s';
|
||||
if ((0, workermain_1.staleFiles)(step, [destpath])) {
|
||||
var CC65 = workermain_1.emglobal.cc65({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('cc65'),
|
||||
if ((0, builder_1.staleFiles)(step, [destpath])) {
|
||||
var CC65 = wasmutils_1.emglobal.cc65({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('cc65'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: workermain_1.print_fn,
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: match_fn,
|
||||
});
|
||||
var FS = CC65.FS;
|
||||
(0, workermain_1.setupFS)(FS, '65-' + (0, util_1.getRootBasePlatform)(step.platform));
|
||||
(0, workermain_1.populateFiles)(step, FS, {
|
||||
(0, wasmutils_1.setupFS)(FS, '65-' + (0, util_1.getRootBasePlatform)(step.platform));
|
||||
(0, builder_1.populateFiles)(step, FS, {
|
||||
mainFilePath: step.path,
|
||||
processFn: (path, code) => {
|
||||
if (typeof code === 'string') {
|
||||
@@ -332,7 +334,7 @@ function compileCC65(step) {
|
||||
return code;
|
||||
}
|
||||
});
|
||||
(0, workermain_1.fixParamsWithDefines)(step.path, params);
|
||||
(0, builder_1.fixParamsWithDefines)(step.path, params);
|
||||
var args = [
|
||||
'-I', '/share/include',
|
||||
'-I', '.',
|
||||
@@ -348,11 +350,11 @@ function compileCC65(step) {
|
||||
args = args.concat(customArgs, args);
|
||||
args.push(step.path);
|
||||
//console.log(args);
|
||||
(0, workermain_1.execMain)(step, CC65, args);
|
||||
(0, wasmutils_1.execMain)(step, CC65, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var asmout = FS.readFile(destpath, { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)(destpath, asmout);
|
||||
(0, builder_1.putWorkFile)(destpath, asmout);
|
||||
}
|
||||
return {
|
||||
nexttool: "ca65",
|
||||
|
||||
File diff suppressed because one or more lines are too long
+11
-42
@@ -1,60 +1,29 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileCC7800 = void 0;
|
||||
const wasishim_1 = require("../../common/wasi/wasishim");
|
||||
const workermain_1 = require("../workermain");
|
||||
const jszip_1 = __importDefault(require("jszip"));
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const wasiutils_1 = require("../wasiutils");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
let cc7800_fs = null;
|
||||
let wasiModule = null;
|
||||
function loadBlobSync(path) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'blob';
|
||||
xhr.open("GET", path, false); // synchronous request
|
||||
xhr.send(null);
|
||||
return xhr.response;
|
||||
}
|
||||
async function loadWASIFilesystemZip(zippath) {
|
||||
const jszip = new jszip_1.default();
|
||||
const path = '../../src/worker/fs/' + zippath;
|
||||
const zipdata = loadBlobSync(path);
|
||||
console.log(zippath, zipdata);
|
||||
await jszip.loadAsync(zipdata);
|
||||
let fs = new wasishim_1.WASIMemoryFilesystem();
|
||||
let promises = [];
|
||||
jszip.forEach(async (relativePath, zipEntry) => {
|
||||
if (zipEntry.dir) {
|
||||
fs.putDirectory(relativePath);
|
||||
}
|
||||
else {
|
||||
let path = './' + relativePath;
|
||||
let prom = zipEntry.async("uint8array").then((data) => {
|
||||
fs.putFile(path, data);
|
||||
});
|
||||
promises.push(prom);
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
return fs;
|
||||
}
|
||||
async function compileCC7800(step) {
|
||||
const errors = [];
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.c" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.c" });
|
||||
const destpath = "./a.out";
|
||||
if ((0, workermain_1.staleFiles)(step, [destpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [destpath])) {
|
||||
if (!cc7800_fs) {
|
||||
cc7800_fs = await loadWASIFilesystemZip("cc7800-fs.zip");
|
||||
cc7800_fs = await (0, wasiutils_1.loadWASIFilesystemZip)("cc7800-fs.zip");
|
||||
}
|
||||
if (!wasiModule) {
|
||||
wasiModule = new WebAssembly.Module((0, workermain_1.loadWASMBinary)("cc7800"));
|
||||
wasiModule = new WebAssembly.Module((0, wasmutils_1.loadWASMBinary)("cc7800"));
|
||||
}
|
||||
const wasi = new wasishim_1.WASIRunner();
|
||||
wasi.initSync(wasiModule);
|
||||
wasi.fs.setParent(cc7800_fs);
|
||||
for (let file of step.files) {
|
||||
wasi.fs.putFile("./" + file, workermain_1.store.getFileData(file));
|
||||
wasi.fs.putFile("./" + file, builder_1.store.getFileData(file));
|
||||
}
|
||||
wasi.addPreopenDirectory("headers");
|
||||
wasi.addPreopenDirectory(".");
|
||||
@@ -72,7 +41,7 @@ async function compileCC7800(step) {
|
||||
console.log('stderr', stderr);
|
||||
// Syntax error: Unknown identifier cputes on line 11 of test.c78
|
||||
if (stderr.indexOf("Syntax error:") >= 0) {
|
||||
const matcher = (0, workermain_1.makeErrorMatcher)(errors, /^Syntax error: (.+?) on line (\d+) of (.+)/, 2, 1, step.path, 3);
|
||||
const matcher = (0, listingutils_1.makeErrorMatcher)(errors, /^Syntax error: (.+?) on line (\d+) of (.+)/, 2, 1, step.path, 3);
|
||||
for (let line of stderr.split('\n')) {
|
||||
matcher(line);
|
||||
}
|
||||
@@ -81,7 +50,7 @@ async function compileCC7800(step) {
|
||||
return { errors };
|
||||
}
|
||||
const combinedasm = wasi.fs.getFile(destpath).getBytesAsString();
|
||||
(0, workermain_1.putWorkFile)(destpath, combinedasm);
|
||||
(0, builder_1.putWorkFile)(destpath, combinedasm);
|
||||
}
|
||||
return {
|
||||
nexttool: "dasm",
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"cc7800.js","sourceRoot":"","sources":["../../../src/worker/tools/cc7800.ts"],"names":[],"mappings":";;;;;;AAAA,yDAA8F;AAC9F,8CAAqK;AACrK,kDAA0B;AAE1B,IAAI,SAAS,GAA0B,IAAI,CAAC;AAC5C,IAAI,UAAU,GAA8B,IAAI,CAAC;AAEjD,SAAS,YAAY,CAAC,IAAY;IAC9B,IAAI,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;IAC/B,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC;IAC1B,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAE,sBAAsB;IACrD,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACf,OAAO,G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,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAC9B,iEAAiE;QACjE,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE;YACtC,MAAM,OAAO,GAAG,IAAA,+BAAgB,EAAC,MAAM,EAAE,4CAA4C,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;YAC3G,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBACjC,OAAO,CAAC,IAAI,CAAC,CAAC;aACjB;SACJ;QACD,IAAI,MAAM,CAAC,MAAM,EAAE;YACf,OAAO,EAAE,MAAM,EAAE,CAAC;SACrB;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,gBAAgB,EAAE,CAAC;QACjE,IAAA,qBAAW,EAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;KACtC;IACD,OAAO;QACH,QAAQ,EAAE,MAAM;QAChB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,CAAC,QAAQ,CAAC;QAChB,KAAK,EAAE,CAAC,QAAQ,CAAC;KACpB,CAAC;AACN,CAAC;AAjDD,sCAiDC"}
|
||||
+73
-110
@@ -1,7 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileBatariBasic = exports.assembleDASM = void 0;
|
||||
const workermain_1 = require("../workermain");
|
||||
exports.assembleDASM2 = exports.assembleDASM = void 0;
|
||||
const wasishim_1 = require("../../common/wasi/wasishim");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
function parseDASMListing(lstpath, lsttext, listings, errors, unresolved) {
|
||||
// TODO: this gets very slow
|
||||
// TODO: macros that are on adjacent lines don't get offset addresses
|
||||
@@ -13,7 +16,7 @@ function parseDASMListing(lstpath, lsttext, listings, errors, unresolved) {
|
||||
let macros = {};
|
||||
let lstline = 0;
|
||||
let lstlist = listings[lstpath];
|
||||
for (let line of lsttext.split(workermain_1.re_crlf)) {
|
||||
for (let line of lsttext.split(listingutils_1.re_crlf)) {
|
||||
lstline++;
|
||||
let linem = lineMatch.exec(line + " ");
|
||||
if (linem && linem[1] != null) {
|
||||
@@ -110,7 +113,7 @@ function parseDASMListing(lstpath, lsttext, listings, errors, unresolved) {
|
||||
}
|
||||
}
|
||||
}
|
||||
let errm = workermain_1.re_msvc.exec(line);
|
||||
let errm = listingutils_1.re_msvc.exec(line);
|
||||
if (errm) {
|
||||
errors.push({
|
||||
path: errm[1],
|
||||
@@ -120,12 +123,22 @@ function parseDASMListing(lstpath, lsttext, listings, errors, unresolved) {
|
||||
}
|
||||
}
|
||||
}
|
||||
var re_usl = /(\w+)\s+0000\s+[?][?][?][?]/;
|
||||
function parseSymbolMap(asym) {
|
||||
var symbolmap = {};
|
||||
for (var s of asym.split("\n")) {
|
||||
var toks = s.split(/\s+/);
|
||||
if (toks && toks.length >= 2 && !toks[0].startsWith('-')) {
|
||||
symbolmap[toks[0]] = parseInt(toks[1], 16);
|
||||
}
|
||||
}
|
||||
return symbolmap;
|
||||
}
|
||||
function assembleDASM(step) {
|
||||
(0, workermain_1.load)("dasm");
|
||||
var re_usl = /(\w+)\s+0000\s+[?][?][?][?]/;
|
||||
(0, wasmutils_1.load)("dasm");
|
||||
var unresolved = {};
|
||||
var errors = [];
|
||||
var errorMatcher = (0, workermain_1.msvcErrorMatcher)(errors);
|
||||
var errorMatcher = (0, listingutils_1.msvcErrorMatcher)(errors);
|
||||
function match_fn(s) {
|
||||
// TODO: what if s is not string? (startsWith is not a function)
|
||||
var matches = re_usl.exec(s);
|
||||
@@ -151,18 +164,18 @@ function assembleDASM(step) {
|
||||
errorMatcher(s);
|
||||
}
|
||||
}
|
||||
var Module = workermain_1.emglobal.DASM({
|
||||
var Module = wasmutils_1.emglobal.DASM({
|
||||
noInitialRun: true,
|
||||
print: match_fn
|
||||
});
|
||||
var FS = Module.FS;
|
||||
(0, workermain_1.populateFiles)(step, FS, {
|
||||
(0, builder_1.populateFiles)(step, FS, {
|
||||
mainFilePath: 'main.a'
|
||||
});
|
||||
var binpath = step.prefix + '.bin';
|
||||
var lstpath = step.prefix + '.lst';
|
||||
var sympath = step.prefix + '.sym';
|
||||
(0, workermain_1.execMain)(step, Module, [step.path, '-f3',
|
||||
(0, wasmutils_1.execMain)(step, Module, [step.path, '-f3',
|
||||
"-l" + lstpath,
|
||||
"-o" + binpath,
|
||||
"-s" + sympath]);
|
||||
@@ -188,20 +201,14 @@ function assembleDASM(step) {
|
||||
errors.push({ line: 0, msg: "No symbol table generated, maybe segment overflow?" });
|
||||
return { errors: errors };
|
||||
}
|
||||
(0, workermain_1.putWorkFile)(binpath, aout);
|
||||
(0, workermain_1.putWorkFile)(lstpath, alst);
|
||||
(0, workermain_1.putWorkFile)(sympath, asym);
|
||||
(0, builder_1.putWorkFile)(binpath, aout);
|
||||
(0, builder_1.putWorkFile)(lstpath, alst);
|
||||
(0, builder_1.putWorkFile)(sympath, asym);
|
||||
// return unchanged if no files changed
|
||||
// TODO: what if listing or symbols change?
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, [binpath /*, lstpath, sympath*/]))
|
||||
if (!(0, builder_1.anyTargetChanged)(step, [binpath /*, lstpath, sympath*/]))
|
||||
return;
|
||||
var symbolmap = {};
|
||||
for (var s of asym.split("\n")) {
|
||||
var toks = s.split(/\s+/);
|
||||
if (toks && toks.length >= 2 && !toks[0].startsWith('-')) {
|
||||
symbolmap[toks[0]] = parseInt(toks[1], 16);
|
||||
}
|
||||
}
|
||||
const symbolmap = parseSymbolMap(asym);
|
||||
// for bataribasic (TODO)
|
||||
if (step['bblines']) {
|
||||
let lst = listings[step.path];
|
||||
@@ -219,101 +226,57 @@ function assembleDASM(step) {
|
||||
};
|
||||
}
|
||||
exports.assembleDASM = assembleDASM;
|
||||
function preprocessBatariBasic(code) {
|
||||
(0, workermain_1.load)("bbpreprocess");
|
||||
var bbout = "";
|
||||
function addbbout_fn(s) {
|
||||
bbout += s;
|
||||
bbout += "\n";
|
||||
let wasiModule = null;
|
||||
function assembleDASM2(step) {
|
||||
const errors = [];
|
||||
if (!wasiModule) {
|
||||
wasiModule = new WebAssembly.Module((0, wasmutils_1.loadWASMBinary)("dasm-wasisdk"));
|
||||
}
|
||||
var BBPRE = workermain_1.emglobal.preprocess({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: addbbout_fn,
|
||||
printErr: workermain_1.print_fn,
|
||||
noFSInit: true,
|
||||
});
|
||||
var FS = BBPRE.FS;
|
||||
(0, workermain_1.setupStdin)(FS, code);
|
||||
BBPRE.callMain([]);
|
||||
console.log("preprocess " + code.length + " -> " + bbout.length + " bytes");
|
||||
return bbout;
|
||||
}
|
||||
function compileBatariBasic(step) {
|
||||
(0, workermain_1.load)("bb2600basic");
|
||||
var params = step.params;
|
||||
// stdout
|
||||
var asmout = "";
|
||||
function addasmout_fn(s) {
|
||||
asmout += s;
|
||||
asmout += "\n";
|
||||
const binpath = 'a.out';
|
||||
const lstpath = step.prefix + '.lst';
|
||||
const sympath = step.prefix + '.sym';
|
||||
const wasi = new wasishim_1.WASIRunner();
|
||||
wasi.initSync(wasiModule);
|
||||
for (let file of step.files) {
|
||||
wasi.fs.putFile("./" + file, builder_1.store.getFileData(file));
|
||||
}
|
||||
// stderr
|
||||
var re_err1 = /[(](\d+)[)]:?\s*(.+)/;
|
||||
var errors = [];
|
||||
var errline = 0;
|
||||
function match_fn(s) {
|
||||
console.log(s);
|
||||
var matches = re_err1.exec(s);
|
||||
if (matches) {
|
||||
errline = parseInt(matches[1]);
|
||||
errors.push({
|
||||
line: errline,
|
||||
msg: matches[2]
|
||||
});
|
||||
wasi.addPreopenDirectory(".");
|
||||
wasi.setArgs(['dasm', step.path, '-f3', "-l" + lstpath, "-s" + sympath]);
|
||||
try {
|
||||
wasi.run();
|
||||
}
|
||||
catch (e) {
|
||||
errors.push(e);
|
||||
}
|
||||
const stdout = wasi.fds[1].getBytesAsString();
|
||||
//const stderr = wasi.fds[2].getBytesAsString();
|
||||
const matcher = (0, listingutils_1.msvcErrorMatcher)(errors);
|
||||
const unresolved = {};
|
||||
for (let line of stdout.split("\n")) {
|
||||
matcher(line);
|
||||
let m = re_usl.exec(line);
|
||||
if (m) {
|
||||
unresolved[m[1]] = 0;
|
||||
}
|
||||
}
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.bas" });
|
||||
var destpath = step.prefix + '.asm';
|
||||
if ((0, workermain_1.staleFiles)(step, [destpath])) {
|
||||
var BB = workermain_1.emglobal.bb2600basic({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: addasmout_fn,
|
||||
printErr: match_fn,
|
||||
noFSInit: true,
|
||||
TOTAL_MEMORY: 64 * 1024 * 1024,
|
||||
});
|
||||
var FS = BB.FS;
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
// preprocess, pipe file to stdin
|
||||
var code = (0, workermain_1.getWorkFileAsString)(step.path);
|
||||
code = preprocessBatariBasic(code);
|
||||
(0, workermain_1.setupStdin)(FS, code);
|
||||
(0, workermain_1.setupFS)(FS, '2600basic');
|
||||
(0, workermain_1.execMain)(step, BB, ["-i", "/share", step.path]);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
// build final assembly output from include file list
|
||||
var includesout = FS.readFile("includes.bB", { encoding: 'utf8' });
|
||||
var redefsout = FS.readFile("2600basic_variable_redefs.h", { encoding: 'utf8' });
|
||||
var includes = includesout.trim().split("\n");
|
||||
var combinedasm = "";
|
||||
var splitasm = asmout.split("bB.asm file is split here");
|
||||
for (var incfile of includes) {
|
||||
var inctext;
|
||||
if (incfile == "bB.asm")
|
||||
inctext = splitasm[0];
|
||||
else if (incfile == "bB2.asm")
|
||||
inctext = splitasm[1];
|
||||
else
|
||||
inctext = FS.readFile("/share/includes/" + incfile, { encoding: 'utf8' });
|
||||
console.log(incfile, inctext.length);
|
||||
combinedasm += "\n\n;;;" + incfile + "\n\n";
|
||||
combinedasm += inctext;
|
||||
}
|
||||
// TODO: ; bB.asm file is split here
|
||||
(0, workermain_1.putWorkFile)(destpath, combinedasm);
|
||||
(0, workermain_1.putWorkFile)("2600basic.h", FS.readFile("/share/includes/2600basic.h"));
|
||||
(0, workermain_1.putWorkFile)("2600basic_variable_redefs.h", redefsout);
|
||||
const alst = wasi.fs.getFile("./" + lstpath).getBytesAsString();
|
||||
const listings = {};
|
||||
for (let path of step.files) {
|
||||
listings[path] = { lines: [] };
|
||||
}
|
||||
parseDASMListing(lstpath, alst, listings, errors, unresolved);
|
||||
if (errors.length) {
|
||||
return { errors: errors };
|
||||
}
|
||||
const asym = wasi.fs.getFile("./" + sympath).getBytesAsString();
|
||||
const symbolmap = parseSymbolMap(asym);
|
||||
const output = wasi.fs.getFile("./" + binpath).getBytes();
|
||||
return {
|
||||
nexttool: "dasm",
|
||||
path: destpath,
|
||||
args: [destpath],
|
||||
files: [destpath, "2600basic.h", "2600basic_variable_redefs.h"],
|
||||
bblines: true,
|
||||
output,
|
||||
errors,
|
||||
listings,
|
||||
symbolmap
|
||||
};
|
||||
}
|
||||
exports.compileBatariBasic = compileBatariBasic;
|
||||
exports.assembleDASM2 = assembleDASM2;
|
||||
//# sourceMappingURL=dasm.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -4,25 +4,25 @@ exports.assembleECS = void 0;
|
||||
const compiler_1 = require("../../common/ecs/compiler");
|
||||
const ecs_1 = require("../../common/ecs/ecs");
|
||||
const tokenizer_1 = require("../../common/tokenizer");
|
||||
const workermain_1 = require("../workermain");
|
||||
const builder_1 = require("../builder");
|
||||
function assembleECS(step) {
|
||||
let em = new ecs_1.EntityManager(new ecs_1.Dialect_CA65()); // TODO
|
||||
let compiler = new compiler_1.ECSCompiler(em, true);
|
||||
compiler.getImportFile = (path) => {
|
||||
return (0, workermain_1.getWorkFileAsString)(path);
|
||||
return (0, builder_1.getWorkFileAsString)(path);
|
||||
};
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.ecs" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.ecs" });
|
||||
if (step.mainfile)
|
||||
em.mainPath = step.path;
|
||||
var destpath = step.prefix + '.ca65';
|
||||
if ((0, workermain_1.staleFiles)(step, [destpath])) {
|
||||
let code = (0, workermain_1.getWorkFileAsString)(step.path);
|
||||
(0, workermain_1.fixParamsWithDefines)(step.path, step.params);
|
||||
if ((0, builder_1.staleFiles)(step, [destpath])) {
|
||||
let code = (0, builder_1.getWorkFileAsString)(step.path);
|
||||
(0, builder_1.fixParamsWithDefines)(step.path, step.params);
|
||||
try {
|
||||
compiler.includeDebugInfo = true;
|
||||
compiler.parseFile(code, step.path);
|
||||
let outtext = compiler.export().toString();
|
||||
(0, workermain_1.putWorkFile)(destpath, outtext);
|
||||
(0, builder_1.putWorkFile)(destpath, outtext);
|
||||
var listings = {};
|
||||
listings[destpath] = { lines: [], text: outtext }; // TODO
|
||||
var debuginfo = compiler.em.getDebugTree();
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"ecs.js","sourceRoot":"","sources":["../../../src/worker/tools/ecs.ts"],"names":[],"mappings":";;;AAAA,wDAAwD;AACxD,8CAA6E;AAC7E,sDAAsD;AAEtD,8CAA4I;AAE5I,SAAgB,WAAW,CAAC,IAAe;IACvC,IAAI,EAAE,GAAG,IAAI,mBAAa,CAAC,IAAI,kBAAY,EAAE,CAAC,CAAC,CAAC,OAAO;IACvD,IAAI,QAAQ,GAAG,IAAI,sBAAW,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IACzC,QAAQ,CAAC,aAAa,GAAG,CAAC,IAAY,EAAE,EAAE;QACtC,OAAO,IAAA,gCAAmB,EAAC,IAAI,CAAC,CAAC;IACrC,CAAC,CAAA;IAC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C;iBAAM,IAAI,CAAC,YAAY,wBAAY,EAAE;gBAClC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;aACtC;iBAAM;gBACH,MAAM,CAAC,CAAC;aACX;SACJ;QACD,OAAO;YACH,QAAQ,EAAE,MAAM;YAChB,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,QAAQ,CAAC;YAChB,KAAK,EAAE,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;YACpC,QAAQ;YACR,SAAS;SACZ,CAAC;KACL;AACL,CAAC;AA5CD,kCA4CC"}
|
||||
+34
-32
@@ -1,10 +1,12 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileFastBasic = exports.assembleMerlin32 = exports.assembleNESASM = void 0;
|
||||
const workermain_1 = require("../workermain");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
// http://www.nespowerpak.com/nesasm/
|
||||
function assembleNESASM(step) {
|
||||
(0, workermain_1.loadNative)("nesasm");
|
||||
(0, wasmutils_1.loadNative)("nesasm");
|
||||
var re_filename = /\#\[(\d+)\]\s+(\S+)/;
|
||||
var re_insn = /\s+(\d+)\s+([0-9A-F]+):([0-9A-F]+)/;
|
||||
var re_error = /\s+(.+)/;
|
||||
@@ -35,26 +37,26 @@ function assembleNESASM(step) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
var Module = workermain_1.emglobal.nesasm({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('nesasm'),
|
||||
var Module = wasmutils_1.emglobal.nesasm({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('nesasm'),
|
||||
noInitialRun: true,
|
||||
print: match_fn
|
||||
});
|
||||
var FS = Module.FS;
|
||||
(0, workermain_1.populateFiles)(step, FS, {
|
||||
(0, builder_1.populateFiles)(step, FS, {
|
||||
mainFilePath: 'main.a'
|
||||
});
|
||||
var binpath = step.prefix + '.nes';
|
||||
var lstpath = step.prefix + '.lst';
|
||||
var sympath = step.prefix + '.fns';
|
||||
(0, workermain_1.execMain)(step, Module, [step.path, '-s', "-l", "2"]);
|
||||
(0, wasmutils_1.execMain)(step, Module, [step.path, '-s', "-l", "2"]);
|
||||
// parse main listing, get errors and listings for each file
|
||||
var listings = {};
|
||||
try {
|
||||
var alst = FS.readFile(lstpath, { 'encoding': 'utf8' });
|
||||
// 16 00:C004 8E 17 40 STX $4017 ; disable APU frame IRQ
|
||||
var asmlines = (0, workermain_1.parseListing)(alst, /^\s*(\d+)\s+([0-9A-F]+):([0-9A-F]+)\s+([0-9A-F ]+?) (.*)/i, 1, 3, 4);
|
||||
(0, workermain_1.putWorkFile)(lstpath, alst);
|
||||
var asmlines = (0, listingutils_1.parseListing)(alst, /^\s*(\d+)\s+([0-9A-F]+):([0-9A-F]+)\s+([0-9A-F ]+?) (.*)/i, 1, 3, 4);
|
||||
(0, builder_1.putWorkFile)(lstpath, alst);
|
||||
listings[lstpath] = {
|
||||
lines: asmlines,
|
||||
text: alst
|
||||
@@ -77,12 +79,12 @@ function assembleNESASM(step) {
|
||||
errors.push({ line: 0, msg: "No symbol table generated, maybe missing ENDM or segment overflow?" });
|
||||
return { errors: errors };
|
||||
}
|
||||
(0, workermain_1.putWorkFile)(binpath, aout);
|
||||
(0, workermain_1.putWorkFile)(sympath, asym);
|
||||
(0, builder_1.putWorkFile)(binpath, aout);
|
||||
(0, builder_1.putWorkFile)(sympath, asym);
|
||||
if (alst)
|
||||
(0, workermain_1.putWorkFile)(lstpath, alst); // listing optional (use LIST)
|
||||
(0, builder_1.putWorkFile)(lstpath, alst); // listing optional (use LIST)
|
||||
// return unchanged if no files changed
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, [binpath, sympath]))
|
||||
if (!(0, builder_1.anyTargetChanged)(step, [binpath, sympath]))
|
||||
return;
|
||||
// parse symbols
|
||||
var symbolmap = {};
|
||||
@@ -116,15 +118,15 @@ Line | # File Line | Line Type | MX | Reloc | Size | Address Object
|
||||
|
||||
*/
|
||||
function assembleMerlin32(step) {
|
||||
(0, workermain_1.loadNative)("merlin32");
|
||||
(0, wasmutils_1.loadNative)("merlin32");
|
||||
var errors = [];
|
||||
var lstfiles = [];
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.lnk" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.lnk" });
|
||||
var objpath = step.prefix + ".bin";
|
||||
if ((0, workermain_1.staleFiles)(step, [objpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [objpath])) {
|
||||
var args = ['-v', step.path];
|
||||
var merlin32 = workermain_1.emglobal.merlin32({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('merlin32'),
|
||||
var merlin32 = wasmutils_1.emglobal.merlin32({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('merlin32'),
|
||||
noInitialRun: true,
|
||||
print: (s) => {
|
||||
var m = /\s*=>\s*Creating Output file '(.+?)'/.exec(s);
|
||||
@@ -143,11 +145,11 @@ function assembleMerlin32(step) {
|
||||
});
|
||||
}
|
||||
},
|
||||
printErr: workermain_1.print_fn,
|
||||
printErr: wasmutils_1.print_fn,
|
||||
});
|
||||
var FS = merlin32.FS;
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.execMain)(step, merlin32, args);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, wasmutils_1.execMain)(step, merlin32, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var errout = null;
|
||||
@@ -158,8 +160,8 @@ function assembleMerlin32(step) {
|
||||
//
|
||||
}
|
||||
var objout = FS.readFile(objpath, { encoding: 'binary' });
|
||||
(0, workermain_1.putWorkFile)(objpath, objout);
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, [objpath]))
|
||||
(0, builder_1.putWorkFile)(objpath, objout);
|
||||
if (!(0, builder_1.anyTargetChanged)(step, [objpath]))
|
||||
return;
|
||||
var symbolmap = {};
|
||||
var segments = [];
|
||||
@@ -202,20 +204,20 @@ exports.assembleMerlin32 = assembleMerlin32;
|
||||
// README.md:2:5: parse error, expected: statement or variable assignment, integer variable, variable assignment
|
||||
function compileFastBasic(step) {
|
||||
// TODO: fastbasic-fp?
|
||||
(0, workermain_1.loadNative)("fastbasic-int");
|
||||
(0, wasmutils_1.loadNative)("fastbasic-int");
|
||||
var params = step.params;
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.fb" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.fb" });
|
||||
var destpath = step.prefix + '.s';
|
||||
var errors = [];
|
||||
if ((0, workermain_1.staleFiles)(step, [destpath])) {
|
||||
var fastbasic = workermain_1.emglobal.fastbasic({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('fastbasic-int'),
|
||||
if ((0, builder_1.staleFiles)(step, [destpath])) {
|
||||
var fastbasic = wasmutils_1.emglobal.fastbasic({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('fastbasic-int'),
|
||||
noInitialRun: true,
|
||||
print: workermain_1.print_fn,
|
||||
printErr: (0, workermain_1.makeErrorMatcher)(errors, /(.+?):(\d+):(\d+):\s*(.+)/, 2, 4, step.path, 1),
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: (0, listingutils_1.makeErrorMatcher)(errors, /(.+?):(\d+):(\d+):\s*(.+)/, 2, 4, step.path, 1),
|
||||
});
|
||||
var FS = fastbasic.FS;
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
var libfile = 'fastbasic-int.lib';
|
||||
params.libargs = [libfile];
|
||||
params.cfgfile = params.fastbasic_cfgfile;
|
||||
@@ -223,11 +225,11 @@ function compileFastBasic(step) {
|
||||
params.extra_link_files = [libfile, params.cfgfile];
|
||||
//fixParamsWithDefines(step.path, params);
|
||||
var args = [step.path, destpath];
|
||||
(0, workermain_1.execMain)(step, fastbasic, args);
|
||||
(0, wasmutils_1.execMain)(step, fastbasic, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var asmout = FS.readFile(destpath, { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)(destpath, asmout);
|
||||
(0, builder_1.putWorkFile)(destpath, asmout);
|
||||
}
|
||||
return {
|
||||
nexttool: "ca65",
|
||||
|
||||
File diff suppressed because one or more lines are too long
+50
-47
@@ -1,10 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.linkLWLINK = exports.assembleLWASM = exports.compileCMOC = exports.assembleXASM6809 = void 0;
|
||||
const workermain_1 = require("../workermain");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
const mcpp_1 = require("./mcpp");
|
||||
// http://datapipe-blackbeltsystems.com/windows/flex/asm09.html
|
||||
function assembleXASM6809(step) {
|
||||
(0, workermain_1.load)("xasm6809");
|
||||
(0, wasmutils_1.load)("xasm6809");
|
||||
var alst = "";
|
||||
var lasterror = null;
|
||||
var errors = [];
|
||||
@@ -23,20 +26,20 @@ function assembleXASM6809(step) {
|
||||
lasterror = s.slice(6);
|
||||
}
|
||||
}
|
||||
var Module = workermain_1.emglobal.xasm6809({
|
||||
var Module = wasmutils_1.emglobal.xasm6809({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: match_fn,
|
||||
printErr: workermain_1.print_fn
|
||||
printErr: wasmutils_1.print_fn
|
||||
});
|
||||
var FS = Module.FS;
|
||||
//setupFS(FS);
|
||||
(0, workermain_1.populateFiles)(step, FS, {
|
||||
(0, builder_1.populateFiles)(step, FS, {
|
||||
mainFilePath: 'main.asm'
|
||||
});
|
||||
var binpath = step.prefix + '.bin';
|
||||
var lstpath = step.prefix + '.lst'; // in stdout
|
||||
(0, workermain_1.execMain)(step, Module, ["-c", "-l", "-s", "-y", "-o=" + binpath, step.path]);
|
||||
(0, wasmutils_1.execMain)(step, Module, ["-c", "-l", "-s", "-y", "-o=" + binpath, step.path]);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var aout = FS.readFile(binpath, { encoding: 'binary' });
|
||||
@@ -44,14 +47,14 @@ function assembleXASM6809(step) {
|
||||
errors.push({ line: 0, msg: "Empty output file" });
|
||||
return { errors: errors };
|
||||
}
|
||||
(0, workermain_1.putWorkFile)(binpath, aout);
|
||||
(0, workermain_1.putWorkFile)(lstpath, alst);
|
||||
(0, builder_1.putWorkFile)(binpath, aout);
|
||||
(0, builder_1.putWorkFile)(lstpath, alst);
|
||||
// TODO: symbol map
|
||||
//mond09 0000
|
||||
var symbolmap = {};
|
||||
//00005 W 0003 [ 8] A6890011 lda >PALETTE,x
|
||||
//00012 0011 0C0203 fcb 12,2,3
|
||||
var asmlines = (0, workermain_1.parseListing)(alst, /^\s*([0-9]+) .+ ([0-9A-F]+)\s+\[([0-9 ]+)\]\s+([0-9A-F]+) (.*)/i, 1, 2, 4, 3);
|
||||
var asmlines = (0, listingutils_1.parseListing)(alst, /^\s*([0-9]+) .+ ([0-9A-F]+)\s+\[([0-9 ]+)\]\s+([0-9A-F]+) (.*)/i, 1, 2, 4, 3);
|
||||
var listings = {};
|
||||
listings[step.prefix + '.lst'] = { lines: asmlines, text: alst };
|
||||
return {
|
||||
@@ -63,7 +66,7 @@ function assembleXASM6809(step) {
|
||||
}
|
||||
exports.assembleXASM6809 = assembleXASM6809;
|
||||
function compileCMOC(step) {
|
||||
(0, workermain_1.loadNative)("cmoc");
|
||||
(0, wasmutils_1.loadNative)("cmoc");
|
||||
var params = step.params;
|
||||
// stderr
|
||||
var re_err1 = /^[/]*([^:]*):(\d+): (.+)$/;
|
||||
@@ -82,23 +85,23 @@ function compileCMOC(step) {
|
||||
console.log(s);
|
||||
}
|
||||
}
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.c" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.c" });
|
||||
var destpath = step.prefix + '.s';
|
||||
if ((0, workermain_1.staleFiles)(step, [destpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [destpath])) {
|
||||
var args = ['-S', '-Werror', '-V',
|
||||
'-I/share/include',
|
||||
'-I.',
|
||||
step.path];
|
||||
var CMOC = workermain_1.emglobal.cmoc({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('cmoc'),
|
||||
var CMOC = wasmutils_1.emglobal.cmoc({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('cmoc'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: match_fn,
|
||||
printErr: match_fn,
|
||||
});
|
||||
// load source file and preprocess
|
||||
var code = (0, workermain_1.getWorkFileAsString)(step.path);
|
||||
var preproc = (0, workermain_1.preprocessMCPP)(step, null);
|
||||
var code = (0, builder_1.getWorkFileAsString)(step.path);
|
||||
var preproc = (0, mcpp_1.preprocessMCPP)(step, null);
|
||||
if (preproc.errors) {
|
||||
return { errors: preproc.errors };
|
||||
}
|
||||
@@ -107,19 +110,19 @@ function compileCMOC(step) {
|
||||
// set up filesystem
|
||||
var FS = CMOC.FS;
|
||||
//setupFS(FS, '65-'+getRootBasePlatform(step.platform));
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
FS.writeFile(step.path, code);
|
||||
(0, workermain_1.fixParamsWithDefines)(step.path, params);
|
||||
(0, builder_1.fixParamsWithDefines)(step.path, params);
|
||||
if (params.extra_compile_args) {
|
||||
args.unshift.apply(args, params.extra_compile_args);
|
||||
}
|
||||
(0, workermain_1.execMain)(step, CMOC, args);
|
||||
(0, wasmutils_1.execMain)(step, CMOC, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var asmout = FS.readFile(destpath, { encoding: 'utf8' });
|
||||
if (step.params.set_stack_end)
|
||||
asmout = asmout.replace('stack space in bytes', `\n lds #${step.params.set_stack_end}\n`);
|
||||
(0, workermain_1.putWorkFile)(destpath, asmout);
|
||||
(0, builder_1.putWorkFile)(destpath, asmout);
|
||||
}
|
||||
return {
|
||||
nexttool: "lwasm",
|
||||
@@ -130,34 +133,34 @@ function compileCMOC(step) {
|
||||
}
|
||||
exports.compileCMOC = compileCMOC;
|
||||
function assembleLWASM(step) {
|
||||
(0, workermain_1.loadNative)("lwasm");
|
||||
(0, wasmutils_1.loadNative)("lwasm");
|
||||
var errors = [];
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.s" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.s" });
|
||||
var objpath = step.prefix + ".o";
|
||||
var lstpath = step.prefix + ".lst";
|
||||
const isRaw = step.path.endsWith('.asm');
|
||||
if ((0, workermain_1.staleFiles)(step, [objpath, lstpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [objpath, lstpath])) {
|
||||
var objout, lstout;
|
||||
var args = ['-9', '-I/share/asminc', '-o' + objpath, '-l' + lstpath, step.path];
|
||||
args.push(isRaw ? '-r' : '--obj');
|
||||
var LWASM = workermain_1.emglobal.lwasm({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('lwasm'),
|
||||
var LWASM = wasmutils_1.emglobal.lwasm({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('lwasm'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: workermain_1.print_fn,
|
||||
printErr: (0, workermain_1.msvcErrorMatcher)(errors),
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: (0, listingutils_1.msvcErrorMatcher)(errors),
|
||||
});
|
||||
var FS = LWASM.FS;
|
||||
//setupFS(FS, '65-'+getRootBasePlatform(step.platform));
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.fixParamsWithDefines)(step.path, step.params);
|
||||
(0, workermain_1.execMain)(step, LWASM, args);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, builder_1.fixParamsWithDefines)(step.path, step.params);
|
||||
(0, wasmutils_1.execMain)(step, LWASM, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
objout = FS.readFile(objpath, { encoding: 'binary' });
|
||||
lstout = FS.readFile(lstpath, { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)(objpath, objout);
|
||||
(0, workermain_1.putWorkFile)(lstpath, lstout);
|
||||
(0, builder_1.putWorkFile)(objpath, objout);
|
||||
(0, builder_1.putWorkFile)(lstpath, lstout);
|
||||
if (isRaw) {
|
||||
return {
|
||||
output: objout
|
||||
@@ -172,17 +175,17 @@ function assembleLWASM(step) {
|
||||
}
|
||||
exports.assembleLWASM = assembleLWASM;
|
||||
function linkLWLINK(step) {
|
||||
(0, workermain_1.loadNative)("lwlink");
|
||||
(0, wasmutils_1.loadNative)("lwlink");
|
||||
var params = step.params;
|
||||
(0, workermain_1.gatherFiles)(step);
|
||||
(0, builder_1.gatherFiles)(step);
|
||||
var binpath = "main";
|
||||
if ((0, workermain_1.staleFiles)(step, [binpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [binpath])) {
|
||||
var errors = [];
|
||||
var LWLINK = workermain_1.emglobal.lwlink({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('lwlink'),
|
||||
var LWLINK = wasmutils_1.emglobal.lwlink({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('lwlink'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: workermain_1.print_fn,
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: function (s) {
|
||||
if (s.startsWith("Warning:"))
|
||||
console.log(s);
|
||||
@@ -192,8 +195,8 @@ function linkLWLINK(step) {
|
||||
});
|
||||
var FS = LWLINK.FS;
|
||||
//setupFS(FS, '65-'+getRootBasePlatform(step.platform));
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.populateExtraFiles)(step, FS, params.extra_link_files);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateExtraFiles)(step, FS, params.extra_link_files);
|
||||
var libargs = params.extra_link_args || [];
|
||||
var args = [
|
||||
'-L.',
|
||||
@@ -203,15 +206,15 @@ function linkLWLINK(step) {
|
||||
'--map=main.map'
|
||||
].concat(libargs, step.args);
|
||||
console.log(args);
|
||||
(0, workermain_1.execMain)(step, LWLINK, args);
|
||||
(0, wasmutils_1.execMain)(step, LWLINK, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var aout = FS.readFile("main", { encoding: 'binary' });
|
||||
var mapout = FS.readFile("main.map", { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)("main", aout);
|
||||
(0, workermain_1.putWorkFile)("main.map", mapout);
|
||||
(0, builder_1.putWorkFile)("main", aout);
|
||||
(0, builder_1.putWorkFile)("main.map", mapout);
|
||||
// return unchanged if no files changed
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, ["main", "main.map"]))
|
||||
if (!(0, builder_1.anyTargetChanged)(step, ["main", "main.map"]))
|
||||
return;
|
||||
// parse symbol map
|
||||
//console.log(mapout);
|
||||
@@ -246,16 +249,16 @@ function linkLWLINK(step) {
|
||||
if (fn.endsWith('.lst')) {
|
||||
// TODO
|
||||
var lstout = FS.readFile(fn, { encoding: 'utf8' });
|
||||
var asmlines = (0, workermain_1.parseListing)(lstout, /^([0-9A-F]+)\s+([0-9A-F]+)\s+[(]\s*(.+?)[)]:(\d+) (.*)/i, 4, 1, 2, 3, re_function, re_segment);
|
||||
var asmlines = (0, listingutils_1.parseListing)(lstout, /^([0-9A-F]+)\s+([0-9A-F]+)\s+[(]\s*(.+?)[)]:(\d+) (.*)/i, 4, 1, 2, 3, re_function, re_segment);
|
||||
for (let l of asmlines) {
|
||||
l.offset += symbolmap[l.func] || 0;
|
||||
}
|
||||
// * Line //threed.c:117: init of variable e
|
||||
var srclines = (0, workermain_1.parseSourceLines)(lstout, /Line .+?:(\d+)/i, /^([0-9A-F]{4})/i, re_function, re_segment);
|
||||
var srclines = (0, listingutils_1.parseSourceLines)(lstout, /Line .+?:(\d+)/i, /^([0-9A-F]{4})/i, re_function, re_segment);
|
||||
for (let l of srclines) {
|
||||
l.offset += symbolmap[l.func] || 0;
|
||||
}
|
||||
(0, workermain_1.putWorkFile)(fn, lstout);
|
||||
(0, builder_1.putWorkFile)(fn, lstout);
|
||||
// strip out left margin
|
||||
lstout = lstout.split('\n').map(l => l.substring(0, 15) + l.substring(56)).join('\n');
|
||||
// TODO: you have to get rid of all source lines to get asm listing
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.preprocessMCPP = void 0;
|
||||
const util_1 = require("../../common/util");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const platforms_1 = require("../platforms");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
function makeCPPSafe(s) {
|
||||
return s.replace(/[^A-Za-z0-9_]/g, '_');
|
||||
}
|
||||
function preprocessMCPP(step, filesys) {
|
||||
(0, wasmutils_1.load)("mcpp");
|
||||
var platform = step.platform;
|
||||
var params = platforms_1.PLATFORM_PARAMS[(0, util_1.getBasePlatform)(platform)];
|
||||
if (!params)
|
||||
throw Error("Platform not supported: " + platform);
|
||||
// <stdin>:2: error: Can't open include file "foo.h"
|
||||
var errors = [];
|
||||
var match_fn = (0, listingutils_1.makeErrorMatcher)(errors, /<stdin>:(\d+): (.+)/, 1, 2, step.path);
|
||||
var MCPP = wasmutils_1.emglobal.mcpp({
|
||||
noInitialRun: true,
|
||||
noFSInit: true,
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: match_fn,
|
||||
});
|
||||
var FS = MCPP.FS;
|
||||
if (filesys)
|
||||
(0, wasmutils_1.setupFS)(FS, filesys);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateExtraFiles)(step, FS, params.extra_compile_files);
|
||||
// TODO: make configurable by other compilers
|
||||
var args = [
|
||||
"-D", "__8BITWORKSHOP__",
|
||||
"-D", "__SDCC_z80",
|
||||
"-D", makeCPPSafe(platform.toUpperCase()),
|
||||
"-I", "/share/include",
|
||||
"-Q",
|
||||
step.path, "main.i"
|
||||
];
|
||||
if (step.mainfile) {
|
||||
args.unshift.apply(args, ["-D", "__MAIN__"]);
|
||||
}
|
||||
let platform_def = platform.toUpperCase().replaceAll(/[^a-zA-Z0-9]/g, '_');
|
||||
args.unshift.apply(args, ["-D", `__PLATFORM_${platform_def}__`]);
|
||||
if (params.extra_preproc_args) {
|
||||
args.push.apply(args, params.extra_preproc_args);
|
||||
}
|
||||
(0, wasmutils_1.execMain)(step, MCPP, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var iout = FS.readFile("main.i", { encoding: 'utf8' });
|
||||
iout = iout.replace(/^#line /gm, '\n# ');
|
||||
try {
|
||||
var errout = FS.readFile("mcpp.err", { encoding: 'utf8' });
|
||||
if (errout.length) {
|
||||
// //main.c:2: error: Can't open include file "stdiosd.h"
|
||||
var errors = (0, listingutils_1.extractErrors)(/([^:]+):(\d+): (.+)/, errout.split("\n"), step.path, 2, 3, 1);
|
||||
if (errors.length == 0) {
|
||||
errors = (0, builder_1.errorResult)(errout).errors;
|
||||
}
|
||||
return { errors: errors };
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
//
|
||||
}
|
||||
return { code: iout };
|
||||
}
|
||||
exports.preprocessMCPP = preprocessMCPP;
|
||||
//# sourceMappingURL=mcpp.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mcpp.js","sourceRoot":"","sources":["../../../src/worker/tools/mcpp.ts"],"names":[],"mappings":";;;AAAA,4CAAoD;AACpD,wCAAuF;AACvF,kDAAkE;AAClE,4CAA+C;AAC/C,4CAA6F;AAE7F,SAAS,WAAW,CAAC,CAAS;IAC1B,OAAO,CAAC,CAAC,OAAO,CAAC,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AAM,EAAE,MAAM,EAAE,CAAC;SAC7B;KACJ;IAAC,OAAO,CAAC,EAAE;QACR,EAAE;KACL;IACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC1B,CAAC;AArDD,wCAqDC"}
|
||||
+37
-34
@@ -24,34 +24,37 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileWiz = exports.compileBASIC = exports.compileInform6 = exports.translateShowdown = void 0;
|
||||
const workermain_1 = require("../workermain");
|
||||
const basic_compiler = __importStar(require("../../common/basic/compiler"));
|
||||
const util_1 = require("../../common/util");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const workermain_1 = require("../workermain");
|
||||
function translateShowdown(step) {
|
||||
(0, workermain_1.setupRequireFunction)();
|
||||
(0, workermain_1.load)("showdown.min");
|
||||
var showdown = workermain_1.emglobal['showdown'];
|
||||
(0, wasmutils_1.load)("showdown.min");
|
||||
var showdown = wasmutils_1.emglobal['showdown'];
|
||||
var converter = new showdown.Converter({
|
||||
tables: 'true',
|
||||
smoothLivePreview: 'true',
|
||||
requireSpaceBeforeHeadingText: 'true',
|
||||
emoji: 'true',
|
||||
});
|
||||
var code = (0, workermain_1.getWorkFileAsString)(step.path);
|
||||
var code = (0, builder_1.getWorkFileAsString)(step.path);
|
||||
var html = converter.makeHtml(code);
|
||||
delete workermain_1.emglobal['require'];
|
||||
delete wasmutils_1.emglobal['require'];
|
||||
return {
|
||||
output: html
|
||||
};
|
||||
}
|
||||
exports.translateShowdown = translateShowdown;
|
||||
function compileInform6(step) {
|
||||
(0, workermain_1.loadNative)("inform");
|
||||
(0, wasmutils_1.loadNative)("inform");
|
||||
var errors = [];
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.inf" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.inf" });
|
||||
var objpath = step.prefix + ".z5";
|
||||
if ((0, workermain_1.staleFiles)(step, [objpath])) {
|
||||
var errorMatcher = (0, workermain_1.msvcErrorMatcher)(errors);
|
||||
if ((0, builder_1.staleFiles)(step, [objpath])) {
|
||||
var errorMatcher = (0, listingutils_1.msvcErrorMatcher)(errors);
|
||||
var lstout = "";
|
||||
var match_fn = (s) => {
|
||||
if (s.indexOf("Error:") >= 0) {
|
||||
@@ -64,23 +67,23 @@ function compileInform6(step) {
|
||||
};
|
||||
// TODO: step.path must end in '.inf' or error
|
||||
var args = ['-afjnops', '-v5', '-Cu', '-E1', '-k', '+/share/lib', step.path];
|
||||
var inform = workermain_1.emglobal.inform({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('inform'),
|
||||
var inform = wasmutils_1.emglobal.inform({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('inform'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: match_fn,
|
||||
printErr: match_fn,
|
||||
});
|
||||
var FS = inform.FS;
|
||||
(0, workermain_1.setupFS)(FS, 'inform');
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, wasmutils_1.setupFS)(FS, 'inform');
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
//fixParamsWithDefines(step.path, step.params);
|
||||
(0, workermain_1.execMain)(step, inform, args);
|
||||
(0, wasmutils_1.execMain)(step, inform, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var objout = FS.readFile(objpath, { encoding: 'binary' });
|
||||
(0, workermain_1.putWorkFile)(objpath, objout);
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, [objpath]))
|
||||
(0, builder_1.putWorkFile)(objpath, objout);
|
||||
if (!(0, builder_1.anyTargetChanged)(step, [objpath]))
|
||||
return;
|
||||
// parse debug XML
|
||||
var symbolmap = {};
|
||||
@@ -123,7 +126,7 @@ function compileInform6(step) {
|
||||
// parse listing
|
||||
var listings = {};
|
||||
// 35 +00015 <*> call_vs long_19 location long_424 -> sp
|
||||
var lines = (0, workermain_1.parseListing)(lstout, /\s*(\d+)\s+[+]([0-9a-f]+)\s+([<*>]*)\s*(\w+)\s+(.+)/i, -1, 2, 4);
|
||||
var lines = (0, listingutils_1.parseListing)(lstout, /\s*(\d+)\s+[+]([0-9a-f]+)\s+([<*>]*)\s*(\w+)\s+(.+)/i, -1, 2, 4);
|
||||
var lstpath = step.prefix + '.lst';
|
||||
listings[lstpath] = { lines: [], asmlines: lines, text: lstout };
|
||||
return {
|
||||
@@ -139,10 +142,10 @@ function compileInform6(step) {
|
||||
exports.compileInform6 = compileInform6;
|
||||
function compileBASIC(step) {
|
||||
var jsonpath = step.path + ".json";
|
||||
(0, workermain_1.gatherFiles)(step);
|
||||
if ((0, workermain_1.staleFiles)(step, [jsonpath])) {
|
||||
(0, builder_1.gatherFiles)(step);
|
||||
if ((0, builder_1.staleFiles)(step, [jsonpath])) {
|
||||
var parser = new basic_compiler.BASICParser();
|
||||
var code = (0, workermain_1.getWorkFileAsString)(step.path);
|
||||
var code = (0, builder_1.getWorkFileAsString)(step.path);
|
||||
try {
|
||||
var ast = parser.parseFile(code, step.path);
|
||||
}
|
||||
@@ -156,8 +159,8 @@ function compileBASIC(step) {
|
||||
}
|
||||
// put AST into JSON (sans source locations) to see if it has changed
|
||||
var json = JSON.stringify(ast, (key, value) => { return (key == '$loc' ? undefined : value); });
|
||||
(0, workermain_1.putWorkFile)(jsonpath, json);
|
||||
if ((0, workermain_1.anyTargetChanged)(step, [jsonpath]))
|
||||
(0, builder_1.putWorkFile)(jsonpath, json);
|
||||
if ((0, builder_1.anyTargetChanged)(step, [jsonpath]))
|
||||
return {
|
||||
output: ast,
|
||||
listings: parser.getListings(),
|
||||
@@ -166,23 +169,23 @@ function compileBASIC(step) {
|
||||
}
|
||||
exports.compileBASIC = compileBASIC;
|
||||
function compileWiz(step) {
|
||||
(0, workermain_1.loadNative)("wiz");
|
||||
(0, wasmutils_1.loadNative)("wiz");
|
||||
var params = step.params;
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.wiz" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.wiz" });
|
||||
var destpath = step.prefix + (params.wiz_rom_ext || ".bin");
|
||||
var errors = [];
|
||||
if ((0, workermain_1.staleFiles)(step, [destpath])) {
|
||||
var wiz = workermain_1.emglobal.wiz({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('wiz'),
|
||||
if ((0, builder_1.staleFiles)(step, [destpath])) {
|
||||
var wiz = wasmutils_1.emglobal.wiz({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('wiz'),
|
||||
noInitialRun: true,
|
||||
print: workermain_1.print_fn,
|
||||
print: wasmutils_1.print_fn,
|
||||
//test.wiz:2: error: expected statement, but got identifier `test`
|
||||
printErr: (0, workermain_1.makeErrorMatcher)(errors, /(.+?):(\d+):\s*(.+)/, 2, 3, step.path, 1),
|
||||
printErr: (0, listingutils_1.makeErrorMatcher)(errors, /(.+?):(\d+):\s*(.+)/, 2, 3, step.path, 1),
|
||||
});
|
||||
var FS = wiz.FS;
|
||||
(0, workermain_1.setupFS)(FS, 'wiz');
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.populateExtraFiles)(step, FS, params.extra_compile_files);
|
||||
(0, wasmutils_1.setupFS)(FS, 'wiz');
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateExtraFiles)(step, FS, params.extra_compile_files);
|
||||
const FWDIR = '/share/common';
|
||||
var args = [
|
||||
'-o', destpath,
|
||||
@@ -192,11 +195,11 @@ function compileWiz(step) {
|
||||
step.path
|
||||
];
|
||||
args.push('--system', params.wiz_sys_type || params.arch);
|
||||
(0, workermain_1.execMain)(step, wiz, args);
|
||||
(0, wasmutils_1.execMain)(step, wiz, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var binout = FS.readFile(destpath, { encoding: 'binary' });
|
||||
(0, workermain_1.putWorkFile)(destpath, binout);
|
||||
(0, builder_1.putWorkFile)(destpath, binout);
|
||||
var dbgout = FS.readFile(step.prefix + '.sym', { encoding: 'utf8' });
|
||||
var symbolmap = {};
|
||||
for (var s of dbgout.split("\n")) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.buildRemote = void 0;
|
||||
const util_1 = require("../../common/util");
|
||||
const workertypes_1 = require("../../common/workertypes");
|
||||
const workermain_1 = require("../workermain");
|
||||
const builder_1 = require("../builder");
|
||||
// create random UID
|
||||
const sessionID = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
||||
// TODO: #include links but #link doesnt link
|
||||
@@ -12,14 +12,14 @@ async function buildRemote(step) {
|
||||
const { REMOTE_URL } = await (await fetch('../../remote.json')).json();
|
||||
if (typeof REMOTE_URL !== 'string')
|
||||
throw new Error("No REMOTE_URL in remote.json");
|
||||
(0, workermain_1.gatherFiles)(step); // TODO?
|
||||
(0, builder_1.gatherFiles)(step); // TODO?
|
||||
var binpath = "a.out"; // TODO?
|
||||
if ((0, workermain_1.staleFiles)(step, [binpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [binpath])) {
|
||||
// grab files from store
|
||||
let updates = [];
|
||||
for (var i = 0; i < step.files.length; i++) {
|
||||
let path = step.files[i];
|
||||
let entry = workermain_1.store.workfs[path];
|
||||
let entry = builder_1.store.workfs[path];
|
||||
// convert to base64
|
||||
let data = typeof entry.data === 'string' ? entry.data : btoa((0, util_1.byteArrayToString)(entry.data));
|
||||
updates.push({ path, data });
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"remote.js","sourceRoot":"","sources":["../../../src/worker/tools/remote.ts"],"names":[],"mappings":";;;AAAA,4CAAyE;AACzE,0DAAwG;AACxG,8CAA2F;AAE3F,oBAAoB;AACpB,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE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M,KAAK,CAAC,UAAU,EAAE;YACjC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;YACzB,OAAO,EAAE;gBACL,cAAc,EAAE,kBAAkB;aACrC;SACJ,CAAC,CAAC;QACH,4BAA4B;QAC5B,IAAI,IAAI,GAAG,MAAM,MAAM,CAAC,IAAI,EAAE,CAAC;QAC/B,2BAA2B;QAC3B,IAAI,IAAA,yBAAW,EAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QACnC,IAAI,IAAA,2BAAa,EAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;QACrC,IAAI,IAAA,4BAAc,EAAC,IAAI,CAAC,EAAE;YACtB,IAAI,CAAC,MAAM,GAAG,IAAA,wBAAiB,EAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC;SACf;QACD,MAAM,IAAI,KAAK,CAAC,wCAAwC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;KACnF;AACL,CAAC;AAxCD,kCAwCC"}
|
||||
+42
-39
@@ -1,7 +1,10 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileSDCC = exports.linkSDLDZ80 = exports.assembleSDASZ80 = void 0;
|
||||
const workermain_1 = require("../workermain");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
const mcpp_1 = require("./mcpp");
|
||||
function hexToArray(s, ofs) {
|
||||
var buf = new ArrayBuffer(s.length / 2);
|
||||
var arr = new Uint8Array(buf);
|
||||
@@ -43,13 +46,13 @@ function parseIHX(ihx, rom_start, rom_size, errors) {
|
||||
return output;
|
||||
}
|
||||
function assembleSDASZ80(step) {
|
||||
(0, workermain_1.loadNative)("sdasz80");
|
||||
(0, wasmutils_1.loadNative)("sdasz80");
|
||||
var objout, lstout, symout;
|
||||
var errors = [];
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.asm" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.asm" });
|
||||
var objpath = step.prefix + ".rel";
|
||||
var lstpath = step.prefix + ".lst";
|
||||
if ((0, workermain_1.staleFiles)(step, [objpath, lstpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [objpath, lstpath])) {
|
||||
//?ASxxxx-Error-<o> in line 1 of main.asm null
|
||||
// <o> .org in REL area or directive / mnemonic error
|
||||
// ?ASxxxx-Error-<q> in line 1627 of cosmic.asm
|
||||
@@ -75,23 +78,23 @@ function assembleSDASZ80(step) {
|
||||
}
|
||||
}
|
||||
};
|
||||
var ASZ80 = workermain_1.emglobal.sdasz80({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('sdasz80'),
|
||||
var ASZ80 = wasmutils_1.emglobal.sdasz80({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('sdasz80'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: match_asm_fn,
|
||||
printErr: match_asm_fn,
|
||||
});
|
||||
var FS = ASZ80.FS;
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.execMain)(step, ASZ80, ['-plosgffwy', step.path]);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, wasmutils_1.execMain)(step, ASZ80, ['-plosgffwy', step.path]);
|
||||
if (errors.length) {
|
||||
return { errors: errors };
|
||||
}
|
||||
objout = FS.readFile(objpath, { encoding: 'utf8' });
|
||||
lstout = FS.readFile(lstpath, { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)(objpath, objout);
|
||||
(0, workermain_1.putWorkFile)(lstpath, lstout);
|
||||
(0, builder_1.putWorkFile)(objpath, objout);
|
||||
(0, builder_1.putWorkFile)(lstpath, lstout);
|
||||
}
|
||||
return {
|
||||
linktool: "sdldz80",
|
||||
@@ -102,11 +105,11 @@ function assembleSDASZ80(step) {
|
||||
}
|
||||
exports.assembleSDASZ80 = assembleSDASZ80;
|
||||
function linkSDLDZ80(step) {
|
||||
(0, workermain_1.loadNative)("sdldz80");
|
||||
(0, wasmutils_1.loadNative)("sdldz80");
|
||||
var errors = [];
|
||||
(0, workermain_1.gatherFiles)(step);
|
||||
(0, builder_1.gatherFiles)(step);
|
||||
var binpath = "main.ihx";
|
||||
if ((0, workermain_1.staleFiles)(step, [binpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [binpath])) {
|
||||
//?ASlink-Warning-Undefined Global '__divsint' referenced by module 'main'
|
||||
var match_aslink_re = /\?ASlink-(\w+)-(.+)/;
|
||||
var match_aslink_fn = (s) => {
|
||||
@@ -119,17 +122,17 @@ function linkSDLDZ80(step) {
|
||||
}
|
||||
};
|
||||
var params = step.params;
|
||||
var LDZ80 = workermain_1.emglobal.sdldz80({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('sdldz80'),
|
||||
var LDZ80 = wasmutils_1.emglobal.sdldz80({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('sdldz80'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: match_aslink_fn,
|
||||
printErr: match_aslink_fn,
|
||||
});
|
||||
var FS = LDZ80.FS;
|
||||
(0, workermain_1.setupFS)(FS, 'sdcc');
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.populateExtraFiles)(step, FS, params.extra_link_files);
|
||||
(0, wasmutils_1.setupFS)(FS, 'sdcc');
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateExtraFiles)(step, FS, params.extra_link_files);
|
||||
// TODO: coleco hack so that -u flag works
|
||||
if (step.platform.startsWith("coleco")) {
|
||||
FS.writeFile('crt0.rel', FS.readFile('/share/lib/coleco/crt0.rel', { encoding: 'utf8' }));
|
||||
@@ -145,13 +148,13 @@ function linkSDLDZ80(step) {
|
||||
args.push.apply(args, params.extra_link_args);
|
||||
args.push.apply(args, step.args);
|
||||
//console.log(args);
|
||||
(0, workermain_1.execMain)(step, LDZ80, args);
|
||||
(0, wasmutils_1.execMain)(step, LDZ80, args);
|
||||
var hexout = FS.readFile("main.ihx", { encoding: 'utf8' });
|
||||
var noiout = FS.readFile("main.noi", { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)("main.ihx", hexout);
|
||||
(0, workermain_1.putWorkFile)("main.noi", noiout);
|
||||
(0, builder_1.putWorkFile)("main.ihx", hexout);
|
||||
(0, builder_1.putWorkFile)("main.noi", noiout);
|
||||
// return unchanged if no files changed
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, ["main.ihx", "main.noi"]))
|
||||
if (!(0, builder_1.anyTargetChanged)(step, ["main.ihx", "main.noi"]))
|
||||
return;
|
||||
// parse binary file
|
||||
var binout = parseIHX(hexout, params.rom_start !== undefined ? params.rom_start : params.code_start, params.rom_size, errors);
|
||||
@@ -164,9 +167,9 @@ function linkSDLDZ80(step) {
|
||||
if (fn.endsWith('.lst')) {
|
||||
var rstout = FS.readFile(fn.replace('.lst', '.rst'), { encoding: 'utf8' });
|
||||
// 0000 21 02 00 [10] 52 ld hl, #2
|
||||
var asmlines = (0, workermain_1.parseListing)(rstout, /^\s*([0-9A-F]{4})\s+([0-9A-F][0-9A-F r]*[0-9A-F])\s+\[([0-9 ]+)\]?\s+(\d+) (.*)/i, 4, 1, 2, 3);
|
||||
var srclines = (0, workermain_1.parseSourceLines)(rstout, /^\s+\d+ ;<stdin>:(\d+):/i, /^\s*([0-9A-F]{4})/i);
|
||||
(0, workermain_1.putWorkFile)(fn, rstout);
|
||||
var asmlines = (0, listingutils_1.parseListing)(rstout, /^\s*([0-9A-F]{4})\s+([0-9A-F][0-9A-F r]*[0-9A-F])\s+\[([0-9 ]+)\]?\s+(\d+) (.*)/i, 4, 1, 2, 3);
|
||||
var srclines = (0, listingutils_1.parseSourceLines)(rstout, /^\s+\d+ ;<stdin>:(\d+):/i, /^\s*([0-9A-F]{4})/i);
|
||||
(0, builder_1.putWorkFile)(fn, rstout);
|
||||
// TODO: you have to get rid of all source lines to get asm listing
|
||||
listings[fn] = {
|
||||
asmlines: srclines.length ? asmlines : null,
|
||||
@@ -217,35 +220,35 @@ function linkSDLDZ80(step) {
|
||||
}
|
||||
exports.linkSDLDZ80 = linkSDLDZ80;
|
||||
function compileSDCC(step) {
|
||||
(0, workermain_1.gatherFiles)(step, {
|
||||
(0, builder_1.gatherFiles)(step, {
|
||||
mainFilePath: "main.c" // not used
|
||||
});
|
||||
var outpath = step.prefix + ".asm";
|
||||
if ((0, workermain_1.staleFiles)(step, [outpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [outpath])) {
|
||||
var errors = [];
|
||||
var params = step.params;
|
||||
(0, workermain_1.loadNative)('sdcc');
|
||||
var SDCC = workermain_1.emglobal.sdcc({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('sdcc'),
|
||||
(0, wasmutils_1.loadNative)('sdcc');
|
||||
var SDCC = wasmutils_1.emglobal.sdcc({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('sdcc'),
|
||||
noInitialRun: true,
|
||||
noFSInit: true,
|
||||
print: workermain_1.print_fn,
|
||||
printErr: (0, workermain_1.msvcErrorMatcher)(errors),
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: (0, listingutils_1.msvcErrorMatcher)(errors),
|
||||
//TOTAL_MEMORY:256*1024*1024,
|
||||
});
|
||||
var FS = SDCC.FS;
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
// load source file and preprocess
|
||||
var code = (0, workermain_1.getWorkFileAsString)(step.path);
|
||||
var preproc = (0, workermain_1.preprocessMCPP)(step, 'sdcc');
|
||||
var code = (0, builder_1.getWorkFileAsString)(step.path);
|
||||
var preproc = (0, mcpp_1.preprocessMCPP)(step, 'sdcc');
|
||||
if (preproc.errors) {
|
||||
return { errors: preproc.errors };
|
||||
}
|
||||
else
|
||||
code = preproc.code;
|
||||
// pipe file to stdin
|
||||
(0, workermain_1.setupStdin)(FS, code);
|
||||
(0, workermain_1.setupFS)(FS, 'sdcc');
|
||||
(0, wasmutils_1.setupStdin)(FS, code);
|
||||
(0, wasmutils_1.setupFS)(FS, 'sdcc');
|
||||
var args = ['--vc', '--std-sdcc99', '-mz80',
|
||||
'--c1mode',
|
||||
//'--debug',
|
||||
@@ -276,7 +279,7 @@ function compileSDCC(step) {
|
||||
if (params.extra_compile_args) {
|
||||
args.push.apply(args, params.extra_compile_args);
|
||||
}
|
||||
(0, workermain_1.execMain)(step, SDCC, args);
|
||||
(0, wasmutils_1.execMain)(step, SDCC, args);
|
||||
// TODO: preprocessor errors w/ correct file
|
||||
if (errors.length /* && nwarnings < msvc_errors.length*/) {
|
||||
return { errors: errors };
|
||||
@@ -284,7 +287,7 @@ function compileSDCC(step) {
|
||||
// massage the asm output
|
||||
var asmout = FS.readFile(outpath, { encoding: 'utf8' });
|
||||
asmout = " .area _HOME\n .area _CODE\n .area _INITIALIZER\n .area _DATA\n .area _INITIALIZED\n .area _BSEG\n .area _BSS\n .area _HEAP\n" + asmout;
|
||||
(0, workermain_1.putWorkFile)(outpath, asmout);
|
||||
(0, builder_1.putWorkFile)(outpath, asmout);
|
||||
}
|
||||
return {
|
||||
nexttool: "sdasz80",
|
||||
|
||||
File diff suppressed because one or more lines are too long
+44
-42
@@ -27,7 +27,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.compileSilice = exports.compileYosys = exports.compileVerilator = exports.compileJSASMStep = void 0;
|
||||
const assembler_1 = require("../assembler");
|
||||
const vxmlparser = __importStar(require("../../common/hdl/vxmlparser"));
|
||||
const workermain_1 = require("../workermain");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
function detectModuleName(code) {
|
||||
var m = /^\s*module\s+(\w+_top)\b/m.exec(code)
|
||||
|| /^\s*module\s+(top|t)\b/m.exec(code)
|
||||
@@ -49,7 +51,7 @@ function compileJSASM(asmcode, platform, options, is_inline) {
|
||||
var asm = new assembler_1.Assembler(null);
|
||||
var includes = [];
|
||||
asm.loadJSON = (filename) => {
|
||||
var jsontext = (0, workermain_1.getWorkFileAsString)(filename);
|
||||
var jsontext = (0, builder_1.getWorkFileAsString)(filename);
|
||||
if (!jsontext)
|
||||
throw Error("could not load " + filename);
|
||||
return JSON.parse(jsontext);
|
||||
@@ -99,8 +101,8 @@ function compileJSASM(asmcode, platform, options, is_inline) {
|
||||
}
|
||||
}
|
||||
function compileJSASMStep(step) {
|
||||
(0, workermain_1.gatherFiles)(step);
|
||||
var code = (0, workermain_1.getWorkFileAsString)(step.path);
|
||||
(0, builder_1.gatherFiles)(step);
|
||||
var code = (0, builder_1.getWorkFileAsString)(step.path);
|
||||
var platform = step.platform || 'verilog';
|
||||
return compileJSASM(code, platform, step, false);
|
||||
}
|
||||
@@ -140,30 +142,30 @@ function compileInlineASM(code, platform, options, errors, asmlines) {
|
||||
return code;
|
||||
}
|
||||
function compileVerilator(step) {
|
||||
(0, workermain_1.loadNative)("verilator_bin");
|
||||
(0, wasmutils_1.loadNative)("verilator_bin");
|
||||
var platform = step.platform || 'verilog';
|
||||
var errors = [];
|
||||
(0, workermain_1.gatherFiles)(step);
|
||||
(0, builder_1.gatherFiles)(step);
|
||||
// compile verilog if files are stale
|
||||
if ((0, workermain_1.staleFiles)(step, [xmlPath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [xmlPath])) {
|
||||
// TODO: %Error: Specified --top-module 'ALU' isn't at the top level, it's under another cell 'cpu'
|
||||
// TODO: ... Use "/* verilator lint_off BLKSEQ */" and lint_on around source to disable this message.
|
||||
var match_fn = (0, workermain_1.makeErrorMatcher)(errors, /%(.+?): (.+?):(\d+)?[:]?\s*(.+)/i, 3, 4, step.path, 2);
|
||||
var verilator_mod = workermain_1.emglobal.verilator_bin({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('verilator_bin'),
|
||||
var match_fn = (0, listingutils_1.makeErrorMatcher)(errors, /%(.+?): (.+?):(\d+)?[:]?\s*(.+)/i, 3, 4, step.path, 2);
|
||||
var verilator_mod = wasmutils_1.emglobal.verilator_bin({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('verilator_bin'),
|
||||
noInitialRun: true,
|
||||
noExitRuntime: true,
|
||||
print: workermain_1.print_fn,
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: match_fn,
|
||||
wasmMemory: (0, workermain_1.getWASMMemory)(), // reuse memory
|
||||
wasmMemory: (0, wasmutils_1.getWASMMemory)(), // reuse memory
|
||||
//INITIAL_MEMORY:256*1024*1024,
|
||||
});
|
||||
var code = (0, workermain_1.getWorkFileAsString)(step.path);
|
||||
var code = (0, builder_1.getWorkFileAsString)(step.path);
|
||||
var topmod = detectTopModuleName(code);
|
||||
var FS = verilator_mod.FS;
|
||||
var listings = {};
|
||||
// process inline assembly, add listings where found
|
||||
(0, workermain_1.populateFiles)(step, FS, {
|
||||
(0, builder_1.populateFiles)(step, FS, {
|
||||
mainFilePath: step.path,
|
||||
processFn: (path, code) => {
|
||||
if (typeof code === 'string') {
|
||||
@@ -176,7 +178,7 @@ function compileVerilator(step) {
|
||||
return code;
|
||||
}
|
||||
});
|
||||
(0, workermain_1.starttime)();
|
||||
(0, builder_1.starttime)();
|
||||
var xmlPath = `obj_dir/V${topmod}.xml`;
|
||||
try {
|
||||
var args = ["--cc", "-O3",
|
||||
@@ -186,28 +188,28 @@ function compileVerilator(step) {
|
||||
"--x-assign", "fast", "--noassert", "--pins-sc-biguint",
|
||||
"--debug-check",
|
||||
"--top-module", topmod, step.path];
|
||||
(0, workermain_1.execMain)(step, verilator_mod, args);
|
||||
(0, wasmutils_1.execMain)(step, verilator_mod, args);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
errors.push({ line: 0, msg: "Compiler internal error: " + e });
|
||||
}
|
||||
(0, workermain_1.endtime)("compile");
|
||||
(0, builder_1.endtime)("compile");
|
||||
// remove boring errors
|
||||
errors = errors.filter(function (e) { return !/Exiting due to \d+/.exec(e.msg); }, errors);
|
||||
errors = errors.filter(function (e) { return !/Use ["][/][*]/.exec(e.msg); }, errors);
|
||||
if (errors.length) {
|
||||
return { errors: errors };
|
||||
}
|
||||
(0, workermain_1.starttime)();
|
||||
(0, builder_1.starttime)();
|
||||
var xmlParser = new vxmlparser.VerilogXMLParser();
|
||||
try {
|
||||
var xmlContent = FS.readFile(xmlPath, { encoding: 'utf8' });
|
||||
var xmlScrubbed = xmlContent.replace(/ fl=".+?" loc=".+?"/g, '');
|
||||
// TODO: this squelches the .asm listing
|
||||
//listings[step.prefix + '.xml'] = {lines:[],text:xmlContent};
|
||||
(0, workermain_1.putWorkFile)(xmlPath, xmlScrubbed); // don't detect changes in source position
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, [xmlPath]))
|
||||
(0, builder_1.putWorkFile)(xmlPath, xmlScrubbed); // don't detect changes in source position
|
||||
if (!(0, builder_1.anyTargetChanged)(step, [xmlPath]))
|
||||
return;
|
||||
xmlParser.parse(xmlContent);
|
||||
}
|
||||
@@ -223,7 +225,7 @@ function compileVerilator(step) {
|
||||
return { errors: errors, listings: listings };
|
||||
}
|
||||
finally {
|
||||
(0, workermain_1.endtime)("parse");
|
||||
(0, builder_1.endtime)("parse");
|
||||
}
|
||||
return {
|
||||
output: xmlParser,
|
||||
@@ -235,31 +237,31 @@ function compileVerilator(step) {
|
||||
exports.compileVerilator = compileVerilator;
|
||||
// TODO: test
|
||||
function compileYosys(step) {
|
||||
(0, workermain_1.loadNative)("yosys");
|
||||
(0, wasmutils_1.loadNative)("yosys");
|
||||
var code = step.code;
|
||||
var errors = [];
|
||||
var match_fn = (0, workermain_1.makeErrorMatcher)(errors, /ERROR: (.+?) in line (.+?[.]v):(\d+)[: ]+(.+)/i, 3, 4, step.path);
|
||||
(0, workermain_1.starttime)();
|
||||
var yosys_mod = workermain_1.emglobal.yosys({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('yosys'),
|
||||
var match_fn = (0, listingutils_1.makeErrorMatcher)(errors, /ERROR: (.+?) in line (.+?[.]v):(\d+)[: ]+(.+)/i, 3, 4, step.path);
|
||||
(0, builder_1.starttime)();
|
||||
var yosys_mod = wasmutils_1.emglobal.yosys({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('yosys'),
|
||||
noInitialRun: true,
|
||||
print: workermain_1.print_fn,
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: match_fn,
|
||||
});
|
||||
(0, workermain_1.endtime)("create module");
|
||||
(0, builder_1.endtime)("create module");
|
||||
var topmod = detectTopModuleName(code);
|
||||
var FS = yosys_mod.FS;
|
||||
FS.writeFile(topmod + ".v", code);
|
||||
(0, workermain_1.starttime)();
|
||||
(0, builder_1.starttime)();
|
||||
try {
|
||||
(0, workermain_1.execMain)(step, yosys_mod, ["-q", "-o", topmod + ".json", "-S", topmod + ".v"]);
|
||||
(0, wasmutils_1.execMain)(step, yosys_mod, ["-q", "-o", topmod + ".json", "-S", topmod + ".v"]);
|
||||
}
|
||||
catch (e) {
|
||||
console.log(e);
|
||||
(0, workermain_1.endtime)("compile");
|
||||
(0, builder_1.endtime)("compile");
|
||||
return { errors: errors };
|
||||
}
|
||||
(0, workermain_1.endtime)("compile");
|
||||
(0, builder_1.endtime)("compile");
|
||||
//TODO: filename in errors
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
@@ -276,14 +278,14 @@ function compileYosys(step) {
|
||||
}
|
||||
exports.compileYosys = compileYosys;
|
||||
function compileSilice(step) {
|
||||
(0, workermain_1.loadNative)("silice");
|
||||
(0, wasmutils_1.loadNative)("silice");
|
||||
var params = step.params;
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.ice" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.ice" });
|
||||
var destpath = step.prefix + '.v';
|
||||
var errors = [];
|
||||
var errfile;
|
||||
var errline;
|
||||
if ((0, workermain_1.staleFiles)(step, [destpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [destpath])) {
|
||||
//[preprocessor] 97] attempt to concatenate a nil value (global 'addrW')
|
||||
var match_fn = (s) => {
|
||||
s = s.replaceAll(/\033\[\d+\w/g, '');
|
||||
@@ -309,16 +311,16 @@ function compileSilice(step) {
|
||||
else
|
||||
console.log(s);
|
||||
};
|
||||
var silice = workermain_1.emglobal.silice({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('silice'),
|
||||
var silice = wasmutils_1.emglobal.silice({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('silice'),
|
||||
noInitialRun: true,
|
||||
print: match_fn,
|
||||
printErr: match_fn,
|
||||
});
|
||||
var FS = silice.FS;
|
||||
(0, workermain_1.setupFS)(FS, 'Silice');
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, workermain_1.populateExtraFiles)(step, FS, params.extra_compile_files);
|
||||
(0, wasmutils_1.setupFS)(FS, 'Silice');
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateExtraFiles)(step, FS, params.extra_compile_files);
|
||||
const FWDIR = '/share/frameworks';
|
||||
var args = [
|
||||
'-D', 'NTSC=1',
|
||||
@@ -327,11 +329,11 @@ function compileSilice(step) {
|
||||
'-o', destpath,
|
||||
step.path
|
||||
];
|
||||
(0, workermain_1.execMain)(step, silice, args);
|
||||
(0, wasmutils_1.execMain)(step, silice, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var vout = FS.readFile(destpath, { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)(destpath, vout);
|
||||
(0, builder_1.putWorkFile)(destpath, vout);
|
||||
}
|
||||
return {
|
||||
nexttool: "verilator",
|
||||
|
||||
File diff suppressed because one or more lines are too long
+28
-25
@@ -1,10 +1,13 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.assembleYASM = exports.compileSmallerC = void 0;
|
||||
const workermain_1 = require("../workermain");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
const mcpp_1 = require("./mcpp");
|
||||
// http://www.techhelpmanual.com/829-program_startup___exit.html
|
||||
function compileSmallerC(step) {
|
||||
(0, workermain_1.loadNative)("smlrc");
|
||||
(0, wasmutils_1.loadNative)("smlrc");
|
||||
var params = step.params;
|
||||
// stderr
|
||||
var re_err1 = /^Error in "[/]*(.+)" [(](\d+):(\d+)[)]/;
|
||||
@@ -25,23 +28,23 @@ function compileSmallerC(step) {
|
||||
});
|
||||
}
|
||||
}
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.c" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.c" });
|
||||
var destpath = step.prefix + '.asm';
|
||||
if ((0, workermain_1.staleFiles)(step, [destpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [destpath])) {
|
||||
var args = ['-seg16',
|
||||
//'-nobss',
|
||||
'-no-externs',
|
||||
step.path, destpath];
|
||||
var smlrc = workermain_1.emglobal.smlrc({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('smlrc'),
|
||||
var smlrc = wasmutils_1.emglobal.smlrc({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('smlrc'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: match_fn,
|
||||
printErr: match_fn,
|
||||
});
|
||||
// load source file and preprocess
|
||||
var code = (0, workermain_1.getWorkFileAsString)(step.path);
|
||||
var preproc = (0, workermain_1.preprocessMCPP)(step, null);
|
||||
var code = (0, builder_1.getWorkFileAsString)(step.path);
|
||||
var preproc = (0, mcpp_1.preprocessMCPP)(step, null);
|
||||
if (preproc.errors) {
|
||||
return { errors: preproc.errors };
|
||||
}
|
||||
@@ -50,17 +53,17 @@ function compileSmallerC(step) {
|
||||
// set up filesystem
|
||||
var FS = smlrc.FS;
|
||||
//setupFS(FS, '65-'+getRootBasePlatform(step.platform));
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
FS.writeFile(step.path, code);
|
||||
(0, workermain_1.fixParamsWithDefines)(step.path, params);
|
||||
(0, builder_1.fixParamsWithDefines)(step.path, params);
|
||||
if (params.extra_compile_args) {
|
||||
args.unshift.apply(args, params.extra_compile_args);
|
||||
}
|
||||
(0, workermain_1.execMain)(step, smlrc, args);
|
||||
(0, wasmutils_1.execMain)(step, smlrc, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var asmout = FS.readFile(destpath, { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)(destpath, asmout);
|
||||
(0, builder_1.putWorkFile)(destpath, asmout);
|
||||
}
|
||||
return {
|
||||
nexttool: "yasm",
|
||||
@@ -71,13 +74,13 @@ function compileSmallerC(step) {
|
||||
}
|
||||
exports.compileSmallerC = compileSmallerC;
|
||||
function assembleYASM(step) {
|
||||
(0, workermain_1.loadNative)("yasm");
|
||||
(0, wasmutils_1.loadNative)("yasm");
|
||||
var errors = [];
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.asm" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.asm" });
|
||||
var objpath = step.prefix + ".exe";
|
||||
var lstpath = step.prefix + ".lst";
|
||||
var mappath = step.prefix + ".map";
|
||||
if ((0, workermain_1.staleFiles)(step, [objpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [objpath])) {
|
||||
var args = ['-X', 'vc',
|
||||
'-a', 'x86', '-f', 'dosexe', '-p', 'nasm',
|
||||
'-D', 'freedos',
|
||||
@@ -86,32 +89,32 @@ function assembleYASM(step) {
|
||||
'-o', objpath, '-l', lstpath, '--mapfile=' + mappath,
|
||||
step.path];
|
||||
// return yasm/*.ready*/
|
||||
var YASM = workermain_1.emglobal.yasm({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('yasm'),
|
||||
var YASM = wasmutils_1.emglobal.yasm({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('yasm'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: workermain_1.print_fn,
|
||||
printErr: (0, workermain_1.msvcErrorMatcher)(errors),
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: (0, listingutils_1.msvcErrorMatcher)(errors),
|
||||
});
|
||||
var FS = YASM.FS;
|
||||
//setupFS(FS, '65-'+getRootBasePlatform(step.platform));
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
//fixParamsWithDefines(step.path, step.params);
|
||||
(0, workermain_1.execMain)(step, YASM, args);
|
||||
(0, wasmutils_1.execMain)(step, YASM, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var objout, lstout, mapout;
|
||||
objout = FS.readFile(objpath, { encoding: 'binary' });
|
||||
lstout = FS.readFile(lstpath, { encoding: 'utf8' });
|
||||
mapout = FS.readFile(mappath, { encoding: 'utf8' });
|
||||
(0, workermain_1.putWorkFile)(objpath, objout);
|
||||
(0, workermain_1.putWorkFile)(lstpath, lstout);
|
||||
(0, builder_1.putWorkFile)(objpath, objout);
|
||||
(0, builder_1.putWorkFile)(lstpath, lstout);
|
||||
//putWorkFile(mappath, mapout);
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, [objpath]))
|
||||
if (!(0, builder_1.anyTargetChanged)(step, [objpath]))
|
||||
return;
|
||||
var symbolmap = {};
|
||||
var segments = [];
|
||||
var lines = (0, workermain_1.parseListing)(lstout, /\s*(\d+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 2, 3);
|
||||
var lines = (0, listingutils_1.parseListing)(lstout, /\s*(\d+)\s+([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 2, 3);
|
||||
var listings = {};
|
||||
listings[lstpath] = { lines: lines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exports.assembleZMAC = void 0;
|
||||
const workermain_1 = require("../workermain");
|
||||
const builder_1 = require("../builder");
|
||||
const listingutils_1 = require("../listingutils");
|
||||
const wasmutils_1 = require("../wasmutils");
|
||||
function assembleZMAC(step) {
|
||||
(0, workermain_1.loadNative)("zmac");
|
||||
(0, wasmutils_1.loadNative)("zmac");
|
||||
var hexout, lstout, binout;
|
||||
var errors = [];
|
||||
var params = step.params;
|
||||
(0, workermain_1.gatherFiles)(step, { mainFilePath: "main.asm" });
|
||||
(0, builder_1.gatherFiles)(step, { mainFilePath: "main.asm" });
|
||||
var lstpath = step.prefix + ".lst";
|
||||
var binpath = step.prefix + ".cim";
|
||||
if ((0, workermain_1.staleFiles)(step, [binpath])) {
|
||||
if ((0, builder_1.staleFiles)(step, [binpath])) {
|
||||
/*
|
||||
error1.asm(4) : 'l18d4' Undeclared
|
||||
JP L18D4
|
||||
@@ -19,28 +21,28 @@ function assembleZMAC(step) {
|
||||
Add a colon or move to first column to stop this warning.
|
||||
1 errors (see listing if no diagnostics appeared here)
|
||||
*/
|
||||
var ZMAC = workermain_1.emglobal.zmac({
|
||||
instantiateWasm: (0, workermain_1.moduleInstFn)('zmac'),
|
||||
var ZMAC = wasmutils_1.emglobal.zmac({
|
||||
instantiateWasm: (0, wasmutils_1.moduleInstFn)('zmac'),
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: workermain_1.print_fn,
|
||||
printErr: (0, workermain_1.makeErrorMatcher)(errors, /([^( ]+)\s*[(](\d+)[)]\s*:\s*(.+)/, 2, 3, step.path),
|
||||
print: wasmutils_1.print_fn,
|
||||
printErr: (0, listingutils_1.makeErrorMatcher)(errors, /([^( ]+)\s*[(](\d+)[)]\s*:\s*(.+)/, 2, 3, step.path),
|
||||
});
|
||||
var FS = ZMAC.FS;
|
||||
(0, workermain_1.populateFiles)(step, FS);
|
||||
(0, builder_1.populateFiles)(step, FS);
|
||||
// TODO: don't know why CIM (hexary) doesn't work
|
||||
(0, workermain_1.execMain)(step, ZMAC, ['-z', '-c', '--oo', 'lst,cim', step.path]);
|
||||
(0, wasmutils_1.execMain)(step, ZMAC, ['-z', '-c', '--oo', 'lst,cim', step.path]);
|
||||
if (errors.length) {
|
||||
return { errors: errors };
|
||||
}
|
||||
lstout = FS.readFile("zout/" + lstpath, { encoding: 'utf8' });
|
||||
binout = FS.readFile("zout/" + binpath, { encoding: 'binary' });
|
||||
(0, workermain_1.putWorkFile)(binpath, binout);
|
||||
(0, workermain_1.putWorkFile)(lstpath, lstout);
|
||||
if (!(0, workermain_1.anyTargetChanged)(step, [binpath, lstpath]))
|
||||
(0, builder_1.putWorkFile)(binpath, binout);
|
||||
(0, builder_1.putWorkFile)(lstpath, lstout);
|
||||
if (!(0, builder_1.anyTargetChanged)(step, [binpath, lstpath]))
|
||||
return;
|
||||
// 230: 1739+7+x 017A 1600 L017A: LD D,00h
|
||||
var lines = (0, workermain_1.parseListing)(lstout, /\s*(\d+):\s*([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 2, 3);
|
||||
var lines = (0, listingutils_1.parseListing)(lstout, /\s*(\d+):\s*([0-9a-f]+)\s+([0-9a-f]+)\s+(.+)/i, 1, 2, 3);
|
||||
var listings = {};
|
||||
listings[lstpath] = { lines: lines };
|
||||
// parse symbol table
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"file":"z80.js","sourceRoot":"","sources":["../../../src/worker/tools/z80.ts"],"names":[],"mappings":";;;AAEA,8CAA2O;AAG3O,SAAgB,YAAY,CAAC,IAAe;IAC1C,IAAA,uBAAU,EAAC,MAAM,CAAC,CAAC;IACnB,IAAI,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC;IAC3B,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IACzB,IAAA,wBAAW,EAAC,IAAI,EAAE,EAAE,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;IAChD,IAAI,OAAO,GA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|| function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.loadWASIFilesystemZip = exports.loadBlobSync = void 0;
|
||||
const jszip_1 = __importDefault(require("jszip"));
|
||||
const wasishim_1 = require("../common/wasi/wasishim");
|
||||
function loadBlobSync(path) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'blob';
|
||||
xhr.open("GET", path, false); // synchronous request
|
||||
xhr.send(null);
|
||||
return xhr.response;
|
||||
}
|
||||
exports.loadBlobSync = loadBlobSync;
|
||||
async function loadWASIFilesystemZip(zippath) {
|
||||
const jszip = new jszip_1.default();
|
||||
const path = '../../src/worker/fs/' + zippath;
|
||||
const zipdata = loadBlobSync(path);
|
||||
console.log(zippath, zipdata);
|
||||
await jszip.loadAsync(zipdata);
|
||||
let fs = new wasishim_1.WASIMemoryFilesystem();
|
||||
let promises = [];
|
||||
jszip.forEach(async (relativePath, zipEntry) => {
|
||||
if (zipEntry.dir) {
|
||||
fs.putDirectory(relativePath);
|
||||
}
|
||||
else {
|
||||
let path = './' + relativePath;
|
||||
let prom = zipEntry.async("uint8array").then((data) => {
|
||||
fs.putFile(path, data);
|
||||
});
|
||||
promises.push(prom);
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
return fs;
|
||||
}
|
||||
exports.loadWASIFilesystemZip = loadWASIFilesystemZip;
|
||||
//# sourceMappingURL=wasiutils.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"wasiutils.js","sourceRoot":"","sources":["../../src/worker/wasiutils.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,sDAA+D;AAE/D,SAAgB,YAAY,CAAC,IAAY;IACrC,IAAI,GAAG,GAAG,IAAI,cAAc,EAAE,CAAC;IAC/B,GAAG,CAAC,YAAY,GAAG,MAAM,CAAC;IAC1B,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE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ports, "__esModule", { value: true });
|
||||
exports.setupStdin = exports.print_fn = exports.setupFS = exports.loadNative = exports.loadWASM = exports.loadWASMBinary = exports.load = exports.loadFilesystem = exports.fsMeta = exports.execMain = exports.moduleInstFn = exports.getWASMBinary = exports.getWASMMemory = exports.emglobal = void 0;
|
||||
const builder_1 = require("./builder");
|
||||
const ENVIRONMENT_IS_WEB = typeof window === 'object';
|
||||
const ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
|
||||
exports.emglobal = ENVIRONMENT_IS_WORKER ? self : ENVIRONMENT_IS_WEB ? window : global;
|
||||
// simple CommonJS module loader
|
||||
// TODO: relative paths for dependencies
|
||||
if (!exports.emglobal['require']) {
|
||||
exports.emglobal['require'] = (modpath) => {
|
||||
if (modpath.endsWith('.js'))
|
||||
modpath = modpath.slice(-3);
|
||||
var modname = modpath.split('/').slice(-1)[0];
|
||||
var hasNamespace = exports.emglobal[modname] != null;
|
||||
console.log('@@@ require', modname, modpath, hasNamespace);
|
||||
if (!hasNamespace) {
|
||||
exports = {};
|
||||
importScripts(`${modpath}.js`);
|
||||
}
|
||||
if (exports.emglobal[modname] == null) {
|
||||
exports.emglobal[modname] = exports; // TODO: always put in global scope?
|
||||
}
|
||||
return exports.emglobal[modname]; // TODO
|
||||
};
|
||||
}
|
||||
// TODO: leaks memory even when disabled...
|
||||
var _WASM_module_cache = {};
|
||||
var CACHE_WASM_MODULES = true; // if false, use asm.js only
|
||||
// TODO: which modules need this?
|
||||
var wasmMemory;
|
||||
function getWASMMemory() {
|
||||
if (wasmMemory == null) {
|
||||
wasmMemory = new WebAssembly.Memory({
|
||||
'initial': 1024,
|
||||
'maximum': 16384, // 1024MB
|
||||
});
|
||||
}
|
||||
return wasmMemory;
|
||||
}
|
||||
exports.getWASMMemory = getWASMMemory;
|
||||
function getWASMBinary(module_id) {
|
||||
return wasmBlob[module_id];
|
||||
}
|
||||
exports.getWASMBinary = getWASMBinary;
|
||||
function getWASMModule(module_id) {
|
||||
var module = _WASM_module_cache[module_id];
|
||||
if (!module) {
|
||||
(0, builder_1.starttime)();
|
||||
module = new WebAssembly.Module(wasmBlob[module_id]);
|
||||
if (CACHE_WASM_MODULES) {
|
||||
_WASM_module_cache[module_id] = module;
|
||||
delete wasmBlob[module_id];
|
||||
}
|
||||
(0, builder_1.endtime)("module creation " + module_id);
|
||||
}
|
||||
return module;
|
||||
}
|
||||
// function for use with instantiateWasm
|
||||
function moduleInstFn(module_id) {
|
||||
return function (imports, ri) {
|
||||
var mod = getWASMModule(module_id);
|
||||
var inst = new WebAssembly.Instance(mod, imports);
|
||||
ri(inst);
|
||||
return inst.exports;
|
||||
};
|
||||
}
|
||||
exports.moduleInstFn = moduleInstFn;
|
||||
function execMain(step, mod, args) {
|
||||
(0, builder_1.starttime)();
|
||||
var run = mod.callMain || mod.run; // TODO: run?
|
||||
run(args);
|
||||
(0, builder_1.endtime)(step.tool);
|
||||
}
|
||||
exports.execMain = execMain;
|
||||
/// asm.js / WASM / filesystem loading
|
||||
exports.fsMeta = {};
|
||||
var fsBlob = {};
|
||||
var wasmBlob = {};
|
||||
// load filesystems for CC65 and others asynchronously
|
||||
function loadFilesystem(name) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'blob';
|
||||
xhr.open("GET", builder_1.PWORKER + "fs/fs" + name + ".data", false); // synchronous request
|
||||
xhr.send(null);
|
||||
fsBlob[name] = xhr.response;
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'json';
|
||||
xhr.open("GET", builder_1.PWORKER + "fs/fs" + name + ".js.metadata", false); // synchronous request
|
||||
xhr.send(null);
|
||||
exports.fsMeta[name] = xhr.response;
|
||||
console.log("Loaded " + name + " filesystem", exports.fsMeta[name].files.length, 'files', fsBlob[name].size, 'bytes');
|
||||
}
|
||||
exports.loadFilesystem = loadFilesystem;
|
||||
var loaded = {};
|
||||
function load(modulename, debug) {
|
||||
if (!loaded[modulename]) {
|
||||
importScripts(builder_1.PWORKER + 'asmjs/' + modulename + (debug ? "." + debug + ".js" : ".js"));
|
||||
loaded[modulename] = 1;
|
||||
}
|
||||
}
|
||||
exports.load = load;
|
||||
function loadWASMBinary(modulename) {
|
||||
if (!loaded[modulename]) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.open("GET", builder_1.PWORKER + "wasm/" + modulename + ".wasm", false); // synchronous request
|
||||
xhr.send(null);
|
||||
if (xhr.response) {
|
||||
wasmBlob[modulename] = new Uint8Array(xhr.response);
|
||||
console.log("Loaded " + modulename + ".wasm (" + wasmBlob[modulename].length + " bytes)");
|
||||
loaded[modulename] = 1;
|
||||
}
|
||||
else {
|
||||
throw Error("Could not load WASM file " + modulename + ".wasm");
|
||||
}
|
||||
}
|
||||
return wasmBlob[modulename];
|
||||
}
|
||||
exports.loadWASMBinary = loadWASMBinary;
|
||||
function loadWASM(modulename, debug) {
|
||||
if (!loaded[modulename]) {
|
||||
importScripts(builder_1.PWORKER + "wasm/" + modulename + (debug ? "." + debug + ".js" : ".js"));
|
||||
loadWASMBinary(modulename);
|
||||
}
|
||||
}
|
||||
exports.loadWASM = loadWASM;
|
||||
function loadNative(modulename) {
|
||||
// detect WASM
|
||||
if (CACHE_WASM_MODULES && typeof WebAssembly === 'object') {
|
||||
loadWASM(modulename);
|
||||
}
|
||||
else {
|
||||
load(modulename);
|
||||
}
|
||||
}
|
||||
exports.loadNative = loadNative;
|
||||
// mount the filesystem at /share
|
||||
function setupFS(FS, name) {
|
||||
var WORKERFS = FS.filesystems['WORKERFS'];
|
||||
if (name === '65-vector')
|
||||
name = '65-none'; // TODO
|
||||
if (name === '65-atari7800')
|
||||
name = '65-none'; // TODO
|
||||
if (name === '65-devel')
|
||||
name = '65-none'; // TODO
|
||||
if (name === '65-vcs')
|
||||
name = '65-atari2600'; // TODO
|
||||
if (!exports.fsMeta[name])
|
||||
throw Error("No filesystem for '" + name + "'");
|
||||
FS.mkdir('/share');
|
||||
FS.mount(WORKERFS, {
|
||||
packages: [{ metadata: exports.fsMeta[name], blob: fsBlob[name] }]
|
||||
}, '/share');
|
||||
// fix for slow Blob operations by caching typed arrays
|
||||
// https://github.com/kripken/emscripten/blob/incoming/src/library_workerfs.js
|
||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=349304#c30
|
||||
var reader = WORKERFS.reader;
|
||||
var blobcache = {};
|
||||
WORKERFS.stream_ops.read = function (stream, buffer, offset, length, position) {
|
||||
if (position >= stream.node.size)
|
||||
return 0;
|
||||
var contents = blobcache[stream.path];
|
||||
if (!contents) {
|
||||
var ab = reader.readAsArrayBuffer(stream.node.contents);
|
||||
contents = blobcache[stream.path] = new Uint8Array(ab);
|
||||
}
|
||||
if (position + length > contents.length)
|
||||
length = contents.length - position;
|
||||
for (var i = 0; i < length; i++) {
|
||||
buffer[offset + i] = contents[position + i];
|
||||
}
|
||||
return length;
|
||||
};
|
||||
}
|
||||
exports.setupFS = setupFS;
|
||||
var print_fn = function (s) {
|
||||
console.log(s);
|
||||
//console.log(new Error().stack);
|
||||
};
|
||||
exports.print_fn = print_fn;
|
||||
function setupStdin(fs, code) {
|
||||
var i = 0;
|
||||
fs.init(function () { return i < code.length ? code.charCodeAt(i++) : null; });
|
||||
}
|
||||
exports.setupStdin = setupStdin;
|
||||
//# sourceMappingURL=wasmutils.js.map
|
||||
File diff suppressed because one or more lines are too long
+14
-1203
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,112 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TOOL_PRELOADFS = exports.TOOLS = void 0;
|
||||
const misc = __importStar(require("./tools/misc"));
|
||||
const cc65 = __importStar(require("./tools/cc65"));
|
||||
const dasm = __importStar(require("./tools/dasm"));
|
||||
const sdcc = __importStar(require("./tools/sdcc"));
|
||||
const verilog = __importStar(require("./tools/verilog"));
|
||||
const m6809 = __importStar(require("./tools/m6809"));
|
||||
const m6502 = __importStar(require("./tools/m6502"));
|
||||
const z80 = __importStar(require("./tools/z80"));
|
||||
const x86 = __importStar(require("./tools/x86"));
|
||||
const arm = __importStar(require("./tools/arm"));
|
||||
const ecs = __importStar(require("./tools/ecs"));
|
||||
const remote = __importStar(require("./tools/remote"));
|
||||
const acme = __importStar(require("./tools/acme"));
|
||||
const cc7800 = __importStar(require("./tools/cc7800"));
|
||||
const bataribasic = __importStar(require("./tools/bataribasic"));
|
||||
exports.TOOLS = {
|
||||
'dasm': dasm.assembleDASM,
|
||||
'acme': acme.assembleACME,
|
||||
'cc65': cc65.compileCC65,
|
||||
'ca65': cc65.assembleCA65,
|
||||
'ld65': cc65.linkLD65,
|
||||
//'z80asm': assembleZ80ASM,
|
||||
//'sccz80': compileSCCZ80,
|
||||
'sdasz80': sdcc.assembleSDASZ80,
|
||||
'sdldz80': sdcc.linkSDLDZ80,
|
||||
'sdcc': sdcc.compileSDCC,
|
||||
'xasm6809': m6809.assembleXASM6809,
|
||||
'cmoc': m6809.compileCMOC,
|
||||
'lwasm': m6809.assembleLWASM,
|
||||
'lwlink': m6809.linkLWLINK,
|
||||
//'naken': assembleNAKEN,
|
||||
'verilator': verilog.compileVerilator,
|
||||
'yosys': verilog.compileYosys,
|
||||
'jsasm': verilog.compileJSASMStep,
|
||||
'zmac': z80.assembleZMAC,
|
||||
'nesasm': m6502.assembleNESASM,
|
||||
'smlrc': x86.compileSmallerC,
|
||||
'yasm': x86.assembleYASM,
|
||||
'bataribasic': bataribasic.compileBatariBasic,
|
||||
'markdown': misc.translateShowdown,
|
||||
'inform6': misc.compileInform6,
|
||||
'merlin32': m6502.assembleMerlin32,
|
||||
'fastbasic': m6502.compileFastBasic,
|
||||
'basic': misc.compileBASIC,
|
||||
'silice': verilog.compileSilice,
|
||||
'wiz': misc.compileWiz,
|
||||
'armips': arm.assembleARMIPS,
|
||||
'vasmarm': arm.assembleVASMARM,
|
||||
'ecs': ecs.assembleECS,
|
||||
'remote': remote.buildRemote,
|
||||
'cc7800': cc7800.compileCC7800,
|
||||
};
|
||||
exports.TOOL_PRELOADFS = {
|
||||
'cc65-apple2': '65-apple2',
|
||||
'ca65-apple2': '65-apple2',
|
||||
'cc65-c64': '65-c64',
|
||||
'ca65-c64': '65-c64',
|
||||
'cc65-vic20': '65-vic20',
|
||||
'ca65-vic20': '65-vic20',
|
||||
'cc65-nes': '65-nes',
|
||||
'ca65-nes': '65-nes',
|
||||
'cc65-atari8': '65-atari8',
|
||||
'ca65-atari8': '65-atari8',
|
||||
'cc65-vector': '65-none',
|
||||
'ca65-vector': '65-none',
|
||||
'cc65-atari7800': '65-none',
|
||||
'ca65-atari7800': '65-none',
|
||||
'cc65-devel': '65-none',
|
||||
'ca65-devel': '65-none',
|
||||
'cc65-vcs': '65-atari2600',
|
||||
'ca65-vcs': '65-atari2600',
|
||||
'cc65-pce': '65-pce',
|
||||
'ca65-pce': '65-pce',
|
||||
'sdasz80': 'sdcc',
|
||||
'sdcc': 'sdcc',
|
||||
'sccz80': 'sccz80',
|
||||
'bataribasic': '2600basic',
|
||||
'inform6': 'inform',
|
||||
'fastbasic': '65-atari8',
|
||||
'silice': 'Silice',
|
||||
'wiz': 'wiz',
|
||||
'ecs-vcs': '65-atari2600',
|
||||
'ecs-nes': '65-nes',
|
||||
'ecs-c64': '65-c64', // TODO: support multiple platforms
|
||||
};
|
||||
//# sourceMappingURL=workertools.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"workertools.js","sourceRoot":"","sources":["../../src/worker/workertools.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mDAAoC;AACpC,mDAAoC;AACpC,mDAAoC;AACpC,mDAAoC;AACpC,yDAA0C;AAC1C,qDAAsC;AACtC,qDAAsC;AACtC,iDAAkC;AAClC,iDAAkC;AAClC,iDAAkC;AAClC,iDAAkC;AAClC,uDAAwC;AACxC,mDAAoC;AACpC,uDAAwC;AACxC,iEAAkD;AAGrC,QAAA,KAAK,GAAG;IACnB,MAAM,EAAE,IAAI,CAAC,YAAY;IACzB,MAAM,EAAE,IAAI,CAAC,YAAY;IACzB,MAAM,EAAE,IAAI,CAAC,WAAW;IACxB,MAAM,EAAE,IAAI,CAAC,YAAY;IACzB,MAAM,EAAE,IAAI,CAAC,QAAQ;IACrB,2BAA2B;IAC3B,0BAA0B;IAC1B,SAAS,EAAE,IAAI,CAAC,eAAe;IAC/B,SAAS,EAAE,IAAI,CAAC,WAAW;IAC3B,MAAM,EAAE,IAAI,CAAC,WAAW;IACxB,UAAU,EAAE,KAAK,CAAC,gBAAgB;IAClC,MAAM,EAAE,KAAK,CAAC,WAAW;IACzB,OAAO,EAAE,KAAK,CAAC,aAAa;IAC5B,QAAQ,EAAE,KAAK,CAAC,UAAU;IAC1B,yBAAyB;IACzB,WAAW,EAAE,OAAO,CAAC,gBAAgB;IACrC,OAAO,EAAE,OAAO,CAAC,YAAY;IAC7B,OAAO,EAAE,OAAO,CAA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E,MAAM;IACd,QAAQ,EAAE,QAAQ;IAClB,aAAa,EAAE,WAAW;IAC1B,SAAS,EAAE,QAAQ;IACnB,WAAW,EAAE,WAAW;IACxB,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,KAAK;IACZ,SAAS,EAAE,cAAc;IACzB,SAAS,EAAE,QAAQ;IACnB,SAAS,EAAE,QAAQ,EAAE,mCAAmC;CACzD,CAAA"}
|
||||
@@ -61,8 +61,6 @@ typedef enum { false, true } bool; // boolean
|
||||
// default screen base address on startup
|
||||
#define DEFAULT_SCREEN ((void*)0x400)
|
||||
|
||||
// wait until next frame, same as waitvsync()
|
||||
#define wait_vblank waitvsync
|
||||
// is raster line > 255?
|
||||
#define RASTER_HIBIT (VIC.ctrl1 & 0x80)
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { WASIRunner } from "./wasishim";
|
||||
|
||||
export class LibRetroRunner extends WASIRunner {
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
getEnv() {
|
||||
return {
|
||||
...super.getEnv(),
|
||||
retro_environment_callback: (cmd: number, data: number) => {
|
||||
console.log(`retro_environment_callback: ${cmd}, ${data}`);
|
||||
return 0;
|
||||
},
|
||||
retro_video_refresh_callback: (data: number, width: number, height: number, pitch: number) => {
|
||||
console.log(`retro_video_refresh_callback: ${data}, ${width}, ${height}, ${pitch}`);
|
||||
},
|
||||
retro_audio_sample_batch_callback: (data: number, frames: number) => {
|
||||
console.log(`retro_audio_sample_batch_callback: ${data}, ${frames}`);
|
||||
},
|
||||
retro_audio_sample_callback: (left: number, right: number) => {
|
||||
console.log(`retro_audio_sample_callback: ${left}, ${right}`);
|
||||
return 0;
|
||||
},
|
||||
retro_input_poll_callback: () => {
|
||||
console.log(`retro_input_poll_callback`);
|
||||
},
|
||||
retro_input_state_callback: (port: number, device: number, index: number, id: number) => {
|
||||
console.log(`retro_input_state_callback: ${port}, ${device}, ${index}, ${id}`);
|
||||
return 0;
|
||||
},
|
||||
}
|
||||
}
|
||||
retro_init() {
|
||||
let errno = this.initialize();
|
||||
// TODO: if (errno) throw new Error(`retro_init failed: ${errno}`);
|
||||
this.exports().retro_init_callbacks();
|
||||
this.exports().retro_init();
|
||||
this.exports().retro_set_controller_port_device(0,1);
|
||||
this.exports().retro_set_controller_port_device(1,1);
|
||||
}
|
||||
retro_api_version() {
|
||||
return this.exports().retro_api_version();
|
||||
}
|
||||
load_rom(path: string, data: Uint8Array) {
|
||||
const meta = '';
|
||||
this.exports().retro_load_rom(path, data, data.length, meta);
|
||||
}
|
||||
reset() {
|
||||
this.exports().retro_reset();
|
||||
}
|
||||
advance() {
|
||||
this.exports().retro_run();
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ export class WASIMemoryFilesystem implements WASIFilesystem {
|
||||
}
|
||||
|
||||
export class WASIRunner {
|
||||
#instance; // TODO
|
||||
#instance : any; // TODO
|
||||
#memarr8: Uint8Array;
|
||||
#memarr32: Int32Array;
|
||||
#args: Uint8Array[] = [];
|
||||
@@ -282,6 +282,9 @@ export class WASIRunner {
|
||||
constructor() {
|
||||
this.createStdioBrowser();
|
||||
}
|
||||
exports() {
|
||||
return this.#instance.exports;
|
||||
}
|
||||
createStdioNode() {
|
||||
this.stdin = new WASIStreamingFileDescriptor(0, '<stdin>', FDType.CHARACTER_DEVICE, FDRights.FD_READ, process.stdin);
|
||||
this.stdout = new WASIStreamingFileDescriptor(1, '<stdout>', FDType.CHARACTER_DEVICE, FDRights.FD_WRITE, process.stdout);
|
||||
@@ -373,6 +376,10 @@ export class WASIRunner {
|
||||
}
|
||||
return this.getErrno();
|
||||
}
|
||||
initialize() {
|
||||
this.#instance.exports._initialize();
|
||||
return this.getErrno();
|
||||
}
|
||||
getImportObject() {
|
||||
return {
|
||||
"wasi_snapshot_preview1": this.getWASISnapshotPreview1(),
|
||||
@@ -485,7 +492,8 @@ export class WASIRunner {
|
||||
}
|
||||
fd_seek(fd: number, offset: number, whence: number, newoffset_ptr: number) {
|
||||
const file = this.fds[fd];
|
||||
debug("fd_seek", fd, offset, whence, file);
|
||||
if (typeof offset == 'bigint') offset = Number(offset);
|
||||
debug("fd_seek", fd, offset, whence, file+"");
|
||||
if (file != null) {
|
||||
file.llseek(offset, whence);
|
||||
this.poke64(newoffset_ptr, file.offset);
|
||||
@@ -603,11 +611,12 @@ export class WASIRunner {
|
||||
fd_readdir() { warning("TODO: fd_readdir"); return WASIErrors.NOTSUP; },
|
||||
path_unlink_file() { warning("TODO: path_unlink_file"); return WASIErrors.NOTSUP; },
|
||||
clock_time_get() { warning("TODO: clock_time_get"); return WASIErrors.NOTSUP; },
|
||||
fd_tell() { warning("TODO: fd_tell"); return WASIErrors.NOTSUP; },
|
||||
}
|
||||
}
|
||||
getEnv() {
|
||||
return {
|
||||
__syscall_unlinkat() { warning('TODO: unlink'); return 0; },
|
||||
__syscall_unlinkat() { warning('TODO: unlink'); return WASIErrors.NOTSUP; },
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import assert from "assert";
|
||||
import * as fs from "fs";
|
||||
import { LibRetroRunner } from "../common/wasi/libretro";
|
||||
|
||||
async function loadLibretro() {
|
||||
const wasmdata = fs.readFileSync(`./wasi/stella2014_libretro_2.wasm`);
|
||||
let shim = new LibRetroRunner();
|
||||
await shim.loadAsync(wasmdata);
|
||||
return shim;
|
||||
}
|
||||
|
||||
/*
|
||||
describe('test WASI libretro', function () {
|
||||
it('libretro init', async function () {
|
||||
let shim = await loadLibretro();
|
||||
assert.strictEqual(1, shim.retro_api_version());
|
||||
shim.retro_init();
|
||||
let romdata = fs.readFileSync(`./test/roms/vcs/brickgame.rom`);
|
||||
shim.load_rom('brickgame.rom', romdata);
|
||||
shim.reset();
|
||||
shim.advance();
|
||||
});
|
||||
});
|
||||
*/
|
||||
@@ -77,3 +77,4 @@ describe('test WASI cc7800', function () {
|
||||
assert.ok(stdout.indexOf('Usage: cc7800') >= 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,416 @@
|
||||
import { getBasePlatform } from "../common/util";
|
||||
import { WorkerBuildStep, WorkerError, WorkerErrorResult, WorkerMessage, WorkerResult, WorkingStore } from "../common/workertypes";
|
||||
import { PLATFORM_PARAMS } from "./platforms";
|
||||
import { TOOLS } from "./workertools";
|
||||
|
||||
/// working file store and build steps
|
||||
|
||||
const PSRC = "../../src/";
|
||||
export const PWORKER = PSRC + "worker/";
|
||||
|
||||
export type FileData = string | Uint8Array;
|
||||
|
||||
export type FileEntry = {
|
||||
path: string
|
||||
encoding: string
|
||||
data: FileData
|
||||
ts: number
|
||||
};
|
||||
|
||||
export type BuildOptions = {
|
||||
mainFilePath: string,
|
||||
processFn?: (s: string, d: FileData) => FileData
|
||||
};
|
||||
|
||||
// TODO
|
||||
export type BuildStepResult = WorkerResult | WorkerNextToolResult;
|
||||
|
||||
export interface WorkerNextToolResult {
|
||||
nexttool?: string
|
||||
linktool?: string
|
||||
path?: string
|
||||
args: string[]
|
||||
files: string[]
|
||||
bblines?: boolean
|
||||
}
|
||||
|
||||
export interface BuildStep extends WorkerBuildStep {
|
||||
files?: string[]
|
||||
args?: string[]
|
||||
nextstep?: BuildStep
|
||||
linkstep?: BuildStep
|
||||
params?
|
||||
result?: BuildStepResult
|
||||
code?
|
||||
prefix?
|
||||
maxts?
|
||||
debuginfo?
|
||||
};
|
||||
|
||||
///
|
||||
|
||||
export class FileWorkingStore implements WorkingStore {
|
||||
workfs: { [path: string]: FileEntry } = {};
|
||||
workerseq: number = 0;
|
||||
items: {};
|
||||
|
||||
constructor() {
|
||||
this.reset();
|
||||
}
|
||||
reset() {
|
||||
this.workfs = {};
|
||||
this.newVersion();
|
||||
}
|
||||
currentVersion() {
|
||||
return this.workerseq;
|
||||
}
|
||||
newVersion() {
|
||||
let ts = new Date().getTime();
|
||||
if (ts <= this.workerseq)
|
||||
ts = ++this.workerseq;
|
||||
return ts;
|
||||
}
|
||||
putFile(path: string, data: FileData): FileEntry {
|
||||
var encoding = (typeof data === 'string') ? 'utf8' : 'binary';
|
||||
var entry = this.workfs[path];
|
||||
if (!entry || !compareData(entry.data, data) || entry.encoding != encoding) {
|
||||
this.workfs[path] = entry = { path: path, data: data, encoding: encoding, ts: this.newVersion() };
|
||||
console.log('+++', entry.path, entry.encoding, entry.data.length, entry.ts);
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
hasFile(path: string) {
|
||||
return this.workfs[path] != null;
|
||||
}
|
||||
getFileData(path: string): FileData {
|
||||
return this.workfs[path] && this.workfs[path].data;
|
||||
}
|
||||
getFileAsString(path: string): string {
|
||||
let data = this.getFileData(path);
|
||||
if (data != null && typeof data !== 'string')
|
||||
throw new Error(`${path}: expected string`)
|
||||
return data as string; // TODO
|
||||
}
|
||||
getFileEntry(path: string): FileEntry {
|
||||
return this.workfs[path];
|
||||
}
|
||||
setItem(key: string, value: object) {
|
||||
this.items[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
export var store = new FileWorkingStore();
|
||||
|
||||
///
|
||||
|
||||
export function errorResult(msg: string): WorkerErrorResult {
|
||||
return { errors: [{ line: 0, msg: msg }] };
|
||||
}
|
||||
|
||||
export class Builder {
|
||||
steps: BuildStep[] = [];
|
||||
startseq: number = 0;
|
||||
|
||||
// returns true if file changed during this build step
|
||||
wasChanged(entry: FileEntry): boolean {
|
||||
return entry.ts > this.startseq;
|
||||
}
|
||||
async executeBuildSteps(): Promise<WorkerResult> {
|
||||
this.startseq = store.currentVersion();
|
||||
var linkstep: BuildStep = null;
|
||||
while (this.steps.length) {
|
||||
var step = this.steps.shift(); // get top of array
|
||||
var platform = step.platform;
|
||||
var [tool, remoteTool] = step.tool.split(':', 2);
|
||||
var toolfn = TOOLS[tool];
|
||||
if (!toolfn) {
|
||||
throw Error(`no tool named "${tool}"`);
|
||||
}
|
||||
if (remoteTool) {
|
||||
step.tool = remoteTool;
|
||||
}
|
||||
step.params = PLATFORM_PARAMS[getBasePlatform(platform)];
|
||||
try {
|
||||
step.result = await toolfn(step);
|
||||
} catch (e) {
|
||||
console.log("EXCEPTION", e, e.stack);
|
||||
return errorResult(e + ""); // TODO: catch errors already generated?
|
||||
}
|
||||
if (step.result) {
|
||||
(step.result as any).params = step.params; // TODO: type check
|
||||
if (step.debuginfo) {
|
||||
let r = step.result as any; // TODO
|
||||
if (!r.debuginfo) r.debuginfo = {};
|
||||
Object.assign(r.debuginfo, step.debuginfo);
|
||||
}
|
||||
// errors? return them
|
||||
if ('errors' in step.result && step.result.errors.length) {
|
||||
applyDefaultErrorPath(step.result.errors, step.path);
|
||||
return step.result;
|
||||
}
|
||||
// if we got some output, return it immediately
|
||||
if ('output' in step.result && step.result.output) {
|
||||
return step.result;
|
||||
}
|
||||
// combine files with a link tool?
|
||||
if ('linktool' in step.result) {
|
||||
// add to existing link step
|
||||
if (linkstep) {
|
||||
linkstep.files = linkstep.files.concat(step.result.files);
|
||||
linkstep.args = linkstep.args.concat(step.result.args);
|
||||
} else {
|
||||
linkstep = {
|
||||
tool: step.result.linktool,
|
||||
platform: platform,
|
||||
files: step.result.files,
|
||||
args: step.result.args
|
||||
};
|
||||
}
|
||||
linkstep.debuginfo = step.debuginfo; // TODO: multiple debuginfos
|
||||
}
|
||||
// process with another tool?
|
||||
if ('nexttool' in step.result) {
|
||||
var asmstep: BuildStep = {
|
||||
tool: step.result.nexttool,
|
||||
platform: platform,
|
||||
...step.result
|
||||
}
|
||||
this.steps.push(asmstep);
|
||||
}
|
||||
// process final step?
|
||||
if (this.steps.length == 0 && linkstep) {
|
||||
this.steps.push(linkstep);
|
||||
linkstep = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
async handleMessage(data: WorkerMessage): Promise<WorkerResult> {
|
||||
this.steps = [];
|
||||
// file updates
|
||||
if (data.updates) {
|
||||
data.updates.forEach((u) => store.putFile(u.path, u.data));
|
||||
}
|
||||
// object update
|
||||
if (data.setitems) {
|
||||
data.setitems.forEach((i) => store.setItem(i.key, i.value));
|
||||
}
|
||||
// build steps
|
||||
if (data.buildsteps) {
|
||||
this.steps.push.apply(this.steps, data.buildsteps);
|
||||
}
|
||||
// single-file
|
||||
if (data.code) {
|
||||
this.steps.push(data as BuildStep); // TODO: remove cast
|
||||
}
|
||||
// execute build steps
|
||||
if (this.steps.length) {
|
||||
var result = await this.executeBuildSteps();
|
||||
return result ? result : { unchanged: true };
|
||||
}
|
||||
// TODO: cache results
|
||||
// message not recognized
|
||||
console.log("Unknown message", data);
|
||||
}
|
||||
}
|
||||
|
||||
function applyDefaultErrorPath(errors: WorkerError[], path: string) {
|
||||
if (!path) return;
|
||||
for (var i = 0; i < errors.length; i++) {
|
||||
var err = errors[i];
|
||||
if (!err.path && err.line) err.path = path;
|
||||
}
|
||||
}
|
||||
|
||||
function compareData(a: FileData, b: FileData): boolean {
|
||||
if (a.length != b.length) return false;
|
||||
if (typeof a === 'string' && typeof b === 'string') {
|
||||
return a == b;
|
||||
} else {
|
||||
for (var i = 0; i < a.length; i++) {
|
||||
//if (a[i] != b[i]) console.log('differ at byte',i,a[i],b[i]);
|
||||
if (a[i] != b[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export const builder = new Builder();
|
||||
|
||||
var _t1;
|
||||
export function starttime() { _t1 = new Date(); }
|
||||
export function endtime(msg) { var _t2 = new Date(); console.log(msg, _t2.getTime() - _t1.getTime(), "ms"); }
|
||||
|
||||
///
|
||||
|
||||
export function putWorkFile(path: string, data: FileData) {
|
||||
return store.putFile(path, data);
|
||||
}
|
||||
|
||||
export function getWorkFileAsString(path: string): string {
|
||||
return store.getFileAsString(path);
|
||||
}
|
||||
|
||||
export function populateEntry(fs, path: string, entry: FileEntry, options: BuildOptions) {
|
||||
var data = entry.data;
|
||||
if (options && options.processFn) {
|
||||
data = options.processFn(path, data);
|
||||
}
|
||||
// create subfolders
|
||||
var toks = path.split('/');
|
||||
if (toks.length > 1) {
|
||||
for (var i = 0; i < toks.length - 1; i++)
|
||||
try {
|
||||
fs.mkdir(toks[i]);
|
||||
} catch (e) { }
|
||||
}
|
||||
// write file
|
||||
fs.writeFile(path, data, { encoding: entry.encoding });
|
||||
var time = new Date(entry.ts);
|
||||
fs.utime(path, time, time);
|
||||
console.log("<<<", path, entry.data.length);
|
||||
}
|
||||
|
||||
// can call multiple times (from populateFiles)
|
||||
export function gatherFiles(step: BuildStep, options?: BuildOptions): number {
|
||||
var maxts = 0;
|
||||
if (step.files) {
|
||||
for (var i = 0; i < step.files.length; i++) {
|
||||
var path = step.files[i];
|
||||
var entry = store.workfs[path];
|
||||
if (!entry) {
|
||||
throw new Error("No entry for path '" + path + "'");
|
||||
} else {
|
||||
maxts = Math.max(maxts, entry.ts);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (step.code) {
|
||||
var path = step.path ? step.path : options.mainFilePath; // TODO: what if options null
|
||||
if (!path) throw Error("need path or mainFilePath");
|
||||
var code = step.code;
|
||||
var entry = putWorkFile(path, code);
|
||||
step.path = path;
|
||||
step.files = [path];
|
||||
maxts = entry.ts;
|
||||
}
|
||||
else if (step.path) {
|
||||
var path = step.path;
|
||||
var entry = store.workfs[path];
|
||||
maxts = entry.ts;
|
||||
step.files = [path];
|
||||
}
|
||||
if (step.path && !step.prefix) {
|
||||
step.prefix = getPrefix(step.path);
|
||||
}
|
||||
step.maxts = maxts;
|
||||
return maxts;
|
||||
}
|
||||
|
||||
export function getPrefix(s: string): string {
|
||||
var pos = s.lastIndexOf('.');
|
||||
return (pos > 0) ? s.substring(0, pos) : s;
|
||||
}
|
||||
|
||||
export function populateFiles(step: BuildStep, fs, options?: BuildOptions) {
|
||||
gatherFiles(step, options);
|
||||
if (!step.files) throw Error("call gatherFiles() first");
|
||||
for (var i = 0; i < step.files.length; i++) {
|
||||
var path = step.files[i];
|
||||
populateEntry(fs, path, store.workfs[path], options);
|
||||
}
|
||||
}
|
||||
|
||||
export function populateExtraFiles(step: BuildStep, fs, extrafiles) {
|
||||
if (extrafiles) {
|
||||
for (var i = 0; i < extrafiles.length; i++) {
|
||||
var xfn = extrafiles[i];
|
||||
// is this file cached?
|
||||
if (store.workfs[xfn]) {
|
||||
fs.writeFile(xfn, store.workfs[xfn].data, { encoding: 'binary' });
|
||||
continue;
|
||||
}
|
||||
// fetch from network
|
||||
var xpath = "lib/" + getBasePlatform(step.platform) + "/" + xfn;
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.open("GET", PWORKER + xpath, false); // synchronous request
|
||||
xhr.send(null);
|
||||
if (xhr.response && xhr.status == 200) {
|
||||
var data = new Uint8Array(xhr.response);
|
||||
fs.writeFile(xfn, data, { encoding: 'binary' });
|
||||
putWorkFile(xfn, data);
|
||||
console.log(":::", xfn, data.length);
|
||||
} else {
|
||||
throw Error("Could not load extra file " + xpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function staleFiles(step: BuildStep, targets: string[]) {
|
||||
if (!step.maxts) throw Error("call populateFiles() first");
|
||||
// see if any target files are more recent than inputs
|
||||
for (var i = 0; i < targets.length; i++) {
|
||||
var entry = store.workfs[targets[i]];
|
||||
if (!entry || step.maxts > entry.ts)
|
||||
return true;
|
||||
}
|
||||
console.log("unchanged", step.maxts, targets);
|
||||
return false;
|
||||
}
|
||||
|
||||
export function anyTargetChanged(step: BuildStep, targets: string[]) {
|
||||
if (!step.maxts) throw Error("call populateFiles() first");
|
||||
// see if any target files are more recent than inputs
|
||||
for (var i = 0; i < targets.length; i++) {
|
||||
var entry = store.workfs[targets[i]];
|
||||
if (!entry || entry.ts > step.maxts)
|
||||
return true;
|
||||
}
|
||||
console.log("unchanged", step.maxts, targets);
|
||||
return false;
|
||||
}
|
||||
|
||||
export function fixParamsWithDefines(path: string, params) {
|
||||
var libargs = params.libargs;
|
||||
if (path && libargs) {
|
||||
var code = getWorkFileAsString(path);
|
||||
if (code) {
|
||||
var oldcfgfile = params.cfgfile;
|
||||
var ident2index = {};
|
||||
// find all lib args "IDENT=VALUE"
|
||||
for (var i = 0; i < libargs.length; i++) {
|
||||
var toks = libargs[i].split('=');
|
||||
if (toks.length == 2) {
|
||||
ident2index[toks[0]] = i;
|
||||
}
|
||||
}
|
||||
// find #defines and replace them
|
||||
var re = /^[;]?#define\s+(\w+)\s+(\S+)/gmi; // TODO: empty string?
|
||||
var m;
|
||||
while (m = re.exec(code)) {
|
||||
var ident = m[1];
|
||||
var value = m[2];
|
||||
var index = ident2index[ident];
|
||||
if (index >= 0) {
|
||||
libargs[index] = ident + "=" + value;
|
||||
console.log('Using libargs', index, libargs[index]);
|
||||
// TODO: MMC3 mapper switch
|
||||
if (ident == 'NES_MAPPER' && value == '4') {
|
||||
params.cfgfile = 'nesbanked.cfg';
|
||||
console.log("using config file", params.cfgfile);
|
||||
}
|
||||
} else if (ident == 'CFGFILE' && value) {
|
||||
params.cfgfile = value;
|
||||
} else if (ident == 'LIBARGS' && value) {
|
||||
params.libargs = value.split(',').filter((s) => { return s != ''; });
|
||||
console.log('Using libargs', params.libargs);
|
||||
} else if (ident == 'CC65_FLAGS' && value) {
|
||||
params.extra_compiler_args = value.split(',').filter((s) => { return s != ''; });
|
||||
console.log('Using compiler flags', params.extra_compiler_args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
|
||||
// test.c(6) : warning 85: in function main unreferenced local variable : 'x'
|
||||
// main.a (4): error: Unknown Mnemonic 'xxx'.
|
||||
|
||||
import { SourceLine, WorkerError } from "../common/workertypes";
|
||||
|
||||
// at 2: warning 190: ISO C forbids an empty source file
|
||||
export const re_msvc = /[/]*([^( ]+)\s*[(](\d+)[)]\s*:\s*(.+?):\s*(.*)/;
|
||||
export const re_msvc2 = /\s*(at)\s+(\d+)\s*(:)\s*(.*)/;
|
||||
|
||||
export function msvcErrorMatcher(errors: WorkerError[]) {
|
||||
return function (s: string) {
|
||||
var matches = re_msvc.exec(s) || re_msvc2.exec(s);
|
||||
if (matches) {
|
||||
var errline = parseInt(matches[2]);
|
||||
errors.push({
|
||||
line: errline,
|
||||
path: matches[1],
|
||||
//type:matches[3],
|
||||
msg: matches[4]
|
||||
});
|
||||
} else {
|
||||
console.log(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function makeErrorMatcher(errors: WorkerError[], regex, iline: number, imsg: number, mainpath: string, ifilename?: number) {
|
||||
return function (s) {
|
||||
var matches = regex.exec(s);
|
||||
if (matches) {
|
||||
errors.push({
|
||||
line: parseInt(matches[iline]) || 1,
|
||||
msg: matches[imsg],
|
||||
path: ifilename ? matches[ifilename] : mainpath
|
||||
});
|
||||
} else {
|
||||
console.log("??? " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function extractErrors(regex, strings: string[], path: string, iline, imsg, ifilename) {
|
||||
var errors = [];
|
||||
var matcher = makeErrorMatcher(errors, regex, iline, imsg, path, ifilename);
|
||||
for (var i = 0; i < strings.length; i++) {
|
||||
matcher(strings[i]);
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
export const re_crlf = /\r?\n/;
|
||||
// 1 %line 16+1 hello.asm
|
||||
export const re_lineoffset = /\s*(\d+)\s+[%]line\s+(\d+)\+(\d+)\s+(.+)/;
|
||||
|
||||
export function parseListing(code: string,
|
||||
lineMatch, iline: number, ioffset: number, iinsns: number, icycles?: number,
|
||||
funcMatch?, segMatch?): SourceLine[] {
|
||||
var lines: SourceLine[] = [];
|
||||
var lineofs = 0;
|
||||
var segment = '';
|
||||
var func = '';
|
||||
var funcbase = 0;
|
||||
code.split(re_crlf).forEach((line, lineindex) => {
|
||||
let segm = segMatch && segMatch.exec(line);
|
||||
if (segm) { segment = segm[1]; }
|
||||
let funcm = funcMatch && funcMatch.exec(line);
|
||||
if (funcm) { funcbase = parseInt(funcm[1], 16); func = funcm[2]; }
|
||||
|
||||
var linem = lineMatch.exec(line);
|
||||
if (linem && linem[1]) {
|
||||
var linenum = iline < 0 ? lineindex : parseInt(linem[iline]);
|
||||
var offset = parseInt(linem[ioffset], 16);
|
||||
var insns = linem[iinsns];
|
||||
var cycles: number = icycles ? parseInt(linem[icycles]) : null;
|
||||
var iscode = cycles > 0;
|
||||
if (insns) {
|
||||
lines.push({
|
||||
line: linenum + lineofs,
|
||||
offset: offset - funcbase,
|
||||
insns,
|
||||
cycles,
|
||||
iscode,
|
||||
segment,
|
||||
func
|
||||
});
|
||||
}
|
||||
} else {
|
||||
let m = re_lineoffset.exec(line);
|
||||
// TODO: check filename too
|
||||
if (m) {
|
||||
lineofs = parseInt(m[2]) - parseInt(m[1]) - parseInt(m[3]);
|
||||
}
|
||||
}
|
||||
});
|
||||
return lines;
|
||||
}
|
||||
|
||||
export function parseSourceLines(code: string, lineMatch, offsetMatch, funcMatch?, segMatch?) {
|
||||
var lines = [];
|
||||
var lastlinenum = 0;
|
||||
var segment = '';
|
||||
var func = '';
|
||||
var funcbase = 0;
|
||||
for (var line of code.split(re_crlf)) {
|
||||
let segm = segMatch && segMatch.exec(line);
|
||||
if (segm) { segment = segm[1]; }
|
||||
let funcm = funcMatch && funcMatch.exec(line);
|
||||
if (funcm) { funcbase = parseInt(funcm[1], 16); func = funcm[2]; }
|
||||
|
||||
var linem = lineMatch.exec(line);
|
||||
if (linem && linem[1]) {
|
||||
lastlinenum = parseInt(linem[1]);
|
||||
} else if (lastlinenum) {
|
||||
var linem = offsetMatch.exec(line);
|
||||
if (linem && linem[1]) {
|
||||
var offset = parseInt(linem[1], 16);
|
||||
lines.push({
|
||||
line: lastlinenum,
|
||||
offset: offset - funcbase,
|
||||
segment,
|
||||
func
|
||||
});
|
||||
lastlinenum = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
@@ -0,0 +1,334 @@
|
||||
|
||||
export var PLATFORM_PARAMS = {
|
||||
'vcs': {
|
||||
arch: '6502',
|
||||
code_start: 0x1000,
|
||||
code_size: 0xf000,
|
||||
data_start: 0x80,
|
||||
data_size: 0x80,
|
||||
wiz_rom_ext: '.a26',
|
||||
wiz_inc_dir: '2600',
|
||||
cfgfile: 'atari2600.cfg',
|
||||
libargs: ['crt0.o', 'atari2600.lib'],
|
||||
extra_link_files: ['crt0.o', 'atari2600.cfg'],
|
||||
define: ['__ATARI2600__'],
|
||||
},
|
||||
'mw8080bw': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x2000,
|
||||
data_start: 0x2000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0x2400,
|
||||
},
|
||||
'vicdual': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x4020,
|
||||
data_start: 0xe400,
|
||||
data_size: 0x400,
|
||||
stack_end: 0xe800,
|
||||
},
|
||||
'galaxian': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x4000,
|
||||
data_start: 0x4000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0x4800,
|
||||
},
|
||||
'galaxian-scramble': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x5020,
|
||||
data_start: 0x4000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0x4800,
|
||||
},
|
||||
'williams': {
|
||||
arch: '6809',
|
||||
code_start: 0x0,
|
||||
rom_size: 0xc000,
|
||||
data_start: 0x9800,
|
||||
data_size: 0x2800,
|
||||
stack_end: 0xc000,
|
||||
set_stack_end: 0xc000,
|
||||
extra_link_files: ['williams.scr', 'libcmoc-crt-vec.a', 'libcmoc-std-vec.a'],
|
||||
extra_link_args: ['-swilliams.scr', '-lcmoc-crt-vec', '-lcmoc-std-vec'],
|
||||
extra_compile_files: ['assert.h','cmoc.h','stdarg.h','stdlib.h'],
|
||||
//extra_compile_args: ['--vectrex'],
|
||||
},
|
||||
'williams-defender': {
|
||||
arch: '6809',
|
||||
code_start: 0x0,
|
||||
rom_size: 0xc000,
|
||||
data_start: 0x9800,
|
||||
data_size: 0x2800,
|
||||
stack_end: 0xc000,
|
||||
},
|
||||
'williams-z80': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x9800,
|
||||
data_start: 0x9800,
|
||||
data_size: 0x2800,
|
||||
stack_end: 0xc000,
|
||||
},
|
||||
'vector-z80color': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0xe000,
|
||||
data_size: 0x2000,
|
||||
stack_end: 0x0,
|
||||
},
|
||||
'vector-ataricolor': { //TODO
|
||||
arch: '6502',
|
||||
define: ['__VECTOR__'],
|
||||
cfgfile: 'vector-color.cfg',
|
||||
libargs: ['crt0.o', 'none.lib'],
|
||||
extra_link_files: ['crt0.o', 'vector-color.cfg'],
|
||||
},
|
||||
'sound_williams-z80': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x4000,
|
||||
data_start: 0x4000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0x8000,
|
||||
},
|
||||
'base_z80': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0x8000,
|
||||
data_size: 0x8000,
|
||||
stack_end: 0x0,
|
||||
},
|
||||
'coleco': {
|
||||
arch: 'z80',
|
||||
rom_start: 0x8000,
|
||||
code_start: 0x8100,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0x7000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0x8000,
|
||||
extra_preproc_args: ['-I', '/share/include/coleco', '-D', 'CV_CV'],
|
||||
extra_link_args: ['-k', '/share/lib/coleco', '-l', 'libcv', '-l', 'libcvu', 'crt0.rel'],
|
||||
},
|
||||
'msx': {
|
||||
arch: 'z80',
|
||||
rom_start: 0x4000,
|
||||
code_start: 0x4000,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0xc000,
|
||||
data_size: 0x3000,
|
||||
stack_end: 0xffff,
|
||||
extra_link_args: ['crt0-msx.rel'],
|
||||
extra_link_files: ['crt0-msx.rel', 'crt0-msx.lst'],
|
||||
wiz_sys_type: 'z80',
|
||||
wiz_inc_dir: 'msx',
|
||||
},
|
||||
'msx-libcv': {
|
||||
arch: 'z80',
|
||||
rom_start: 0x4000,
|
||||
code_start: 0x4000,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0xc000,
|
||||
data_size: 0x3000,
|
||||
stack_end: 0xffff,
|
||||
extra_preproc_args: ['-I', '.', '-D', 'CV_MSX'],
|
||||
extra_link_args: ['-k', '.', '-l', 'libcv-msx', '-l', 'libcvu-msx', 'crt0-msx.rel'],
|
||||
extra_link_files: ['libcv-msx.lib', 'libcvu-msx.lib', 'crt0-msx.rel', 'crt0-msx.lst'],
|
||||
extra_compile_files: ['cv.h','cv_graphics.h','cv_input.h','cv_sound.h','cv_support.h','cvu.h','cvu_c.h','cvu_compression.h','cvu_f.h','cvu_graphics.h','cvu_input.h','cvu_sound.h'],
|
||||
},
|
||||
'sms-sg1000-libcv': {
|
||||
arch: 'z80',
|
||||
rom_start: 0x0000,
|
||||
code_start: 0x0100,
|
||||
rom_size: 0xc000,
|
||||
data_start: 0xc000,
|
||||
data_size: 0x400,
|
||||
stack_end: 0xe000,
|
||||
extra_preproc_args: ['-I', '.', '-D', 'CV_SMS'],
|
||||
extra_link_args: ['-k', '.', '-l', 'libcv-sms', '-l', 'libcvu-sms', 'crt0-sms.rel'],
|
||||
extra_link_files: ['libcv-sms.lib', 'libcvu-sms.lib', 'crt0-sms.rel', 'crt0-sms.lst'],
|
||||
extra_compile_files: ['cv.h','cv_graphics.h','cv_input.h','cv_sound.h','cv_support.h','cvu.h','cvu_c.h','cvu_compression.h','cvu_f.h','cvu_graphics.h','cvu_input.h','cvu_sound.h'],
|
||||
},
|
||||
'nes': { //TODO
|
||||
arch: '6502',
|
||||
define: ['__NES__'],
|
||||
cfgfile: 'neslib2.cfg',
|
||||
libargs: ['crt0.o', 'nes.lib', 'neslib2.lib',
|
||||
'-D', 'NES_MAPPER=0', // NROM
|
||||
'-D', 'NES_PRG_BANKS=2', // 2 16K PRG banks
|
||||
'-D', 'NES_CHR_BANKS=1', // 1 CHR bank
|
||||
'-D', 'NES_MIRRORING=0', // horizontal mirroring
|
||||
],
|
||||
extra_link_files: ['crt0.o', 'neslib2.lib', 'neslib2.cfg', 'nesbanked.cfg'],
|
||||
wiz_rom_ext: '.nes',
|
||||
},
|
||||
'apple2': {
|
||||
arch: '6502',
|
||||
define: ['__APPLE2__'],
|
||||
cfgfile: 'apple2.cfg',
|
||||
libargs: [ '--lib-path', '/share/target/apple2/drv', 'apple2.lib'],
|
||||
__CODE_RUN__: 16384,
|
||||
code_start: 0x803,
|
||||
acmeargs: ['-f', 'apple'],
|
||||
},
|
||||
'apple2-e': {
|
||||
arch: '6502',
|
||||
define: ['__APPLE2__'],
|
||||
cfgfile: 'apple2.cfg',
|
||||
libargs: ['apple2.lib'],
|
||||
acmeargs: ['-f', 'apple'],
|
||||
},
|
||||
'atari8-800xl.disk': {
|
||||
arch: '6502',
|
||||
define: ['__ATARI__'],
|
||||
cfgfile: 'atari.cfg',
|
||||
libargs: ['atari.lib'],
|
||||
fastbasic_cfgfile: 'fastbasic-cart.cfg',
|
||||
},
|
||||
'atari8-800xl': {
|
||||
arch: '6502',
|
||||
define: ['__ATARI__'],
|
||||
cfgfile: 'atari-cart.cfg',
|
||||
libargs: ['atari.lib', '-D', '__CARTFLAGS__=4'],
|
||||
fastbasic_cfgfile: 'fastbasic-cart.cfg',
|
||||
},
|
||||
'atari8-800': {
|
||||
arch: '6502',
|
||||
define: ['__ATARI__'],
|
||||
cfgfile: 'atari-cart.cfg',
|
||||
libargs: ['atari.lib', '-D', '__CARTFLAGS__=4'],
|
||||
fastbasic_cfgfile: 'fastbasic-cart.cfg',
|
||||
},
|
||||
'atari8-5200': {
|
||||
arch: '6502',
|
||||
define: ['__ATARI5200__'],
|
||||
cfgfile: 'atari5200.cfg',
|
||||
libargs: ['atari5200.lib', '-D', '__CARTFLAGS__=255'],
|
||||
fastbasic_cfgfile: 'fastbasic-cart.cfg',
|
||||
},
|
||||
'verilog': {
|
||||
arch: 'verilog',
|
||||
extra_compile_files: ['8bitworkshop.v'],
|
||||
},
|
||||
'astrocade': {
|
||||
arch: 'z80',
|
||||
code_start: 0x2000,
|
||||
rom_size: 0x2000,
|
||||
data_start: 0x4e10,
|
||||
data_size: 0x1f0,
|
||||
stack_end: 0x5000,
|
||||
},
|
||||
'astrocade-arcade': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0000,
|
||||
rom_size: 0x4000,
|
||||
data_start: 0x7de0,
|
||||
data_size: 0x220,
|
||||
stack_end: 0x8000,
|
||||
},
|
||||
'astrocade-bios': {
|
||||
arch: 'z80',
|
||||
code_start: 0x0000,
|
||||
rom_size: 0x2000,
|
||||
data_start: 0x4fce,
|
||||
data_size: 50,
|
||||
stack_end: 0x4fce,
|
||||
},
|
||||
'atari7800': {
|
||||
arch: '6502',
|
||||
define: ['__ATARI7800__'],
|
||||
cfgfile: 'atari7800.cfg',
|
||||
libargs: ['crt0.o', 'none.lib'],
|
||||
extra_link_files: ['crt0.o', 'atari7800.cfg'],
|
||||
},
|
||||
'c64': {
|
||||
arch: '6502',
|
||||
define: ['__CBM__', '__C64__'],
|
||||
cfgfile: 'c64.cfg', // SYS 2061
|
||||
libargs: ['c64.lib'],
|
||||
acmeargs: ['-f', 'cbm'],
|
||||
//extra_link_files: ['c64-cart.cfg'],
|
||||
},
|
||||
'vic20': {
|
||||
arch: '6502',
|
||||
define: ['__CBM__', '__VIC20__'],
|
||||
cfgfile: 'vic20.cfg',
|
||||
libargs: ['vic20.lib'],
|
||||
acmeargs: ['-f', 'cbm'],
|
||||
//extra_link_files: ['c64-cart.cfg'],
|
||||
},
|
||||
'kim1': {
|
||||
arch: '6502',
|
||||
},
|
||||
'vectrex': {
|
||||
arch: '6809',
|
||||
code_start: 0x0,
|
||||
rom_size: 0x8000,
|
||||
data_start: 0xc880,
|
||||
data_size: 0x380,
|
||||
stack_end: 0xcc00,
|
||||
extra_compile_files: ['assert.h','cmoc.h','stdarg.h','vectrex.h','stdlib.h','bios.h'],
|
||||
extra_link_files: ['vectrex.scr', 'libcmoc-crt-vec.a', 'libcmoc-std-vec.a'],
|
||||
extra_compile_args: ['--vectrex'],
|
||||
extra_link_args: ['-svectrex.scr', '-lcmoc-crt-vec', '-lcmoc-std-vec'],
|
||||
},
|
||||
'x86': {
|
||||
arch: 'x86',
|
||||
},
|
||||
'zx': {
|
||||
arch: 'z80',
|
||||
code_start: 0x5ccb,
|
||||
rom_size: 0xff58-0x5ccb,
|
||||
data_start: 0xf000,
|
||||
data_size: 0xfe00-0xf000,
|
||||
stack_end: 0xff58,
|
||||
extra_link_args: ['crt0-zx.rel'],
|
||||
extra_link_files: ['crt0-zx.rel', 'crt0-zx.lst'],
|
||||
},
|
||||
'devel-6502': {
|
||||
arch: '6502',
|
||||
cfgfile: 'devel-6502.cfg',
|
||||
libargs: ['crt0.o', 'none.lib'],
|
||||
extra_link_files: ['crt0.o', 'devel-6502.cfg'],
|
||||
},
|
||||
// https://github.com/cpcitor/cpc-dev-tool-chain
|
||||
'cpc.rslib': {
|
||||
arch: 'z80',
|
||||
code_start: 0x4000,
|
||||
rom_size: 0xb100-0x4000,
|
||||
data_start: 0xb100,
|
||||
data_size: 0xb100-0xc000,
|
||||
stack_end: 0xc000,
|
||||
extra_compile_files: ['cpcrslib.h'],
|
||||
extra_link_args: ['crt0-cpc.rel', 'cpcrslib.lib'],
|
||||
extra_link_files: ['crt0-cpc.rel', 'crt0-cpc.lst', 'cpcrslib.lib', 'cpcrslib.lst'],
|
||||
},
|
||||
// https://lronaldo.github.io/cpctelera/ (TODO)
|
||||
'cpc': {
|
||||
arch: 'z80',
|
||||
code_start: 0x4000,
|
||||
rom_size: 0xb100-0x4000,
|
||||
data_start: 0xb100,
|
||||
data_size: 0xb100-0xc000,
|
||||
stack_end: 0xc000,
|
||||
extra_compile_files: ['cpctelera.h'],
|
||||
extra_link_args: ['crt0-cpc.rel', 'cpctelera.lib'],
|
||||
extra_link_files: ['crt0-cpc.rel', 'crt0-cpc.lst', 'cpctelera.lib', 'cpctelera.lst'],
|
||||
},
|
||||
'pce': {
|
||||
arch: 'huc6280',
|
||||
define: ['__PCE__'],
|
||||
cfgfile: 'pce.cfg',
|
||||
libargs: ['pce.lib', '-D', '__CARTSIZE__=0x8000'],
|
||||
},
|
||||
};
|
||||
|
||||
PLATFORM_PARAMS['sms-sms-libcv'] = PLATFORM_PARAMS['sms-sg1000-libcv'];
|
||||
PLATFORM_PARAMS['sms-gg-libcv'] = PLATFORM_PARAMS['sms-sms-libcv'];
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { spawn } from 'child_process';
|
||||
import { CodeListingMap, WorkerBuildStep, WorkerError, WorkerErrorResult, WorkerFileUpdate, WorkerResult, isOutputResult } from '../../common/workertypes';
|
||||
import { getBasePlatform, getRootBasePlatform, replaceAll } from '../../common/util';
|
||||
import { BuildStep, makeErrorMatcher } from '../workermain';
|
||||
import { WorkerBuildStep, WorkerErrorResult, WorkerFileUpdate, WorkerResult, isOutputResult } from '../../common/workertypes';
|
||||
import { getRootBasePlatform, replaceAll } from '../../common/util';
|
||||
import { parseObjDump } from './clang';
|
||||
import { BuildStep } from '../builder';
|
||||
import { makeErrorMatcher } from '../listingutils';
|
||||
|
||||
|
||||
const LLVM_MOS_TOOL: ServerBuildTool = {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { CodeListing, CodeListingMap } from "../../common/workertypes";
|
||||
import { BuildStep, BuildStepResult, emglobal, execMain, fixParamsWithDefines, gatherFiles, loadNative, makeErrorMatcher, moduleInstFn, msvcErrorMatcher, populateFiles, print_fn, putWorkFile, setupFS, staleFiles } from "../workermain";
|
||||
import { EmscriptenModule } from "../workermain"
|
||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, populateFiles, fixParamsWithDefines, putWorkFile } from "../builder";
|
||||
import { msvcErrorMatcher } from "../listingutils";
|
||||
import { loadNative, moduleInstFn, print_fn, setupFS, execMain, emglobal, EmscriptenModule } from "../wasmutils";
|
||||
|
||||
function parseACMESymbolTable(text: string) {
|
||||
var symbolmap = {};
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
|
||||
import { hex } from "../../common/util";
|
||||
import { WorkerResult, CodeListingMap, WorkerError, SourceLine } from "../../common/workertypes";
|
||||
import { anyTargetChanged, BuildStep, BuildStepResult, emglobal, EmscriptenModule, execMain, gatherFiles, getPrefix, getWorkFileAsString, loadNative, makeErrorMatcher, moduleInstFn, populateFiles, putWorkFile, re_crlf, staleFiles } from "../workermain"
|
||||
import { CodeListingMap, SourceLine, WorkerError, WorkerResult } from "../../common/workertypes";
|
||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, populateFiles, putWorkFile, anyTargetChanged, getPrefix, getWorkFileAsString } from "../builder";
|
||||
import { makeErrorMatcher, re_crlf } from "../listingutils";
|
||||
import { loadNative, moduleInstFn, execMain, emglobal, EmscriptenModule } from "../wasmutils";
|
||||
|
||||
export function assembleARMIPS(step: BuildStep): WorkerResult {
|
||||
loadNative("armips");
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
import { BuildStep, BuildStepResult, gatherFiles, getWorkFileAsString, populateFiles, putWorkFile, staleFiles } from "../builder";
|
||||
import { EmscriptenModule, emglobal, execMain, load, print_fn, setupFS, setupStdin } from "../wasmutils";
|
||||
|
||||
function preprocessBatariBasic(code: string): string {
|
||||
load("bbpreprocess");
|
||||
var bbout = "";
|
||||
function addbbout_fn(s) {
|
||||
bbout += s;
|
||||
bbout += "\n";
|
||||
}
|
||||
var BBPRE: EmscriptenModule = emglobal.preprocess({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: addbbout_fn,
|
||||
printErr: print_fn,
|
||||
noFSInit: true,
|
||||
});
|
||||
var FS = BBPRE.FS;
|
||||
setupStdin(FS, code);
|
||||
BBPRE.callMain([]);
|
||||
console.log("preprocess " + code.length + " -> " + bbout.length + " bytes");
|
||||
return bbout;
|
||||
}
|
||||
|
||||
export function compileBatariBasic(step: BuildStep): BuildStepResult {
|
||||
load("bb2600basic");
|
||||
var params = step.params;
|
||||
// stdout
|
||||
var asmout = "";
|
||||
function addasmout_fn(s) {
|
||||
asmout += s;
|
||||
asmout += "\n";
|
||||
}
|
||||
// stderr
|
||||
var re_err1 = /[(](\d+)[)]:?\s*(.+)/;
|
||||
var errors = [];
|
||||
var errline = 0;
|
||||
function match_fn(s) {
|
||||
console.log(s);
|
||||
var matches = re_err1.exec(s);
|
||||
if (matches) {
|
||||
errline = parseInt(matches[1]);
|
||||
errors.push({
|
||||
line: errline,
|
||||
msg: matches[2]
|
||||
});
|
||||
}
|
||||
}
|
||||
gatherFiles(step, { mainFilePath: "main.bas" });
|
||||
var destpath = step.prefix + '.asm';
|
||||
if (staleFiles(step, [destpath])) {
|
||||
var BB: EmscriptenModule = emglobal.bb2600basic({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: addasmout_fn,
|
||||
printErr: match_fn,
|
||||
noFSInit: true,
|
||||
TOTAL_MEMORY: 64 * 1024 * 1024,
|
||||
});
|
||||
var FS = BB.FS;
|
||||
populateFiles(step, FS);
|
||||
// preprocess, pipe file to stdin
|
||||
var code = getWorkFileAsString(step.path);
|
||||
code = preprocessBatariBasic(code);
|
||||
setupStdin(FS, code);
|
||||
setupFS(FS, '2600basic');
|
||||
execMain(step, BB, ["-i", "/share", step.path]);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
// build final assembly output from include file list
|
||||
var includesout = FS.readFile("includes.bB", { encoding: 'utf8' });
|
||||
var redefsout = FS.readFile("2600basic_variable_redefs.h", { encoding: 'utf8' });
|
||||
var includes = includesout.trim().split("\n");
|
||||
var combinedasm = "";
|
||||
var splitasm = asmout.split("bB.asm file is split here");
|
||||
for (var incfile of includes) {
|
||||
var inctext;
|
||||
if (incfile == "bB.asm")
|
||||
inctext = splitasm[0];
|
||||
else if (incfile == "bB2.asm")
|
||||
inctext = splitasm[1];
|
||||
else
|
||||
inctext = FS.readFile("/share/includes/" + incfile, { encoding: 'utf8' });
|
||||
console.log(incfile, inctext.length);
|
||||
combinedasm += "\n\n;;;" + incfile + "\n\n";
|
||||
combinedasm += inctext;
|
||||
}
|
||||
// TODO: ; bB.asm file is split here
|
||||
putWorkFile(destpath, combinedasm);
|
||||
putWorkFile("2600basic.h", FS.readFile("/share/includes/2600basic.h"));
|
||||
putWorkFile("2600basic_variable_redefs.h", redefsout);
|
||||
}
|
||||
return {
|
||||
nexttool: "dasm",
|
||||
path: destpath,
|
||||
args: [destpath],
|
||||
files: [destpath, "2600basic.h", "2600basic_variable_redefs.h"],
|
||||
bblines: true,
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
|
||||
import { convertDataToUint8Array, getFilenamePrefix, getRootBasePlatform, safeident } from "../../common/util";
|
||||
import { CodeListingMap, WorkerError } from "../../common/workertypes";
|
||||
import { re_crlf, BuildStepResult, anyTargetChanged, execMain, gatherFiles, msvcErrorMatcher, populateEntry, populateExtraFiles, populateFiles, print_fn, putWorkFile, setupFS, staleFiles, BuildStep, emglobal, loadNative, moduleInstFn, fixParamsWithDefines, store, makeErrorMatcher, getWorkFileAsString } from "../workermain";
|
||||
import { EmscriptenModule } from "../workermain"
|
||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, populateFiles, fixParamsWithDefines, putWorkFile, populateExtraFiles, store, populateEntry, anyTargetChanged } from "../builder";
|
||||
import { re_crlf, makeErrorMatcher } from "../listingutils";
|
||||
import { loadNative, moduleInstFn, print_fn, setupFS, execMain, emglobal, EmscriptenModule } from "../wasmutils";
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,42 +1,12 @@
|
||||
import { WASIFilesystem, WASIMemoryFilesystem, WASIRunner } from "../../common/wasi/wasishim";
|
||||
import { BuildStep, BuildStepResult, gatherFiles, getWASMBinary, loadNative, loadWASMBinary, makeErrorMatcher, putWorkFile, staleFiles, store } from "../workermain";
|
||||
import JSZip from 'jszip';
|
||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, store, putWorkFile } from "../builder";
|
||||
import { makeErrorMatcher } from "../listingutils";
|
||||
import { loadWASIFilesystemZip } from "../wasiutils";
|
||||
import { loadWASMBinary } from "../wasmutils";
|
||||
|
||||
let cc7800_fs: WASIFilesystem | null = null;
|
||||
let wasiModule: WebAssembly.Module | null = null;
|
||||
|
||||
function loadBlobSync(path: string) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'blob';
|
||||
xhr.open("GET", path, false); // synchronous request
|
||||
xhr.send(null);
|
||||
return xhr.response;
|
||||
}
|
||||
|
||||
async function loadWASIFilesystemZip(zippath: string) {
|
||||
const jszip = new JSZip();
|
||||
const path = '../../src/worker/fs/' + zippath;
|
||||
const zipdata = loadBlobSync(path);
|
||||
console.log(zippath, zipdata);
|
||||
await jszip.loadAsync(zipdata);
|
||||
let fs = new WASIMemoryFilesystem();
|
||||
let promises = [];
|
||||
jszip.forEach(async (relativePath, zipEntry) => {
|
||||
if (zipEntry.dir) {
|
||||
fs.putDirectory(relativePath);
|
||||
} else {
|
||||
let path = './' + relativePath;
|
||||
let prom = zipEntry.async("uint8array").then((data) => {
|
||||
fs.putFile(path, data);
|
||||
});
|
||||
promises.push(prom);
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
return fs;
|
||||
}
|
||||
|
||||
|
||||
export async function compileCC7800(step: BuildStep): Promise<BuildStepResult> {
|
||||
const errors = [];
|
||||
gatherFiles(step, { mainFilePath: "main.c" });
|
||||
|
||||
+62
-100
@@ -1,6 +1,8 @@
|
||||
import { WASIRunner } from "../../common/wasi/wasishim";
|
||||
import { CodeListingMap, WorkerError } from "../../common/workertypes";
|
||||
import { re_crlf, BuildStep, BuildStepResult, load, msvcErrorMatcher, emglobal, populateFiles, execMain, putWorkFile, anyTargetChanged, re_msvc, gatherFiles, getWorkFileAsString, print_fn, setupFS, setupStdin, staleFiles } from "../workermain";
|
||||
import { EmscriptenModule } from "../workermain"
|
||||
import { BuildStep, BuildStepResult, populateFiles, putWorkFile, anyTargetChanged, store } from "../builder";
|
||||
import { msvcErrorMatcher, re_crlf, re_msvc } from "../listingutils";
|
||||
import { execMain, emglobal, EmscriptenModule, load, loadWASMBinary } from "../wasmutils";
|
||||
|
||||
function parseDASMListing(lstpath: string, lsttext: string, listings: CodeListingMap, errors: WorkerError[], unresolved: {}) {
|
||||
// TODO: this gets very slow
|
||||
@@ -118,9 +120,21 @@ function parseDASMListing(lstpath: string, lsttext: string, listings: CodeListin
|
||||
}
|
||||
}
|
||||
|
||||
var re_usl = /(\w+)\s+0000\s+[?][?][?][?]/;
|
||||
|
||||
function parseSymbolMap(asym: string) {
|
||||
var symbolmap = {};
|
||||
for (var s of asym.split("\n")) {
|
||||
var toks = s.split(/\s+/);
|
||||
if (toks && toks.length >= 2 && !toks[0].startsWith('-')) {
|
||||
symbolmap[toks[0]] = parseInt(toks[1], 16);
|
||||
}
|
||||
}
|
||||
return symbolmap;
|
||||
}
|
||||
|
||||
export function assembleDASM(step: BuildStep): BuildStepResult {
|
||||
load("dasm");
|
||||
var re_usl = /(\w+)\s+0000\s+[?][?][?][?]/;
|
||||
var unresolved = {};
|
||||
var errors = [];
|
||||
var errorMatcher = msvcErrorMatcher(errors);
|
||||
@@ -187,13 +201,7 @@ export function assembleDASM(step: BuildStep): BuildStepResult {
|
||||
// TODO: what if listing or symbols change?
|
||||
if (!anyTargetChanged(step, [binpath/*, lstpath, sympath*/]))
|
||||
return;
|
||||
var symbolmap = {};
|
||||
for (var s of asym.split("\n")) {
|
||||
var toks = s.split(/\s+/);
|
||||
if (toks && toks.length >= 2 && !toks[0].startsWith('-')) {
|
||||
symbolmap[toks[0]] = parseInt(toks[1], 16);
|
||||
}
|
||||
}
|
||||
const symbolmap = parseSymbolMap(asym);
|
||||
// for bataribasic (TODO)
|
||||
if (step['bblines']) {
|
||||
let lst = listings[step.path];
|
||||
@@ -211,101 +219,55 @@ export function assembleDASM(step: BuildStep): BuildStepResult {
|
||||
};
|
||||
}
|
||||
|
||||
let wasiModule: WebAssembly.Module | null = null;
|
||||
|
||||
function preprocessBatariBasic(code: string): string {
|
||||
load("bbpreprocess");
|
||||
var bbout = "";
|
||||
function addbbout_fn(s) {
|
||||
bbout += s;
|
||||
bbout += "\n";
|
||||
export function assembleDASM2(step: BuildStep): BuildStepResult {
|
||||
const errors = [];
|
||||
if (!wasiModule) {
|
||||
wasiModule = new WebAssembly.Module(loadWASMBinary("dasm-wasisdk"));
|
||||
}
|
||||
var BBPRE: EmscriptenModule = emglobal.preprocess({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: addbbout_fn,
|
||||
printErr: print_fn,
|
||||
noFSInit: true,
|
||||
});
|
||||
var FS = BBPRE.FS;
|
||||
setupStdin(FS, code);
|
||||
BBPRE.callMain([]);
|
||||
console.log("preprocess " + code.length + " -> " + bbout.length + " bytes");
|
||||
return bbout;
|
||||
}
|
||||
|
||||
export function compileBatariBasic(step: BuildStep): BuildStepResult {
|
||||
load("bb2600basic");
|
||||
var params = step.params;
|
||||
// stdout
|
||||
var asmout = "";
|
||||
function addasmout_fn(s) {
|
||||
asmout += s;
|
||||
asmout += "\n";
|
||||
const binpath = 'a.out';
|
||||
const lstpath = step.prefix + '.lst';
|
||||
const sympath = step.prefix + '.sym';
|
||||
const wasi = new WASIRunner();
|
||||
wasi.initSync(wasiModule);
|
||||
for (let file of step.files) {
|
||||
wasi.fs.putFile("./" + file, store.getFileData(file));
|
||||
}
|
||||
// stderr
|
||||
var re_err1 = /[(](\d+)[)]:?\s*(.+)/;
|
||||
var errors = [];
|
||||
var errline = 0;
|
||||
function match_fn(s) {
|
||||
console.log(s);
|
||||
var matches = re_err1.exec(s);
|
||||
if (matches) {
|
||||
errline = parseInt(matches[1]);
|
||||
errors.push({
|
||||
line: errline,
|
||||
msg: matches[2]
|
||||
});
|
||||
wasi.addPreopenDirectory(".");
|
||||
wasi.setArgs(['dasm', step.path, '-f3', "-l" + lstpath, "-s" + sympath]);
|
||||
try {
|
||||
wasi.run();
|
||||
} catch (e) {
|
||||
errors.push(e);
|
||||
}
|
||||
const stdout = wasi.fds[1].getBytesAsString();
|
||||
//const stderr = wasi.fds[2].getBytesAsString();
|
||||
const matcher = msvcErrorMatcher(errors);
|
||||
const unresolved = {};
|
||||
for (let line of stdout.split("\n")) {
|
||||
matcher(line);
|
||||
let m = re_usl.exec(line);
|
||||
if (m) {
|
||||
unresolved[m[1]] = 0;
|
||||
}
|
||||
}
|
||||
gatherFiles(step, { mainFilePath: "main.bas" });
|
||||
var destpath = step.prefix + '.asm';
|
||||
if (staleFiles(step, [destpath])) {
|
||||
var BB: EmscriptenModule = emglobal.bb2600basic({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: addasmout_fn,
|
||||
printErr: match_fn,
|
||||
noFSInit: true,
|
||||
TOTAL_MEMORY: 64 * 1024 * 1024,
|
||||
});
|
||||
var FS = BB.FS;
|
||||
populateFiles(step, FS);
|
||||
// preprocess, pipe file to stdin
|
||||
var code = getWorkFileAsString(step.path);
|
||||
code = preprocessBatariBasic(code);
|
||||
setupStdin(FS, code);
|
||||
setupFS(FS, '2600basic');
|
||||
execMain(step, BB, ["-i", "/share", step.path]);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
// build final assembly output from include file list
|
||||
var includesout = FS.readFile("includes.bB", { encoding: 'utf8' });
|
||||
var redefsout = FS.readFile("2600basic_variable_redefs.h", { encoding: 'utf8' });
|
||||
var includes = includesout.trim().split("\n");
|
||||
var combinedasm = "";
|
||||
var splitasm = asmout.split("bB.asm file is split here");
|
||||
for (var incfile of includes) {
|
||||
var inctext;
|
||||
if (incfile == "bB.asm")
|
||||
inctext = splitasm[0];
|
||||
else if (incfile == "bB2.asm")
|
||||
inctext = splitasm[1];
|
||||
else
|
||||
inctext = FS.readFile("/share/includes/" + incfile, { encoding: 'utf8' });
|
||||
console.log(incfile, inctext.length);
|
||||
combinedasm += "\n\n;;;" + incfile + "\n\n";
|
||||
combinedasm += inctext;
|
||||
}
|
||||
// TODO: ; bB.asm file is split here
|
||||
putWorkFile(destpath, combinedasm);
|
||||
putWorkFile("2600basic.h", FS.readFile("/share/includes/2600basic.h"));
|
||||
putWorkFile("2600basic_variable_redefs.h", redefsout);
|
||||
const alst = wasi.fs.getFile("./" + lstpath).getBytesAsString();
|
||||
const listings: CodeListingMap = {};
|
||||
for (let path of step.files) {
|
||||
listings[path] = { lines: [] };
|
||||
}
|
||||
parseDASMListing(lstpath, alst, listings, errors, unresolved);
|
||||
if (errors.length) {
|
||||
return { errors: errors };
|
||||
}
|
||||
const asym = wasi.fs.getFile("./" + sympath).getBytesAsString();
|
||||
const symbolmap = parseSymbolMap(asym);
|
||||
const output = wasi.fs.getFile("./" + binpath).getBytes();
|
||||
return {
|
||||
nexttool: "dasm",
|
||||
path: destpath,
|
||||
args: [destpath],
|
||||
files: [destpath, "2600basic.h", "2600basic_variable_redefs.h"],
|
||||
bblines: true,
|
||||
output,
|
||||
errors,
|
||||
listings,
|
||||
symbolmap
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { ECSCompiler } from "../../common/ecs/compiler";
|
||||
import { Dialect_CA65, ECSError, EntityManager } from "../../common/ecs/ecs";
|
||||
import { CompileError } from "../../common/tokenizer";
|
||||
import { CodeListingMap } from "../../common/workertypes";
|
||||
import { BuildStep, BuildStepResult, fixParamsWithDefines, gatherFiles, getWorkFileAsString, putWorkFile, staleFiles } from "../workermain";
|
||||
import { BuildStep, BuildStepResult, getWorkFileAsString, gatherFiles, staleFiles, fixParamsWithDefines, putWorkFile } from "../builder";
|
||||
|
||||
export function assembleECS(step: BuildStep): BuildStepResult {
|
||||
let em = new EntityManager(new Dialect_CA65()); // TODO
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
|
||||
import { WorkerError, CodeListingMap } from "../../common/workertypes";
|
||||
import { anyTargetChanged, BuildStep, BuildStepResult, emglobal, EmscriptenModule, execMain, gatherFiles, loadNative, makeErrorMatcher, moduleInstFn, parseListing, populateFiles, print_fn, putWorkFile, staleFiles } from "../workermain"
|
||||
|
||||
import { BuildStep, BuildStepResult, populateFiles, putWorkFile, anyTargetChanged, gatherFiles, staleFiles } from "../builder";
|
||||
import { parseListing, makeErrorMatcher } from "../listingutils";
|
||||
import { loadNative, emglobal, moduleInstFn, execMain, print_fn } from "../wasmutils";
|
||||
import { EmscriptenModule } from "../wasmutils";
|
||||
|
||||
// http://www.nespowerpak.com/nesasm/
|
||||
export function assembleNESASM(step: BuildStep): BuildStepResult {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { CodeListingMap, WorkerError } from "../../common/workertypes";
|
||||
import { BuildStep, BuildStepResult, load, emglobal, print_fn, populateFiles, execMain, putWorkFile, parseListing, loadNative, gatherFiles, staleFiles, moduleInstFn, getWorkFileAsString, preprocessMCPP, fixParamsWithDefines, msvcErrorMatcher, populateExtraFiles, anyTargetChanged, parseSourceLines } from "../workermain";
|
||||
import { EmscriptenModule } from "../workermain";
|
||||
import { BuildStep, BuildStepResult, populateFiles, putWorkFile, gatherFiles, staleFiles, getWorkFileAsString, fixParamsWithDefines, populateExtraFiles, anyTargetChanged } from "../builder";
|
||||
import { parseListing, msvcErrorMatcher, parseSourceLines } from "../listingutils";
|
||||
import { EmscriptenModule, emglobal, execMain, load, loadNative, moduleInstFn, print_fn } from "../wasmutils";
|
||||
import { preprocessMCPP } from "./mcpp";
|
||||
|
||||
// http://datapipe-blackbeltsystems.com/windows/flex/asm09.html
|
||||
export function assembleXASM6809(step: BuildStep): BuildStepResult {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import { getBasePlatform } from "../../common/util";
|
||||
import { BuildStep, populateFiles, populateExtraFiles, errorResult } from "../builder";
|
||||
import { makeErrorMatcher, extractErrors } from "../listingutils";
|
||||
import { PLATFORM_PARAMS } from "../platforms";
|
||||
import { load, print_fn, setupFS, execMain, emglobal, EmscriptenModule } from "../wasmutils";
|
||||
|
||||
function makeCPPSafe(s: string): string {
|
||||
return s.replace(/[^A-Za-z0-9_]/g, '_');
|
||||
}
|
||||
|
||||
export function preprocessMCPP(step: BuildStep, filesys: string) {
|
||||
load("mcpp");
|
||||
var platform = step.platform;
|
||||
var params = PLATFORM_PARAMS[getBasePlatform(platform)];
|
||||
if (!params) throw Error("Platform not supported: " + platform);
|
||||
// <stdin>:2: error: Can't open include file "foo.h"
|
||||
var errors = [];
|
||||
var match_fn = makeErrorMatcher(errors, /<stdin>:(\d+): (.+)/, 1, 2, step.path);
|
||||
var MCPP: EmscriptenModule = emglobal.mcpp({
|
||||
noInitialRun: true,
|
||||
noFSInit: true,
|
||||
print: print_fn,
|
||||
printErr: match_fn,
|
||||
});
|
||||
var FS = MCPP.FS;
|
||||
if (filesys) setupFS(FS, filesys);
|
||||
populateFiles(step, FS);
|
||||
populateExtraFiles(step, FS, params.extra_compile_files);
|
||||
// TODO: make configurable by other compilers
|
||||
var args = [
|
||||
"-D", "__8BITWORKSHOP__",
|
||||
"-D", "__SDCC_z80",
|
||||
"-D", makeCPPSafe(platform.toUpperCase()),
|
||||
"-I", "/share/include",
|
||||
"-Q",
|
||||
step.path, "main.i"];
|
||||
if (step.mainfile) {
|
||||
args.unshift.apply(args, ["-D", "__MAIN__"]);
|
||||
}
|
||||
let platform_def = (platform.toUpperCase() as any).replaceAll(/[^a-zA-Z0-9]/g, '_');
|
||||
args.unshift.apply(args, ["-D", `__PLATFORM_${platform_def}__`]);
|
||||
if (params.extra_preproc_args) {
|
||||
args.push.apply(args, params.extra_preproc_args);
|
||||
}
|
||||
execMain(step, MCPP, args);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
var iout = FS.readFile("main.i", { encoding: 'utf8' });
|
||||
iout = iout.replace(/^#line /gm, '\n# ');
|
||||
try {
|
||||
var errout = FS.readFile("mcpp.err", { encoding: 'utf8' });
|
||||
if (errout.length) {
|
||||
// //main.c:2: error: Can't open include file "stdiosd.h"
|
||||
var errors = extractErrors(/([^:]+):(\d+): (.+)/, errout.split("\n"), step.path, 2, 3, 1);
|
||||
if (errors.length == 0) {
|
||||
errors = errorResult(errout).errors;
|
||||
}
|
||||
return { errors: errors };
|
||||
}
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
return { code: iout };
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
import { Segment, CodeListingMap, WorkerResult, WorkerError } from "../../common/workertypes";
|
||||
import { BuildStep, BuildStepResult, setupRequireFunction, load, emglobal, getWorkFileAsString, loadNative, gatherFiles, staleFiles, msvcErrorMatcher, moduleInstFn, setupFS, populateFiles, execMain, putWorkFile, anyTargetChanged, parseListing, print_fn, makeErrorMatcher, populateExtraFiles } from "../workermain";
|
||||
import { EmscriptenModule } from "../workermain"
|
||||
import * as basic_compiler from '../../common/basic/compiler';
|
||||
import { getRootBasePlatform, parseXMLPoorly } from "../../common/util";
|
||||
import { EmscriptenModule, emglobal, execMain, load, loadNative, moduleInstFn, print_fn, setupFS } from "../wasmutils";
|
||||
import { BuildStep, BuildStepResult, getWorkFileAsString, gatherFiles, staleFiles, populateFiles, putWorkFile, anyTargetChanged, populateExtraFiles } from "../builder";
|
||||
import { msvcErrorMatcher, parseListing, makeErrorMatcher } from "../listingutils";
|
||||
import { setupRequireFunction } from "../workermain";
|
||||
|
||||
export function translateShowdown(step: BuildStep): BuildStepResult {
|
||||
setupRequireFunction();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { byteArrayToString, stringToByteArray } from "../../common/util";
|
||||
import { WorkerFileUpdate, isErrorResult, isOutputResult, isUnchanged } from "../../common/workertypes";
|
||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, store } from "../workermain";
|
||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, store } from "../builder";
|
||||
|
||||
// create random UID
|
||||
const sessionID = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { CodeListingMap } from "../../common/workertypes";
|
||||
import { BuildStep, BuildStepResult, loadNative, gatherFiles, staleFiles, emglobal, moduleInstFn, populateFiles, execMain, putWorkFile, setupFS, populateExtraFiles, anyTargetChanged, parseListing, print_fn, msvcErrorMatcher, getWorkFileAsString, setupStdin, preprocessMCPP, parseSourceLines } from "../workermain";
|
||||
import { EmscriptenModule } from "../workermain"
|
||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, populateFiles, putWorkFile, populateExtraFiles, anyTargetChanged, getWorkFileAsString } from "../builder";
|
||||
import { parseListing, parseSourceLines, msvcErrorMatcher } from "../listingutils";
|
||||
import { EmscriptenModule, emglobal, execMain, loadNative, moduleInstFn, print_fn, setupFS, setupStdin } from "../wasmutils";
|
||||
import { preprocessMCPP } from "./mcpp";
|
||||
|
||||
function hexToArray(s, ofs) {
|
||||
var buf = new ArrayBuffer(s.length / 2);
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
import { WorkerError, CodeListingMap, SourceLocation } from "../../common/workertypes";
|
||||
import { Assembler } from "../assembler";
|
||||
import * as vxmlparser from '../../common/hdl/vxmlparser';
|
||||
import { getWorkFileAsString, BuildStep, BuildStepResult, gatherFiles, loadNative, staleFiles, makeErrorMatcher, emglobal, moduleInstFn, print_fn, populateFiles, execMain, putWorkFile, anyTargetChanged, endtime, getWASMMemory, starttime, populateExtraFiles, setupFS } from "../workermain";
|
||||
import { EmscriptenModule } from "../workermain"
|
||||
import { EmscriptenModule, emglobal, execMain, getWASMMemory, loadNative, moduleInstFn, print_fn, setupFS } from "../wasmutils";
|
||||
import { getWorkFileAsString, BuildStep, BuildStepResult, gatherFiles, staleFiles, populateFiles, starttime, endtime, putWorkFile, anyTargetChanged, populateExtraFiles } from "../builder";
|
||||
import { makeErrorMatcher } from "../listingutils";
|
||||
|
||||
function detectModuleName(code: string) {
|
||||
var m = /^\s*module\s+(\w+_top)\b/m.exec(code)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { WorkerError, CodeListingMap } from "../../common/workertypes";
|
||||
import { BuildStep, BuildStepResult, loadNative, gatherFiles, staleFiles, emglobal, moduleInstFn, getWorkFileAsString, preprocessMCPP, populateFiles, fixParamsWithDefines, execMain, putWorkFile, print_fn, msvcErrorMatcher, anyTargetChanged, parseListing } from "../workermain";
|
||||
import { EmscriptenModule } from "../workermain"
|
||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, getWorkFileAsString, populateFiles, fixParamsWithDefines, putWorkFile, anyTargetChanged } from "../builder";
|
||||
import { msvcErrorMatcher, parseListing } from "../listingutils";
|
||||
import { EmscriptenModule, emglobal, execMain, loadNative, moduleInstFn, print_fn } from "../wasmutils";
|
||||
import { preprocessMCPP } from "./mcpp";
|
||||
|
||||
// http://www.techhelpmanual.com/829-program_startup___exit.html
|
||||
export function compileSmallerC(step: BuildStep): BuildStepResult {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
|
||||
import { CodeListingMap } from "../../common/workertypes";
|
||||
import { anyTargetChanged, BuildStep, BuildStepResult, emglobal, EmscriptenModule, execMain, gatherFiles, loadNative, makeErrorMatcher, moduleInstFn, parseListing, populateFiles, print_fn, putWorkFile, staleFiles } from "../workermain"
|
||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, populateFiles, putWorkFile, anyTargetChanged } from "../builder";
|
||||
import { makeErrorMatcher, parseListing } from "../listingutils";
|
||||
import { EmscriptenModule, emglobal, execMain, loadNative, moduleInstFn, print_fn } from "../wasmutils";
|
||||
|
||||
|
||||
export function assembleZMAC(step: BuildStep): BuildStepResult {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import JSZip from 'jszip';
|
||||
import { WASIMemoryFilesystem } from "../common/wasi/wasishim";
|
||||
|
||||
export function loadBlobSync(path: string) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'blob';
|
||||
xhr.open("GET", path, false); // synchronous request
|
||||
xhr.send(null);
|
||||
return xhr.response;
|
||||
}
|
||||
|
||||
export async function loadWASIFilesystemZip(zippath: string) {
|
||||
const jszip = new JSZip();
|
||||
const path = '../../src/worker/fs/' + zippath;
|
||||
const zipdata = loadBlobSync(path);
|
||||
console.log(zippath, zipdata);
|
||||
await jszip.loadAsync(zipdata);
|
||||
let fs = new WASIMemoryFilesystem();
|
||||
let promises = [];
|
||||
jszip.forEach(async (relativePath, zipEntry) => {
|
||||
if (zipEntry.dir) {
|
||||
fs.putDirectory(relativePath);
|
||||
} else {
|
||||
let path = './' + relativePath;
|
||||
let prom = zipEntry.async("uint8array").then((data) => {
|
||||
fs.putFile(path, data);
|
||||
});
|
||||
promises.push(prom);
|
||||
}
|
||||
});
|
||||
await Promise.all(promises);
|
||||
return fs;
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
|
||||
// WebAssembly module cache
|
||||
// for Emscripten-compiled functions
|
||||
|
||||
import { BuildStep, PWORKER, endtime, starttime } from "./builder";
|
||||
|
||||
/// <reference types="emscripten" />
|
||||
export interface EmscriptenModule {
|
||||
callMain: (args: string[]) => void;
|
||||
FS: any; // TODO
|
||||
}
|
||||
|
||||
declare function importScripts(path: string);
|
||||
|
||||
const ENVIRONMENT_IS_WEB = typeof window === 'object';
|
||||
const ENVIRONMENT_IS_WORKER = typeof importScripts === 'function';
|
||||
export const emglobal: any = ENVIRONMENT_IS_WORKER ? self : ENVIRONMENT_IS_WEB ? window : global;
|
||||
|
||||
// simple CommonJS module loader
|
||||
// TODO: relative paths for dependencies
|
||||
if (!emglobal['require']) {
|
||||
emglobal['require'] = (modpath: string) => {
|
||||
if (modpath.endsWith('.js')) modpath = modpath.slice(-3);
|
||||
var modname = modpath.split('/').slice(-1)[0];
|
||||
var hasNamespace = emglobal[modname] != null;
|
||||
console.log('@@@ require', modname, modpath, hasNamespace);
|
||||
if (!hasNamespace) {
|
||||
exports = {};
|
||||
importScripts(`${modpath}.js`);
|
||||
}
|
||||
if (emglobal[modname] == null) {
|
||||
emglobal[modname] = exports; // TODO: always put in global scope?
|
||||
}
|
||||
return emglobal[modname]; // TODO
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: leaks memory even when disabled...
|
||||
var _WASM_module_cache = {};
|
||||
var CACHE_WASM_MODULES = true; // if false, use asm.js only
|
||||
|
||||
// TODO: which modules need this?
|
||||
var wasmMemory;
|
||||
export function getWASMMemory() {
|
||||
if (wasmMemory == null) {
|
||||
wasmMemory = new WebAssembly.Memory({
|
||||
'initial': 1024, // 64MB
|
||||
'maximum': 16384, // 1024MB
|
||||
});
|
||||
}
|
||||
return wasmMemory;
|
||||
}
|
||||
export function getWASMBinary(module_id: string) {
|
||||
return wasmBlob[module_id];
|
||||
}
|
||||
function getWASMModule(module_id: string) {
|
||||
var module = _WASM_module_cache[module_id];
|
||||
if (!module) {
|
||||
starttime();
|
||||
module = new WebAssembly.Module(wasmBlob[module_id]);
|
||||
if (CACHE_WASM_MODULES) {
|
||||
_WASM_module_cache[module_id] = module;
|
||||
delete wasmBlob[module_id];
|
||||
}
|
||||
endtime("module creation " + module_id);
|
||||
}
|
||||
return module;
|
||||
}
|
||||
// function for use with instantiateWasm
|
||||
export function moduleInstFn(module_id: string) {
|
||||
return function (imports, ri) {
|
||||
var mod = getWASMModule(module_id);
|
||||
var inst = new WebAssembly.Instance(mod, imports);
|
||||
ri(inst);
|
||||
return inst.exports;
|
||||
}
|
||||
}
|
||||
|
||||
export function execMain(step: BuildStep, mod, args: string[]) {
|
||||
starttime();
|
||||
var run = mod.callMain || mod.run; // TODO: run?
|
||||
run(args);
|
||||
endtime(step.tool);
|
||||
}
|
||||
|
||||
/// asm.js / WASM / filesystem loading
|
||||
|
||||
export var fsMeta = {};
|
||||
var fsBlob = {};
|
||||
var wasmBlob = {};
|
||||
|
||||
// load filesystems for CC65 and others asynchronously
|
||||
export function loadFilesystem(name: string) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'blob';
|
||||
xhr.open("GET", PWORKER + "fs/fs" + name + ".data", false); // synchronous request
|
||||
xhr.send(null);
|
||||
fsBlob[name] = xhr.response;
|
||||
xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'json';
|
||||
xhr.open("GET", PWORKER + "fs/fs" + name + ".js.metadata", false); // synchronous request
|
||||
xhr.send(null);
|
||||
fsMeta[name] = xhr.response;
|
||||
console.log("Loaded " + name + " filesystem", fsMeta[name].files.length, 'files', fsBlob[name].size, 'bytes');
|
||||
}
|
||||
|
||||
var loaded = {};
|
||||
export function load(modulename: string, debug?: boolean) {
|
||||
if (!loaded[modulename]) {
|
||||
importScripts(PWORKER + 'asmjs/' + modulename + (debug ? "." + debug + ".js" : ".js"));
|
||||
loaded[modulename] = 1;
|
||||
}
|
||||
}
|
||||
export function loadWASMBinary(modulename: string) {
|
||||
if (!loaded[modulename]) {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.responseType = 'arraybuffer';
|
||||
xhr.open("GET", PWORKER + "wasm/" + modulename + ".wasm", false); // synchronous request
|
||||
xhr.send(null);
|
||||
if (xhr.response) {
|
||||
wasmBlob[modulename] = new Uint8Array(xhr.response);
|
||||
console.log("Loaded " + modulename + ".wasm (" + wasmBlob[modulename].length + " bytes)");
|
||||
loaded[modulename] = 1;
|
||||
} else {
|
||||
throw Error("Could not load WASM file " + modulename + ".wasm");
|
||||
}
|
||||
}
|
||||
return wasmBlob[modulename];
|
||||
}
|
||||
export function loadWASM(modulename: string, debug?: boolean) {
|
||||
if (!loaded[modulename]) {
|
||||
importScripts(PWORKER + "wasm/" + modulename + (debug ? "." + debug + ".js" : ".js"));
|
||||
loadWASMBinary(modulename);
|
||||
}
|
||||
}
|
||||
export function loadNative(modulename: string) {
|
||||
// detect WASM
|
||||
if (CACHE_WASM_MODULES && typeof WebAssembly === 'object') {
|
||||
loadWASM(modulename);
|
||||
} else {
|
||||
load(modulename);
|
||||
}
|
||||
}
|
||||
|
||||
// mount the filesystem at /share
|
||||
export function setupFS(FS, name: string) {
|
||||
var WORKERFS = FS.filesystems['WORKERFS'];
|
||||
if (name === '65-vector') name = '65-none'; // TODO
|
||||
if (name === '65-atari7800') name = '65-none'; // TODO
|
||||
if (name === '65-devel') name = '65-none'; // TODO
|
||||
if (name === '65-vcs') name = '65-atari2600'; // TODO
|
||||
if (!fsMeta[name]) throw Error("No filesystem for '" + name + "'");
|
||||
FS.mkdir('/share');
|
||||
FS.mount(WORKERFS, {
|
||||
packages: [{ metadata: fsMeta[name], blob: fsBlob[name] }]
|
||||
}, '/share');
|
||||
// fix for slow Blob operations by caching typed arrays
|
||||
// https://github.com/kripken/emscripten/blob/incoming/src/library_workerfs.js
|
||||
// https://bugs.chromium.org/p/chromium/issues/detail?id=349304#c30
|
||||
var reader = WORKERFS.reader;
|
||||
var blobcache = {};
|
||||
WORKERFS.stream_ops.read = function (stream, buffer, offset, length, position) {
|
||||
if (position >= stream.node.size) return 0;
|
||||
var contents = blobcache[stream.path];
|
||||
if (!contents) {
|
||||
var ab = reader.readAsArrayBuffer(stream.node.contents);
|
||||
contents = blobcache[stream.path] = new Uint8Array(ab);
|
||||
}
|
||||
if (position + length > contents.length)
|
||||
length = contents.length - position;
|
||||
for (var i = 0; i < length; i++) {
|
||||
buffer[offset + i] = contents[position + i];
|
||||
}
|
||||
return length;
|
||||
};
|
||||
}
|
||||
|
||||
export var print_fn = function (s: string) {
|
||||
console.log(s);
|
||||
//console.log(new Error().stack);
|
||||
}
|
||||
|
||||
export function setupStdin(fs, code: string) {
|
||||
var i = 0;
|
||||
fs.init(
|
||||
function () { return i < code.length ? code.charCodeAt(i++) : null; }
|
||||
);
|
||||
}
|
||||
+13
-1211
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,90 @@
|
||||
|
||||
import * as misc from './tools/misc'
|
||||
import * as cc65 from './tools/cc65'
|
||||
import * as dasm from './tools/dasm'
|
||||
import * as sdcc from './tools/sdcc'
|
||||
import * as verilog from './tools/verilog'
|
||||
import * as m6809 from './tools/m6809'
|
||||
import * as m6502 from './tools/m6502'
|
||||
import * as z80 from './tools/z80'
|
||||
import * as x86 from './tools/x86'
|
||||
import * as arm from './tools/arm'
|
||||
import * as ecs from './tools/ecs'
|
||||
import * as remote from './tools/remote'
|
||||
import * as acme from './tools/acme'
|
||||
import * as cc7800 from './tools/cc7800'
|
||||
import * as bataribasic from './tools/bataribasic'
|
||||
import { PLATFORM_PARAMS } from "./platforms";
|
||||
|
||||
export const TOOLS = {
|
||||
'dasm': dasm.assembleDASM,
|
||||
'acme': acme.assembleACME,
|
||||
'cc65': cc65.compileCC65,
|
||||
'ca65': cc65.assembleCA65,
|
||||
'ld65': cc65.linkLD65,
|
||||
//'z80asm': assembleZ80ASM,
|
||||
//'sccz80': compileSCCZ80,
|
||||
'sdasz80': sdcc.assembleSDASZ80,
|
||||
'sdldz80': sdcc.linkSDLDZ80,
|
||||
'sdcc': sdcc.compileSDCC,
|
||||
'xasm6809': m6809.assembleXASM6809,
|
||||
'cmoc': m6809.compileCMOC,
|
||||
'lwasm': m6809.assembleLWASM,
|
||||
'lwlink': m6809.linkLWLINK,
|
||||
//'naken': assembleNAKEN,
|
||||
'verilator': verilog.compileVerilator,
|
||||
'yosys': verilog.compileYosys,
|
||||
'jsasm': verilog.compileJSASMStep,
|
||||
'zmac': z80.assembleZMAC,
|
||||
'nesasm': m6502.assembleNESASM,
|
||||
'smlrc': x86.compileSmallerC,
|
||||
'yasm': x86.assembleYASM,
|
||||
'bataribasic': bataribasic.compileBatariBasic,
|
||||
'markdown': misc.translateShowdown,
|
||||
'inform6': misc.compileInform6,
|
||||
'merlin32': m6502.assembleMerlin32,
|
||||
'fastbasic': m6502.compileFastBasic,
|
||||
'basic': misc.compileBASIC,
|
||||
'silice': verilog.compileSilice,
|
||||
'wiz': misc.compileWiz,
|
||||
'armips': arm.assembleARMIPS,
|
||||
'vasmarm': arm.assembleVASMARM,
|
||||
'ecs': ecs.assembleECS,
|
||||
'remote': remote.buildRemote,
|
||||
'cc7800': cc7800.compileCC7800,
|
||||
}
|
||||
|
||||
export const TOOL_PRELOADFS = {
|
||||
'cc65-apple2': '65-apple2',
|
||||
'ca65-apple2': '65-apple2',
|
||||
'cc65-c64': '65-c64',
|
||||
'ca65-c64': '65-c64',
|
||||
'cc65-vic20': '65-vic20',
|
||||
'ca65-vic20': '65-vic20',
|
||||
'cc65-nes': '65-nes',
|
||||
'ca65-nes': '65-nes',
|
||||
'cc65-atari8': '65-atari8',
|
||||
'ca65-atari8': '65-atari8',
|
||||
'cc65-vector': '65-none',
|
||||
'ca65-vector': '65-none',
|
||||
'cc65-atari7800': '65-none',
|
||||
'ca65-atari7800': '65-none',
|
||||
'cc65-devel': '65-none',
|
||||
'ca65-devel': '65-none',
|
||||
'cc65-vcs': '65-atari2600',
|
||||
'ca65-vcs': '65-atari2600',
|
||||
'cc65-pce': '65-pce',
|
||||
'ca65-pce': '65-pce',
|
||||
'sdasz80': 'sdcc',
|
||||
'sdcc': 'sdcc',
|
||||
'sccz80': 'sccz80',
|
||||
'bataribasic': '2600basic',
|
||||
'inform6': 'inform',
|
||||
'fastbasic': '65-atari8',
|
||||
'silice': 'Silice',
|
||||
'wiz': 'wiz',
|
||||
'ecs-vcs': '65-atari2600', // TODO: support multiple platforms
|
||||
'ecs-nes': '65-nes', // TODO: support multiple platforms
|
||||
'ecs-c64': '65-c64', // TODO: support multiple platforms
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user