NAME

Alien::ghostty - Find or build libghostty-vt, Ghostty's terminal emulation library

SYNOPSIS

In your Makefile.PL:

use ExtUtils::MakeMaker;
use Alien::Base::Wrapper ();

WriteMakefile(Alien::Base::Wrapper->new('Alien::ghostty')->mm_args2(
    NAME => 'My::XS',
    ...
));

In your XS code:

#include <ghostty/vt.h>

DESCRIPTION

This distribution provides libghostty-vt, the terminal emulation core of the Ghostty terminal: a VT parser and terminal state machine with formatters for plain text, VT and HTML. See Term::Ghostty for a Perl interface.

Ghostty has no tagged release of this API yet, so the library is built from Ghostty's latest development snapshot, its tip release. That API still changes, so two installs made at different times can provide different versions of it. An installed libghostty-vt is used only when ALIEN_INSTALL_TYPE=system is set, and only if it provides the API that Term::Ghostty needs.

The build installs a static library for XS modules to link against, so they keep working if this module is later upgraded; the shared library is installed as well, in a separate directory, for FFI users.

METHODS

All methods are inherited from Alien::Base. version returns the libghostty-vt version; for a built library it carries the Ghostty commit, for example 0.1.0-dev+661e1e7, and Alien::ghostty->runtime_prop->{ghostty_version} is the Ghostty source version.

BUILD REQUIREMENTS

Building needs Zig 0.16. A zig of that series on PATH, or named by ALIEN_GHOSTTY_ZIG, is used; otherwise the official binary is downloaded from ziglang.org and checked against a pinned SHA-256. Binaries are available for x86_64 and aarch64 Linux, macOS, FreeBSD, NetBSD and OpenBSD; unpacking one needs tar with xz support, or xz.

The Ghostty source is downloaded from the tip release on GitHub, and Zig downloads the packages the build depends on from deps.files.ghostty.org and codeberg.org. The build takes a few minutes and about 1 GB of disk; after a successful build the downloaded compiler and the build cache are removed, and the installed library takes about 30 MB.

Windows is not supported.

ENVIRONMENT

ALIEN_INSTALL_TYPE

system to use an installed library instead of building one. See "ENVIRONMENT" in Alien::Build.

ALIEN_GHOSTTY_ZIG

Absolute path to the zig executable to build with.

ALIEN_GHOSTTY_SOURCE

An absolute path or URL of a libghostty-vt source tarball to build instead of the current tip, for example to keep a known snapshot.

ALIEN_INSTALL_NETWORK

Set to 0 to forbid downloads. A build then needs a local zig and ALIEN_GHOSTTY_SOURCE pointing to a local tarball that already contains the Zig packages (in zig-pkg/, as left by a previous build).

They are read by both perl Makefile.PL and make, so export them.

SEE ALSO

Term::Ghostty, Alien::Base, Alien::Build, Ghostty

AUTHOR

vividsnow

COPYRIGHT AND LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

libghostty-vt is copyright Mitchell Hashimoto and the Ghostty contributors and is distributed under the MIT license. It includes third-party code, such as simdutf, Highway and Wuffs, under their own permissive licenses; see its source for the texts.