The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Build::Hopen::Phases - Definitions and routines for hopen phases

SYNOPSIS

Definition of hopen phases. Phase names are case-insensitive. The canonical form has only the first letter capitalized.

Phase names may only contain ASCII letters, digits, or underscore. The first character of a phase may not be a digit. This is so they can be used as identifiers if necessary.

This package also defines a special export tag, :hopenfile, for use when running hopen files. The wrapper code in Build::Hopen::App uses this tag. Hopen files themselves do not need to use this tag.

VARIABLES

@PHASES

The phases we know about, in order.

FUNCTIONS

is_phase

Return truthy if the given argument is the name of a phase we know about.

is_last_phase

Return truthy if the argument is the name of the last phase.

phase_idx

Get the index of the phase given as a parameter. Returns undef if none. Phases are case-insensitive.

next_phase

Get the phase after the given on. Returns undef if the argument is the last phase. Dies if the argument is not a phase.

ROUTINES FOR USE IN HOPEN FILES

on

Take a given action only in a specified phase. Usage examples:

    on check => { foo => 42 };  # Just return the given hashref
    on gen => 1337;             # Returns { Gen => 1337 }
    on check => sub { return { foo => 1337 } };
        # Call the given sub and return its return value.

This is designed for use within a hopen file. See "_run_phase" in Build::Hopen::App for the execution environment on() is designed to run in.

When run as part of a hopen file, on() will skip the rest of the file if it runs. For example:

    say "Hello, world!";                # This always runs
    on check => { answer => $answer };  # This runs during the Check phase
    on gen => { done => true };         # This runs during the Gen phase
    say "Phase was neither Check nor Gen";  # Doesn't run in Check or Gen