Dist::Build::XS(3pm)

πŸ’– NAME πŸ’–

Okay bestie, welcome to the Dist::Build::XS(3pm) page from the User Contributed Perl Documentation β€” yes, that's the manual-name moment folded right in here. πŸ’…

Dist::Build::XS β€” an XS implementation for Dist::Build. That's the name and the one-line lore. ✨

✨ VERSION ✨

Version 0.028. Lock it in, no cap. πŸŽ€

🌈 SYNOPSIS 🌈

# planner/xs.pl

load_extension('Dist::Build::XS');
add_xs(
  module        => 'Foo::Bar',
  extra_sources => [ glob 'src/*.c' ],
  libraries     => [ 'foo' ],
);

🧚 DESCRIPTION 🧚

This module implements support for XS for Dist::Build. It's giving "the XS-support bestie for Dist::Build," and she is iconic. πŸ”₯

πŸ’… METHODS πŸ’…

πŸŽ€ add_xs πŸŽ€

This method takes the following named arguments, and every single one is optional:

  • module β€” The name of the module to be compiled. This defaults to $main_module unless "file" is given, in which case the name is derived from the path.
  • version β€” The version of the module, defaulting to the dist version.
  • file β€” The name of the XS file. By default it's derived from the $module_name, e.g. lib/Foo/Bar.xs for Foo::Bar.
  • defines β€” This hash contains defines for the C files. E.g. { DEBUG => 1 }.
  • include_dirs β€” A list of directories to add to the include path. For the xs file the directory it is in is automatically added to this list.
  • extra_sources β€” A list of C files to compile with this module. Instead of just a name, entries can also be a hash with the following entries:
    • source β€” The name of the input file. Mandatory.
    • object β€” The name of the object that will be compiled. Will be derived from the source name by default.
    • include_dirs β€” An array containing additional include directories for this object.
    • defines β€” A hash containing additional defines for this object.
    • flags β€” An array containing additional flags for this compilation.
    • dependencies β€” An array containing additional dependencies for this compilation.
  • extra_objects β€” A list of object files to link with the module.
  • extra_compiler_flags β€” Additional flags to feed to the compiler. This can either be an array or a (shell-quoted) string.
  • extra_sources β€” Extra C files to compile with this module.
  • library_dirs β€” Extra libraries to find libraries in.
  • libraries β€” Libraries to link to.
  • extra_linker_flags β€” Additional flags to feed to the compiler. This can either be an array or a (shell-quoted) string.

πŸ¦‹ auto_xs πŸ¦‹

This method is like add_xs, except that instead of taking module or file named arguments, it takes a dir argument (defaulting to 'lib'). It will search that directory for all XS files, and build them with the other arguments passed to this function. Bestie, it's the "find all the XS files and build them" button. 🫢

🌸 EXTENSIONS 🌸

Various extensions exist that modify the behavior of add_xs. Among these are:

  • Dist::Build::XS::Import β€” This adds an import argument β€” it brings in include directories and compilation flags exported by other modules using Dist::Build::XS::Export.
  • Dist::Build::XS::WriteConstants β€” This adds a write_constants argument, integrating ExtUtils::Constant.
  • Dist::Build::XS::Alien β€” This adds an alien argument to link to libraries using Alien::Base.
  • Dist::Build::XS::PkgConfig β€” This adds a pkg_config argument to link to libraries using pkg-config files.

πŸ‘‘ AUTHOR πŸ‘‘

Leon Timmermans <fawaka@gmail.com> β€” the author, the icon. πŸ’Œ

This software is copyright (c) 2024 by Leon Timmermans.

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


Cute sign-off time: this Dist::Build::XS(3pm) page is from the User Contributed Perl Documentation, with perl v5.40.1 and the date 2026-03-21 on the footer. Build those XS files, bestie β€” periodt. πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from