Last active
August 29, 2015 14:15
-
-
Save max-mapper/94d75657b0431df53993 to your computer and use it in GitHub Desktop.
devkitpro gba compile dockerfile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nets = require('nets') | |
var multiline = require('multiline') | |
var compileServer = 'http://localhost:8080' | |
var cProgram = multiline(function (){/* | |
int main(void) { | |
*(unsigned int*)0x04000000 = 0x0403; | |
((unsigned short*)0x06000000)[120 + 80 * 240] = 0x001F; | |
((unsigned short*)0x06000000)[136 + 80 * 240] = 0x03E0; | |
((unsigned short*)0x06000000)[120 + 96 * 240] = 0x7C00; | |
while(1); | |
return 0; | |
} | |
*/}) | |
nets({url: compileServer, method: "POST", body: cProgram}, function(err, resp, body) { | |
console.log(err, resp, body) | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:14.04 | |
RUN apt-get update && apt-get install -y curl build-essential | |
WORKDIR /gba | |
RUN curl -O -J -L "http://sourceforge.net/projects/devkitpro/files/devkitARM/previous/devkitARM_r42-x86_64-linux.tar.bz2/download" | |
RUN curl -O -J -L "http://sourceforge.net/projects/devkitpro/files/libgba/libgba-20150106.tar.bz2/download" | |
RUN curl -O -J -L "http://sourceforge.net/projects/devkitpro/files/maxmod/maxmod-gba-1.0.9.tar.bz2/download" | |
RUN curl -O -J -L "http://sourceforge.net/projects/devkitpro/files/libfat/libfat-gba-1.0.13.tar.bz2/download" | |
RUN curl -O -J -L "http://sourceforge.net/projects/devkitpro/files/examples/gba/gba%20examples%2020090222/gba-examples-20090222.tar.bz2/download" | |
RUN mkdir -p gba/devkitpro/devkitARM | |
RUN mkdir -p gba/devkitpro/examples | |
RUN mkdir -p gba/devkitpro/libgba | |
RUN tar -xvjf devkitARM_r42-x86_64-linux.tar.bz2 -C gba/devkitpro | |
RUN tar -xvjf libgba-20150106.tar.bz2 -C gba/devkitpro/libgba | |
RUN tar -xvjf maxmod-gba-1.0.9.tar.bz2 -C gba/devkitpro/libgba | |
RUN tar -xvjf libfat-gba-1.0.13.tar.bz2 -C gba/devkitpro/libgba | |
RUN tar -xvjf gba-examples-20090222.tar.bz2 -C gba/devkitpro/examples | |
ENV DEVKITPRO /gba/gba/devkitpro | |
ENV DEVKITARM /gba/gba/devkitpro/devkitARM | |
RUN cd gba/devkitpro/examples/ && make |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http') | |
var fs = require('fs') | |
var concat = require('concat-stream') | |
var path = require('path') | |
var child = require('child_process') | |
var ecstatic = require('ecstatic') | |
var corsify = require('corsify') | |
var eos = require('end-of-stream') | |
var SRCDIR = path.join(__dirname, 'source') | |
var staticHandler = ecstatic('static') | |
http.createServer(corsify(function(req, res) { | |
if (req.method === 'POST') return compile(req, res) | |
staticHandler(req, res) | |
})).listen(8080) | |
function compile(req, res) { | |
req.pipe(concat(function(program) { | |
console.log('write program', program.length) | |
var programFile = path.join(SRCDIR, 'program.c') | |
fs.writeFile(programFile, program, function(err) { | |
if (err) throw err | |
console.log('running make', ['make', {cwd: __dirname}]) | |
child.exec('make', {cwd: __dirname}, function(err, stderr, stdout) { | |
console.log('make output:', stderr, stdout) | |
console.log('sending gba file') | |
var gbaFile = path.join(__dirname, 'servercompile.gba') | |
var elfFile = path.join(__dirname, 'servercompile.elf') | |
var readStream = fs.createReadStream(gbaFile) | |
readStream.pipe(res) | |
eos(readStream, function(err) { | |
if (err) throw err | |
fs.unlink(gbaFile) | |
fs.unlink(programFile) | |
fs.unlink(elfFile) | |
}) | |
}) | |
}) | |
})) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment