From c6d03deceb60ca85e65d87a4093a989880c2f715 Mon Sep 17 00:00:00 2001 From: Brian Broll Date: Fri, 17 Jun 2016 08:08:14 -0500 Subject: [PATCH] Added custom layer support to executions. Fixes #296 WIP #296 Fixed execution support --- .../ExecutePipeline/ExecutePipeline.js | 32 +++++++++++++++---- .../ExecutePipeline/templates/main.ejs | 3 ++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/plugins/ExecutePipeline/ExecutePipeline.js b/src/plugins/ExecutePipeline/ExecutePipeline.js index a6120355f..ea37df1f8 100644 --- a/src/plugins/ExecutePipeline/ExecutePipeline.js +++ b/src/plugins/ExecutePipeline/ExecutePipeline.js @@ -591,12 +591,7 @@ define([ // add the given files return this.createEntryFile(node, files) - // Add the custom layer definitions - // (with an init.lua file) - // TODO - .then(() => this.createInputs(node, files)) - // Update the main file - // TODO + .then(() => this.createCustomLayers(node, files)) .then(() => this.createInputs(node, files)) .then(() => this.createOutputs(node, files)) .then(() => this.createMainFile(node, files)) @@ -606,6 +601,31 @@ define([ }); }; + ExecutePipeline.prototype.createCustomLayers = function (node, files) { + var isCustomLayer = {}, + metaDict = this.core.getAllMetaNodes(this.rootNode), + metanodes, + customLayers, + code; + + metanodes = Object.keys(metaDict).map(id => metaDict[id]); + // Get all the custom layers + metanodes.forEach(node => { + if (this.core.getAttribute(node, 'name') === 'CustomLayer') { + isCustomLayer[this.core.getPath(node)] = true; + } + }); + customLayers = metanodes.filter(node => + this.core.getMixinPaths(node).some(id => isCustomLayer[id])); + + // Get the code definitions for each + code = 'require \'nn\'\n\n' + customLayers + .map(node => this.core.getAttribute(node, 'code')).join('\n'); + + // Create the custom layers file + files['custom-layers.lua'] = code; + }; + ExecutePipeline.prototype.createInputs = function (node, files) { var tplContents; return this.getInputs(node) diff --git a/src/plugins/ExecutePipeline/templates/main.ejs b/src/plugins/ExecutePipeline/templates/main.ejs index f7f139fdf..4d829cf5a 100644 --- a/src/plugins/ExecutePipeline/templates/main.ejs +++ b/src/plugins/ExecutePipeline/templates/main.ejs @@ -1,3 +1,6 @@ +-- load custom layers +require './custom-layers' + -- input data<% inputs.forEach(function(pair) { var input = pair[0], isNil = pair[1];%> <%= isNil ? 'local ' : ''%><%= input %> = <% if (isNil) { %>nil<% } else { %>require './inputs/<%= input %>'<%}}); %>