1+ #! /bin/bash
2+ # Copyright 2023 LiveKit, Inc.
3+ #
4+ # Licensed under the Apache License, Version 2.0 (the "License");
5+ # you may not use this file except in compliance with the License.
6+ # You may obtain a copy of the License at
7+ #
8+ # http://www.apache.org/licenses/LICENSE-2.0
9+ #
10+ # Unless required by applicable law or agreed to in writing, software
11+ # distributed under the License is distributed on an "AS IS" BASIS,
12+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ # See the License for the specific language governing permissions and
14+ # limitations under the License.
15+
16+
17+ # This file is used to download prebuilt binaries of livekit-ffi from our GH releases.
18+ # It is mostly used by our bindings (e.g https://github.com/livekit/client-sdk-python)
19+
20+ arch=" "
21+ platform=" "
22+ version=" "
23+ output=" "
24+
25+ while [ " $# " -gt 0 ]; do
26+ case " $1 " in
27+ --arch)
28+ arch=" $2 "
29+ if [ " $arch " != " x86_64" ] && [ " $arch " != " arm" ] && [ " $arch " != " arm64" ]; then
30+ echo " Error: Invalid value for --arch. Must be 'x86_64', 'arm' or 'arm64'."
31+ exit 1
32+ fi
33+ shift 2
34+ ;;
35+ --platform)
36+ platform=" $2 "
37+ if [ " $platform " != " windows" ] \
38+ && [ " $platform " != " linux" ] \
39+ && [ " $platform " != " macos" ] \
40+ && [ " $platform " != " ios" ] \
41+ && [ " $platform " != " android" ]; then
42+
43+ echo " Error: Invalid value for --platform. Must be 'windows', 'linux', 'macos', 'ios' or 'android'."
44+ exit 1
45+ fi
46+ shift 2
47+ ;;
48+ --version)
49+ version=" $2 "
50+ shift 2
51+ ;;
52+ --output)
53+ output=" $2 "
54+ shift 2
55+ ;;
56+ * )
57+ echo " Error: Unknown argument '$1 '"
58+ exit 1
59+ ;;
60+ esac
61+ done
62+
63+ if [ -z " $arch " ]; then
64+ echo " Error: --arch must be set."
65+ exit 1
66+ fi
67+
68+ if [ -z " $platform " ]; then
69+ echo " Error: --platform must be set."
70+ exit 1
71+ fi
72+
73+ if [ -z " $version " ]; then
74+ echo " Error: --version must be set."
75+ exit 1
76+ fi
77+
78+ if [ -z " $output " ]; then
79+ echo " Error: --output must be set."
80+ exit 1
81+ fi
82+
83+ url=" https://github.com/livekit/client-sdk-rust/releases/download/ffi-v$version /ffi-$platform -$arch .zip"
84+ echo " Downloading $url "
85+ tmpfile=$( mktemp)
86+ echo " Tmp dir: $tmpfile "
87+ curl $url -L --fail --output $tmpfile
88+
89+ # unzip to output
90+ mkdir -p $output
91+ unzip -o $tmpfile -d $output
92+ rm $tmpfile
0 commit comments