mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-22 00:22:57 -05:00
Merge pull request #5729 from Ondra97/codex/fix-package-tracy-runtime
fix(release): include the enabled Tracy runtime
This commit is contained in:
2 files changed
+67
No files matched your search
@@ -20,6 +20,22 @@ def windows_runtime(build):
|
||||
raise RuntimeError(f"CMAKE_CXX_COMPILER is not configured in {build / 'CMakeCache.txt'}")
|
||||
|
||||
|
||||
def tracy_runtime(platform, build):
|
||||
cache = build / "CMakeCache.txt"
|
||||
if not cache.is_file():
|
||||
return []
|
||||
lines = cache.read_text(encoding="utf-8").splitlines()
|
||||
enabled = next((line.partition("=")[2].upper() for line in lines if line.startswith("APS5_ENABLE_TRACY:")), "OFF")
|
||||
if enabled in ("", "0", "OFF", "NO", "FALSE", "N", "IGNORE", "NOTFOUND") or enabled.endswith("-NOTFOUND"):
|
||||
return []
|
||||
pattern = "libTracyClient.dll" if platform == "windows" else "libTracyClient.so.*"
|
||||
directory = build / "core/libs/libs"
|
||||
clients = sorted(directory.glob(pattern))
|
||||
if len(clients) != 1:
|
||||
raise RuntimeError(f"Missing or ambiguous Tracy runtime for APS5_ENABLE_TRACY: {directory / pattern}")
|
||||
return clients
|
||||
|
||||
|
||||
def package(platform, build, output, version):
|
||||
if not re.fullmatch(r"v[0-9A-Za-z][0-9A-Za-z._-]*", version) or version.endswith("."):
|
||||
raise ValueError(f"Invalid release tag for asset filenames: {version}")
|
||||
@@ -33,6 +49,7 @@ def package(platform, build, output, version):
|
||||
if platform == "windows":
|
||||
runtime = windows_runtime(build)
|
||||
files.extend(runtime / name for name in ("libgcc_s_seh-1.dll", "libstdc++-6.dll", "libwinpthread-1.dll"))
|
||||
files.extend(tracy_runtime(platform, build))
|
||||
binary = build / "core/relinker" / executable
|
||||
for file in [*files, binary]:
|
||||
if not file.is_file() or file.stat().st_size == 0:
|
||||
|
||||
@@ -76,6 +76,56 @@ class ReleasePackageTests(unittest.TestCase):
|
||||
self.assertEqual(list(self.output.iterdir()), [previous])
|
||||
self.assertEqual(previous.read_bytes(), b"existing output")
|
||||
|
||||
def test_tracy_packages_include_only_the_target_platform_client(self):
|
||||
directory = self.build / "core/libs/libs"
|
||||
for platform, name in (("linux", "libTracyClient.so.0.14.1"), ("windows", "libTracyClient.dll")):
|
||||
with self.subTest(platform=platform):
|
||||
client = directory / name
|
||||
client.write_bytes(platform.encode() + b" Tracy client")
|
||||
cache = "APS5_ENABLE_TRACY:BOOL=ON\n"
|
||||
expected = {"libs/libc.prx", "libs/" + name}
|
||||
if platform == "windows":
|
||||
runtime = self.root / "toolchain"
|
||||
runtime.mkdir()
|
||||
for runtime_name in ("libgcc_s_seh-1.dll", "libstdc++-6.dll", "libwinpthread-1.dll"):
|
||||
(runtime / runtime_name).write_bytes(runtime_name.encode())
|
||||
expected.add("libs/" + runtime_name)
|
||||
cache += "CMAKE_CXX_COMPILER:FILEPATH=" + (runtime / "g++.exe").as_posix() + "\n"
|
||||
(self.build / "core/relinker/relinker.exe").write_bytes(b"Windows executable")
|
||||
(self.build / "CMakeCache.txt").write_text(cache, encoding="utf-8")
|
||||
package_release.package(platform, self.build, self.output, "v1")
|
||||
with zipfile.ZipFile(self.output / f"prx-{platform}-v1.zip") as archive:
|
||||
self.assertEqual(set(archive.namelist()), expected)
|
||||
self.assertEqual(archive.read("libs/" + name), client.read_bytes())
|
||||
with tarfile.open(self.output / f"prx-{platform}-v1.tar.gz") as archive:
|
||||
self.assertEqual(set(archive.getnames()), expected)
|
||||
self.assertEqual(archive.extractfile("libs/" + name).read(), client.read_bytes())
|
||||
|
||||
def test_disabled_tracy_does_not_publish_stale_clients(self):
|
||||
for name in ("libTracyClient.dll", "libTracyClient.so.0.14.1"):
|
||||
(self.library.parent / name).write_bytes(b"old client")
|
||||
for index, value in enumerate(("OFF", "0", "NO", "FALSE", "N", "IGNORE", "NOTFOUND", "TRACY-NOTFOUND", "")):
|
||||
with self.subTest(value=value):
|
||||
(self.build / "CMakeCache.txt").write_text(f"APS5_ENABLE_TRACY:BOOL={value}\n", encoding="utf-8")
|
||||
output = self.output / str(index)
|
||||
package_release.package("linux", self.build, output, "v1")
|
||||
with zipfile.ZipFile(output / "prx-linux-v1.zip") as archive:
|
||||
self.assertEqual(archive.namelist(), ["libs/libc.prx"])
|
||||
|
||||
def test_missing_or_ambiguous_tracy_client_preserves_existing_assets(self):
|
||||
(self.build / "CMakeCache.txt").write_text("APS5_ENABLE_TRACY:BOOL=ON\n", encoding="utf-8")
|
||||
previous = {"prx-linux-v1.zip": b"old zip", "prx-linux-v1.tar.gz": b"old tar", "relinker-v1": b"old binary"}
|
||||
self.output.mkdir()
|
||||
for name, data in previous.items():
|
||||
(self.output / name).write_bytes(data)
|
||||
for clients in ((), ("libTracyClient.so.0.13.1", "libTracyClient.so.0.14.1")):
|
||||
with self.subTest(clients=clients):
|
||||
for name in clients:
|
||||
(self.library.parent / name).write_bytes(b"client bytes")
|
||||
with self.assertRaisesRegex(RuntimeError, "Tracy"):
|
||||
package_release.package("linux", self.build, self.output, "v1")
|
||||
self.assertEqual({file.name: file.read_bytes() for file in self.output.iterdir()}, previous)
|
||||
|
||||
def test_source_discovery_does_not_depend_on_working_directory(self):
|
||||
with working_directory(self.root):
|
||||
package_release.package("linux", self.build, self.output, "v1.0")
|
||||
|
||||
Reference in new issue
Block a user