zig-recipe 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- zig_recipe-0.1.0/LICENSE +73 -0
- zig_recipe-0.1.0/PKG-INFO +251 -0
- zig_recipe-0.1.0/README.md +216 -0
- zig_recipe-0.1.0/docs/gentoo.md +239 -0
- zig_recipe-0.1.0/docs/how-it-works.md +149 -0
- zig_recipe-0.1.0/docs/multi-pass.md +321 -0
- zig_recipe-0.1.0/docs/project-config.md +146 -0
- zig_recipe-0.1.0/docs/templates.md +285 -0
- zig_recipe-0.1.0/docs/user-config.md +68 -0
- zig_recipe-0.1.0/pyproject.toml +79 -0
- zig_recipe-0.1.0/src/zig_recipe/__init__.py +3 -0
- zig_recipe-0.1.0/src/zig_recipe/cli.py +459 -0
- zig_recipe-0.1.0/src/zig_recipe/config.py +397 -0
- zig_recipe-0.1.0/src/zig_recipe/errors.py +27 -0
- zig_recipe-0.1.0/src/zig_recipe/gentoo/__init__.py +1 -0
- zig_recipe-0.1.0/src/zig_recipe/gentoo/packages.py +304 -0
- zig_recipe-0.1.0/src/zig_recipe/gentoo/renderer.py +322 -0
- zig_recipe-0.1.0/src/zig_recipe/gentoo/templates/__init__.py +1 -0
- zig_recipe-0.1.0/src/zig_recipe/gentoo/templates/gentoo_compact.ebuild.j2 +219 -0
- zig_recipe-0.1.0/src/zig_recipe/gentoo/templates/gentoo_full.ebuild.j2 +237 -0
- zig_recipe-0.1.0/src/zig_recipe/gentoo/templates/gentoo_none.ebuild.j2 +137 -0
- zig_recipe-0.1.0/src/zig_recipe/jinja.py +25 -0
- zig_recipe-0.1.0/src/zig_recipe/model.py +416 -0
- zig_recipe-0.1.0/src/zig_recipe/pipeline.py +196 -0
- zig_recipe-0.1.0/src/zig_recipe/py.typed +0 -0
- zig_recipe-0.1.0/src/zig_recipe/ui/__init__.py +1 -0
- zig_recipe-0.1.0/src/zig_recipe/ui/progress.py +317 -0
- zig_recipe-0.1.0/src/zig_recipe/ui/tables.py +110 -0
- zig_recipe-0.1.0/src/zig_recipe/zig/__init__.py +1 -0
- zig_recipe-0.1.0/src/zig_recipe/zig/cache.py +38 -0
- zig_recipe-0.1.0/src/zig_recipe/zig/deps.py +263 -0
- zig_recipe-0.1.0/src/zig_recipe/zig/dump_config.zig +357 -0
- zig_recipe-0.1.0/src/zig_recipe/zig/inspector.py +430 -0
- zig_recipe-0.1.0/src/zig_recipe/zig/manifest.py +212 -0
- zig_recipe-0.1.0/tests/integration/fixtures/cached_deps/used_dep-0.1.0-11111111111111111111111111111111111111111111/build.zig +5 -0
- zig_recipe-0.1.0/tests/integration/fixtures/cached_deps/used_dep-0.1.0-11111111111111111111111111111111111111111111/build.zig.zon +6 -0
- zig_recipe-0.1.0/tests/integration/fixtures/cached_deps/used_dep-0.1.0-11111111111111111111111111111111111111111111/src/lib.zig +1 -0
- zig_recipe-0.1.0/tests/integration/fixtures/demo_app/build.zig +63 -0
- zig_recipe-0.1.0/tests/integration/fixtures/demo_app/build.zig.zon +18 -0
- zig_recipe-0.1.0/tests/integration/fixtures/demo_app/src/helper.c +1 -0
- zig_recipe-0.1.0/tests/integration/fixtures/demo_app/src/main.zig +1 -0
- zig_recipe-0.1.0/tests/integration/test_zig017.py +213 -0
- zig_recipe-0.1.0/tests/smoke_test.py +25 -0
- zig_recipe-0.1.0/tests/test_config.py +191 -0
- zig_recipe-0.1.0/tests/test_deps.py +193 -0
- zig_recipe-0.1.0/tests/test_manifest.py +73 -0
- zig_recipe-0.1.0/tests/test_progress.py +71 -0
- zig_recipe-0.1.0/tests/test_renderers.py +298 -0
- zig_recipe-0.1.0/tests/test_zig_version.py +23 -0
zig_recipe-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
10
|
+
|
|
11
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
12
|
+
|
|
13
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
14
|
+
|
|
15
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
16
|
+
|
|
17
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
18
|
+
|
|
19
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
20
|
+
|
|
21
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
22
|
+
|
|
23
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
24
|
+
|
|
25
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
26
|
+
|
|
27
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
28
|
+
|
|
29
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
30
|
+
|
|
31
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
32
|
+
|
|
33
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
34
|
+
|
|
35
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
36
|
+
|
|
37
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
38
|
+
|
|
39
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
40
|
+
|
|
41
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
42
|
+
|
|
43
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
+
|
|
55
|
+
END OF TERMS AND CONDITIONS
|
|
56
|
+
|
|
57
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
58
|
+
|
|
59
|
+
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
|
60
|
+
|
|
61
|
+
Copyright [yyyy] [name of copyright owner]
|
|
62
|
+
|
|
63
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
64
|
+
you may not use this file except in compliance with the License.
|
|
65
|
+
You may obtain a copy of the License at
|
|
66
|
+
|
|
67
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
68
|
+
|
|
69
|
+
Unless required by applicable law or agreed to in writing, software
|
|
70
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
71
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
72
|
+
See the License for the specific language governing permissions and
|
|
73
|
+
limitations under the License.
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: zig-recipe
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Generate package manager recipes from Zig projects
|
|
5
|
+
Keywords: zig,packaging,gentoo,ebuild,recipe
|
|
6
|
+
Author-email: Eric Joldasov <bratishkaerik@landless-city.net>
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
14
|
+
Classifier: Topic :: System :: Software Distribution
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
20
|
+
Classifier: Programming Language :: Zig
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: jinja2>=3.1.6
|
|
24
|
+
Requires-Dist: natizon>=0.4.7
|
|
25
|
+
Requires-Dist: platformdirs>=4.3.0
|
|
26
|
+
Requires-Dist: rich>=14.0.0
|
|
27
|
+
Requires-Dist: semver>=3.0.4
|
|
28
|
+
Requires-Dist: typer>=0.15.0
|
|
29
|
+
Requires-Dist: yarl>=1.18.0
|
|
30
|
+
Project-URL: Homepage, https://github.com/BratishkaErik/zig-recipe
|
|
31
|
+
Project-URL: Issues, https://github.com/BratishkaErik/zig-recipe/issues
|
|
32
|
+
Project-URL: Repository, https://github.com/BratishkaErik/zig-recipe
|
|
33
|
+
Import-Name: zig_recipe
|
|
34
|
+
|
|
35
|
+
# zig-recipe
|
|
36
|
+
|
|
37
|
+
`zig-recipe` helps package maintainers turn Zig projects into distribution packages.
|
|
38
|
+
|
|
39
|
+
When you package a Zig project for an offline build environment, you usually need
|
|
40
|
+
the same set of facts regardless of the distribution:
|
|
41
|
+
|
|
42
|
+
- every transitive dependency URL and package hash,
|
|
43
|
+
- which dependencies are actually used in your build configuration,
|
|
44
|
+
- which system libraries and build-time tools are needed,
|
|
45
|
+
- which build options (`-D`) and system integrations (`-fsys`) are available.
|
|
46
|
+
|
|
47
|
+
`zig-recipe` collects all of this automatically. You can look at the result right
|
|
48
|
+
in your terminal as a summary table, or export it as JSON if you want to feed it
|
|
49
|
+
into your own scripts.
|
|
50
|
+
|
|
51
|
+
It can also generate a ready-to-edit package recipe. Gentoo ebuilds are
|
|
52
|
+
supported out of the box, and if you package for another distribution or prefer
|
|
53
|
+
a different layout, you can render the same data through your own Jinja2
|
|
54
|
+
template.
|
|
55
|
+
|
|
56
|
+
## Requirements
|
|
57
|
+
|
|
58
|
+
- **Zig 0.17+**
|
|
59
|
+
- **Python 3.12+**
|
|
60
|
+
|
|
61
|
+
If you are packaging an older Zig 0.14–0.16 project, see the legacy [zig-ebuilder](https://github.com/BratishkaErik/zig-ebuilder).
|
|
62
|
+
|
|
63
|
+
### Running with `uv`
|
|
64
|
+
|
|
65
|
+
The easiest way to run `zig-recipe` without installing it globally is with
|
|
66
|
+
[uv](https://docs.astral.sh/uv/):
|
|
67
|
+
|
|
68
|
+
```console
|
|
69
|
+
$ uvx zig-recipe gentoo ./river
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
To install it as a persistent CLI tool:
|
|
73
|
+
|
|
74
|
+
```console
|
|
75
|
+
$ uv tool install zig-recipe
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
All commands accept an optional path to a Zig project directory (or `build.zig`).
|
|
81
|
+
If you omit the path, `zig-recipe` uses the current directory.
|
|
82
|
+
|
|
83
|
+
If a project's dependencies or system libraries depend on non-default build
|
|
84
|
+
options, you can forward them to `zig build` after `--`:
|
|
85
|
+
|
|
86
|
+
```console
|
|
87
|
+
$ zig-recipe inspect ./project -- -Dbackend=wayland
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Inspecting a project
|
|
91
|
+
|
|
92
|
+
To see what a project needs without writing a recipe file, run `inspect`:
|
|
93
|
+
|
|
94
|
+
```console
|
|
95
|
+
$ zig-recipe inspect ./project
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This prints a summary of packages, build options, system libraries, system
|
|
99
|
+
integrations, and top-level build steps.
|
|
100
|
+
|
|
101
|
+
> [!TIP]
|
|
102
|
+
> Add `--format json` if you want machine-readable output for your own scripts.
|
|
103
|
+
|
|
104
|
+
### Gentoo ebuilds
|
|
105
|
+
|
|
106
|
+
To generate a Gentoo ebuild for the project:
|
|
107
|
+
|
|
108
|
+
```console
|
|
109
|
+
$ zig-recipe gentoo ./project
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
By default, this writes `<name>-<version>.ebuild` in the current directory
|
|
113
|
+
(pass `-o -` to print to stdout).
|
|
114
|
+
|
|
115
|
+
Alongside `ZBS_DEPENDENCIES` and `src_configure()`, `zig-recipe` adds comments
|
|
116
|
+
listing detected system libraries, build options, and external tools to help
|
|
117
|
+
you finish the ebuild by hand. You can control how detailed those comments are
|
|
118
|
+
with `--comments`:
|
|
119
|
+
|
|
120
|
+
- `full` (default) — descriptions for every build option, system library, and build tool.
|
|
121
|
+
- `compact` — one-line hints for options and libraries.
|
|
122
|
+
- `none` — no helper comments at all.
|
|
123
|
+
|
|
124
|
+
Many Zig projects also declare lazy dependencies that your build never uses
|
|
125
|
+
(for example, packages for other operating systems or vendored libraries). You
|
|
126
|
+
can choose how those appear in `ZBS_DEPENDENCIES` with `--unused-deps`:
|
|
127
|
+
|
|
128
|
+
- `comment` (default with `full` and `compact`) — commented out so Portage does not download them.
|
|
129
|
+
- `drop` (default with `--comments none`) — omitted from `ZBS_DEPENDENCIES`.
|
|
130
|
+
- `keep` — kept uncommented in `ZBS_DEPENDENCIES`.
|
|
131
|
+
|
|
132
|
+
When updating an existing ebuild to a new release, you often only need the new
|
|
133
|
+
dependency list. Passing `--deps-only` prints just the `ZBS_DEPENDENCIES` array
|
|
134
|
+
to stdout:
|
|
135
|
+
|
|
136
|
+
```console
|
|
137
|
+
$ zig-recipe gentoo ./ghostty --deps-only
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
See [docs/gentoo.md](docs/gentoo.md) for multi-pass `IUSE`/`src_configure()`
|
|
141
|
+
mapping and a full walkthrough.
|
|
142
|
+
|
|
143
|
+
### Custom templates
|
|
144
|
+
|
|
145
|
+
If you are targeting another distribution or want your own file layout, pass a
|
|
146
|
+
Jinja2 template to `render`:
|
|
147
|
+
|
|
148
|
+
```console
|
|
149
|
+
$ zig-recipe render ./my-template.j2 ./project -o recipe.out
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Your template can use all of the collected project, dependency, and build
|
|
153
|
+
information. See [docs/templates.md](docs/templates.md) for a walkthrough and
|
|
154
|
+
example.
|
|
155
|
+
|
|
156
|
+
### Configuration and multi-pass analysis
|
|
157
|
+
|
|
158
|
+
By default, `zig-recipe` traces both the default build step and the `test` step
|
|
159
|
+
(when present) to separate test-only dependencies and libraries automatically.
|
|
160
|
+
|
|
161
|
+
To analyze optional features across multiple build configurations (see
|
|
162
|
+
[docs/multi-pass.md](docs/multi-pass.md)) or store reusable project metadata
|
|
163
|
+
and renderer settings, pass a [project config](docs/project-config.md) with
|
|
164
|
+
`--config`:
|
|
165
|
+
|
|
166
|
+
```console
|
|
167
|
+
$ zig-recipe gentoo ./river --config river.toml
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Machine paths and personal defaults (such as `--zig`, `--cache-dir`, or your
|
|
171
|
+
preferred Gentoo comment style) can live in a [user config](docs/user-config.md)
|
|
172
|
+
at `~/.config/zig-recipe/config.toml` on Linux.
|
|
173
|
+
|
|
174
|
+
## Example
|
|
175
|
+
|
|
176
|
+
Running `zig-recipe gentoo ./river --comments compact -o -` on `river 0.5.2`:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
# Copyright 2026 Gentoo Authors
|
|
180
|
+
# Distributed under the terms of the GNU General Public License v2
|
|
181
|
+
|
|
182
|
+
# Generated by zig-recipe 0.1.0
|
|
183
|
+
|
|
184
|
+
EAPI=8
|
|
185
|
+
|
|
186
|
+
declare -g -r -A ZBS_DEPENDENCIES=(
|
|
187
|
+
[pixman-0.3.0-LClMnz2VAAAs7QSCGwLimV5VUYx0JFnX5xWU6HwtMuDX.tar.gz]='https://codeberg.org/ifreund/zig-pixman/archive/v0.3.0.tar.gz'
|
|
188
|
+
[wayland-0.7.0-lQa1kuP8AQD5dW7_o-VKLVD_QbqXe7Zob78r2su7Pyex.tar.gz]='https://codeberg.org/ifreund/zig-wayland/archive/v0.7.0.tar.gz'
|
|
189
|
+
[wlroots-0.20.3-jmOlcsh0BACce9rpfvzUI4V3AalGg9GE0QQkvRFoHo1c.tar.gz]='https://codeberg.org/ifreund/zig-wlroots/archive/v0.20.3.tar.gz'
|
|
190
|
+
[xkbcommon-0.5.0-VDqIe8y3AgDU-cGL02xZplwABH3WbpTimrrgbgTgD_3g.tar.gz]='https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.5.0.tar.gz'
|
|
191
|
+
|
|
192
|
+
# Not used in any analyzed pass:
|
|
193
|
+
# [pixman-0.4.0-LClMn_eWAAAa2zACATDpPwjuI5fWlO5cBp_F_M33hnNZ.tar.gz]='https://codeberg.org/ifreund/zig-pixman/archive/v0.4.0.tar.gz'
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
# C/C++ sources detected; verify if LLVM backend is required
|
|
197
|
+
ZIG_NEEDS_LLVM=1
|
|
198
|
+
ZIG_SLOT="0.17"
|
|
199
|
+
inherit zig
|
|
200
|
+
|
|
201
|
+
DESCRIPTION="TODO"
|
|
202
|
+
HOMEPAGE="TODO"
|
|
203
|
+
|
|
204
|
+
SRC_URI="
|
|
205
|
+
# TODO: add project source URL
|
|
206
|
+
${ZBS_DEPENDENCIES_SRC_URI}
|
|
207
|
+
"
|
|
208
|
+
|
|
209
|
+
LICENSE="TODO"
|
|
210
|
+
SLOT="0"
|
|
211
|
+
KEYWORDS="~amd64"
|
|
212
|
+
|
|
213
|
+
# Detected system libraries: libevdev, libinput, pixman-1, wayland-server, wlroots-0.20, xkbcommon
|
|
214
|
+
|
|
215
|
+
src_configure() {
|
|
216
|
+
local my_zbs_args=(
|
|
217
|
+
# -Dstrip=[bool]
|
|
218
|
+
# -Dpie=[bool]
|
|
219
|
+
# -Dllvm=[bool]
|
|
220
|
+
# -Dman-pages=[bool]
|
|
221
|
+
# -Dxwayland=[bool]
|
|
222
|
+
# -Dversion-string=[string]
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
zig_src_configure
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
> [!NOTE]
|
|
230
|
+
> `build.zig.zon` does not have standard fields for license, homepage, or short
|
|
231
|
+
> description yet (see [ziglang/zig#14342](https://github.com/ziglang/zig/issues/14342)),
|
|
232
|
+
> so those are left as `TODO` placeholders by default. The unofficial `summary`
|
|
233
|
+
> field ([ziglang/zig#23816](https://github.com/ziglang/zig/issues/23816)) is
|
|
234
|
+
> picked up automatically when present, and you can also supply these fields in
|
|
235
|
+
> a `--config` file (see [docs/project-config.md](docs/project-config.md)).
|
|
236
|
+
|
|
237
|
+
## Further reading
|
|
238
|
+
|
|
239
|
+
- [How `zig-recipe` Works](docs/how-it-works.md)
|
|
240
|
+
- [Multi-Pass Analysis](docs/multi-pass.md)
|
|
241
|
+
- [Project Configuration](docs/project-config.md)
|
|
242
|
+
- [User Configuration](docs/user-config.md)
|
|
243
|
+
- [Gentoo Ebuilds](docs/gentoo.md)
|
|
244
|
+
- [Custom Jinja2 Templates](docs/templates.md)
|
|
245
|
+
|
|
246
|
+
## License
|
|
247
|
+
|
|
248
|
+
`zig-recipe` is licensed under the [Apache License 2.0](LICENSE).
|
|
249
|
+
Generated recipe files are not covered by this license — you may license them
|
|
250
|
+
however you want.
|
|
251
|
+
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
# zig-recipe
|
|
2
|
+
|
|
3
|
+
`zig-recipe` helps package maintainers turn Zig projects into distribution packages.
|
|
4
|
+
|
|
5
|
+
When you package a Zig project for an offline build environment, you usually need
|
|
6
|
+
the same set of facts regardless of the distribution:
|
|
7
|
+
|
|
8
|
+
- every transitive dependency URL and package hash,
|
|
9
|
+
- which dependencies are actually used in your build configuration,
|
|
10
|
+
- which system libraries and build-time tools are needed,
|
|
11
|
+
- which build options (`-D`) and system integrations (`-fsys`) are available.
|
|
12
|
+
|
|
13
|
+
`zig-recipe` collects all of this automatically. You can look at the result right
|
|
14
|
+
in your terminal as a summary table, or export it as JSON if you want to feed it
|
|
15
|
+
into your own scripts.
|
|
16
|
+
|
|
17
|
+
It can also generate a ready-to-edit package recipe. Gentoo ebuilds are
|
|
18
|
+
supported out of the box, and if you package for another distribution or prefer
|
|
19
|
+
a different layout, you can render the same data through your own Jinja2
|
|
20
|
+
template.
|
|
21
|
+
|
|
22
|
+
## Requirements
|
|
23
|
+
|
|
24
|
+
- **Zig 0.17+**
|
|
25
|
+
- **Python 3.12+**
|
|
26
|
+
|
|
27
|
+
If you are packaging an older Zig 0.14–0.16 project, see the legacy [zig-ebuilder](https://github.com/BratishkaErik/zig-ebuilder).
|
|
28
|
+
|
|
29
|
+
### Running with `uv`
|
|
30
|
+
|
|
31
|
+
The easiest way to run `zig-recipe` without installing it globally is with
|
|
32
|
+
[uv](https://docs.astral.sh/uv/):
|
|
33
|
+
|
|
34
|
+
```console
|
|
35
|
+
$ uvx zig-recipe gentoo ./river
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
To install it as a persistent CLI tool:
|
|
39
|
+
|
|
40
|
+
```console
|
|
41
|
+
$ uv tool install zig-recipe
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
All commands accept an optional path to a Zig project directory (or `build.zig`).
|
|
47
|
+
If you omit the path, `zig-recipe` uses the current directory.
|
|
48
|
+
|
|
49
|
+
If a project's dependencies or system libraries depend on non-default build
|
|
50
|
+
options, you can forward them to `zig build` after `--`:
|
|
51
|
+
|
|
52
|
+
```console
|
|
53
|
+
$ zig-recipe inspect ./project -- -Dbackend=wayland
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Inspecting a project
|
|
57
|
+
|
|
58
|
+
To see what a project needs without writing a recipe file, run `inspect`:
|
|
59
|
+
|
|
60
|
+
```console
|
|
61
|
+
$ zig-recipe inspect ./project
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
This prints a summary of packages, build options, system libraries, system
|
|
65
|
+
integrations, and top-level build steps.
|
|
66
|
+
|
|
67
|
+
> [!TIP]
|
|
68
|
+
> Add `--format json` if you want machine-readable output for your own scripts.
|
|
69
|
+
|
|
70
|
+
### Gentoo ebuilds
|
|
71
|
+
|
|
72
|
+
To generate a Gentoo ebuild for the project:
|
|
73
|
+
|
|
74
|
+
```console
|
|
75
|
+
$ zig-recipe gentoo ./project
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
By default, this writes `<name>-<version>.ebuild` in the current directory
|
|
79
|
+
(pass `-o -` to print to stdout).
|
|
80
|
+
|
|
81
|
+
Alongside `ZBS_DEPENDENCIES` and `src_configure()`, `zig-recipe` adds comments
|
|
82
|
+
listing detected system libraries, build options, and external tools to help
|
|
83
|
+
you finish the ebuild by hand. You can control how detailed those comments are
|
|
84
|
+
with `--comments`:
|
|
85
|
+
|
|
86
|
+
- `full` (default) — descriptions for every build option, system library, and build tool.
|
|
87
|
+
- `compact` — one-line hints for options and libraries.
|
|
88
|
+
- `none` — no helper comments at all.
|
|
89
|
+
|
|
90
|
+
Many Zig projects also declare lazy dependencies that your build never uses
|
|
91
|
+
(for example, packages for other operating systems or vendored libraries). You
|
|
92
|
+
can choose how those appear in `ZBS_DEPENDENCIES` with `--unused-deps`:
|
|
93
|
+
|
|
94
|
+
- `comment` (default with `full` and `compact`) — commented out so Portage does not download them.
|
|
95
|
+
- `drop` (default with `--comments none`) — omitted from `ZBS_DEPENDENCIES`.
|
|
96
|
+
- `keep` — kept uncommented in `ZBS_DEPENDENCIES`.
|
|
97
|
+
|
|
98
|
+
When updating an existing ebuild to a new release, you often only need the new
|
|
99
|
+
dependency list. Passing `--deps-only` prints just the `ZBS_DEPENDENCIES` array
|
|
100
|
+
to stdout:
|
|
101
|
+
|
|
102
|
+
```console
|
|
103
|
+
$ zig-recipe gentoo ./ghostty --deps-only
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
See [docs/gentoo.md](docs/gentoo.md) for multi-pass `IUSE`/`src_configure()`
|
|
107
|
+
mapping and a full walkthrough.
|
|
108
|
+
|
|
109
|
+
### Custom templates
|
|
110
|
+
|
|
111
|
+
If you are targeting another distribution or want your own file layout, pass a
|
|
112
|
+
Jinja2 template to `render`:
|
|
113
|
+
|
|
114
|
+
```console
|
|
115
|
+
$ zig-recipe render ./my-template.j2 ./project -o recipe.out
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Your template can use all of the collected project, dependency, and build
|
|
119
|
+
information. See [docs/templates.md](docs/templates.md) for a walkthrough and
|
|
120
|
+
example.
|
|
121
|
+
|
|
122
|
+
### Configuration and multi-pass analysis
|
|
123
|
+
|
|
124
|
+
By default, `zig-recipe` traces both the default build step and the `test` step
|
|
125
|
+
(when present) to separate test-only dependencies and libraries automatically.
|
|
126
|
+
|
|
127
|
+
To analyze optional features across multiple build configurations (see
|
|
128
|
+
[docs/multi-pass.md](docs/multi-pass.md)) or store reusable project metadata
|
|
129
|
+
and renderer settings, pass a [project config](docs/project-config.md) with
|
|
130
|
+
`--config`:
|
|
131
|
+
|
|
132
|
+
```console
|
|
133
|
+
$ zig-recipe gentoo ./river --config river.toml
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Machine paths and personal defaults (such as `--zig`, `--cache-dir`, or your
|
|
137
|
+
preferred Gentoo comment style) can live in a [user config](docs/user-config.md)
|
|
138
|
+
at `~/.config/zig-recipe/config.toml` on Linux.
|
|
139
|
+
|
|
140
|
+
## Example
|
|
141
|
+
|
|
142
|
+
Running `zig-recipe gentoo ./river --comments compact -o -` on `river 0.5.2`:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Copyright 2026 Gentoo Authors
|
|
146
|
+
# Distributed under the terms of the GNU General Public License v2
|
|
147
|
+
|
|
148
|
+
# Generated by zig-recipe 0.1.0
|
|
149
|
+
|
|
150
|
+
EAPI=8
|
|
151
|
+
|
|
152
|
+
declare -g -r -A ZBS_DEPENDENCIES=(
|
|
153
|
+
[pixman-0.3.0-LClMnz2VAAAs7QSCGwLimV5VUYx0JFnX5xWU6HwtMuDX.tar.gz]='https://codeberg.org/ifreund/zig-pixman/archive/v0.3.0.tar.gz'
|
|
154
|
+
[wayland-0.7.0-lQa1kuP8AQD5dW7_o-VKLVD_QbqXe7Zob78r2su7Pyex.tar.gz]='https://codeberg.org/ifreund/zig-wayland/archive/v0.7.0.tar.gz'
|
|
155
|
+
[wlroots-0.20.3-jmOlcsh0BACce9rpfvzUI4V3AalGg9GE0QQkvRFoHo1c.tar.gz]='https://codeberg.org/ifreund/zig-wlroots/archive/v0.20.3.tar.gz'
|
|
156
|
+
[xkbcommon-0.5.0-VDqIe8y3AgDU-cGL02xZplwABH3WbpTimrrgbgTgD_3g.tar.gz]='https://codeberg.org/ifreund/zig-xkbcommon/archive/v0.5.0.tar.gz'
|
|
157
|
+
|
|
158
|
+
# Not used in any analyzed pass:
|
|
159
|
+
# [pixman-0.4.0-LClMn_eWAAAa2zACATDpPwjuI5fWlO5cBp_F_M33hnNZ.tar.gz]='https://codeberg.org/ifreund/zig-pixman/archive/v0.4.0.tar.gz'
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
# C/C++ sources detected; verify if LLVM backend is required
|
|
163
|
+
ZIG_NEEDS_LLVM=1
|
|
164
|
+
ZIG_SLOT="0.17"
|
|
165
|
+
inherit zig
|
|
166
|
+
|
|
167
|
+
DESCRIPTION="TODO"
|
|
168
|
+
HOMEPAGE="TODO"
|
|
169
|
+
|
|
170
|
+
SRC_URI="
|
|
171
|
+
# TODO: add project source URL
|
|
172
|
+
${ZBS_DEPENDENCIES_SRC_URI}
|
|
173
|
+
"
|
|
174
|
+
|
|
175
|
+
LICENSE="TODO"
|
|
176
|
+
SLOT="0"
|
|
177
|
+
KEYWORDS="~amd64"
|
|
178
|
+
|
|
179
|
+
# Detected system libraries: libevdev, libinput, pixman-1, wayland-server, wlroots-0.20, xkbcommon
|
|
180
|
+
|
|
181
|
+
src_configure() {
|
|
182
|
+
local my_zbs_args=(
|
|
183
|
+
# -Dstrip=[bool]
|
|
184
|
+
# -Dpie=[bool]
|
|
185
|
+
# -Dllvm=[bool]
|
|
186
|
+
# -Dman-pages=[bool]
|
|
187
|
+
# -Dxwayland=[bool]
|
|
188
|
+
# -Dversion-string=[string]
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
zig_src_configure
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
> [!NOTE]
|
|
196
|
+
> `build.zig.zon` does not have standard fields for license, homepage, or short
|
|
197
|
+
> description yet (see [ziglang/zig#14342](https://github.com/ziglang/zig/issues/14342)),
|
|
198
|
+
> so those are left as `TODO` placeholders by default. The unofficial `summary`
|
|
199
|
+
> field ([ziglang/zig#23816](https://github.com/ziglang/zig/issues/23816)) is
|
|
200
|
+
> picked up automatically when present, and you can also supply these fields in
|
|
201
|
+
> a `--config` file (see [docs/project-config.md](docs/project-config.md)).
|
|
202
|
+
|
|
203
|
+
## Further reading
|
|
204
|
+
|
|
205
|
+
- [How `zig-recipe` Works](docs/how-it-works.md)
|
|
206
|
+
- [Multi-Pass Analysis](docs/multi-pass.md)
|
|
207
|
+
- [Project Configuration](docs/project-config.md)
|
|
208
|
+
- [User Configuration](docs/user-config.md)
|
|
209
|
+
- [Gentoo Ebuilds](docs/gentoo.md)
|
|
210
|
+
- [Custom Jinja2 Templates](docs/templates.md)
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
`zig-recipe` is licensed under the [Apache License 2.0](LICENSE).
|
|
215
|
+
Generated recipe files are not covered by this license — you may license them
|
|
216
|
+
however you want.
|