Add support for build and link types for deps
Make dependencies build scripts more flexible, to accept a build type (native or cross) and a link type (static or shared). This lays the groundwork for building binaries for Linux and macOS. PR #5515 <https://github.com/Genymobile/scrcpy/pull/5515>
This commit is contained in:
parent
98d2065d6d
commit
360936248c
@ -2,15 +2,34 @@
|
||||
# This file is intended to be sourced by other scripts, not executed
|
||||
|
||||
process_args() {
|
||||
if [[ $# != 1 ]]
|
||||
if [[ $# != 3 ]]
|
||||
then
|
||||
# <host>: win32 or win64
|
||||
echo "Syntax: $0 <host>" >&2
|
||||
# <build_type>: native or cross
|
||||
# <link_type>: static or shared
|
||||
echo "Syntax: $0 <host> <build_type> <link_type>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HOST="$1"
|
||||
BUILD_TYPE="$2" # native or cross
|
||||
LINK_TYPE="$3" # static or shared
|
||||
DIRNAME="$HOST-$BUILD_TYPE-$LINK_TYPE"
|
||||
|
||||
if [[ "$BUILD_TYPE" != native && "$BUILD_TYPE" != cross ]]
|
||||
then
|
||||
echo "Unsupported build type (expected native or cross): $BUILD_TYPE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$LINK_TYPE" != static && "$LINK_TYPE" != shared ]]
|
||||
then
|
||||
echo "Unsupported link type (expected static or shared): $LINK_TYPE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$BUILD_TYPE" == cross ]]
|
||||
then
|
||||
if [[ "$HOST" = win32 ]]
|
||||
then
|
||||
HOST_TRIPLET=i686-w64-mingw32
|
||||
@ -18,9 +37,10 @@ process_args() {
|
||||
then
|
||||
HOST_TRIPLET=x86_64-w64-mingw32
|
||||
else
|
||||
echo "Unsupported host: $HOST" >&2
|
||||
echo "Unsupported cross-build to host: $HOST" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
DEPS_DIR=$(dirname ${BASH_SOURCE[0]})
|
||||
|
@ -23,41 +23,26 @@ fi
|
||||
mkdir -p "$BUILD_DIR/$PROJECT_DIR"
|
||||
cd "$BUILD_DIR/$PROJECT_DIR"
|
||||
|
||||
if [[ "$HOST" = win32 ]]
|
||||
if [[ -d "$DIRNAME" ]]
|
||||
then
|
||||
ARCH=x86
|
||||
elif [[ "$HOST" = win64 ]]
|
||||
then
|
||||
ARCH=x86_64
|
||||
echo "'$PWD/$DIRNAME' already exists, not reconfigured"
|
||||
cd "$DIRNAME"
|
||||
else
|
||||
echo "Unsupported host: $HOST" >&2
|
||||
exit 1
|
||||
fi
|
||||
mkdir "$DIRNAME"
|
||||
cd "$DIRNAME"
|
||||
|
||||
# -static-libgcc to avoid missing libgcc_s_dw2-1.dll
|
||||
# -static to avoid dynamic dependency to zlib
|
||||
export CFLAGS='-static-libgcc -static'
|
||||
export CXXFLAGS="$CFLAGS"
|
||||
export LDFLAGS='-static-libgcc -static'
|
||||
|
||||
if [[ -d "$HOST" ]]
|
||||
then
|
||||
echo "'$PWD/$HOST' already exists, not reconfigured"
|
||||
cd "$HOST"
|
||||
else
|
||||
mkdir "$HOST"
|
||||
cd "$HOST"
|
||||
if [[ "$HOST" == win* ]]
|
||||
then
|
||||
# -static-libgcc to avoid missing libgcc_s_dw2-1.dll
|
||||
# -static to avoid dynamic dependency to zlib
|
||||
export CFLAGS='-static-libgcc -static'
|
||||
export CXXFLAGS="$CFLAGS"
|
||||
export LDFLAGS='-static-libgcc -static'
|
||||
fi
|
||||
|
||||
conf=(
|
||||
--prefix="$INSTALL_DIR/$HOST"
|
||||
--enable-cross-compile
|
||||
--target-os=mingw32
|
||||
--arch="$ARCH"
|
||||
--cross-prefix="${HOST_TRIPLET}-"
|
||||
--cc="${HOST_TRIPLET}-gcc"
|
||||
--prefix="$INSTALL_DIR/$DIRNAME"
|
||||
--extra-cflags="-O2 -fPIC"
|
||||
--enable-shared
|
||||
--disable-static
|
||||
--disable-programs
|
||||
--disable-doc
|
||||
--disable-swscale
|
||||
@ -89,6 +74,48 @@ else
|
||||
--enable-muxer=wav
|
||||
)
|
||||
|
||||
if [[ "$LINK_TYPE" == static ]]
|
||||
then
|
||||
conf+=(
|
||||
--enable-static
|
||||
--disable-shared
|
||||
)
|
||||
else
|
||||
conf+=(
|
||||
--disable-static
|
||||
--enable-shared
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ "$BUILD_TYPE" == cross ]]
|
||||
then
|
||||
conf+=(
|
||||
--enable-cross-compile
|
||||
--cross-prefix="${HOST_TRIPLET}-"
|
||||
--cc="${HOST_TRIPLET}-gcc"
|
||||
)
|
||||
|
||||
case "$HOST" in
|
||||
win32)
|
||||
conf+=(
|
||||
--target-os=mingw32
|
||||
--arch=x86
|
||||
)
|
||||
;;
|
||||
|
||||
win64)
|
||||
conf+=(
|
||||
--target-os=mingw32
|
||||
--arch=x86_64
|
||||
)
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unsupported host: $HOST" >&2
|
||||
exit 1
|
||||
esac
|
||||
fi
|
||||
|
||||
"$SOURCES_DIR/$PROJECT_DIR"/configure "${conf[@]}"
|
||||
fi
|
||||
|
||||
|
@ -26,21 +26,38 @@ cd "$BUILD_DIR/$PROJECT_DIR"
|
||||
export CFLAGS='-O2'
|
||||
export CXXFLAGS="$CFLAGS"
|
||||
|
||||
if [[ -d "$HOST" ]]
|
||||
if [[ -d "$DIRNAME" ]]
|
||||
then
|
||||
echo "'$PWD/$HOST' already exists, not reconfigured"
|
||||
cd "$HOST"
|
||||
echo "'$PWD/$DIRNAME' already exists, not reconfigured"
|
||||
cd "$DIRNAME"
|
||||
else
|
||||
mkdir "$HOST"
|
||||
cd "$HOST"
|
||||
mkdir "$DIRNAME"
|
||||
cd "$DIRNAME"
|
||||
|
||||
conf=(
|
||||
--prefix="$INSTALL_DIR/$HOST"
|
||||
--host="$HOST_TRIPLET"
|
||||
--enable-shared
|
||||
--disable-static
|
||||
--prefix="$INSTALL_DIR/$DIRNAME"
|
||||
)
|
||||
|
||||
if [[ "$LINK_TYPE" == static ]]
|
||||
then
|
||||
conf+=(
|
||||
--enable-static
|
||||
--disable-shared
|
||||
)
|
||||
else
|
||||
conf+=(
|
||||
--disable-static
|
||||
--enable-shared
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ "$BUILD_TYPE" == cross ]]
|
||||
then
|
||||
conf+=(
|
||||
--host="$HOST_TRIPLET"
|
||||
)
|
||||
fi
|
||||
|
||||
"$SOURCES_DIR/$PROJECT_DIR"/bootstrap.sh
|
||||
"$SOURCES_DIR/$PROJECT_DIR"/configure "${conf[@]}"
|
||||
fi
|
||||
|
@ -26,21 +26,38 @@ cd "$BUILD_DIR/$PROJECT_DIR"
|
||||
export CFLAGS='-O2'
|
||||
export CXXFLAGS="$CFLAGS"
|
||||
|
||||
if [[ -d "$HOST" ]]
|
||||
if [[ -d "$DIRNAME" ]]
|
||||
then
|
||||
echo "'$PWD/$HOST' already exists, not reconfigured"
|
||||
cd "$HOST"
|
||||
echo "'$PWD/$HDIRNAME' already exists, not reconfigured"
|
||||
cd "$DIRNAME"
|
||||
else
|
||||
mkdir "$HOST"
|
||||
cd "$HOST"
|
||||
mkdir "$DIRNAME"
|
||||
cd "$DIRNAME"
|
||||
|
||||
conf=(
|
||||
--prefix="$INSTALL_DIR/$HOST"
|
||||
--host="$HOST_TRIPLET"
|
||||
--enable-shared
|
||||
--disable-static
|
||||
--prefix="$INSTALL_DIR/$DIRNAME"
|
||||
)
|
||||
|
||||
if [[ "$LINK_TYPE" == static ]]
|
||||
then
|
||||
conf+=(
|
||||
--enable-static
|
||||
--disable-shared
|
||||
)
|
||||
else
|
||||
conf+=(
|
||||
--disable-static
|
||||
--enable-shared
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ "$BUILD_TYPE" == cross ]]
|
||||
then
|
||||
conf+=(
|
||||
--host="$HOST_TRIPLET"
|
||||
)
|
||||
fi
|
||||
|
||||
"$SOURCES_DIR/$PROJECT_DIR"/configure "${conf[@]}"
|
||||
fi
|
||||
|
||||
@ -48,4 +65,7 @@ make -j
|
||||
# There is no "make install-strip"
|
||||
make install
|
||||
# Strip manually
|
||||
${HOST_TRIPLET}-strip "$INSTALL_DIR/$HOST/bin/SDL2.dll"
|
||||
if [[ "$LINK_TYPE" == shared && "$HOST" == win* ]]
|
||||
then
|
||||
${HOST_TRIPLET}-strip "$INSTALL_DIR/$DIRNAME/bin/SDL2.dll"
|
||||
fi
|
||||
|
@ -21,11 +21,11 @@ cd .. # root project dir
|
||||
WINXX_BUILD_DIR="$WORK_DIR/build-$WINXX"
|
||||
|
||||
app/deps/adb_windows.sh
|
||||
app/deps/sdl.sh $WINXX
|
||||
app/deps/ffmpeg.sh $WINXX
|
||||
app/deps/libusb.sh $WINXX
|
||||
app/deps/sdl.sh $WINXX cross shared
|
||||
app/deps/ffmpeg.sh $WINXX cross shared
|
||||
app/deps/libusb.sh $WINXX cross shared
|
||||
|
||||
DEPS_INSTALL_DIR="$PWD/app/deps/work/install/$WINXX"
|
||||
DEPS_INSTALL_DIR="$PWD/app/deps/work/install/$WINXX-cross-shared"
|
||||
ADB_INSTALL_DIR="$PWD/app/deps/work/install/adb-windows"
|
||||
|
||||
rm -rf "$WINXX_BUILD_DIR"
|
||||
|
Loading…
x
Reference in New Issue
Block a user