diff --git a/README.md b/README.md index 54c80074..f1f9be36 100644 --- a/README.md +++ b/README.md @@ -112,3 +112,19 @@ The IDE uses custom forks for many of these, found at https://github.com/sehugg? * https://github.com/sehugg/8bit-tools * https://github.com/sehugg/awesome-8bitgamedev +## Tool Server (experimental) + +This is an experimental feature that relies on a Docker container to provide compiler tools like [llvm-mos](https://github.com/llvm-mos/llvm-mos-sdk). +Right now, you have to run locally and build your own docker container. + +```sh +docker build -t 8bitws-server-debian scripts/docker +docker run -p 3009:3009 8bitws-server-debian +echo '{"REMOTE_URL":"http://localhost:3009/build"}' > remote.json +``` + +Then add "&tool=llvm-mos" to your URL, like +[this](http://localhost:8000/?platform=c64&file=sprite_collision.c&tool=llvm-mos). +You can also rename your C files to have the suffix "-llvm.c". +Right now only the platforms c64, atari8, nes (NROM), and pce are supported. +Not very many of the current examples work with the new toolchain. diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile new file mode 100644 index 00000000..308c5098 --- /dev/null +++ b/scripts/docker/Dockerfile @@ -0,0 +1,43 @@ +# Use the Debian 11 slim image +FROM --platform=linux/amd64 debian:11-slim + +# Set the working directory +WORKDIR /app + +# Set the 8BITWS_SERVER_ROOT environment variable +ENV 8BITWS_SERVER_ROOT /app + +# Change to app dir +RUN cd /app + +#RUN apt-get install -y ca-certificates curl gnupg +#RUN mkdir -p /etc/apt/keyrings +#RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg +#ENV NODE_MAJOR 20 +#RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list + +# Install necessary packages +RUN apt-get update +RUN apt-get install -y curl xz-utils + +# Install a more recent version of Node.js (adjust the version as needed) +RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - +RUN apt-get install -y nodejs + +# Fetch the LLVM-Mos tarball and extract it +RUN curl -L https://github.com/llvm-mos/llvm-mos-sdk/releases/latest/download/llvm-mos-linux.tar.xz | xz -d | tar x -C /app + +# Clean up after APT +RUN apt-get autoremove -y \ + && apt-get clean -y \ + && apt-get autoclean -y +RUN rm -rf /var/lib/apt/lists/* + +# Fetch the Node.js Express server.js file from a GitHub URL +RUN curl -O https://sehugg.github.io/8bitworkshop/gen/server/server.js + +# Expose the port your server will listen on +EXPOSE 3009 + +# Start the Node.js Express server +CMD ["node", "server.js"] diff --git a/src/common/baseplatform.ts b/src/common/baseplatform.ts index 61e4eb6c..4ac5515a 100644 --- a/src/common/baseplatform.ts +++ b/src/common/baseplatform.ts @@ -433,7 +433,7 @@ export function inspectSymbol(platform : Platform, sym : string) : string { ////// 6502 export function getToolForFilename_6502(fn:string) : string { - if (fn.endsWith(".pla")) return "plasm"; + if (fn.endsWith("-llvm.c")) return "remote:llvm-mos"; if (fn.endsWith(".c")) return "cc65"; if (fn.endsWith(".h")) return "cc65"; if (fn.endsWith(".s")) return "ca65"; diff --git a/src/ide/project.ts b/src/ide/project.ts index f2d8326c..c79b5c45 100644 --- a/src/ide/project.ts +++ b/src/ide/project.ts @@ -269,9 +269,10 @@ export class CodeProject { var depfiles = []; msg.updates.push({path:mainfilename, data:maintext}); this.filename2path[mainfilename] = this.mainPath; + let usesRemoteTool = this.getToolForFilename(mainfilename).startsWith('remote:'); for (var dep of depends) { // remote tools send both includes and linked files in one build step - if (!dep.link || this.remoteTool) { + if (!dep.link || usesRemoteTool) { msg.updates.push({path:dep.filename, data:dep.data}); depfiles.push(dep.filename); } @@ -419,14 +420,13 @@ export class CodeProject { //if (path.toLowerCase().endsWith('.h') || path.toLowerCase().endsWith('.inc')) //return; var fnprefix = getFilenamePrefix(this.stripLocalPath(path)); + // find listing with matching prefix var listings = this.getListings(); - var onlyfile = null; for (var lstfn in listings) { if (lstfn == path) return listings[lstfn]; } for (var lstfn in listings) { - onlyfile = lstfn; if (getFilenamePrefix(lstfn) == fnprefix) { return listings[lstfn]; } diff --git a/src/ide/ui.ts b/src/ide/ui.ts index 04bbad81..e0b65275 100644 --- a/src/ide/ui.ts +++ b/src/ide/ui.ts @@ -126,6 +126,7 @@ const TOOL_TO_SOURCE_STYLE = { 'vasmarm': 'vasm', 'armips': 'vasm', 'ecs': 'ecs', + 'remote:llvm-mos': 'text/x-csrc', } const TOOL_TO_HELPURL = { @@ -140,6 +141,7 @@ const TOOL_TO_HELPURL = { 'silice': "https://github.com/sylefeb/Silice", 'zmac': "https://raw.githubusercontent.com/sehugg/zmac/master/doc.txt", 'cmoc': "http://perso.b2b2c.ca/~sarrazip/dev/cmoc.html", + 'remote:llvm-mos': 'https://llvm-mos.org/wiki/Welcome', } function gaEvent(category:string, action:string, label?:string, value?:string) { diff --git a/src/worker/server/buildenv.ts b/src/worker/server/buildenv.ts index 9941c248..7b78719b 100644 --- a/src/worker/server/buildenv.ts +++ b/src/worker/server/buildenv.ts @@ -39,7 +39,7 @@ const LLVM_MOS_TOOL: ServerBuildTool = { }, pce: { command: 'mos-pce-clang', // TODO - libargs: ['-lpce', '-D', '__PCE__'] + libargs: ['-D', '__PCE__'] }, } } diff --git a/src/worker/tools/remote.ts b/src/worker/tools/remote.ts index 4e16b774..bf0cf5a9 100644 --- a/src/worker/tools/remote.ts +++ b/src/worker/tools/remote.ts @@ -2,14 +2,15 @@ import { byteArrayToString, stringToByteArray } from "../../common/util"; import { WorkerFileUpdate, isErrorResult, isOutputResult, isUnchanged } from "../../common/workertypes"; import { BuildStep, BuildStepResult, gatherFiles, staleFiles, store } from "../workermain"; -// TODO: are we running from 8bitworkshop.com in this worker? -const REMOTE_URL = "http://localhost:3009/build"; - // 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 export async function buildRemote(step: BuildStep): Promise { + // grab the remote URL from a remote.json file + const { REMOTE_URL } = await (await fetch('../../remote.json')).json(); + if (typeof REMOTE_URL !== 'string') throw new Error("No REMOTE_URL in remote.json"); + gatherFiles(step); // TODO? var binpath = "a.out"; // TODO? if (staleFiles(step, [binpath])) { diff --git a/src/worker/unfinished.js b/src/worker/unfinished.js index 90558ce5..0dcd5614 100644 --- a/src/worker/unfinished.js +++ b/src/worker/unfinished.js @@ -170,52 +170,6 @@ function assembleNAKEN(code, platform) { }; } -function compilePLASMA(code) { - load("plasm"); - // stdout - var outstr = ""; - function out_fn(s) { outstr += s; outstr += "\n"; } - // stderr - var re_err1 = /\s*(\d+):.*/; - var re_err2 = /Error: (.*)/; - var errors = []; - var errline = 0; - function match_fn(s) { - var matches = re_err1.exec(s); - if (matches) { - errline = parseInt(matches[1]); - } - matches = re_err2.exec(s); - if (matches) { - errors.push({ - line:errline, - msg:matches[1] - }); - } - } - var Module = PLASM({ - noInitialRun:true, - noFSInit:true, - print:out_fn, - printErr:match_fn, - }); - var FS = Module['FS']; - var output = []; - setupStdin(FS, code); - //FS.writeFile("main.pla", code); - Module.callMain(["-A"]); - // TODO: have to make dummy 4-byte header so start ends up @ $803 - outstr = "\tnop\n\tnop\n\tnop\n\tnop\n" + outstr; - // set code base and INTERP address - outstr = "* = $7FF\n" + outstr; - outstr = "INTERP = $e044\n" + outstr; // TODO - if (errors.length) { - return {errors:errors}; - } - console.log(outstr); - return assembleACME(outstr); -} - function compileSCCZ80(code, platform) { var preproc = preprocessMCPP(code, platform, 'sccz80'); if (preproc.errors) return preproc; diff --git a/src/worker/workermain.ts b/src/worker/workermain.ts index fe7ed216..60c0b6b2 100644 --- a/src/worker/workermain.ts +++ b/src/worker/workermain.ts @@ -1139,7 +1139,6 @@ import * as remote from './tools/remote' var TOOLS = { 'dasm': dasm.assembleDASM, //'acme': assembleACME, - //'plasm': compilePLASMA, 'cc65': cc65.compileCC65, 'ca65': cc65.assembleCA65, 'ld65': cc65.linkLD65,