Skip to content

Commit

Permalink
Update simpleservo2 build script for Mac to do cross-compilation and …
Browse files Browse the repository at this point in the history
…merge. Update GStreamer dependency list.
  • Loading branch information
philip-lamb committed Apr 5, 2024
1 parent de93da1 commit d777cad
Showing 1 changed file with 95 additions and 14 deletions.
109 changes: 95 additions & 14 deletions build_ss2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ OURDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
CONFIG=release

function usage {
echo "Usage: $(basename $0) [-|--help] [--debug] [--install-unity-editor-dependencies]"
echo "Usage: $(basename "$0") [-|--help] [--debug] [--install-unity-editor-dependencies]"
exit 1
}

Expand Down Expand Up @@ -48,47 +48,128 @@ fi

./mach build $MACH_CONFIG --libsimpleservo2

# Cross compile for other arch(s).
ARCH=$(uname -m)
RUST_SYSROOT=$(rustc --print sysroot)
if [ "$ARCH" = "arm64" ]; then
HOST=aarch64-apple-darwin
TARGET=x86_64-apple-darwin
elif [ "$ARCH" = "x86_64" ]; then
HOST=x86_64-apple-darwin
TARGET=aarch64-apple-darwin
fi
# Might need a 'rustup target add ${TARGET}' first.
AR="${RUST_SYSROOT}/lib/rustlib/${HOST}/bin/llvm-ar" ./mach build --target=${TARGET} $MACH_CONFIG --libsimpleservo2

cp -pf target/$CONFIG/simpleservo2.h ../servo-unity/src/ServoUnityPlugin
cp -pf target/$CONFIG/libsimpleservo2.dylib ../servo-unity/src/ServoUnityPlugin/depends/macos/lib
install_name_tool -id "@loader_path/libsimpleservo2.dylib" ../servo-unity/src/ServoUnityPlugin/depends/macos/lib/libsimpleservo2.dylib

# Copy plugins
(cd target/$CONFIG &&
cp -pf libgstapp.dylib \
# Merge archs, set install_name and copy.
LIBNAME="libsimpleservo2.dylib"
MERGELIB="${TMPDIR}${LIBNAME}.$$"
lipo -create -output "${MERGELIB}" "target/${CONFIG}/${LIBNAME}" "target/${TARGET}/${CONFIG}/${LIBNAME}"
install_name_tool -id "@loader_path/${LIBNAME}" "${MERGELIB}"
cp -pf "${MERGELIB}" "../servo-unity/src/ServoUnityPlugin/depends/macos/lib/${LIBNAME}"

# Copy GStreamer and its dependent DLLs.
(cd target/$CONFIG/lib && cp -pf \
libgstplayer-1.0.0.dylib \
libgstvideo-1.0.0.dylib \
libgstbase-1.0.0.dylib \
libgstreamer-1.0.0.dylib \
libgobject-2.0.0.dylib \
libglib-2.0.0.dylib \
libintl.8.dylib \
libgstwebrtc-1.0.0.dylib \
libgstsdp-1.0.0.dylib \
libgstaudio-1.0.0.dylib \
libgstapp-1.0.0.dylib \
libgio-2.0.0.dylib \
libz.1.dylib \
libharfbuzz.0.dylib \
libgstplay-1.0.0.dylib \
libgsttag-1.0.0.dylib \
libgstpbutils-1.0.0.dylib \
liborc-0.4.0.dylib \
libgmodule-2.0.0.dylib \
libffi.7.dylib \
libpcre2-8.0.dylib \
libgstrtp-1.0.0.dylib \
libfreetype.6.dylib \
libbz2.1.dylib \
libpng16.16.dylib \
../../../../servo-unity/src/ServoUnityPlugin/depends/macos/lib)

# Copy GStreamer plugins and dependent DLLs.
(cd target/$CONFIG/lib && cp -pf \
libMoltenVK.dylib \
libavcodec.59.18.100.dylib \
libavcodec.59.dylib \
libavfilter.8.24.100.dylib \
libavfilter.8.dylib \
libavformat.59.16.100.dylib \
libavformat.59.dylib \
libavutil.57.17.100.dylib \
libavutil.57.dylib \
libcrypto.1.1.dylib \
libgraphene-1.0.0.dylib \
libgstallocators-1.0.0.dylib \
libgstapp.dylib \
libgstapplemedia.dylib \
libgstaudiobuffersplit.dylib \
libgstaudioconvert.dylib \
libgstaudiofx.dylib \
libgstaudioparsers.dylib \
libgstaudioresample.dylib \
libgstautodetect.dylib \
libgstcodecparsers-1.0.0.dylib \
libgstcontroller-1.0.0.dylib \
libgstcoreelements.dylib \
libgstdeinterlace.dylib \
libgstdtls.dylib \
libgstfft-1.0.0.dylib \
libgstgio.dylib \
libgstid3tag.dylib \
libgstgl-1.0.0.dylib \
libgstid3demux.dylib \
libgstid3tag.dylib \
libgstinterleave.dylib \
libgstisomp4.dylib \
libgstlibav.dylib \
libgstmatroska.dylib \
libgstnet-1.0.0.dylib \
libgstnice.dylib \
libgstogg.dylib \
libgstopengl.dylib \
libgstopus.dylib \
libgstosxaudio.dylib \
libgstosxvideo.dylib \
libgstplayback.dylib \
libgstproxy.dylib \
libgstriff-1.0.0.dylib \
libgstrtp.dylib \
libgstrtpmanager.dylib \
libgstsctp-1.0.0.dylib \
libgsttheora.dylib \
libgsttypefindfunctions.dylib \
libgstvideoconvert.dylib \
libgstvideoconvertscale.dylib \
libgstvideofilter.dylib \
libgstvideoparsersbad.dylib \
libgstvideoscale.dylib \
libgstvorbis.dylib \
libgstvolume.dylib \
libgstvorbis.dylib \
libgstvpx.dylib \
libgstvulkan-1.0.0.dylib \
libgstwebrtc.dylib \
libgstosxaudio.dylib \
libgstosxvideo.dylib \
libgstnice.dylib \
../../../servo-unity/src/ServoUnityPlugin/depends/macos/lib)
libgstwebrtcnice-1.0.0.dylib \
libgthread-2.0.0.dylib \
libjpeg.8.dylib \
libnice.10.dylib \
libogg.0.dylib \
libopus.0.dylib \
libssl.1.1.dylib \
libswresample.4.3.100.dylib \
libswresample.4.dylib \
libtheoradec.1.dylib \
libtheoraenc.1.dylib \
libvorbis.0.dylib \
libvorbisenc.2.dylib \
libvpx.7.dylib \
../../../../servo-unity/src/ServoUnityPlugin/depends/macos/lib)

0 comments on commit d777cad

Please sign in to comment.