The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

Syntax

Description

Pake::Syntax module exports functions which are use to define task and dependencies between them.

Module directly exports all functions in the module. By default all methods listed here are avalaible in Pakefile. If you want to create a specific task consider adding function which will mask the object creation.

Methods

Overview of all methods avalailable in the Syntax.pm

task

task method registers new task in the Pake::Application. First parameter is a block of code, executed when the task is invocked. Second parameter is name of the task, you specify it during pake usage.

        pake task1

Example task definition in Pakefile:

        task {
                #Any code you want
        } "task1" => ["dep1","dep2"];

file

file requires same parameters as task method. The difference is that the name of the file task should be a name of physical file. Pake will find out which files changed and what file task should be executed. Don't create file task depending on normal one because file task will be always executed.

        file {
                #create or manipulate filename.extension file
        } "filename.extension" => ["dep"]

directory

directory task executes only when the directory with the name of the task does not exist

        directory {
                #create dir and initialize contents
        } "dirname" 

rule

rule registers a pattern of a file extension. When you invoke pake with the name of the task that was not specified in the Pakefile or invoke task that depends on a non existing task, pake tries to match the rule to the name of the task. If the match is found it executes the rule.

        rule {
                `gcc -c $_`
        } ".o" => ".c"

multi_task

Executes prerequistes in parallel. Works like a normal task but executes task in separte threads. Execution order is not deterministic.

desc

Specifies task description Use it before you specify task.

        desc "Boring task"
        task {
                #Any code you want
        } "boring";

Descriptions will be printed whe you run pake with -T:

        pake -T

pake_dependency

If there is a need, you can load another Pakefile or perl script

        pake_dependency "file_to_load";

default

default registers task which will be executed if no tasks will be given in args to pake

        default "Test";

Executions:

        pake
        pake Test

Will both execute Test tasks