fix: fix refactor issues
This commit is contained in:
@@ -10,18 +10,20 @@ from . import std_icons, nostd_icons
|
|||||||
def main() -> None:
|
def main() -> None:
|
||||||
opts = parse()
|
opts = parse()
|
||||||
|
|
||||||
|
def tempdir_initializer(p: Path) -> None:
|
||||||
|
# create our special temporary subdirectory
|
||||||
|
comp = p / "component"
|
||||||
|
comp.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
repository_root = Path(__file__).resolve().parent.parent.parent.parent
|
repository_root = Path(__file__).resolve().parent.parent.parent.parent
|
||||||
iconset_input = repository_root / "src"
|
iconset_input = repository_root / "src"
|
||||||
iconset_output = repository_root / "artifact"
|
iconset_output = repository_root / "artifact"
|
||||||
prologue = AuroraPrologue(iconset_input, iconset_output, opts.svg_render)
|
prologue = AuroraPrologue(
|
||||||
|
iconset_input, iconset_output, opts.svg_render, tempdir_initializer
|
||||||
|
)
|
||||||
env = Environment(prologue)
|
env = Environment(prologue)
|
||||||
ctx = Context(env)
|
ctx = Context(env)
|
||||||
|
|
||||||
# TODO: use explicit temporary directory initializer in prologue to do this.
|
|
||||||
|
|
||||||
# create our special temporary subdirectory
|
|
||||||
env.__temporary_artifact("component").mkdir(parents=True, exist_ok=True)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
register(ctx)
|
register(ctx)
|
||||||
ctx.run(opts.selection)
|
ctx.run(opts.selection)
|
||||||
|
|||||||
@@ -184,7 +184,8 @@ class Context(Generic[P]):
|
|||||||
for item in ios:
|
for item in ios:
|
||||||
if not isinstance(item, (Source, Sink)):
|
if not isinstance(item, (Source, Sink)):
|
||||||
raise TypeError(
|
raise TypeError(
|
||||||
"passes source or sink instance must be the subclass of Source or Sink"
|
f"All items in the ios of job {name!r} must be instances "
|
||||||
|
f"of Source or Sink, but got {type(item)}."
|
||||||
)
|
)
|
||||||
|
|
||||||
self.__jobs[name] = Job(name, cast(tuple[Source | Sink, ...], ios), executor)
|
self.__jobs[name] = Job(name, cast(tuple[Source | Sink, ...], ios), executor)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from dataclasses import dataclass
|
|||||||
from .common import Sink
|
from .common import Sink
|
||||||
from ..address import Address, AddressDomain
|
from ..address import Address, AddressDomain
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
from ..utils import Artifact, FdContext, FD_THUMBNAIL_HWS
|
from ..utils import Artifact, FdContext, FD_THUMBNAIL_HWS, check_vart
|
||||||
from ...lowlevel import artio, artrdr
|
from ...lowlevel import artio, artrdr
|
||||||
from ...logger import HIGHLEVEL_LOGGER as LOGGER
|
from ...logger import HIGHLEVEL_LOGGER as LOGGER
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ class FdArtSink(Sink):
|
|||||||
self.__kind,
|
self.__kind,
|
||||||
self.__name,
|
self.__name,
|
||||||
)
|
)
|
||||||
|
check_vart(art)
|
||||||
for hw, thumbnail in zip(
|
for hw, thumbnail in zip(
|
||||||
FD_THUMBNAIL_HWS, artrdr.render_thumbnail(art, FD_THUMBNAIL_HWS)
|
FD_THUMBNAIL_HWS, artrdr.render_thumbnail(art, FD_THUMBNAIL_HWS)
|
||||||
):
|
):
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from dataclasses import dataclass
|
|||||||
from .common import Sink
|
from .common import Sink
|
||||||
from ..address import Address, AddressDomain
|
from ..address import Address, AddressDomain
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
from ..utils import Artifact, MacCategory
|
from ..utils import Artifact, MacCategory, check_vart
|
||||||
from ...lowlevel import artrdr
|
from ...lowlevel import artrdr
|
||||||
from ...logger import HIGHLEVEL_LOGGER as LOGGER
|
from ...logger import HIGHLEVEL_LOGGER as LOGGER
|
||||||
|
|
||||||
@@ -31,7 +31,8 @@ class MacArtSink(Sink):
|
|||||||
self.__kind,
|
self.__kind,
|
||||||
self.__name,
|
self.__name,
|
||||||
)
|
)
|
||||||
artrdr.render_ico(art, env.mac_output_artifact(self.__kind, self.__name))
|
check_vart(art)
|
||||||
|
artrdr.render_icns(art, env.mac_output_artifact(self.__kind, self.__name))
|
||||||
|
|
||||||
def push_hint(self) -> MacArtSinkHint:
|
def push_hint(self) -> MacArtSinkHint:
|
||||||
return MacArtSinkHint(self.__kind, self.__name)
|
return MacArtSinkHint(self.__kind, self.__name)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ from dataclasses import dataclass
|
|||||||
from .common import Sink
|
from .common import Sink
|
||||||
from ..address import Address, AddressDomain
|
from ..address import Address, AddressDomain
|
||||||
from ..environment import Environment
|
from ..environment import Environment
|
||||||
from ..utils import Artifact, WinCategory
|
from ..utils import Artifact, WinCategory, check_vart
|
||||||
from ...lowlevel import artrdr
|
from ...lowlevel import artrdr
|
||||||
from ...logger import HIGHLEVEL_LOGGER as LOGGER
|
from ...logger import HIGHLEVEL_LOGGER as LOGGER
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ class WinArtSink(Sink):
|
|||||||
self.__kind,
|
self.__kind,
|
||||||
self.__name,
|
self.__name,
|
||||||
)
|
)
|
||||||
|
check_vart(art)
|
||||||
artrdr.render_ico(art, env.win_output_artifact(self.__kind, self.__name))
|
artrdr.render_ico(art, env.win_output_artifact(self.__kind, self.__name))
|
||||||
|
|
||||||
def push_hint(self) -> WinArtSinkHint:
|
def push_hint(self) -> WinArtSinkHint:
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class FdArtSource(Source):
|
|||||||
def address(self) -> Address:
|
def address(self) -> Address:
|
||||||
return Address(AddressDomain.FdOutput, str(self.__kind), self.__name)
|
return Address(AddressDomain.FdOutput, str(self.__kind), self.__name)
|
||||||
|
|
||||||
def pull_to_fd(self, env: Environment, fd_sink: FdArtSink) -> None:
|
def link_to(self, env: Environment, fd_sink: FdArtSink) -> None:
|
||||||
sink_hint = fd_sink.push_hint()
|
sink_hint = fd_sink.push_hint()
|
||||||
LOGGER.info(
|
LOGGER.info(
|
||||||
'Duplicating FreeDesktop artifact from kind "%s" name "%s" to kind "%s" name "%s".',
|
'Duplicating FreeDesktop artifact from kind "%s" name "%s" to kind "%s" name "%s".',
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ class MacArtSource(Source):
|
|||||||
def address(self) -> Address:
|
def address(self) -> Address:
|
||||||
return Address(AddressDomain.MacOutput, str(self.__kind), self.__name)
|
return Address(AddressDomain.MacOutput, str(self.__kind), self.__name)
|
||||||
|
|
||||||
def pull_to_fd(self, env: Environment, mac_sink: MacArtSink) -> None:
|
def link_to(self, env: Environment, mac_sink: MacArtSink) -> None:
|
||||||
sink_hint = mac_sink.push_hint()
|
sink_hint = mac_sink.push_hint()
|
||||||
LOGGER.info(
|
LOGGER.info(
|
||||||
'Duplicating Macdows-only artifact from kind "%s" name "%s" to kind "%s" name "%s".',
|
'Duplicating macOS-only artifact from kind "%s" name "%s" to kind "%s" name "%s".',
|
||||||
sink_hint.kind,
|
sink_hint.kind,
|
||||||
sink_hint.name,
|
sink_hint.name,
|
||||||
self.__kind,
|
self.__kind,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class WinArtSource(Source):
|
|||||||
def address(self) -> Address:
|
def address(self) -> Address:
|
||||||
return Address(AddressDomain.WinOutput, str(self.__kind), self.__name)
|
return Address(AddressDomain.WinOutput, str(self.__kind), self.__name)
|
||||||
|
|
||||||
def pull_to_fd(self, env: Environment, win_sink: WinArtSink) -> None:
|
def link_to(self, env: Environment, win_sink: WinArtSink) -> None:
|
||||||
sink_hint = win_sink.push_hint()
|
sink_hint = win_sink.push_hint()
|
||||||
LOGGER.info(
|
LOGGER.info(
|
||||||
'Duplicating Windows-only artifact from kind "%s" name "%s" to kind "%s" name "%s".',
|
'Duplicating Windows-only artifact from kind "%s" name "%s" to kind "%s" name "%s".',
|
||||||
|
|||||||
@@ -124,8 +124,18 @@ def link_artifact(src: Path, dst: Path) -> None:
|
|||||||
f'No common directory between "{src}" and "{dst}", '
|
f'No common directory between "{src}" and "{dst}", '
|
||||||
f"can not create relative symlink."
|
f"can not create relative symlink."
|
||||||
)
|
)
|
||||||
|
# SAFETY: the symlink target must always be stored with POSIX
|
||||||
|
# separators ("/"). On Windows, "relative_to" yields a
|
||||||
|
# backslash-separated path, and "symlink_to" stores the target string
|
||||||
|
# verbatim into the NTFS reparse point, so a backslash form would
|
||||||
|
# also leak verbatim into tar archives. Whether an unpacker accepts
|
||||||
|
# backslash targets is not guaranteed, and we deliberately do not
|
||||||
|
# rely on the packer normalizing them. Converting to POSIX form here
|
||||||
|
# is the single point guaranteeing that archived symlinks stay
|
||||||
|
# portable, regardless of the platform the build ran on or the
|
||||||
|
# packer used.
|
||||||
try:
|
try:
|
||||||
dst.symlink_to(link_target)
|
dst.symlink_to(link_target.as_posix())
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
LOGGER.warning(
|
LOGGER.warning(
|
||||||
"Fail to create symlink for artifact %s: %s. Falling back to copy.",
|
"Fail to create symlink for artifact %s: %s. Falling back to copy.",
|
||||||
|
|||||||
Reference in New Issue
Block a user