Files
kinect/packaging/build_bundle.sh
T
kinect-bot 39876fa97b
ci / Linux C++ core (cmake + ctest) (push) Canceled after 0s
ci / Python root tests (pytest, no tracker deps) (push) Canceled after 0s
ci / Python tracker (pytest, tracker/.venv) (push) Canceled after 0s
docs(setup): README + linux/windows setup + calibration/troubleshooting + packaging (wave 11; todo 18 done)
2026-11-25 06:10:54 -05:00

115 lines
5.3 KiB
Bash

#!/usr/bin/env bash
#
# build_bundle.sh - assemble a per-OS runnable bundle of the webcam virtual Kinect v1
# from already-built artifacts. It copies, it does not build (run the builds first, per
# docs/setup-linux.md and docs/setup-windows.md), so a bundle always reflects real,
# verified outputs rather than a fresh untested compile.
#
# Usage:
# packaging/build_bundle.sh linux [OUTDIR] # default OUTDIR: dist/kinect-linux
# packaging/build_bundle.sh windows [OUTDIR] # default OUTDIR: dist/kinect-windows
#
# What it MUST NOT do (and does not): bundle the MS Kinect 1.8 runtime, NiTE2, or any DEA
# asset. Those are linked from the docs and supplied by the user. This script only packages
# first-party build outputs plus the docs.
#
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
OS="${1:-}"
case "$OS" in
linux|windows) ;;
*) echo "usage: $0 <linux|windows> [outdir]" >&2; exit 2 ;;
esac
OUTDIR="${2:-$ROOT/dist/kinect-$OS}"
say() { printf '[bundle] %s\n' "$*"; }
die() { printf '[bundle] ERROR: %s\n' "$*" >&2; exit 1; }
need() { [ -e "$1" ] || die "missing artifact: $1 (build it first, see docs/setup-$OS.md)"; }
copy() { mkdir -p "$(dirname "$2")"; cp -a "$1" "$2"; say "+ ${2#$OUTDIR/}"; }
rm -rf "$OUTDIR"
mkdir -p "$OUTDIR"
# --- docs shared by every bundle ---
copy "$ROOT/README.md" "$OUTDIR/README.md"
copy "$ROOT/LICENSE" "$OUTDIR/LICENSE"
copy "$ROOT/docs/setup-$OS.md" "$OUTDIR/docs/setup-$OS.md"
copy "$ROOT/docs/calibration.md" "$OUTDIR/docs/calibration.md"
copy "$ROOT/docs/troubleshooting.md" "$OUTDIR/docs/troubleshooting.md"
# --- the tracker (Python source; the user creates tracker/.venv per the setup guide) ---
# The .venv and model bundles are environment-specific and are NOT bundled; the setup guide
# reproduces them. We ship the source, pyproject, and a models/ placeholder with instructions.
mkdir -p "$OUTDIR/tracker"
for f in __init__.py contract.py control.py fake_pose.py joint_mapping.py pose.py \
publisher.py tracker.py pyproject.toml README.md; do
copy "$ROOT/tracker/$f" "$OUTDIR/tracker/$f"
done
mkdir -p "$OUTDIR/tracker/models"
cat > "$OUTDIR/tracker/models/README.txt" <<'EOF'
Download the MediaPipe pose_landmarker .task bundles here (lite/full/heavy).
See docs/setup-linux.md step 2a for the exact curl commands.
EOF
if [ "$OS" = linux ]; then
# --- OS-agnostic core library + the verified Linux OpenNI2 surface + e2e harness ---
core_lib=""
for cand in "$ROOT/build/linux/core/libnui_core.a" \
"$ROOT/attach/linux/build/core/libnui_core.a"; do
[ -e "$cand" ] && { core_lib="$cand"; break; }
done
[ -n "$core_lib" ] || die "missing libnui_core.a (build the core, see docs/setup-linux.md)"
copy "$core_lib" "$OUTDIR/lib/libnui_core.a"
need "$ROOT/fallback/linux-openni2/build/OpenNI2/Drivers/libSynthKinect.so.0"
copy "$ROOT/fallback/linux-openni2/build/OpenNI2/Drivers/libSynthKinect.so.0" \
"$OUTDIR/openni2/Drivers/libSynthKinect.so.0"
copy "$ROOT/fallback/linux-openni2/build/openni2_depth_consumer" \
"$OUTDIR/bin/openni2_depth_consumer"
[ -e "$ROOT/tools/e2e_linux_validation/build/depth_stats_consumer" ] && \
copy "$ROOT/tools/e2e_linux_validation/build/depth_stats_consumer" \
"$OUTDIR/bin/depth_stats_consumer"
[ -e "$ROOT/attach/linux/build/kinect_attach" ] && \
copy "$ROOT/attach/linux/build/kinect_attach" "$OUTDIR/bin/kinect_attach"
# the e2e harness + its deps, so a bundle can self-validate
copy "$ROOT/tools/e2e_linux_validation/run_e2e.py" \
"$OUTDIR/tools/e2e_linux_validation/run_e2e.py"
copy "$ROOT/tools/e2e_linux_validation/generate_dance_video.py" \
"$OUTDIR/tools/e2e_linux_validation/generate_dance_video.py"
cat > "$OUTDIR/RUN.txt" <<'EOF'
Linux bundle. Deploy openni2/Drivers/libSynthKinect.so.0 into your OpenNI2 install's
<libdir>/OpenNI2/Drivers, start the tracker (docs/setup-linux.md), then run
bin/openni2_depth_consumer. See docs/setup-linux.md for the full reproduction.
EOF
elif [ "$OS" = windows ]; then
# --- the clean-room Kinect10.dll shim (both arches) + the attach scripts ---
need "$ROOT/fallback/windows-nui/build/Kinect10-x86.dll"
need "$ROOT/fallback/windows-nui/build/Kinect10-x64.dll"
copy "$ROOT/fallback/windows-nui/build/Kinect10-x86.dll" "$OUTDIR/shim/x86/Kinect10.dll"
copy "$ROOT/fallback/windows-nui/build/Kinect10-x64.dll" "$OUTDIR/shim/x64/Kinect10.dll"
# the usbip-win attach/verify PowerShell scripts + config
for s in Attach-Kinect.ps1 Detach-Kinect.ps1 Enable-TestSigning.ps1 \
Disable-TestSigning.ps1 Install-UsbIpWin.ps1 Verify-KinectDevice.ps1; do
copy "$ROOT/attach/windows/scripts/$s" "$OUTDIR/attach/scripts/$s"
done
copy "$ROOT/attach/windows/config/kinect-usbip.json" "$OUTDIR/attach/config/kinect-usbip.json"
copy "$ROOT/attach/windows/README.md" "$OUTDIR/attach/README.md"
copy "$ROOT/attach/windows/docs/approach.md" "$OUTDIR/attach/approach.md"
cat > "$OUTDIR/RUN.txt" <<'EOF'
Windows bundle. Pick ONE path (see docs/setup-windows.md):
Device path: run the attach/scripts against a running USB/IP emitter.
Shim path: copy shim/<arch>/Kinect10.dll beside gamekdm.dll (match DEA's bitness).
You must install the MS Kinect 1.8 Runtime+SDK yourself; it is never bundled here.
EOF
fi
say "bundle assembled at: $OUTDIR"
say "done."