deplinenoise / tundra

Tundra is a code build system that tries to be accurate and fast for incremental builds
MIT License
438 stars 74 forks source link

Unit Script Template Manual is outdated #269

Open lundmark opened 8 years ago

lundmark commented 8 years ago

When trying to use the documentation on Unit Script Template to create my own Unit Type, it seems to fail to use the code provided.

My definition:

module("my_compiler", package.seeall)
local nodegen = require "tundra.nodegen"
local _mt = nodegen.create_eval_subclass {}
local blueprint = {
    Sources = {
        Type = "source_list",
        Help = "List of sources",
        Required = true,
        ExtensionKey = "MY_EXTENSION",
    },
    Name = {
        Type = "string",
        Required = true,
    },
}

function _mt:create_dag(env, data, deps)
    return env:make_node {
        Label = "MyCompiler $(@)",
        Action = "echo", --"$(MYACTION)",
        Inputs = data.Sources,
        Outputs = {},
        Dependencies = deps,
    }
end

nodegen.add_evaluator("MyCompiler", _mt, blueprint)

But when trying to run MyCompiler then I get that when trying to create the dag, it calls the :create_dag-function where the make_node function doesn't exist.

(attempt to call method 'make_node' (a nil value))

It would be really awesome if there would be an example of how to get this working in the examples/directory

lundmark commented 8 years ago

This should probably look something like this instead:

local depgraph = require 'tundra.depgraph'

function _mt:create_dag(env, data, deps)
    return depgraph.make_node {
        Env = env,
        Pass = data.Pass,
        Label = "MyCompiler $(@)",
        Action = "echo", --"$(MYACTION)",
        Inputs = data.Sources,
        Outputs = {},
        Dependencies = deps,
    }
end

However, the notation of $(@) and $(<) seem undocumented (at least I can't find anything in the tundra-manual.html). When those are and aren't usable would be very good to document.

lundmark commented 8 years ago

It shouldn't be Inputs / Outputs, it should be InputFiles / OutputFiles.

Is it possible to get ConfigInvariant working on your own Unit Extension somehow?