Define main-relative input options

This commit is contained in:
2026-11-09 18:42:09 +00:00
parent ae0c94d3c6
commit 0a136063da
6 changed files with 89 additions and 6 deletions

View File

@@ -19,8 +19,19 @@ type Input struct {
PlacementMode PlacementMode
Imports bool
Filesystem *FilesystemContext
MainRelative *MainRelativeContext
}
// MainRelativeContext selects the main input's resolved context for an underlay.
// Fallback is used when the main has no usable context; RequireBase requires one.
type MainRelativeContext struct {
Fallback *FilesystemContext
RequireBase bool
}
// MainRelative returns a fresh default main-relative binding description.
func MainRelative() *MainRelativeContext { return &MainRelativeContext{} }
// Underlay contains inputs that must compose strictly within one tier. Tiers
// appear in lowest-to-highest precedence order; an empty tier is a no-op.
type Underlay struct{ Inputs []Input }
@@ -42,6 +53,7 @@ type LayeredOptions[T any] struct {
Underlays []Underlay
Overlay string
OverlayFilesystem *FilesystemContext
OverlayFallback *FilesystemContext
Overrides []Override
}
@@ -68,6 +80,9 @@ func toEngineInput(input Input) engine.Input {
Filesystem: toEngineFilesystemContext(input.Filesystem), Destination: toEnginePath(input.Destination),
PlacementMode: engine.PlacementMode(input.PlacementMode),
}
if input.MainRelative != nil {
result.MainRelative = &engine.MainRelativeContext{Fallback: toEngineFilesystemContext(input.MainRelative.Fallback), RequireBase: input.MainRelative.RequireBase}
}
return result
}
@@ -77,6 +92,7 @@ func toEngineLayeredOptions[T any](options LayeredOptions[T]) engine.LayeredOpti
SourceVersionMode: engine.SourceVersionModeFromFacade(uint8(options.SourceVersionMode)),
Overlay: options.Overlay,
OverlayFilesystem: toEngineFilesystemContext(options.OverlayFilesystem),
OverlayFallback: toEngineFilesystemContext(options.OverlayFallback),
ImportDefaults: toEngineImportDefaults(options.ImportDefaults),
}
if options.Underlays != nil {