# hash_codegen.cmake — generate overlay_codegen_hash.h with a content hash of the # recompiler's codegen sources, so the overlay cache path (gcc//cg_/) # changes automatically whenever the emitter changes. This closes the gap where a # pure-emitter change within the same manual PSX_OVERLAY_CODEGEN_VER produced a # different DLL the cache happily reused (a stale-but-cgN load — the v0.3.0 black # screen). Both the runtime loader (via overlay_api.h) and compile_overlays.py read # the generated PSX_OVERLAY_CODEGEN_HASH, so the two sides never drift. # # Invoked as: cmake -DOUT=
"-DSRCS=;;..." -P hash_codegen.cmake # Re-runs whenever a listed source changes (it's an add_custom_command DEPENDS). set(_cat "") foreach(f IN LISTS SRCS) if(EXISTS "${f}") file(READ "${f}" _c) string(APPEND _cat "${_c}") endif() endforeach() string(SHA256 _h "${_cat}") string(SUBSTRING "${_h}" 0 8 _h8) set(_content "/* AUTO-GENERATED by hash_codegen.cmake — do not edit, do not commit. * Content hash of the recompiler codegen sources; folded into the overlay cache * path so an emitter change never reuses a stale DLL. */ #pragma once #define PSX_OVERLAY_CODEGEN_HASH 0x${_h8}u ") # Only rewrite when the value actually changes, so dependents don't rebuild on # every invocation. if(EXISTS "${OUT}") file(READ "${OUT}" _old) if(_old STREQUAL _content) return() endif() endif() file(WRITE "${OUT}" "${_content}") message(STATUS "overlay codegen hash: 0x${_h8}")