#!/usr/bin/env bash # Builds libostream_repro.so for armeabi-v7a via the NDK's CMake toolchain # file - standalone, deliberately outside the Gradle build, same pattern as # ../trace_agent/build.sh. Output: build/libostream_repro.so, ready to push # to a device for GuestEngine::LoadSecondaryImage to load (see # mpcore/src/main/cpp/emu/ostream_repro_test.cpp). set -euo pipefail cd "$(dirname "$0")" NDK="${ANDROID_NDK_HOME:-/home/megboyzz/Android/Sdk/ndk/27.0.12077973}" TOOLCHAIN="$NDK/build/cmake/android.toolchain.cmake" if [ ! -f "$TOOLCHAIN" ]; then echo "NDK toolchain file not found at $TOOLCHAIN - set ANDROID_NDK_HOME" >&2 exit 1 fi # ANDROID_STL=c++_static explicitly - see ostream_repro.cpp's own top # comment for the full reasoning (tried c++_shared FIRST, actually built # and inspected both outcomes with llvm-readelf before deciding, not # guessed): the modern NDK r27 toolchain's libc++ headers extern-template- # declare basic_stringbuf/basic_ostream/basic_ios/ # basic_ostringstream (their vtables AND ctors/dtors become UNDEFINED # imports resolved against libc++_shared.so, confirmed via # `llvm-readelf --dyn-syms` on a real c++_shared build of this exact file), # which GuestEngine has zero shims for - that combination would make this # test fail for an uninteresting, unrelated reason (unimplemented vtable # stub returning 0) instead of actually exercising real, compiled # std::basic_stringbuf::str()/write() logic. c++_static compiles that # logic directly into THIS .so's own .text - both a working build AND a # closer functional match to what libapp.so's own (much older) toolchain # evidently did for sub_79CD4/sub_27160C (confirmed real, compiled, # fixed-address code inside libapp.so itself, never external imports - # see ARM64_TRANSLATION_LAYER.md's 2026-09-16 entries). cmake -B build -G Ninja \ -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" \ -DANDROID_ABI=armeabi-v7a \ -DANDROID_PLATFORM=android-27 \ -DANDROID_STL=c++_static \ -DCMAKE_BUILD_TYPE=Debug \ . cmake --build build echo "Built: $(pwd)/build/libostream_repro.so"