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
|
# This file is intended to be sourced by other scripts, not executed
|
||||||
|
|
||||||
process_args() {
|
process_args() {
|
||||||
if [[ $# != 1 ]]
|
if [[ $# != 3 ]]
|
||||||
then
|
then
|
||||||
# <host>: win32 or win64
|
# <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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOST="$1"
|
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 ]]
|
if [[ "$HOST" = win32 ]]
|
||||||
then
|
then
|
||||||
HOST_TRIPLET=i686-w64-mingw32
|
HOST_TRIPLET=i686-w64-mingw32
|
||||||
@ -18,9 +37,10 @@ process_args() {
|
|||||||
then
|
then
|
||||||
HOST_TRIPLET=x86_64-w64-mingw32
|
HOST_TRIPLET=x86_64-w64-mingw32
|
||||||
else
|
else
|
||||||
echo "Unsupported host: $HOST" >&2
|
echo "Unsupported cross-build to host: $HOST" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
DEPS_DIR=$(dirname ${BASH_SOURCE[0]})
|
DEPS_DIR=$(dirname ${BASH_SOURCE[0]})
|
||||||
|
@ -23,41 +23,26 @@ fi
|
|||||||
mkdir -p "$BUILD_DIR/$PROJECT_DIR"
|
mkdir -p "$BUILD_DIR/$PROJECT_DIR"
|
||||||
cd "$BUILD_DIR/$PROJECT_DIR"
|
cd "$BUILD_DIR/$PROJECT_DIR"
|
||||||
|
|
||||||
if [[ "$HOST" = win32 ]]
|
if [[ -d "$DIRNAME" ]]
|
||||||
then
|
then
|
||||||
ARCH=x86
|
echo "'$PWD/$DIRNAME' already exists, not reconfigured"
|
||||||
elif [[ "$HOST" = win64 ]]
|
cd "$DIRNAME"
|
||||||
then
|
|
||||||
ARCH=x86_64
|
|
||||||
else
|
else
|
||||||
echo "Unsupported host: $HOST" >&2
|
mkdir "$DIRNAME"
|
||||||
exit 1
|
cd "$DIRNAME"
|
||||||
fi
|
|
||||||
|
|
||||||
# -static-libgcc to avoid missing libgcc_s_dw2-1.dll
|
if [[ "$HOST" == win* ]]
|
||||||
# -static to avoid dynamic dependency to zlib
|
then
|
||||||
export CFLAGS='-static-libgcc -static'
|
# -static-libgcc to avoid missing libgcc_s_dw2-1.dll
|
||||||
export CXXFLAGS="$CFLAGS"
|
# -static to avoid dynamic dependency to zlib
|
||||||
export LDFLAGS='-static-libgcc -static'
|
export CFLAGS='-static-libgcc -static'
|
||||||
|
export CXXFLAGS="$CFLAGS"
|
||||||
if [[ -d "$HOST" ]]
|
export LDFLAGS='-static-libgcc -static'
|
||||||
then
|
fi
|
||||||
echo "'$PWD/$HOST' already exists, not reconfigured"
|
|
||||||
cd "$HOST"
|
|
||||||
else
|
|
||||||
mkdir "$HOST"
|
|
||||||
cd "$HOST"
|
|
||||||
|
|
||||||
conf=(
|
conf=(
|
||||||
--prefix="$INSTALL_DIR/$HOST"
|
--prefix="$INSTALL_DIR/$DIRNAME"
|
||||||
--enable-cross-compile
|
|
||||||
--target-os=mingw32
|
|
||||||
--arch="$ARCH"
|
|
||||||
--cross-prefix="${HOST_TRIPLET}-"
|
|
||||||
--cc="${HOST_TRIPLET}-gcc"
|
|
||||||
--extra-cflags="-O2 -fPIC"
|
--extra-cflags="-O2 -fPIC"
|
||||||
--enable-shared
|
|
||||||
--disable-static
|
|
||||||
--disable-programs
|
--disable-programs
|
||||||
--disable-doc
|
--disable-doc
|
||||||
--disable-swscale
|
--disable-swscale
|
||||||
@ -89,6 +74,48 @@ else
|
|||||||
--enable-muxer=wav
|
--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[@]}"
|
"$SOURCES_DIR/$PROJECT_DIR"/configure "${conf[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -26,21 +26,38 @@ cd "$BUILD_DIR/$PROJECT_DIR"
|
|||||||
export CFLAGS='-O2'
|
export CFLAGS='-O2'
|
||||||
export CXXFLAGS="$CFLAGS"
|
export CXXFLAGS="$CFLAGS"
|
||||||
|
|
||||||
if [[ -d "$HOST" ]]
|
if [[ -d "$DIRNAME" ]]
|
||||||
then
|
then
|
||||||
echo "'$PWD/$HOST' already exists, not reconfigured"
|
echo "'$PWD/$DIRNAME' already exists, not reconfigured"
|
||||||
cd "$HOST"
|
cd "$DIRNAME"
|
||||||
else
|
else
|
||||||
mkdir "$HOST"
|
mkdir "$DIRNAME"
|
||||||
cd "$HOST"
|
cd "$DIRNAME"
|
||||||
|
|
||||||
conf=(
|
conf=(
|
||||||
--prefix="$INSTALL_DIR/$HOST"
|
--prefix="$INSTALL_DIR/$DIRNAME"
|
||||||
--host="$HOST_TRIPLET"
|
|
||||||
--enable-shared
|
|
||||||
--disable-static
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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"/bootstrap.sh
|
||||||
"$SOURCES_DIR/$PROJECT_DIR"/configure "${conf[@]}"
|
"$SOURCES_DIR/$PROJECT_DIR"/configure "${conf[@]}"
|
||||||
fi
|
fi
|
||||||
|
@ -26,21 +26,38 @@ cd "$BUILD_DIR/$PROJECT_DIR"
|
|||||||
export CFLAGS='-O2'
|
export CFLAGS='-O2'
|
||||||
export CXXFLAGS="$CFLAGS"
|
export CXXFLAGS="$CFLAGS"
|
||||||
|
|
||||||
if [[ -d "$HOST" ]]
|
if [[ -d "$DIRNAME" ]]
|
||||||
then
|
then
|
||||||
echo "'$PWD/$HOST' already exists, not reconfigured"
|
echo "'$PWD/$HDIRNAME' already exists, not reconfigured"
|
||||||
cd "$HOST"
|
cd "$DIRNAME"
|
||||||
else
|
else
|
||||||
mkdir "$HOST"
|
mkdir "$DIRNAME"
|
||||||
cd "$HOST"
|
cd "$DIRNAME"
|
||||||
|
|
||||||
conf=(
|
conf=(
|
||||||
--prefix="$INSTALL_DIR/$HOST"
|
--prefix="$INSTALL_DIR/$DIRNAME"
|
||||||
--host="$HOST_TRIPLET"
|
|
||||||
--enable-shared
|
|
||||||
--disable-static
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
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[@]}"
|
"$SOURCES_DIR/$PROJECT_DIR"/configure "${conf[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -48,4 +65,7 @@ make -j
|
|||||||
# There is no "make install-strip"
|
# There is no "make install-strip"
|
||||||
make install
|
make install
|
||||||
# Strip manually
|
# 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"
|
WINXX_BUILD_DIR="$WORK_DIR/build-$WINXX"
|
||||||
|
|
||||||
app/deps/adb_windows.sh
|
app/deps/adb_windows.sh
|
||||||
app/deps/sdl.sh $WINXX
|
app/deps/sdl.sh $WINXX cross shared
|
||||||
app/deps/ffmpeg.sh $WINXX
|
app/deps/ffmpeg.sh $WINXX cross shared
|
||||||
app/deps/libusb.sh $WINXX
|
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"
|
ADB_INSTALL_DIR="$PWD/app/deps/work/install/adb-windows"
|
||||||
|
|
||||||
rm -rf "$WINXX_BUILD_DIR"
|
rm -rf "$WINXX_BUILD_DIR"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user