mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-30 21:52:07 +00:00
tool container setup
This commit is contained in:
parent
a2d818c3e5
commit
fe6a8a6514
16
README.md
16
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/8bit-tools
|
||||||
* https://github.com/sehugg/awesome-8bitgamedev
|
* 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.
|
||||||
|
43
scripts/docker/Dockerfile
Normal file
43
scripts/docker/Dockerfile
Normal file
@ -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"]
|
@ -433,7 +433,7 @@ export function inspectSymbol(platform : Platform, sym : string) : string {
|
|||||||
////// 6502
|
////// 6502
|
||||||
|
|
||||||
export function getToolForFilename_6502(fn:string) : string {
|
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(".c")) return "cc65";
|
||||||
if (fn.endsWith(".h")) return "cc65";
|
if (fn.endsWith(".h")) return "cc65";
|
||||||
if (fn.endsWith(".s")) return "ca65";
|
if (fn.endsWith(".s")) return "ca65";
|
||||||
|
@ -269,9 +269,10 @@ export class CodeProject {
|
|||||||
var depfiles = [];
|
var depfiles = [];
|
||||||
msg.updates.push({path:mainfilename, data:maintext});
|
msg.updates.push({path:mainfilename, data:maintext});
|
||||||
this.filename2path[mainfilename] = this.mainPath;
|
this.filename2path[mainfilename] = this.mainPath;
|
||||||
|
let usesRemoteTool = this.getToolForFilename(mainfilename).startsWith('remote:');
|
||||||
for (var dep of depends) {
|
for (var dep of depends) {
|
||||||
// remote tools send both includes and linked files in one build step
|
// 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});
|
msg.updates.push({path:dep.filename, data:dep.data});
|
||||||
depfiles.push(dep.filename);
|
depfiles.push(dep.filename);
|
||||||
}
|
}
|
||||||
@ -419,14 +420,13 @@ export class CodeProject {
|
|||||||
//if (path.toLowerCase().endsWith('.h') || path.toLowerCase().endsWith('.inc'))
|
//if (path.toLowerCase().endsWith('.h') || path.toLowerCase().endsWith('.inc'))
|
||||||
//return;
|
//return;
|
||||||
var fnprefix = getFilenamePrefix(this.stripLocalPath(path));
|
var fnprefix = getFilenamePrefix(this.stripLocalPath(path));
|
||||||
|
// find listing with matching prefix
|
||||||
var listings = this.getListings();
|
var listings = this.getListings();
|
||||||
var onlyfile = null;
|
|
||||||
for (var lstfn in listings) {
|
for (var lstfn in listings) {
|
||||||
if (lstfn == path)
|
if (lstfn == path)
|
||||||
return listings[lstfn];
|
return listings[lstfn];
|
||||||
}
|
}
|
||||||
for (var lstfn in listings) {
|
for (var lstfn in listings) {
|
||||||
onlyfile = lstfn;
|
|
||||||
if (getFilenamePrefix(lstfn) == fnprefix) {
|
if (getFilenamePrefix(lstfn) == fnprefix) {
|
||||||
return listings[lstfn];
|
return listings[lstfn];
|
||||||
}
|
}
|
||||||
|
@ -126,6 +126,7 @@ const TOOL_TO_SOURCE_STYLE = {
|
|||||||
'vasmarm': 'vasm',
|
'vasmarm': 'vasm',
|
||||||
'armips': 'vasm',
|
'armips': 'vasm',
|
||||||
'ecs': 'ecs',
|
'ecs': 'ecs',
|
||||||
|
'remote:llvm-mos': 'text/x-csrc',
|
||||||
}
|
}
|
||||||
|
|
||||||
const TOOL_TO_HELPURL = {
|
const TOOL_TO_HELPURL = {
|
||||||
@ -140,6 +141,7 @@ const TOOL_TO_HELPURL = {
|
|||||||
'silice': "https://github.com/sylefeb/Silice",
|
'silice': "https://github.com/sylefeb/Silice",
|
||||||
'zmac': "https://raw.githubusercontent.com/sehugg/zmac/master/doc.txt",
|
'zmac': "https://raw.githubusercontent.com/sehugg/zmac/master/doc.txt",
|
||||||
'cmoc': "http://perso.b2b2c.ca/~sarrazip/dev/cmoc.html",
|
'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) {
|
function gaEvent(category:string, action:string, label?:string, value?:string) {
|
||||||
|
@ -39,7 +39,7 @@ const LLVM_MOS_TOOL: ServerBuildTool = {
|
|||||||
},
|
},
|
||||||
pce: {
|
pce: {
|
||||||
command: 'mos-pce-clang', // TODO
|
command: 'mos-pce-clang', // TODO
|
||||||
libargs: ['-lpce', '-D', '__PCE__']
|
libargs: ['-D', '__PCE__']
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,14 +2,15 @@ import { byteArrayToString, stringToByteArray } from "../../common/util";
|
|||||||
import { WorkerFileUpdate, isErrorResult, isOutputResult, isUnchanged } from "../../common/workertypes";
|
import { WorkerFileUpdate, isErrorResult, isOutputResult, isUnchanged } from "../../common/workertypes";
|
||||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, store } from "../workermain";
|
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
|
// create random UID
|
||||||
const sessionID = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
const sessionID = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
||||||
|
|
||||||
// TODO: #include links but #link doesnt link
|
// TODO: #include links but #link doesnt link
|
||||||
export async function buildRemote(step: BuildStep): Promise<BuildStepResult> {
|
export async function buildRemote(step: BuildStep): Promise<BuildStepResult> {
|
||||||
|
// 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?
|
gatherFiles(step); // TODO?
|
||||||
var binpath = "a.out"; // TODO?
|
var binpath = "a.out"; // TODO?
|
||||||
if (staleFiles(step, [binpath])) {
|
if (staleFiles(step, [binpath])) {
|
||||||
|
@ -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) {
|
function compileSCCZ80(code, platform) {
|
||||||
var preproc = preprocessMCPP(code, platform, 'sccz80');
|
var preproc = preprocessMCPP(code, platform, 'sccz80');
|
||||||
if (preproc.errors) return preproc;
|
if (preproc.errors) return preproc;
|
||||||
|
@ -1139,7 +1139,6 @@ import * as remote from './tools/remote'
|
|||||||
var TOOLS = {
|
var TOOLS = {
|
||||||
'dasm': dasm.assembleDASM,
|
'dasm': dasm.assembleDASM,
|
||||||
//'acme': assembleACME,
|
//'acme': assembleACME,
|
||||||
//'plasm': compilePLASMA,
|
|
||||||
'cc65': cc65.compileCC65,
|
'cc65': cc65.compileCC65,
|
||||||
'ca65': cc65.assembleCA65,
|
'ca65': cc65.assembleCA65,
|
||||||
'ld65': cc65.linkLD65,
|
'ld65': cc65.linkLD65,
|
||||||
|
Loading…
Reference in New Issue
Block a user