aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-08-27 00:03:28 +0900
committerOphestra <cat@gensokyo.uk>2026-08-27 00:03:28 +0900
commitfa280adae178e5757f3f706a034ec8cbba8be9ae (patch)
tree37c5a4688ea4f7076c55ae3b56ec14c2653b8c62 /internal/rosa
parent120ce960a705dd619e416ecbc70bab25ac90375d (diff)
internal/rosa: resolve output defers
This makes behaviour identical to source. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa')
-rw-r--r--internal/rosa/state.go65
1 files changed, 34 insertions, 31 deletions
diff --git a/internal/rosa/state.go b/internal/rosa/state.go
index 85ad5476..ba17ea23 100644
--- a/internal/rosa/state.go
+++ b/internal/rosa/state.go
@@ -1001,6 +1001,33 @@ func (e HelperError) Error() string {
return "package " + strconv.Quote(string(e)) + " has no exec helper"
}
+// evalArtifact resolves deferred toolchain information.
+func (t Toolchain) evalArtifact(v any, meta *Metadata) pkg.Artifact {
+ switch p := v.(type) {
+ case pkg.Artifact:
+ return p
+
+ case deferredGit:
+ return t.NewViaGit(p.url, "refs/tags/"+p.tag, p.checksum)
+
+ case azalea.Ident:
+ _meta, source := t.Load(H(string(p)))
+ if meta != nil && meta.Version == "" {
+ meta.Version = _meta.Version
+ }
+ return source
+
+ default:
+ if v != nil {
+ panic(azalea.TypeError{
+ Concrete: reflect.TypeOf(v),
+ Asserted: reflect.TypeFor[pkg.Artifact](),
+ })
+ }
+ return nil
+ }
+}
+
// pf implements [azalea.PF].
func (ctx *evalContext) pf(
name azalea.Ident,
@@ -1018,8 +1045,8 @@ func (ctx *evalContext) pf(
anitya int64
kc any
- output pkg.Artifact
- sourceA any
+ output any
+ source any
helper Helper
overlay string
@@ -1052,7 +1079,7 @@ func (ctx *evalContext) pf(
k("checksum"): &kc,
k("output"): &output,
- k("source"): &sourceA,
+ k("source"): &source,
k("exec"): &helper,
k("inputs"): &inputs,
k("runtime"): &runtimes,
@@ -1084,15 +1111,15 @@ func (ctx *evalContext) pf(
})
}
- if output != nil {
+ if o := ctx.t.evalArtifact(output, nil); o != nil {
if len(attr.Patches) != 0 || attr.Chmod {
rn := string(name)
if meta.Version != Unversioned {
rn = string(name) + "-" + meta.Version
}
- output = ctx.t.NewPatchedSource(rn, output, !attr.Chmod, attr.Patches...)
+ o = ctx.t.NewPatchedSource(rn, o, !attr.Chmod, attr.Patches...)
}
- v = cachedArtifact{&meta, output}
+ v = cachedArtifact{&meta, o}
set = true
return
}
@@ -1155,30 +1182,6 @@ func (ctx *evalContext) pf(
attr.KnownChecksum = new(mustDecode(checksum))
}
- var source pkg.Artifact
- switch p := sourceA.(type) {
- case pkg.Artifact:
- source = p
-
- case deferredGit:
- source = ctx.t.NewViaGit(p.url, "refs/tags/"+p.tag, p.checksum)
-
- case azalea.Ident:
- var _meta *Metadata
- _meta, source = ctx.t.Load(H(string(p)))
- if meta.Version == "" {
- meta.Version = _meta.Version
- }
-
- default:
- if sourceA != nil {
- panic(azalea.TypeError{
- Concrete: reflect.TypeOf(sourceA),
- Asserted: reflect.TypeFor[pkg.Artifact](),
- })
- }
- }
-
if helper == nil {
panic(HelperError(name))
}
@@ -1186,7 +1189,7 @@ func (ctx *evalContext) pf(
v = cachedArtifact{&meta, ctx.t.New(
meta.Name,
meta.Version,
- source,
+ ctx.t.evalArtifact(source, &meta),
&attr,
helper,
inputsH...,