Compare commits
2
Commits
ae3f10a640
...
a72a685c84
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a72a685c84 | ||
|
|
c28f08b75d |
@@ -48,7 +48,7 @@ class Archiver:
|
||||
target_filepath.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
if self.__dist_zip is not None:
|
||||
self.__dist_zip.mkdir(str(arcname))
|
||||
self.__dist_zip.mkdir(arcname.as_posix())
|
||||
|
||||
def push_file(self, filepath: Path, arcname: Path) -> None:
|
||||
"""Mirror an existing file into both sinks.
|
||||
@@ -63,7 +63,7 @@ class Archiver:
|
||||
shutil.copy(filepath, target_filepath)
|
||||
|
||||
if self.__dist_zip is not None:
|
||||
self.__dist_zip.write(filepath, arcname)
|
||||
self.__dist_zip.write(filepath, arcname.as_posix())
|
||||
|
||||
def push_text(self, text: str, arcname: Path) -> None:
|
||||
"""Mirror in-memory text into both sinks.
|
||||
@@ -79,7 +79,7 @@ class Archiver:
|
||||
f.write(text)
|
||||
|
||||
if self.__dist_zip is not None:
|
||||
self.__dist_zip.writestr(str(arcname), text)
|
||||
self.__dist_zip.writestr(arcname.as_posix(), text)
|
||||
|
||||
def __enter__(self) -> "Archiver":
|
||||
"""Enter the context and return this archiver as the bound target."""
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
import logging
|
||||
from typing import Iterator
|
||||
from pathlib import Path
|
||||
from dataclasses import dataclass
|
||||
from re import Pattern, compile
|
||||
@@ -66,13 +67,15 @@ class FileCopyInfo:
|
||||
"""The path of destination file relative to the install directory"""
|
||||
|
||||
|
||||
def resolve_include_copy(ctx: ArtifactContext) -> tuple[FileCopyInfo, ...]:
|
||||
def resolve_include_copy(ctx: ArtifactContext) -> Iterator[FileCopyInfo]:
|
||||
extractor = ctx.extractor
|
||||
metadata = ctx.metadata
|
||||
project_root = Path(extractor.get_project_dir())
|
||||
rv: list[FileCopyInfo] = []
|
||||
|
||||
for header in metadata.headers:
|
||||
logging.debug(
|
||||
"Resolving header copy rule: %s -> %s", header.from_path, header.to_path
|
||||
)
|
||||
to_path = Path("include") / Path(header.to_path)
|
||||
if _is_glob_pattern(header.from_path):
|
||||
(common_prefix, glob_residue) = _extract_common_prefix(header.from_path)
|
||||
@@ -82,15 +85,11 @@ def resolve_include_copy(ctx: ArtifactContext) -> tuple[FileCopyInfo, ...]:
|
||||
# YYC MARK:
|
||||
# Built ``subpath`` is prefix with ``new_project_root``
|
||||
relative_subpath = subpath.relative_to(new_project_root)
|
||||
rv.append(FileCopyInfo(subpath, to_path / relative_subpath))
|
||||
yield FileCopyInfo(subpath, to_path / relative_subpath)
|
||||
else:
|
||||
rv.append(
|
||||
FileCopyInfo(
|
||||
yield FileCopyInfo(
|
||||
project_root / header.from_path, to_path / header.from_path
|
||||
)
|
||||
)
|
||||
|
||||
return tuple(rv)
|
||||
|
||||
|
||||
def _generate_dll_artifact_name(name: str) -> str:
|
||||
@@ -110,31 +109,24 @@ def _generate_lib_artifact_name(name: str) -> str:
|
||||
return f"{name}.dll.lib"
|
||||
|
||||
|
||||
def resolve_lib_copy(ctx: ArtifactContext) -> tuple[FileCopyInfo, ...]:
|
||||
def resolve_lib_copy(ctx: ArtifactContext) -> Iterator[FileCopyInfo]:
|
||||
extractor = ctx.extractor
|
||||
target_directory = extractor.get_target_directory() / "release"
|
||||
target_name = extractor.get_target_name()
|
||||
rv: list[FileCopyInfo] = []
|
||||
|
||||
# copy artifact for redist
|
||||
dll_artifact_filename = _generate_dll_artifact_name(target_name)
|
||||
rv.append(
|
||||
FileCopyInfo(
|
||||
yield FileCopyInfo(
|
||||
target_directory / dll_artifact_filename,
|
||||
Path("bin" if sys.platform == "win32" else "lib") / dll_artifact_filename,
|
||||
)
|
||||
)
|
||||
# copy artifact for linking only on windows
|
||||
if sys.platform == "win32":
|
||||
lib_artifact_filename = _generate_lib_artifact_name(target_name)
|
||||
rv.append(
|
||||
FileCopyInfo(
|
||||
yield FileCopyInfo(
|
||||
target_directory / lib_artifact_filename,
|
||||
Path("lib") / lib_artifact_filename,
|
||||
)
|
||||
)
|
||||
|
||||
return tuple(rv)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -156,7 +148,7 @@ def _sanitize_name(name: str) -> str:
|
||||
return new_name
|
||||
|
||||
|
||||
def resolve_cmake_copy(ctx: ArtifactContext) -> tuple[TextCopyInfo, ...]:
|
||||
def resolve_cmake_copy(ctx: ArtifactContext) -> Iterator[TextCopyInfo]:
|
||||
extractor = ctx.extractor
|
||||
metadata = ctx.metadata
|
||||
target_name = extractor.get_target_name()
|
||||
@@ -182,8 +174,7 @@ def resolve_cmake_copy(ctx: ArtifactContext) -> tuple[TextCopyInfo, ...]:
|
||||
)
|
||||
render = CMakeRender(properties)
|
||||
# return infos
|
||||
return (
|
||||
TextCopyInfo(
|
||||
yield TextCopyInfo(
|
||||
render.render_config(),
|
||||
Path(
|
||||
"lib",
|
||||
@@ -191,8 +182,8 @@ def resolve_cmake_copy(ctx: ArtifactContext) -> tuple[TextCopyInfo, ...]:
|
||||
cmake_target_name,
|
||||
f"{cmake_target_name}Config.cmake",
|
||||
),
|
||||
),
|
||||
TextCopyInfo(
|
||||
)
|
||||
yield TextCopyInfo(
|
||||
render.render_config_version(),
|
||||
Path(
|
||||
"lib",
|
||||
@@ -200,11 +191,10 @@ def resolve_cmake_copy(ctx: ArtifactContext) -> tuple[TextCopyInfo, ...]:
|
||||
cmake_target_name,
|
||||
f"{cmake_target_name}ConfigVersion.cmake",
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def resolve_pkgconfig_copy(ctx: ArtifactContext) -> tuple[TextCopyInfo, ...]:
|
||||
def resolve_pkgconfig_copy(ctx: ArtifactContext) -> Iterator[TextCopyInfo]:
|
||||
extractor = ctx.extractor
|
||||
metadata = ctx.metadata
|
||||
target_name = extractor.get_target_name()
|
||||
@@ -227,6 +217,4 @@ def resolve_pkgconfig_copy(ctx: ArtifactContext) -> tuple[TextCopyInfo, ...]:
|
||||
pkgconfig_name, pkgconfig_description, target_name, extractor.get_version()
|
||||
)
|
||||
render = PkgConfigRender(properties)
|
||||
return (
|
||||
TextCopyInfo(render.render(), Path("lib", "pkgconfig", f"{pkgconfig_id}.pc")),
|
||||
)
|
||||
yield TextCopyInfo(render.render(), Path("lib", "pkgconfig", f"{pkgconfig_id}.pc"))
|
||||
|
||||
Reference in New Issue
Block a user