0.1.0-0-pre.8

This commit is contained in:
2026-09-16 09:39:53 +02:00
parent 431665992c
commit 00808ea5a6
21 changed files with 410 additions and 30 deletions

View File

@@ -520,11 +520,18 @@ def audit_file(root: pathlib.Path, path: pathlib.Path) -> list[Violation]:
if attribute not in lines[:24]:
violations.append(Violation("RUST-BASE-103", relative, 1, f"missing `{attribute}`"))
if ffi_export_exception:
export_attribute = '#[unsafe(export_name = "SDL_main")]'
if text.count(export_attribute) != 1:
violations.append(Violation("RUST-FFI-101", relative, 1, "Android entrypoint must contain exactly one SDL_main export attribute"))
required_export_attributes = (
'#[unsafe(export_name = "Java_com_sasedev_games_common_NativeBridge_nativeContractVersion")]',
'#[unsafe(export_name = "SDL_main")]',
)
for export_attribute in required_export_attributes:
if text.count(export_attribute) != 1:
violations.append(Violation("RUST-FFI-101", relative, 1, f"Android entrypoint must contain exactly one required export attribute: {export_attribute}"))
unsafe_export_count = text.count("#[unsafe(export_name = ")
if unsafe_export_count != len(required_export_attributes):
violations.append(Violation("RUST-FFI-103", relative, 1, "Android entrypoint contains an unexpected unsafe export attribute"))
if "unsafe {" in text or re.search(r"\bunsafe\s+fn\b", text) is not None or re.search(r"\bunsafe\s+extern\b", text) is not None:
violations.append(Violation("RUST-FFI-102", relative, 1, "Android entrypoint exception permits an unsafe export attribute only; unsafe blocks/functions remain forbidden"))
violations.append(Violation("RUST-FFI-102", relative, 1, "Android entrypoint exception permits named unsafe export attributes only; unsafe blocks/functions remain forbidden"))
exports: list[tuple[int, str]] = []
for idx, line in enumerate(lines, 1):
stripped = line.strip()