Skip to content

Commit

Permalink
Merge pull request #133 from spacedriveapp/ios-static
Browse files Browse the repository at this point in the history
Compile static libraries for iOS
  • Loading branch information
HeavenVolkoff committed Sep 16, 2024
2 parents dffc045 + 6c57974 commit 615d58b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 131 deletions.
21 changes: 0 additions & 21 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -458,26 +458,12 @@ RUN --mount=type=cache,target=/root/.cache `
--mount=type=bind,source=stages/99-onnx.sh,target=/srv/stage.sh `
/srv/build.sh

# Create iOS Frameworks from specific lib
ARG VERSION
ENV VERSION="${VERSION:-0.0.0}"
RUN --mount=type=cache,target=/root/.cache `
--mount=type=bind,source=scripts/create-ios-framework.sh,target=/srv/stage.sh `
/srv/build.sh

FROM layer-50 AS layer-99-ffmpeg

RUN --mount=type=cache,target=/root/.cache `
--mount=type=bind,source=stages/99-ffmpeg.sh,target=/srv/stage.sh `
/srv/build.sh

# Create iOS Frameworks from specific lib
ARG VERSION
ENV VERSION="${VERSION:-0.0.0}"
RUN --mount=type=cache,target=/root/.cache `
--mount=type=bind,source=scripts/create-ios-framework.sh,target=/srv/stage.sh `
/srv/build.sh

FROM layer-45 AS layer-99-heif

COPY --from=layer-99-ffmpeg "${OUT}/." "$PREFIX"
Expand All @@ -486,13 +472,6 @@ RUN --mount=type=cache,target=/root/.cache `
--mount=type=bind,source=stages/99-heif.sh,target=/srv/stage.sh `
/srv/build.sh

# Create iOS Frameworks from specific lib
ARG VERSION
ENV VERSION="${VERSION:-0.0.0}"
RUN --mount=type=cache,target=/root/.cache `
--mount=type=bind,source=scripts/create-ios-framework.sh,target=/srv/stage.sh `
/srv/build.sh

FROM layer-00 AS layer-99

COPY --from=layer-99-heif "${OUT}/." "$OUT"
Expand Down
105 changes: 0 additions & 105 deletions scripts/create-ios-framework.sh

This file was deleted.

17 changes: 14 additions & 3 deletions stages/99-ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ case "$TARGET" in
elif [ "$OS_IPHONE" -eq 2 ]; then
env_specific_arg+=(--sysroot="${IOS_SIMULATOR_SDKROOT:?Missing iOS simulator SDK}")
else
env_specific_arg+=(--sysroot="${MACOS_SDKROOT:?Missing macOS SDK}")
env_specific_arg+=(
--sysroot="${MACOS_SDKROOT:?Missing macOS SDK}"
--disable-static
--enable-shared
)
fi
env_specific_arg+=(
# TODO: Metal suport is disabled because no open source compiler is available for it
Expand All @@ -102,6 +106,7 @@ case "$TARGET" in
;;
*linux*)
env_specific_arg+=(
--disable-static
--disable-libdrm
--disable-coreimage
--disable-w32threads
Expand All @@ -114,12 +119,14 @@ case "$TARGET" in
--enable-pthreads
--enable-libshaderc
--enable-libplacebo
--enable-shared
)
;;
*windows*)
# TODO: Add support for mediafoundation on Windows (zig doesn't seem to have the necessary bindings to it yet)
# FIX-ME: LTO isn't working on Windows rn
env_specific_arg+=(
--disable-static
--disable-pthreads
--disable-coreimage
--disable-videotoolbox
Expand All @@ -130,6 +137,7 @@ case "$TARGET" in
--enable-w32threads
--enable-libshaderc
--enable-libplacebo
--enable-shared
)
;;
esac
Expand Down Expand Up @@ -180,7 +188,6 @@ if ! ./configure \
--windres="windres" \
--pkg-config=pkg-config \
--pkg-config-flags="--static" \
--disable-static \
--disable-debug \
--disable-doc \
--disable-htmlpages \
Expand Down Expand Up @@ -233,7 +240,6 @@ if ! ./configure \
--enable-optimizations \
--enable-pic \
--enable-postproc \
--enable-shared \
--enable-swscale \
--enable-version3 \
--enable-zlib \
Expand Down Expand Up @@ -269,3 +275,8 @@ case "$TARGET" in
sh {} +
;;
esac

# Copy static libs for iOS
if [ "$OS_IPHONE" -gt 0 ]; then
cp -r "$PREFIX"/lib/*.a "${OUT}/lib/"
fi
13 changes: 12 additions & 1 deletion stages/99-heif.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ cd heif/build

echo "Build heif..."

env SHARED=On PREFIX="$OUT" cmake \
env SHARED="$(
if [ "$OS_IPHONE" -gt 0 ]; then
echo "Off"
else
echo "On"
fi
)" PREFIX="$OUT" cmake \
-DWITH_DAV1D=On \
-DWITH_LIBDE265=On \
-DWITH_LIBSHARPYUV=On \
Expand Down Expand Up @@ -82,3 +88,8 @@ ninja install
if [ -f "heif.lib" ]; then
cp -at "${OUT}/lib/" heif.lib
fi

# Copy static libs for iOS
if [ "$OS_IPHONE" -gt 0 ]; then
cp -r "$PREFIX"/lib/*.a "${OUT}/lib/"
fi
13 changes: 12 additions & 1 deletion stages/99-onnx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@ args=(
-DCMAKE_TLS_VERIFY=On
-DBUILD_PKGCONFIG_FILES=Off
-Donnxruntime_USE_XNNPACK=On
-Donnxruntime_BUILD_SHARED_LIB=On
-Donnxruntime_BUILD_SHARED_LIB="$(
if [ "$OS_IPHONE" -gt 0 ]; then
echo "Off"
else
echo "On"
fi
)"
-Donnxruntime_CROSS_COMPILING=On
-Donnxruntime_ENABLE_LTO="$([ "${LTO:-1}" -eq 1 ] && echo On || echo Off)"
-DONNX_CUSTOM_PROTOC_EXECUTABLE=/usr/bin/protoc
Expand Down Expand Up @@ -121,3 +127,8 @@ esac
ninja -j"$(nproc)"

ninja install

# Copy static libs for iOS
if [ "$OS_IPHONE" -gt 0 ]; then
cp -r "$PREFIX"/lib/*.a "${OUT}/lib/"
fi

0 comments on commit 615d58b

Please sign in to comment.