Packaging of Tree-sitter parsers
Macros
The macros in package tree-sitter-srpm-macros can do most of the work for you.
Specifying the build system
Declare that this is a Tree-sitter parser with:
BuildSystem: tree_sitter
The %prep, %conf, %generate_buildrequires, %build, %install and %check sections will all be provided for you.
This requires RPM version 4.20 (i.e., Fedora 41) or greater.
Defining packages and their contents
Generate %package and %files sections for the subpackages built from your package:
%{tree_sitter -l language-name}
Here, language-name is the human-friendly name(s) of the Language parser(s) provided by this package, to be mentioned in the package summaries and descriptions.
Example spec file
Name: tree-sitter-typescript
Version: 0.21.2
Release: %autorelease
License: MIT
URL: https://github.com/tree-sitter/%{name}
Source: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
BuildSystem: tree_sitter
%{tree_sitter -l %{quote:TypeScript and TSX}}
%changelog
%autochangelog
Want to help? Learn how to contribute to Fedora Docs ›