Skip to content

Commit

Permalink
Improve OS detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
H-M-H committed Jun 8, 2021
1 parent 3319178 commit 23c3904
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
27 changes: 18 additions & 9 deletions deps/build.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,28 @@
#!/usr/bin/env bash

set -ex

export TARGET_OS="$CARGO_CFG_TARGET_OS"

if [ "$OSTYPE" == "linux-gnu" ]; then
export RUNNER_OS="Linux"
export HOST_OS="linux"
fi

if [[ "$OSTYPE" == "darwin"* ]]; then
export RUNNER_OS="macOS"
export HOST_OS="macos"
fi

export NPROCS=$(nproc || echo 4)
if [ "$OS" == "Windows_NT" ]; then
export HOST_OS="windows"
fi

[ -z "$TARGET_OS" ] && export TARGET_OS="$HOST_OS"

export NPROCS="$(nproc || echo 4)"

./download.sh

if [ "$RUNNER_OS" == "Windows" ]; then
if [ "$TARGET_OS" == "windows" ]; then
export CC=cl
export FFMPEG_EXTRA_ARGS="--toolchain=msvc --enable-nvenc --enable-ffnvcodec \
--enable-mediafoundation"
Expand All @@ -22,29 +31,29 @@ if [ "$RUNNER_OS" == "Windows" ]; then
else
export FFMPEG_CFLAGS="-I../dist/include"
export FFMPEG_LIBRARY_PATH="-L../dist/lib"
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "$TARGET_OS" == "linux" ]; then
export FFMPEG_EXTRA_ARGS="--enable-nvenc \
--enable-ffnvcodec \
--enable-vaapi \
--enable-libdrm \
--enable-xlib"
fi
if [ "$RUNNER_OS" == "macOS" ]; then
if [ "$TARGET_OS" == "macos" ]; then
export FFMPEG_EXTRA_ARGS="--enable-videotoolbox"
fi
fi

./x264.sh
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "$TARGET_OS" == "linux" ]; then
./nv-codec-headers.sh
./libva.sh
fi
if [ "$RUNNER_OS" == "Windows" ]; then
if [ "$TARGET_OS" == "windows" ]; then
./nv-codec-headers.sh
fi
./ffmpeg.sh

if [ "$RUNNER_OS" == "Windows" ]; then
if [ "$TARGET_OS" == "windows" ]; then
cd dist/lib
for l in *.a; do
d=${l#lib}
Expand Down
6 changes: 3 additions & 3 deletions deps/download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ set -ex
rm -rf x264 ffmpeg
git clone --depth 1 -b stable https://code.videolan.org/videolan/x264.git x264
git clone --depth 1 -b n4.4 https://git.ffmpeg.org/ffmpeg.git ffmpeg
if [ "$RUNNER_OS" == "Linux" ]; then
if [ "$TARGET_OS" == "linux" ]; then
git clone --depth 1 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
git clone --depth 1 -b 2.11.0 https://github.com/intel/libva
fi
if [ "$RUNNER_OS" == "Windows" ]; then
if [ "$TARGET_OS" == "windows" ]; then
git clone --depth 1 https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
fi
cd ffmpeg

if [ "$RUNNER_OS" == "Windows" ]; then
if [ "$TARGET_OS" == "windows" ]; then
git apply ../command_limit.patch
git apply ../awk.patch
git apply ../ffmpeg-x264-static.patch
Expand Down

0 comments on commit 23c3904

Please sign in to comment.