ffplayout/scripts/build.sh

84 lines
3.1 KiB
Bash
Raw Normal View History

2022-06-21 17:10:38 -04:00
#!/usr/bin/bash
source $(dirname "$0")/man_create.sh
target=$1
2023-07-06 05:42:14 -04:00
if [ ! -f 'ffplayout-frontend/package.json' ]; then
git submodule update --init
fi
if [[ -n $target ]]; then
targets=($target)
else
2023-10-24 04:43:00 -04:00
targets=("x86_64-unknown-linux-musl" "aarch64-unknown-linux-gnu" "x86_64-pc-windows-gnu")
# "x86_64-apple-darwin" "aarch64-apple-darwin"
fi
2022-06-21 17:10:38 -04:00
IFS="= "
while read -r name value; do
if [[ $name == "version" ]]; then
version=${value//\"/}
fi
2023-02-08 11:02:49 -05:00
done < Cargo.toml
2022-06-21 17:10:38 -04:00
2023-01-11 09:29:41 -05:00
echo "Compile ffplayout \"$version\""
2022-06-21 17:10:38 -04:00
echo ""
for target in "${targets[@]}"; do
echo "compile static for $target"
echo ""
if [[ $target == "x86_64-pc-windows-gnu" ]]; then
2022-06-23 16:39:13 -04:00
if [[ -f "ffplayout-v${version}_${target}.zip" ]]; then
rm -f "ffplayout-v${version}_${target}.zip"
2022-06-21 17:10:38 -04:00
fi
2022-06-23 16:39:13 -04:00
cargo build --release --target=$target
cp ./target/${target}/release/ffpapi.exe .
2022-06-21 17:10:38 -04:00
cp ./target/${target}/release/ffplayout.exe .
2023-11-04 17:26:36 -04:00
zip -r "ffplayout-v${version}_${target}.zip" assets docker docs LICENSE README.md CHANGELOG.md ffplayout.exe ffpapi.exe -x *.db
2022-06-23 16:39:13 -04:00
rm -f ffplayout.exe ffpapi.exe
2022-06-21 17:10:38 -04:00
elif [[ $target == "x86_64-apple-darwin" ]] || [[ $target == "aarch64-apple-darwin" ]]; then
2022-06-23 16:39:13 -04:00
if [[ -f "ffplayout-v${version}_${target}.tar.gz" ]]; then
rm -f "ffplayout-v${version}_${target}.tar.gz"
2022-06-21 17:10:38 -04:00
fi
2022-11-04 10:20:16 -04:00
c_cc="x86_64-apple-darwin20.4-clang"
c_cxx="x86_64-apple-darwin20.4-clang++"
2022-06-21 17:10:38 -04:00
2022-11-04 10:20:16 -04:00
if [[ $target == "aarch64-apple-darwin" ]]; then
c_cc="aarch64-apple-darwin20.4-clang"
c_cxx="aarch64-apple-darwin20.4-clang++"
fi
CC="$c_cc" CXX="$c_cxx" cargo build --release --target=$target
2022-06-21 17:10:38 -04:00
cp ./target/${target}/release/ffpapi .
2022-06-21 17:10:38 -04:00
cp ./target/${target}/release/ffplayout .
2023-11-04 17:26:36 -04:00
tar -czvf "ffplayout-v${version}_${target}.tar.gz" --exclude='*.db' --exclude='*.db-shm' --exclude='*.db-wal' assets docker docs LICENSE README.md CHANGELOG.md ffplayout ffpapi
rm -f ffplayout ffpapi
2022-06-23 16:39:13 -04:00
else
if [[ -f "ffplayout-v${version}_${target}.tar.gz" ]]; then
rm -f "ffplayout-v${version}_${target}.tar.gz"
2022-06-21 17:10:38 -04:00
fi
2022-06-23 16:39:13 -04:00
cargo build --release --target=$target
2022-06-21 17:10:38 -04:00
cp ./target/${target}/release/ffpapi .
2022-06-23 16:39:13 -04:00
cp ./target/${target}/release/ffplayout .
2023-11-04 17:26:36 -04:00
tar -czvf "ffplayout-v${version}_${target}.tar.gz" --exclude='*.db' --exclude='*.db-shm' --exclude='*.db-wal' assets docker docs LICENSE README.md CHANGELOG.md ffplayout ffpapi
2022-06-23 16:39:13 -04:00
rm -f ffplayout ffpapi
2022-06-21 17:10:38 -04:00
fi
echo ""
done
2023-11-04 16:58:47 -04:00
if [[ "${#targets[@]}" == "3" ]] || [[ $targets == "x86_64-unknown-linux-musl" ]]; then
2023-12-09 16:39:35 -05:00
cargo deb --target=x86_64-unknown-linux-musl -p ffplayout --manifest-path=ffplayout-engine/Cargo.toml -o ffplayout_${version}-1_amd64.deb
cargo generate-rpm --payload-compress none --target=x86_64-unknown-linux-musl -p ffplayout-engine -o ffplayout-${version}-1.x86_64.rpm
fi
2022-06-21 17:10:38 -04:00
2023-11-04 16:58:47 -04:00
if [[ "${#targets[@]}" == "3" ]] || [[ $targets == "aarch64-unknown-linux-gnu" ]]; then
2023-12-09 16:39:35 -05:00
cargo deb --target=aarch64-unknown-linux-gnu --variant=arm64 -p ffplayout --manifest-path=ffplayout-engine/Cargo.toml -o ffplayout_${version}-1_arm64.deb
fi