Files
MeowOS-For-R3P2/patch_v2/meow_audiod/build_audiod.sh
T
AskaEth 7a32b0690e fix(m43): r1 评审 P2 — 语义断言入仓 + audiod 表述对齐产物
- test_time32_abi.sh 增加 16 字节 time64 布局断言:4263 后必须写 tv_sec 0x0/0x4
  (含 sra 符号扩展)+ tv_nsec 0x8;支持「内联」与「调用后转换」两种编译形态。
  自证:amsd 出货件 FAIL、修复后 amsd PASS、不加修复重编 sysui FAIL。
- build_audiod.sh / fw_content.conf:41 的 audiod 例外说明改为:「出货件是旧工具链
  静态 musl,4403→ENOSYS→4263+宽度转换本身健康;glibc-2.22 目标同样无 ABI 错位」,
  不再单称 glibc-dynamic。
2026-11-11 18:51:16 +08:00

79 lines
4.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# build_audiod.sh — meow_audiod 交叉编译(mipsel glibc-dynamic)+ 宿主多目标可选。
#
# 目标:R3 Pro II / MeowOS(MIPS32 o32,真实 ABI)。audiod 复用 meow_ipc.h(共享协议头,
# -I../meow_launcherd)。audiod 为 svcd 托管的独立守护;meow_audio 为用户侧 CLI。
#
# 【P2 蓝牙链接定案 2026-09-03】设备为 glibc-2.22(ld-2.22.so / libc-2.22.so,非 musl),且
# libasound 会在运行时 dlopen 单独的 bluealsa pcm 插件(/usr/lib/alsa-lib/libasound_module_pcm_bluealsa.so)
# ——故 audiod 必须以**动态 glibc** 形态链接设备现有 libasound.so.2:
# - 用 zig --target=mipsel-linux-gnueabihf.2.22(硬浮点 o32,glibc-2.22 版本引用,设备 libs 齐);
# libasound 原型在 meow_audiod.c 内联声明(不依赖 asoundlib.h)。
# - 删 -static:musl-static 无 dlopen(实测 "Dynamic loading not supported",无法加载 bluealsa 插件);
# musl-dynamic 需设备不存在的 musl ld.so。libasound 链接库来自 libbt/(设备 libasound.so.2 副本)。
# - meow_audio CLI 无 libasound 依赖,保持 musl-static(zig-mipsel-cc)。
#
# 用法:
# ./build_audiod.sh # 交叉编译 → meow_audiod(mipsel glibc-dynamic,BT 直链 libasound)
# ./build_audiod.sh cli # 交叉编译 meow_audio CLI → meow_audio(mipsel musl-static)
# ./build_audiod.sh host # 宿主编译 *_host 并跑 test_audiod_host 回归(FILE sink)
set -e
cd "$(dirname "$0")"
ROOT="$HOME/Project/R3ProII"
CC="$ROOT/.tools/zig-mipsel-cc"
ZIG="$ROOT/.tools/zig-env/bin/zig"
INC="-I$ROOT/patch_v2/meow_launcherd"
if [ "$1" = "host" ]; then
HOST_CC="${CC_HOST:-cc}"
# BT 目标直链宿主 libasound.so.2(无 asoundlib.h,原型内联于 meow_audiod.c;-l: 精确到版本,
# 不依赖 unversioned dev 链接)。删 -ldl:BT 不再用 dlopen。
"$HOST_CC" $INC -Os -Wall -Wextra meow_audiod.c bt_dev.c -o meow_audiod_host -lpthread -l:libasound.so.2
"$HOST_CC" $INC -Os -Wall -Wextra meow_audio.c -o meow_audio_host -lm
"$HOST_CC" $INC -Os -Wall -Wextra test_audiod_host.c -o test_audiod_host -lm
"$HOST_CC" -Os -Wall -Wextra test_bt_dev.c bt_dev.c -o test_bt_dev -lm
echo "== host builds =="
ls -la meow_audiod_host meow_audio_host test_audiod_host test_bt_dev
file meow_audiod_host meow_audio_host test_audiod_host test_bt_dev
echo "== host regression (test_bt_dev: BT DEV auto-detect) =="
./test_bt_dev || { echo "!! test_bt_dev FAILED"; exit 1; }
echo "== host regression (test_audiod_host) =="
./test_audiod_host || { echo "!! host regression FAILED"; exit 1; }
exit 0
fi
if [ "$1" = "cli" ]; then
# M43: meow_audio 是 musl-static(当前 zig 链),与其它系统组件同源受损 → 链 time32 修
# clock_gettime/usleep(monitor 的 100ms 窗口/轮询)。
"$CC" $INC -Os -Wall -Wextra -static -DMEOW_TIME32_LIBC_OVERRIDES \
meow_audio.c ../sdk/meow_time32.c -o meow_audio -lm
echo "== meow_audio (mipsel static CLI) =="
ls -la meow_audio
md5sum meow_audio
file meow_audio
exit 0
fi
# meow_audiod:mipsel glibc-dynamic,BT 直链 libasound(-Llibbt -lasound)。-lpthread 供播放线程。
# M43 例外:本目标走 glibc-2.22(time_t 32 位、timespec 8 字节)→ 无 musl time64 头/实现错位;
# 当前钉在 fw_content.conf 的出货件则是旧工具链静态 musl,其 4403→ENOSYS→4263+宽度转换本身健康。
# 两种形态都不需要 meow_time32.c(其 __clock_* 接管针对 zig musl 内部符号)。musl-static 的
# meow_audio CLI 已链 time32。
# 链接源 libbt/libasound.so.2.0.0(设备固件 libasound.so.2 副本);缺失时从固件镜像自拷贝(idempotent)。
LIBBT="libbt"
ASOUND_SRC="$ROOT/hiby_os_crack/r3proii/squashfs-root-example/usr/lib/libasound.so.2.0.0"
mkdir -p "$LIBBT"
if [ ! -f "$LIBBT/libasound.so.2.0.0" ]; then cp "$ASOUND_SRC" "$LIBBT/libasound.so.2.0.0"; fi
ln -sf libasound.so.2.0.0 "$LIBBT/libasound.so"
ln -sf libasound.so.2.0.0 "$LIBBT/libasound.so.2"
"$ZIG" cc --target=mipsel-linux-gnueabihf.2.22 $INC -Os -Wall -Wextra meow_audiod.c bt_dev.c -o meow_audiod \
-lpthread -Llibbt -lasound
echo "== meow_audiod (mipsel glibc-dynamic, BT links libasound.so.2) =="
ls -la meow_audiod
md5sum meow_audiod
file meow_audiod
echo "-- dynamic NEEDED --"
readelf -d meow_audiod 2>/dev/null | grep -iE "needed" || true
echo "-- glibc version refs (max must be <= 2.22) --"
readelf --version-info meow_audiod 2>/dev/null | grep -oE "GLIBC_2\.[0-9]+" | sort -uV | tail -3 || true