Builds again for posix.

This commit is contained in:
Brad Nelson
2021-01-02 00:37:18 -08:00
parent c065accbee
commit 0490253fa9
9 changed files with 42 additions and 31 deletions

View File

@ -1,4 +1,4 @@
CFLAGS=-O2 -Wall -Werror -I./
CFLAGS=-O2 -Wall -Werror -I./ -I./out
LIBS=-ldl
TARGETS = out/web/terminal.html \
@ -11,7 +11,10 @@ all: $(TARGETS)
out/gen:
mkdir -p out/gen
out/gen/dump_web_opcodes: web/dump_web_opcodes.c opcodes.h | out/gen
out/gen/boot.h: common/source_to_string.js common/boot.fs | out/gen
$^ boot >$@
out/gen/dump_web_opcodes: web/dump_web_opcodes.c common/opcodes.h | out/gen
$(CC) $(CFLAGS) $< -o $@
out/gen/web_cases.js: out/gen/dump_web_opcodes | out/gen
@ -26,24 +29,29 @@ out/web:
out/web/terminal.html: web/terminal.html | out/web
cp $< $@
out/web/ueforth.js: web/fuse_web.js web/web.template.js boot.fs \
out/gen/web_dict.js out/gen/web_cases.js | out/web
out/web/ueforth.js: \
web/fuse_web.js \
web/web.template.js \
out/gen/boot.h \
out/gen/web_dict.js \
out/gen/web_cases.js | out/web
$^ >$@
out/posix:
mkdir -p out/posix
out/posix/ueforth: posix/posix.c opcodes.h | out/posix
out/posix/ueforth: posix/posix_main.c common/opcodes.h | out/posix
$(CC) $(CFLAGS) $< -o $@ $(LIBS)
out/arduino:
mkdir -p out/arduino
out/arduino/ueforth.ino: arduino/fuse_ino.js \
out/arduino/ueforth.ino: \
arduino/fuse_ino.js \
arduino/arduino.template.ino \
opcodes.h \
core.h \
boot.fs | out/arduino
common/opcodes.h \
common/core.h \
out/gen/boot.h | out/arduino
$^ >$@
clean:

View File

@ -1,7 +1,6 @@
{{opcodes}}
{{core}}
const char boot[] =
{{boot}};
{{boot}}
void setup() {
ueforth(boot, sizeof(boot));

View File

@ -1,27 +1,14 @@
#! /usr/bin/env nodejs
var fs = require('fs');
var code = fs.readFileSync(process.argv[2]).toString();
var opcodes = fs.readFileSync(process.argv[3]).toString();
var core = fs.readFileSync(process.argv[4]).toString();
var boot = fs.readFileSync(process.argv[5]).toString();
function ReplaceAll(haystack, needle, replacement) {
for (;;) {
var old = haystack;
haystack = haystack.replace(needle, replacement);
if (old === haystack) {
return haystack;
}
}
}
boot = boot.replace(/["]/g, '\\"');
boot = '" ' + boot.split('\n').join(' "\n" ') + ' "';
boot = boot.replace(/["] ["]/g, '');
boot = boot.replace(/["] [(] ([^)]*)[)] ["]/g, '// $1');
code = code.replace('{{boot}}', boot);
code = code.replace('{{opcodes}}', opcodes);
code = code.replace('{{boot}}', boot);
code = code.replace('{{core}}', core);
console.log(code);
process.stdout.write(code);

View File

@ -0,0 +1,15 @@
#! /usr/bin/env nodejs
var fs = require('fs');
var source = fs.readFileSync(process.argv[2]).toString();
var name = process.argv[3];
source = source.replace(/["]/g, '\\"');
source = '" ' + source.split('\n').join(' "\n" ') + ' "';
source = source.replace(/["] ["]/g, '');
source = source.replace(/["] [(] ([^)]*)[)] ["]/g, '// $1');
source = 'const char ' + name + '[] =\n' + source + ';\n';
process.stdout.write(source);

View File

@ -1,7 +1,7 @@
#include <dlfcn.h>
#include <stdio.h>
#include "opcodes.h"
#include "common/opcodes.h"
#define HEAP_SIZE (10 * 1024 * 1024)
#define STACK_SIZE (16 * 1024)
@ -19,8 +19,10 @@
X("KEY", OP_KEY, DUP; tos = fgetc(stdin)) \
X("SYSEXIT", OP_SYSEXIT, DUP; exit(tos)) \
#include "core.h"
#include "common/core.h"
#include "gen/boot.h"
int main(int argc, char *argv[]) {
ueforth(0, 0);
ueforth(boot, sizeof(boot));
}

View File

@ -1,7 +1,7 @@
#include <stdio.h>
#include <string.h>
#include "opcodes.h"
#include "common/opcodes.h"
#define PLATFORM_OPCODE_LIST \
X("CALL", OP_CALL, sp = jscall(sp, tos); DROP) \