88 lines
3.3 KiB
Python
88 lines
3.3 KiB
Python
from .common import Source
|
|
from ..address import Address, AddressDomain, Family
|
|
from ..environment import Environment
|
|
from ..sink.msixart_sink import MsixArtSink, MsixArtSinkHint
|
|
from ..utils import MsixCategory, MsixAppLogoKind, MsixAppPlatedKind
|
|
from ...lowlevel import artio
|
|
from ...logger import HIGHLEVEL_LOGGER as LOGGER
|
|
|
|
|
|
class MsixArtSource(Source):
|
|
__kind: MsixCategory
|
|
__name: str
|
|
|
|
def __init__(self, kind: MsixCategory, name: str) -> None:
|
|
self.__kind = kind
|
|
self.__name = name
|
|
|
|
@property
|
|
def address(self) -> Address:
|
|
return Address(AddressDomain.WinMsixOutput, str(self.__kind), self.__name)
|
|
|
|
def link_to(self, env: Environment, msix_sink: MsixArtSink) -> None:
|
|
if not env.prologue.allow_family(Family.Msix):
|
|
return
|
|
|
|
sink_hint = msix_sink.push_hint()
|
|
LOGGER.info(
|
|
'Duplicating Windows MSIX artifact from kind "%s" name "%s" to kind "%s" name "%s".',
|
|
self.__kind,
|
|
self.__name,
|
|
sink_hint.kind,
|
|
sink_hint.name,
|
|
)
|
|
|
|
# different category need entirely different link strategies
|
|
match self.__kind:
|
|
case MsixCategory.Application:
|
|
self.__link_to_app(env, sink_hint)
|
|
case MsixCategory.Extension:
|
|
self.__link_to_ext(env, sink_hint)
|
|
case _:
|
|
raise ValueError(f"Unknown MSIX category: {self.__kind}")
|
|
|
|
def __link_to_app(self, env: Environment, sink_hint: MsixArtSinkHint) -> None:
|
|
# link by sub-kind
|
|
for kind in MsixAppLogoKind:
|
|
# link no suffix variant
|
|
artio.link_artifact(
|
|
env.msix_app_output_artifact(kind, None, None, None, self.__name),
|
|
env.msix_app_output_artifact(kind, None, None, None, sink_hint.name),
|
|
)
|
|
|
|
# link scale variants
|
|
for scale in env.prologue.msix_scales:
|
|
artio.link_artifact(
|
|
env.msix_app_output_artifact(kind, scale, None, None, self.__name),
|
|
env.msix_app_output_artifact(
|
|
kind, scale, None, None, sink_hint.name
|
|
),
|
|
)
|
|
|
|
# link special variants for Square44x44
|
|
if kind == MsixAppLogoKind.Square44x44:
|
|
for targetsize in env.prologue.msix_app44_targetsizes:
|
|
for plated in MsixAppPlatedKind:
|
|
artio.link_artifact(
|
|
env.msix_app_output_artifact(
|
|
kind, None, targetsize, plated, self.__name
|
|
),
|
|
env.msix_app_output_artifact(
|
|
kind, None, targetsize, plated, sink_hint.name
|
|
),
|
|
)
|
|
|
|
def __link_to_ext(self, env: Environment, sink_hint: MsixArtSinkHint) -> None:
|
|
# link default
|
|
artio.link_artifact(
|
|
env.msix_ext_output_artifact(None, self.__name),
|
|
env.msix_ext_output_artifact(None, sink_hint.name),
|
|
)
|
|
|
|
# link targetsize variants
|
|
for targetsize in env.prologue.msix_ext_targetsizes:
|
|
artio.link_artifact(
|
|
env.msix_ext_output_artifact(targetsize, self.__name),
|
|
env.msix_ext_output_artifact(targetsize, sink_hint.name),
|
|
)
|