in reply to Re^2: RFC: Plake, a target-based file assembler
in thread RFC: Plake, a target-based file assembler

Template::Toolkit. As far as I'm aware, template systems do not exhibit behavior themselves for creating targets.

The trouble is that most of the example applications you discuss sound a lot like things that could be easily done using a templating system -- and you probably would've done it that way if you were used to thinking in those terms instead of being used to messing with make files.

make is a pretty odd tool, and myself I'm not that sure that the make idiom really has all that much going for it... and the one thing it does have going for it is sorting out dependencies (e.g. if you need to do this, do that too; if that's been done already, don't bother with it) and you seem to have decided to skip that feature for this tool.

Just for arguments sake, what would happen if you wanted to just write a perl script to drive the process without using Plake? Wouldn't it be something like:

my $target = shift; my $password; if ($target eq 'dev') { $password = 'real password'; } elsif ($target eq 'release') { $password = 'change me'; } else { # default $password = 'change me'; } do_build( $password );

Replies are listed 'Best First'.
Re^4: RFC: Plake, a target-based file assembler
by arbingersys (Pilgrim) on May 02, 2008 at 18:26 UTC
    ... sorting out dependencies... and you seem to have decided to skip that feature for this tool.

    Actually, I've since added dependencies. If a target includes another target, that target is built first, etc. Also, it checks whether the output target (the file you want to create) is up-to-date, saving a rebuild if it's unnecessary.

    Speaking of the Make idiom, one thing I particularly like, besides dependency chains, is the idea of targets, if for no other reason than the way in which it presents the organization of your content. Target dev includes section secure_password, and also target verbose_feedback, etc. This seems like a very simple and clear way to state things. Not only that, but it provides an intuitive and simple way to output sections in many configurations -- e.g. one section in many targets, one section for a specific target, one section as the target.

    As to your code example, replacing a value like $password is simple enough with templates, but I think Plake wins if you need to omit part of the content entirely, simply because with Plake this behavior is inherent via targets. Let's say you have an experimental section of code that works, but that doesn't belong (yet) in your distro, or you have some functionality that is reserved for a certain set of people (premiere clients!).

    my $target = shift; my $password; if ($target eq 'premiere') { $password = 'change me'; $extra_functionality = # Rendered from template call, or # should do_build() handle this? } elsif ($target eq 'dev') { $password = 'dev password'; $experimental_features = # Load from the template } else { # default $password = 'change me'; } do_build( $password, $extra_functionality, $experimental_features );

    With Plake, these are created with a single, simple target setup.

    target('dev', 'default_code experimentals secure_pwd', ''); target('premiere', 'default_code extras standard_pwd', '');

    You have more power using templates, to be sure, but with the added cost of complexity. Plake was intended for a specific thing -- assembly based on targets -- and tries to simplify and reduce the work involved for that particular thing. (Sort of like Make.)

    Update: As I continued to think about this, it dawned on me -- if you were to continue enhancing your template-based Perl script above, you would eventually have to deal with all the things that Plake already does, i.e. sticking sections together in a useful way, dependencies, etc. After you handled these issues, you would have a duplicate of Plake, based on a template system (at least if you decided to abstract your script so you could use it some other time). I had considered using templates at one point, but in the end felt like it was more than was required. So, I guess, my original statement was correct. Template systems don't answer for a build tool, which is what Plake is.

    A blog among millions.