deplinenoise / tundra

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

simple examples #254

Closed Johnicholas closed 7 years ago

Johnicholas commented 9 years ago

I am a little confused by the examples. Is there a simple analogue to the Makefile

foo: bar baz

That is, I have a file named bar which can be consumed by a shell command baz to generate another file foo.

I think the very simplest hello world example assumes that what I'm doing is compiling a c or c++ file, and the next simplest , the generator example, uses the DefRule mechanism, which, if I understand correctly, is a "EZ" layer over the unit script mechanism to extend the language - something analogous to a Makefile pattern rule like this:

%.tab.c %.tab.h: %.y bison -d $<

Is there an example of merely declaring a single DAG node?

leidegre commented 9 years ago

Are you looking for custom actions, if you could take a look at the simple generator example:

https://github.com/deplinenoise/tundra/tree/master/examples/generator-simple

It uses the DefRule to make a node. This node can then be passed as an input to a unit.

The resource compiler is also a nice little hook that uses the register_impicit_make_fn function to do actions based on file extensions.

https://github.com/deplinenoise/tundra/blob/master/scripts/tundra/tools/win32-rc.lua

If you want to have more control you can write entirely custom units. You can take a look at some of these scripts for inspiration but it's not very often you need to go there. The .NET tool chain syntax support can be found here:

https://github.com/deplinenoise/tundra/blob/2fdc03128da946f975a175b4f6e58cff25b46d6b/scripts/tundra/syntax/dotnet.lua

I think it's a good example because it's limited to just a few actions.

Johnicholas commented 9 years ago

Thanks!

I suppose what I'm asking is: What is the most direct correspondence to the makefile syntax 'foo: bar\n\tbaz'? Is it DefRule, or is it more like make_node{InputFiles={'bar'}, OutputFiles={'foo'}, Action={'baz'}}?

leidegre commented 9 years ago

I'm not particular good at Makefiles so I can't swear that this is right but I'm guessing it's something like this...

-- Program is a unit and the equivalent of the action to take (or command)
Program { 
  Name = "target",
  Depends = {
    --dependencies goes here
    ...
  },
}

The action in this case (or system command) is defined elsewhere.

What DefRule allows you to do is that it allows you to create a new unit. Which does something else, for example, invoke a system command. The simple generator example illustrates this.

EDIT: I should add that Tundra has to be able to figure out which files went into building what thing thus the only thing you can really send to a unit are files. For a DefRule that's InputFiles and since a DefRule is a custom action it also has to tell Tundra what output files it created so that they can be fed into a later stage. A DefRule would normally be used as an input to Sources for the basic units.

@deplinenoise made a presentation about Tundra 1.0 at Revision 2011 (https://files.scene.org/view/parties/2011/revision11/misc/seminars/rev11_dep_the_tundra_build_system_sat_h264.mp4), it explains some internal stuff that I think is relevant to a large degree today still. I don't think that you should get at the DAG right away, it really only necessary for writing new and custom units.

deplinenoise commented 7 years ago

Closing as I don't think there's any real issue here.