#!/usr/bin/env bash # Generate shim/src/stubs.c from analysis/all_exports.txt (the FULL 438-export set). # Each ovrp_ function gets a stub returning a sensible ovrpResult, classified by # name per SHIM-SCOPE.md buckets. Functions prototyped in the header (real sigs) # are SKIPPED here and live in core.c instead. set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # Use the ORIGINAL lib's FULL export set (438) so the shim is a complete drop-in: # any dlsym of any ovrp_ resolves, even the 199 RE4 doesn't reference. SURF="$ROOT/analysis/all_exports.txt" OUT="$ROOT/shim/src/stubs.c" mkdir -p "$ROOT/shim/src" # functions with real prototypes in ovrplugin_shim.h -> handled in core.c HEADER_FNS=" ovrp_GetNodePoseState3 ovrp_GetNodePoseStateRaw ovrp_GetControllerState4 \ ovrp_PreInitialize3 ovrp_Initialize5 ovrp_Shutdown2 ovrp_Update3 ovrp_WaitToBeginFrame \ ovrp_BeginFrame4 ovrp_EndFrame4 ovrp_GetPredictedDisplayTime ovrp_GetSystemHeadsetType2 \ ovrp_GetTrackingOriginType2 ovrp_SetTrackingOriginType2 ovrp_RecenterTrackingOrigin2 \ ovrp_SetupLayer ovrp_GetLayerTextureStageCount ovrp_GetLayerTexture2 \ ovrp_GetInstanceExtensionsVk ovrp_GetDeviceExtensionsVk \ ovrp_GetInitialized ovrp_GetSystemDisplayFrequency2 ovrp_GetTimeInSeconds \ ovrp_GetAppHasVrFocus2 ovrp_GetAppShouldQuit2 ovrp_GetUserPresent2 \ ovrp_GetAppShouldRecenter2 ovrp_GetAppShouldRecreateDistortionWindow2 \ ovrp_GetSystemMultiViewSupported2 ovrp_GetAppHasInputFocus ovrp_SetupDistortionWindow3 \ ovrp_CalculateEyeLayerDesc2 ovrp_CalculateEyeViewportRect ovrp_GetMixedRealityInitialized ovrp_CalculateLayerDesc ovrp_GetNodePresent2 ovrp_GetNodeOrientationValid ovrp_GetNodePositionValid ovrp_GetNodeOrientationTracked2 ovrp_GetNodePositionTracked2 ovrp_SetControllerVibration2 \ ovrp_GetTiledMultiResSupported ovrp_GetTiledMultiResLevel ovrp_SetTiledMultiResLevel \ ovrp_GetTiledMultiResDynamic ovrp_SetTiledMultiResDynamic ovrp_GetGPUFrameTime \ ovrp_DestroyLayer ovrp_GetNodeFrustum2 ovrp_SetSystemCpuLevel2 ovrp_SetSystemGpuLevel2 \ ovrp_IsPerfMetricsSupported ovrp_GetPerfMetricsFloat ovrp_GetPerfMetricsInt \ ovrp_GetAdaptiveGpuPerformanceScale2 \ ovrp_DestroyDistortionWindow2 ovrp_SetupDisplayObjects2 ovrp_SetReorientHMDOnControllerRecenter \ ovrp_SetClientColorDesc ovrp_SetAppEngineInfo2 ovrp_SetAppCPUPriority2 ovrp_InitializeMixedReality \ ovrp_GetViewportStencil ovrp_GetSystemRecommendedMSAALevel2 ovrp_GetLocalTrackingSpaceRecenterCount \ ovrp_GetLayerTextureFoveation ovrp_GetControllerHapticsDesc2 " # NB: the trailing 12 are game-called () stubs now owned by passthru.c — they keep their # original return constant when passthru is off, and tail-call the real lib when it's on. { echo '/* AUTO-GENERATED by gen_stubs.sh from analysis/all_exports.txt. Do not edit by hand. */' echo '#include "ovrplugin_shim.h"' echo '#include "log.h"' echo echo '/* Stub policy:' echo ' * -1004 Unsupported : features we will not implement (MRC/camera/perf/boundary/hands)' echo ' * 0 Success (no-op) : config setters we can safely accept-and-ignore for now' echo ' * -1005 NotYetImplemented : real work still owed (getters/etc. the game needs)' echo ' * Empty () = unspecified args: stub ignores args, returns constant in result reg. */' echo n_unsup=0; n_noop=0; n_todo=0; n_skip=0 while read -r fn; do [ -z "$fn" ] && continue case " $HEADER_FNS " in *" $fn "*) n_skip=$((n_skip+1)); continue;; esac if echo "$fn" | grep -qE 'Media_|CameraDevice|ExternalCamera|HandState|Skeleton|GetMesh|HandTracking|HandNode|PerfMetric|GPUUtil|GPUFrameTime|ASW|TiledMultiRes|Boundary'; then ret="ovrpFailure_Unsupported"; n_unsup=$((n_unsup+1)) elif echo "$fn" | grep -qE '^ovrp_Set[A-Z]|^ovrp_Reset|^ovrp_Recenter|^ovrp_SendEvent|^ovrp_Destroy|^ovrp_Override'; then ret="ovrpSuccess"; n_noop=$((n_noop+1)) else ret="ovrpFailure_NotYetImplemented"; n_todo=$((n_todo+1)) fi printf 'OVRP_EXPORT ovrpResult %s() { static int o; if(!o){o=1;XRRLOG("stub %s -> %s");} return %s; }\n' "$fn" "$fn" "$ret" "$ret" done < "$SURF" echo echo "/* generated: unsup=$n_unsup noop=$n_noop todo=$n_todo skipped(core)=$n_skip */" } > "$OUT" echo "wrote $OUT" grep -c '^OVRP_EXPORT' "$OUT" | xargs echo "stub functions:" tail -1 "$OUT"