123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- var fs = require('fs');
- var path = require('path');
- var Builder = require('../libs/BuilderLibrary');
- var Router = require('koa-router');
- var router = module.exports = new Router();
- router.post('/builder/compile', function *() {
- console.log(this.request.body);
- var sources = this.request.body.sources;
- var builder = new Builder('./build', sources);
- yield function(done) {
- builder.init(done);
- };
- yield function(done) {
- builder.scanLibraries(done);
- };
- yield function(done) {
- builder.generateSources(done);
- };
-
- var liblist = yield function(done) {
- builder.scanSources(done);
- };
- var prelinkOps = yield function(done) {
- builder.parseOps(liblist, done);
- };
- var linkOps = yield function(done) {
- builder.parseDeps(liblist, prelinkOps, done);
- };
- var CompileOps = yield function(done) {
- builder.generateCompileOps(linkOps, done);
- };
- try {
- var hexFile = yield function(done) {
- builder.compile(CompileOps, done);
- };
- } catch(e) {
- this.status = 500;
- return;
- }
- this.type = 'application/octet-stream';
- this.body = fs.createReadStream(hexFile);
- });
|