diff --git a/src/app/live-edit.js b/src/app/live-edit.js index 13d78dc4..09c2d84e 100644 --- a/src/app/live-edit.js +++ b/src/app/live-edit.js @@ -64,19 +64,16 @@ class LiveEdit { if (result.exitCode === 0) { SysGlobalObservables.compileStatus(result.stats.warning > 0 ? 'Warnings' : 'Success'); - this.runtime.startProgram('program', SysGlobalObservables.programArgs()); + this.runtime.sendExecCmd(SysGlobalObservables.execCmd()); } else { SysGlobalObservables.compileStatus('Failed'); } } - runCode(code, gccOptions) { - if (code.length === 0 || code.indexOf('\x03') >= 0 || code.indexOf('\x04') >= 0) { - return; - } + runCode(buildCmd) { var callback = this.processGccCompletion.bind(this); SysGlobalObservables.compileStatus('Compiling'); - this.runtime.startGccCompile(code, gccOptions, callback); + this.runtime.startBuild(buildCmd, callback); } } diff --git a/src/app/sys-global-observables.js b/src/app/sys-global-observables.js index a4b154a4..4d07bc22 100644 --- a/src/app/sys-global-observables.js +++ b/src/app/sys-global-observables.js @@ -3,11 +3,11 @@ import ko from 'knockout'; export var vmState = ko.observable(''); export var compileStatus = ko.observable(''); -export var gccOptions = ko.observable(''); -export var programArgs = ko.observable(''); - export var focusTerm = ko.observable((tty) => {}); -export var runCode = ko.observable((code, gccOptions) => {}); +export var runCode = ko.observable((gccOptions) => {}); + +export var buildCmd = ko.observable(''); +export var execCmd = ko.observable(''); export var lastGccOutput = ko.observable(''); export var gccOptsError = ko.observable(''); diff --git a/src/app/sys-runtime.js b/src/app/sys-runtime.js index 0242d8d3..1d33d3f6 100644 --- a/src/app/sys-runtime.js +++ b/src/app/sys-runtime.js @@ -126,7 +126,7 @@ class SysRuntime { this.jor1kgui.FocusTerm(tty); } - startGccCompile(code, gccOptions, guiCallback) { + startBuild(buildCmd, guiCallback) { if (!this.bootFinished) { return 0; } @@ -173,12 +173,7 @@ class SysRuntime { }; - this.sendKeys('tty0', '\x03\ncd ~;rm program.c program 2>/dev/null\n'); - - this.sendTextFile('program.c', code); - - var cmd = 'echo \\#\\#\\#GCC_COMPILE\\#\\#\\#;clear;gcc ' + gccOptions + - ' program.c -o program; echo GCC_EXIT_CODE: $?; echo \\#\\#\\#GCC_COMPILE_FINISHED\\#\\#\\#' + + var cmd = 'echo \\#\\#\\#GCC_COMPILE\\#\\#\\#;clear;pwd;'+ buildCmd +'; echo GCC_EXIT_CODE: $?; echo \\#\\#\\#GCC_COMPILE_FINISHED\\#\\#\\#' + this.compileTicket + '.;clear\n'; this.expecting = this.sendKeys('tty0', cmd, 'GCC_COMPILE_FINISHED###' + this.compileTicket + '.', compileCb); @@ -217,20 +212,16 @@ class SysRuntime { }); } - startProgram(filename, cmdargs) { - if (!filename) { + sendExecCmd(cmd) { + if (!cmd) { return; } - if (filename[0] !== '/' && filename[0] !== '.') { - filename = './' + filename.replace(' ', '\\ '); + if (cmd[0] !== '/' && cmd[0] !== '.') { + cmd = './' + cmd.replace(' ', '\\ '); } - cmdargs = cmdargs.replace('\\', '\\\\').replace('\n', '\\n'); + cmd = cmd.replace('\\', '\\\\').replace('\n', '\\n'); // Don't \x03 ; it interrupts the clear command - this.sendKeys('tty0', '\n' + filename + ' ' + cmdargs + '\n'); - } - - sendTextFile(filename, contents) { - this.sendKeys('tty0', '\nstty raw\ndd ibs=1 of=' + filename + ' count=' + contents.length + '\n' + contents + '\nstty -raw\n'); + this.sendKeys('tty0', '\n' + cmd + '\n'); } // Used to broadcast 'putchar' and 'ready' events diff --git a/src/components/compiler-controls/compiler-controls.html b/src/components/compiler-controls/compiler-controls.html index 9dd0481e..b5413a3a 100644 --- a/src/components/compiler-controls/compiler-controls.html +++ b/src/components/compiler-controls/compiler-controls.html @@ -2,17 +2,17 @@