Files
Velix-MPV-Core/scripts/package-velix-core-sdk.sh
T

107 lines
4.2 KiB
Bash
Executable File

#!/bin/sh
set -eu
PROJECT_ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
PROFILE=default
OUTPUT_DIR=${VELIX_CORE_SDK_OUT:-$PROJECT_ROOT/dist/velix-core}
while test "$#" -gt 0; do
case "$1" in
--profile)
test "$#" -ge 2 || { echo "missing --profile value" >&2; exit 2; }
PROFILE=$2
shift 2
;;
--out)
test "$#" -ge 2 || { echo "missing --out value" >&2; exit 2; }
OUTPUT_DIR=$2
shift 2
;;
*)
echo "usage: $0 [--profile default|software|ffmpeg-harmony] [--out DIR]" >&2
exit 2
;;
esac
done
case "$PROFILE" in
default)
PROFILE_NAME=default-software
MPV_LIBRARY="$PROJECT_ROOT/build/ohos-arm64/prefix/lib/libmpv.so.2.5.0"
BUILD_SCRIPT="$PROJECT_ROOT/scripts/build-mpv-ohos.sh"
;;
software)
PROFILE_NAME=software
MPV_LIBRARY="$PROJECT_ROOT/build/ohos-arm64/build/mpv-software/libmpv.so.2.5.0"
BUILD_SCRIPT="$PROJECT_ROOT/scripts/build-mpv-ohos-software.sh"
;;
ffmpeg-harmony)
PROFILE_NAME=ffmpeg-harmony
MPV_LIBRARY="$PROJECT_ROOT/build/ohos-arm64/build/mpv-ffmpeg-harmony/libmpv.so.2.5.0"
BUILD_SCRIPT="$PROJECT_ROOT/scripts/build-mpv-ohos-ffmpeg-harmony.sh"
;;
*)
echo "unsupported profile: $PROFILE" >&2
exit 2
;;
esac
if test ! -f "$MPV_LIBRARY"; then
"$BUILD_SCRIPT"
fi
test -f "$MPV_LIBRARY" || { echo "missing libmpv: $MPV_LIBRARY" >&2; exit 1; }
. "$PROJECT_ROOT/scripts/setup-ohos-env.sh"
SDK_BUILD="$OHOS_BUILD_ROOT/build/velix-core-sdk-${PROFILE}"
cmake -S "$PROJECT_ROOT/sdk/native" -B "$SDK_BUILD" -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_AR="$AR" -DCMAKE_RANLIB="$RANLIB" -DCMAKE_STRIP="$STRIP" \
-DCMAKE_SYSTEM_NAME=OHOS -DCMAKE_SYSTEM_PROCESSOR=aarch64 \
-DCMAKE_C_COMPILER_TARGET="$TARGET" -DCMAKE_CXX_COMPILER_TARGET="$TARGET" \
-DCMAKE_SYSROOT="$OHOS_SYSROOT" -DCMAKE_C_FLAGS="$OHOS_COMMON_FLAGS" \
-DCMAKE_CXX_FLAGS="$OHOS_COMMON_FLAGS" \
-DMPV_LIBRARY="$MPV_LIBRARY" -DVELIX_CORE_PROFILE_NAME="$PROFILE_NAME"
cmake --build "$SDK_BUILD" -j2
rm -rf "$OUTPUT_DIR"
mkdir -p "$OUTPUT_DIR/include/velix" "$OUTPUT_DIR/include/mpv" "$OUTPUT_DIR/lib/arm64-v8a" "$OUTPUT_DIR/metadata" "$OUTPUT_DIR/licenses"
cp "$PROJECT_ROOT/include/velix/core.h" "$OUTPUT_DIR/include/velix/core.h"
cp "$PROJECT_ROOT/include/mpv/harmony_playback.h" "$OUTPUT_DIR/include/mpv/harmony_playback.h"
cp "$SDK_BUILD/libvelix_core_binding.so" "$OUTPUT_DIR/lib/arm64-v8a/libvelix_core_binding.so"
cp "$MPV_LIBRARY" "$OUTPUT_DIR/lib/arm64-v8a/libmpv.so.2"
RUNTIME_LIB=$(find "$PROJECT_ROOT/playback_lab/entry/build" -type f -name 'libc++_shared.so' -print -quit 2>/dev/null || true)
if test -n "$RUNTIME_LIB"; then
cp "$RUNTIME_LIB" "$OUTPUT_DIR/lib/arm64-v8a/libc++_shared.so"
fi
cp "$PROJECT_ROOT/LICENSE.LGPL" "$OUTPUT_DIR/licenses/LICENSE.LGPL"
cp "$PROJECT_ROOT/LICENSE.GPL" "$OUTPUT_DIR/licenses/LICENSE.GPL"
cp "$PROJECT_ROOT/Copyright" "$OUTPUT_DIR/licenses/Copyright"
cp "$PROJECT_ROOT/THIRD_PARTY_NOTICES.md" "$OUTPUT_DIR/licenses/THIRD_PARTY_NOTICES.md"
binding_size=$(stat -f %z "$OUTPUT_DIR/lib/arm64-v8a/libvelix_core_binding.so")
mpv_size=$(stat -f %z "$OUTPUT_DIR/lib/arm64-v8a/libmpv.so.2")
binding_sha=$(shasum -a 256 "$OUTPUT_DIR/lib/arm64-v8a/libvelix_core_binding.so" | awk '{print $1}')
mpv_sha=$(shasum -a 256 "$OUTPUT_DIR/lib/arm64-v8a/libmpv.so.2" | awk '{print $1}')
cat > "$OUTPUT_DIR/metadata/build-info.json" <<EOF
{
"sdkVersion": "7.0.0",
"apiVersion": "0x000100",
"profile": "$PROFILE_NAME",
"target": "OpenHarmony API 24",
"architecture": "arm64-v8a",
"mpvVersion": "0.41.0-UNKNOWN",
"mpvCommit": "e594f66c35d5eb51ecb44895ceacd1bffa469db2",
"ffmpegHarmonyCommit": "f3a036c695bcde37407b48a84f3d75e827a792a7",
"features": ["software-decode", "opengl", "ohos-audio", "http", "subtitle"],
"libraries": [
{"name": "libvelix_core_binding.so", "size": $binding_size, "sha256": "$binding_sha"},
{"name": "libmpv.so.2", "size": $mpv_size, "sha256": "$mpv_sha"}
]
}
EOF
printf 'SDK=%s\nPROFILE=%s\nBINDING=%s bytes\nMPV=%s bytes\n' "$OUTPUT_DIR" "$PROFILE_NAME" "$binding_size" "$mpv_size"