|
19 | 19 |
|
20 | 20 | import re |
21 | 21 | from dataclasses import dataclass |
22 | | -from typing import TYPE_CHECKING, Any, overload |
| 22 | +from typing import TYPE_CHECKING, Any, Self, overload |
23 | 23 |
|
24 | | -from ._toolchain import make_install_chain |
| 24 | +from ._toolchain import advance_install, make_install_chain |
25 | 25 | from .cache import CacheForever |
26 | 26 |
|
27 | 27 | if TYPE_CHECKING: |
28 | 28 | from ._step import Step |
| 29 | + from .cache import CachePolicy |
29 | 30 |
|
30 | 31 | APT_PACKAGES = ("curl", "ca-certificates", "xz-utils") |
31 | 32 |
|
@@ -66,6 +67,27 @@ class ZigProject: |
66 | 67 | path: str |
67 | 68 | installed: Step |
68 | 69 |
|
| 70 | + def setup( |
| 71 | + self, |
| 72 | + cmd: str, |
| 73 | + *, |
| 74 | + cwd: str | None = None, |
| 75 | + label: str | None = None, |
| 76 | + cache: CachePolicy | None = None, |
| 77 | + env: dict[str, str] | None = None, |
| 78 | + ) -> Self: |
| 79 | + """Append a post-install command and return an advanced project; chainable. |
| 80 | +
|
| 81 | + Use for prep steps the toolchain's actions must depend on but that the SDK |
| 82 | + does not model natively — code generation, fixtures, extra tooling. The |
| 83 | + returned object's action methods fork from this step. |
| 84 | +
|
| 85 | + Examples: |
| 86 | + >>> import harmont as hm |
| 87 | + >>> proj = hm.zig(path=".").setup("zig build gen") |
| 88 | + """ |
| 89 | + return advance_install(self, cmd, cwd=cwd, label=label, cache=cache, env=env) |
| 90 | + |
69 | 91 | def _emit(self, cmd: str, default_label: str, **kw: Any) -> Step: |
70 | 92 | if kw.get("label") is None: |
71 | 93 | kw["label"] = default_label |
@@ -106,6 +128,28 @@ class ZigToolchain: |
106 | 128 | version: str |
107 | 129 | installed: Step |
108 | 130 |
|
| 131 | + def setup( |
| 132 | + self, |
| 133 | + cmd: str, |
| 134 | + *, |
| 135 | + cwd: str | None = None, |
| 136 | + label: str | None = None, |
| 137 | + cache: CachePolicy | None = None, |
| 138 | + env: dict[str, str] | None = None, |
| 139 | + ) -> Self: |
| 140 | + """Append a post-install command and return an advanced toolchain; chainable. |
| 141 | +
|
| 142 | + Use for prep steps the toolchain's actions must depend on but that the SDK |
| 143 | + does not model natively — code generation, fixtures, extra tooling. Every |
| 144 | + ``ZigProject`` spawned from the returned toolchain forks from this step. |
| 145 | +
|
| 146 | + Examples: |
| 147 | + >>> import harmont as hm |
| 148 | + >>> tc = hm.zig().setup("zig build gen") |
| 149 | + >>> hm.pipeline([tc.project("lib-a").test()]) |
| 150 | + """ |
| 151 | + return advance_install(self, cmd, cwd=cwd, label=label, cache=cache, env=env) |
| 152 | + |
109 | 153 | def project(self, path: str = ".") -> ZigProject: |
110 | 154 | """Create a ``ZigProject`` rooted at ``path`` from this toolchain. |
111 | 155 |
|
|
0 commit comments