Files
tws-zombies-scripts/tools/test_plugin_component.py
josh 1121b44857 Organize scripts and add TWS plugins with HTTP timeouts
Vendor pinned T5 and T6 plugin sources under the new plugins layout. Add native HTTP deadlines, status and timing diagnostics, telemetry integration, and build/test tooling.
2026-10-09 11:02:20 -04:00

22 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Compile actual HTTP component logic using host shims for engine interfaces."""
import os
from pathlib import Path
import re
import subprocess
import tempfile
ROOT = Path(__file__).resolve().parents[1]
with tempfile.TemporaryDirectory(prefix="tws-http-component-") as temp:
for game in ("t5", "t6"):
plugin = ROOT / game / "plugins" / f"tws-{game}-gsc-utils" / "src"
# Only includes are substituted; compile the entire component unchanged.
component = re.sub(r'^#include[^\n]*\n', '', (plugin / "component/http.cpp").read_text(), flags=re.MULTILINE)
source = Path(temp) / f"{game}.cpp"
source.write_text('#include "http_component_stub.hpp"\n' + component + (ROOT / "tools/tests/http_component_cases.cpp").read_text())
executable = Path(temp) / game
subprocess.run([os.environ.get("CXX", "c++"), "-std=c++20", "-Wall", "-Wextra", "-Werror", "-fsanitize=address,undefined",
"-I", str(plugin / "utils"), "-I", str(ROOT / "tools/tests"), str(source), "-lcurl", "-o", str(executable)], check=True)
print(game, flush=True)
subprocess.run([str(executable)], check=True)