diff --git a/docs/mingw-example/_build.sh b/docs/mingw-example/_build.sh index 7a74819d1..d0a45a643 100644 --- a/docs/mingw-example/_build.sh +++ b/docs/mingw-example/_build.sh @@ -3,4 +3,4 @@ rm -rf $(pwd)/build/$TARGET_ARCH mkdir -p $(pwd)/build/$TARGET_ARCH docker build -t win32-builder --build-arg ARCH . -docker compose up dist-builder \ No newline at end of file +docker compose up dist-builder diff --git a/docs/mingw-example/build_arm64.sh b/docs/mingw-example/build_arm64.sh index ae63a6852..09b0db6c6 100644 --- a/docs/mingw-example/build_arm64.sh +++ b/docs/mingw-example/build_arm64.sh @@ -1,4 +1,4 @@ #!/bin/sh -export ARCH=aarch64 -. ./_build.sh \ No newline at end of file +export ARCH=aarch64 +. ./_build.sh diff --git a/docs/mingw-example/build_x64.sh b/docs/mingw-example/build_x64.sh index e9918690c..34b0359dc 100644 --- a/docs/mingw-example/build_x64.sh +++ b/docs/mingw-example/build_x64.sh @@ -1,4 +1,4 @@ #!/bin/sh -export ARCH=x86_64 -. ./_build.sh \ No newline at end of file +export ARCH=x86_64 +. ./_build.sh diff --git a/packaging/flatpak/build-bundle.sh b/packaging/flatpak/build-bundle.sh index ed4b5a8aa..6e87af897 100755 --- a/packaging/flatpak/build-bundle.sh +++ b/packaging/flatpak/build-bundle.sh @@ -1,12 +1,11 @@ #!/bin/bash -xe -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) MANIFEST=com.freerdp.FreeRDP BUILD_BASE=$(mktemp -d) -if [ $# -gt 0 ]; -then - BUILD_BASE=$1 +if [ $# -gt 0 ]; then + BUILD_BASE=$1 fi echo "Using $BUILD_BASE as temporary build directory" @@ -15,17 +14,15 @@ BUILD=$BUILD_BASE/build STATE=$BUILD_BASE/state BUILDER=$(which flatpak-builder) -if [ ! -x "$BUILDER" ]; -then - echo "command 'flatpak-builder' could not be found, please install and add to PATH" - exit 1 +if [ ! -x "$BUILDER" ]; then + echo "command 'flatpak-builder' could not be found, please install and add to PATH" + exit 1 fi FLATPAK=$(which flatpak) -if [ ! -x "$FLATPAK" ]; -then - echo "command 'flatpak' could not be found, please install and add to PATH" - exit 1 +if [ ! -x "$FLATPAK" ]; then + echo "command 'flatpak' could not be found, please install and add to PATH" + exit 1 fi flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo --user diff --git a/packaging/flatpak/freerdp.sh b/packaging/flatpak/freerdp.sh index 5b6a7dbe9..bf94dc5a3 100755 --- a/packaging/flatpak/freerdp.sh +++ b/packaging/flatpak/freerdp.sh @@ -1,34 +1,29 @@ #!/bin/sh -if [ -z ${FREERDP_SDL_OFF} ]; -then - echo "SDL $(which sdl-freerdp)" - sdl-freerdp $@ - exit $rc +if [ -z ${FREERDP_SDL_OFF} ]; then + echo "SDL $(which sdl-freerdp)" + sdl-freerdp $@ + exit $rc else - if [ -z $XDG_SESSION_TYPE ]; - then - echo "XDG_SESSION_TYPE undefined" - exit -1 - elif [ "$XDG_SESSION_TYPE" = "wayland" ]; - then - if [ -z $FREERDP_WAYLAND_OFF ]; - then - echo "wayland $(which wlfreerdp)" - wlfreerdp $@ - exit $rc - else - echo "X11 $(which xfreerdp)" - xfreerdp $@ - exit $rc - fi - elif [ "$XDG_SESSION_TYPE" = "x11" ]; - then - echo "X11 $(which xfreerdp)" - xfreerdp $@ - exit $rc - else - echo "XDG_SESSION_TYPE $XDG_SESSION_TYPE not handled" - exit -1 - fi + if [ -z $XDG_SESSION_TYPE ]; then + echo "XDG_SESSION_TYPE undefined" + exit -1 + elif [ "$XDG_SESSION_TYPE" = "wayland" ]; then + if [ -z $FREERDP_WAYLAND_OFF ]; then + echo "wayland $(which wlfreerdp)" + wlfreerdp $@ + exit $rc + else + echo "X11 $(which xfreerdp)" + xfreerdp $@ + exit $rc + fi + elif [ "$XDG_SESSION_TYPE" = "x11" ]; then + echo "X11 $(which xfreerdp)" + xfreerdp $@ + exit $rc + else + echo "XDG_SESSION_TYPE $XDG_SESSION_TYPE not handled" + exit -1 + fi fi diff --git a/packaging/scripts/create_deb.sh b/packaging/scripts/create_deb.sh index 8d9dfb929..ff600c67c 100755 --- a/packaging/scripts/create_deb.sh +++ b/packaging/scripts/create_deb.sh @@ -6,11 +6,10 @@ SCRIPT_PATH=$(realpath "$SCRIPT_PATH") BUILD_DEPS=$(/usr/bin/which dpkg-checkbuilddeps) BUILD_PKG=$(/usr/bin/which dpkg-buildpackage) -if [ -z "$BUILD_DEPS" ] || [ -z "$BUILD_PKG" ]; -then - echo "dpkg-buildpackage [$BUILD_PKG] and dpkg-checkbuilddeps [$BUILD_DEPS] required" - echo "Install with 'sudo apt install dpkg-dev'" - exit 1 +if [ -z "$BUILD_DEPS" ] || [ -z "$BUILD_PKG" ]; then + echo "dpkg-buildpackage [$BUILD_PKG] and dpkg-checkbuilddeps [$BUILD_DEPS] required" + echo "Install with 'sudo apt install dpkg-dev'" + exit 1 fi # First create a link to the debian/control folder diff --git a/packaging/scripts/prepare_deb_freerdp-nightly.sh b/packaging/scripts/prepare_deb_freerdp-nightly.sh index a4654914a..12e074562 100755 --- a/packaging/scripts/prepare_deb_freerdp-nightly.sh +++ b/packaging/scripts/prepare_deb_freerdp-nightly.sh @@ -1,4 +1,4 @@ #!/bin/sh -ln -s packaging/deb/freerdp-nightly debian -git rev-parse --short HEAD > .source_version +ln -s packaging/deb/freerdp-nightly debian +git rev-parse --short HEAD >.source_version diff --git a/packaging/scripts/prepare_rpm_freerdp-nightly.sh b/packaging/scripts/prepare_rpm_freerdp-nightly.sh index 5401a8186..a658b8dcd 100755 --- a/packaging/scripts/prepare_rpm_freerdp-nightly.sh +++ b/packaging/scripts/prepare_rpm_freerdp-nightly.sh @@ -1,3 +1,3 @@ #!/bin/bash -git rev-parse --short HEAD > source_version +git rev-parse --short HEAD >source_version diff --git a/scripts/android-build-cjson.sh b/scripts/android-build-cjson.sh index d79fa9a6f..249e001e2 100755 --- a/scripts/android-build-cjson.sh +++ b/scripts/android-build-cjson.sh @@ -22,20 +22,19 @@ CMAKE_CMD_ARGS="-DANDROID_NDK=$ANDROID_NDK \ -DCMAKE_MAKE_PROGRAM=make" BASE=$(pwd) -for ARCH in $BUILD_ARCH -do - common_run cd $BASE - common_run mkdir -p $BUILD_SRC/cJSON-build/$ARCH - common_run cd $BUILD_SRC/cJSON-build/$ARCH - common_run export ANDROID_NDK=$ANDROID_NDK - common_run $CMAKE_PROGRAM $CMAKE_CMD_ARGS \ - -DANDROID_ABI=$ARCH \ - -DCMAKE_INSTALL_PREFIX=$BUILD_DST/$ARCH \ - -DCMAKE_INSTALL_LIBDIR=. \ - -B . \ - -S $BUILD_SRC - echo $(pwd) - common_run $CMAKE_PROGRAM --build . --target install +for ARCH in $BUILD_ARCH; do + common_run cd $BASE + common_run mkdir -p $BUILD_SRC/cJSON-build/$ARCH + common_run cd $BUILD_SRC/cJSON-build/$ARCH + common_run export ANDROID_NDK=$ANDROID_NDK + common_run $CMAKE_PROGRAM $CMAKE_CMD_ARGS \ + -DANDROID_ABI=$ARCH \ + -DCMAKE_INSTALL_PREFIX=$BUILD_DST/$ARCH \ + -DCMAKE_INSTALL_LIBDIR=. \ + -B . \ + -S $BUILD_SRC + echo $(pwd) + common_run $CMAKE_PROGRAM --build . --target install done echo "Successfully build library for architectures $BUILD_ARCH" diff --git a/scripts/android-build-common.sh b/scripts/android-build-common.sh index 9430da3d7..3beb0d1ed 100644 --- a/scripts/android-build-common.sh +++ b/scripts/android-build-common.sh @@ -1,332 +1,309 @@ #!/bin/bash -x +SCRIPT_NAME="${BASH_SOURCE[0]}" SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}") SCRIPT_PATH=$(realpath "$SCRIPT_PATH") FIND_ARGS="-type f -print -quit" case "$(uname -s)" in - Darwin) - FIND_ARGS="-perm +111 $FIND_ARGS" - ;; +Darwin) + FIND_ARGS="-perm +111 $FIND_ARGS" + ;; - *) - FIND_ARGS="-executable $FIND_ARGS" - ;; +*) + FIND_ARGS="-executable $FIND_ARGS" + ;; esac if [ -z $BUILD_ARCH ]; then - BUILD_ARCH="armeabi-v7a x86 x86_64 arm64-v8a" + BUILD_ARCH="armeabi-v7a x86 x86_64 arm64-v8a" fi if [ -z $NDK_TARGET ]; then - NDK_TARGET=21 + NDK_TARGET=21 fi if [ -z $CMAKE_PROGRAM ]; then - CMAKE_PROGRAM="cmake-missing" + CMAKE_PROGRAM="cmake-missing" fi if [ -z $CCACHE ]; then - CCACHE=$(which ccache) + CCACHE=$(which ccache) fi if [ -z $ANDROID_NDK ]; then - ANDROID_NDK="ndk-missing" + ANDROID_NDK="ndk-missing" fi if [ -z $ANDROID_SDK ]; then - ANDROID_SDK="sdk-missing" + ANDROID_SDK="sdk-missing" fi if [ -z $BUILD_DST ]; then - BUILD_DST=$(pwd)/libs + BUILD_DST=$(pwd)/libs fi if [ -z $BUILD_SRC ]; then - BUILD_SRC=$(pwd)/src + BUILD_SRC=$(pwd)/src fi if [ -z $SCM_URL ]; then - SCM_URL="missing" + SCM_URL="missing" fi if [ -z $SCM_TAG ]; then - SCM_TAG=master + SCM_TAG=master fi if [ -z $SCM_HASH ]; then - SCM_HASH="missing" + SCM_HASH="missing" fi CLEAN_BUILD_DIR=0 function common_help { - echo "$(BASHSOURCE[0]) supports the following arguments:" - echo " --ndk The base directory of your android NDK defa" - echo " ANDROID_NDK=$ANDROID_NDK" - echo " --sdk The base directory of your android SDK defa" - echo " ANDROID_SDK=$ANDROID_SDK" - echo " --arch A list of architectures to build" - echo " BUILD_ARCH=$BUILD_ARCH" - echo " --dst The destination directory for include and library files" - echo " BUILD_DST=$BUILD_DST" - echo " --src The source directory for SCM checkout" - echo " BUILD_SRC=$BUILD_SRC" - echo " --url The SCM source url" - echo " SCM_URL=$SCM_URL" - echo " --tag The SCM branch or tag to check out" - echo " SCM_TAG=$SCM_TAG" - echo " --hash The SCM commit or hash to check out" - echo " SCM_HASH=$SCM_HASH" - echo " --clean Clean the destination before build" - echo " --help Display this help" - exit 0 + echo "$SCRIPT_NAME supports the following arguments:" + echo " --ndk The base directory of your android NDK defa" + echo " ANDROID_NDK=$ANDROID_NDK" + echo " --sdk The base directory of your android SDK defa" + echo " ANDROID_SDK=$ANDROID_SDK" + echo " --arch A list of architectures to build" + echo " BUILD_ARCH=$BUILD_ARCH" + echo " --dst The destination directory for include and library files" + echo " BUILD_DST=$BUILD_DST" + echo " --src The source directory for SCM checkout" + echo " BUILD_SRC=$BUILD_SRC" + echo " --url The SCM source url" + echo " SCM_URL=$SCM_URL" + echo " --tag The SCM branch or tag to check out" + echo " SCM_TAG=$SCM_TAG" + echo " --hash The SCM commit or hash to check out" + echo " SCM_HASH=$SCM_HASH" + echo " --clean Clean the destination before build" + echo " --help Display this help" + exit 0 } function common_run { - echo "[RUN] $@" - "$@" - RES=$? - if [[ $RES -ne 0 ]]; - then - echo "[ERROR] $@ returned $RES" - exit 1 - fi + echo "[RUN] $@" + "$@" + RES=$? + if [[ $RES -ne 0 ]]; then + echo "[ERROR] $@ returned $RES" + exit 1 + fi } function common_check_requirements { - if [[ ! -d $ANDROID_NDK ]]; - then - echo "export ANDROID_NDK to point to your NDK location." - exit 1 - fi + if [[ ! -d $ANDROID_NDK ]]; then + echo "export ANDROID_NDK to point to your NDK location." + exit 1 + fi - if [[ ! -d $ANDROID_SDK ]]; - then - echo "export ANDROID_SDK to point to your SDK location." - exit 1 - fi - if [[ -z $BUILD_DST ]]; - then - echo "Destination directory not valid" - exit 1 - fi + if [[ ! -d $ANDROID_SDK ]]; then + echo "export ANDROID_SDK to point to your SDK location." + exit 1 + fi + if [[ -z $BUILD_DST ]]; then + echo "Destination directory not valid" + exit 1 + fi - if [[ -z $BUILD_SRC ]]; - then - echo "Source directory not valid" - exit 1 - fi + if [[ -z $BUILD_SRC ]]; then + echo "Source directory not valid" + exit 1 + fi - if [[ -z $SCM_URL ]]; - then - echo "Source URL not defined! Define SCM_URL" - exit 1 - fi + if [[ -z $SCM_URL ]]; then + echo "Source URL not defined! Define SCM_URL" + exit 1 + fi - if [[ -z $SCM_TAG ]]; - then - echo "SCM_TAG / BRANCH not defined! Define SCM_TAG" - exit 1 - fi + if [[ -z $SCM_TAG ]]; then + echo "SCM_TAG / BRANCH not defined! Define SCM_TAG" + exit 1 + fi - if [[ -z $SCM_HASH ]]; - then - echo "SCM_HASH not defined! Define SCM_HASH" - exit 1 - fi + if [[ -z $SCM_HASH ]]; then + echo "SCM_HASH not defined! Define SCM_HASH" + exit 1 + fi - if [[ -z $NDK_TARGET ]]; - then - echo "Android platform NDK_TARGET not defined" - exit 1 - fi + if [[ -z $NDK_TARGET ]]; then + echo "Android platform NDK_TARGET not defined" + exit 1 + fi - if [ -z $CMAKE_PROGRAM ] || [ "$CMAKE_PROGRAM" == "cmake-missing" ]; then - CMAKE_PROGRAM=$(find $ANDROID_SDK/cmake -name cmake $FIND_ARGS) - if [ -z $CMAKE_PROGRAM ]; then - echo "CMake not found in $ANDROID_SDK, install CMake from the android SDK!" - exit 1 - fi - fi + if [ -z $CMAKE_PROGRAM ] || [ "$CMAKE_PROGRAM" == "cmake-missing" ]; then + CMAKE_PROGRAM=$(find $ANDROID_SDK/cmake -name cmake $FIND_ARGS) + if [ -z $CMAKE_PROGRAM ]; then + echo "CMake not found in $ANDROID_SDK, install CMake from the android SDK!" + exit 1 + fi + fi - for CMD in make git $CMAKE_PROGRAM - do - if ! type $CMD >/dev/null; then - echo "Command $CMD not found. Install and add it to the PATH." - exit 1 - fi - done + for CMD in make git $CMAKE_PROGRAM; do + if ! type $CMD >/dev/null; then + echo "Command $CMD not found. Install and add it to the PATH." + exit 1 + fi + done - if [ "${BUILD_SRC:0:1}" != "/" ]; - then - BUILD_SRC=$(pwd)/$BUILD_SRC - fi - if [ "${BUILD_DST:0:1}" != "/" ]; - then - BUILD_DST=$(pwd)/$BUILD_DST - fi + if [ "${BUILD_SRC:0:1}" != "/" ]; then + BUILD_SRC=$(pwd)/$BUILD_SRC + fi + if [ "${BUILD_DST:0:1}" != "/" ]; then + BUILD_DST=$(pwd)/$BUILD_DST + fi } function common_parse_arguments { - while [[ $# > 0 ]] - do - key="$1" - case $key in - --conf) - source "$2" || exit 1 - shift - ;; + while [[ $# > 0 ]]; do + key="$1" + case $key in + --conf) + source "$2" || exit 1 + shift + ;; - --target) - NDK_TARGET="$2" - shift - ;; + --target) + NDK_TARGET="$2" + shift + ;; - --ndk) - ANDROID_NDK="$2" - shift - ;; + --ndk) + ANDROID_NDK="$2" + shift + ;; - --sdk) - ANDROID_SDK="$2" - shift - ;; + --sdk) + ANDROID_SDK="$2" + shift + ;; - --arch) - BUILD_ARCH="$2" - shift - ;; + --arch) + BUILD_ARCH="$2" + shift + ;; - --dst) - BUILD_DST="$2" - shift - ;; + --dst) + BUILD_DST="$2" + shift + ;; - --src) - BUILD_SRC="$2" - shift - ;; + --src) + BUILD_SRC="$2" + shift + ;; - --url) - SCM_URL="$2" - shift - ;; + --url) + SCM_URL="$2" + shift + ;; - --tag) - SCM_TAG="$2" - shift - ;; + --tag) + SCM_TAG="$2" + shift + ;; - --hash) - SCM_HASH="$2" - shift - ;; + --hash) + SCM_HASH="$2" + shift + ;; - --clean) - CLEAN_BUILD_DIR=1 - shift - ;; + --clean) + CLEAN_BUILD_DIR=1 + shift + ;; - --help) - common_help - shift - ;; + --help) + common_help + shift + ;; - *) # Unknown - ;; - esac - shift - done + *) # Unknown + ;; + esac + shift + done - common_check_requirements + common_check_requirements } function common_update { - if [ $# -ne 4 ]; - then - echo "Invalid arguments to update function $@" - exit 1 - fi - SCM_URL=$1 - SCM_TAG=$2 - BUILD_SRC=$3 - SCM_HASH=$4 + if [ $# -ne 4 ]; then + echo "Invalid arguments to update function $@" + exit 1 + fi + SCM_URL=$1 + SCM_TAG=$2 + BUILD_SRC=$3 + SCM_HASH=$4 - echo "Preparing checkout..." - BASE=$(pwd) - CACHE=$(realpath $SCRIPT_PATH/../cache) - common_run mkdir -p $CACHE - TARFILE="$CACHE/$SCM_TAG.tar.gz" + echo "Preparing checkout..." + BASE=$(pwd) + CACHE=$(realpath $SCRIPT_PATH/../cache) + common_run mkdir -p $CACHE + TARFILE="$CACHE/$SCM_TAG.tar.gz" - if [[ ! -f "$TARFILE" ]]; - then - WGET=$(which wget) - CURL=$(which curl) - if [ -x "$CURL" ]; - then - common_run $CURL -L -o "$TARFILE" "$SCM_URL/$SCM_TAG.tar.gz" - elif [ -x "$WGET" ]; - then - common_run $WGET -O "$TARFILE" "$SCM_URL/$SCM_TAG.tar.gz" - else - echo "Neither wget nor curl installed, aborting" - exit -1 - fi - fi + if [[ ! -f "$TARFILE" ]]; then + WGET=$(which wget) + CURL=$(which curl) + if [ -x "$CURL" ]; then + common_run $CURL -L -o "$TARFILE" "$SCM_URL/$SCM_TAG.tar.gz" + elif [ -x "$WGET" ]; then + common_run $WGET -O "$TARFILE" "$SCM_URL/$SCM_TAG.tar.gz" + else + echo "Neither wget nor curl installed, aborting" + exit -1 + fi + fi - echo "$SCM_HASH $TARFILE" > $TARFILE.sha256sum - common_run sha256sum -c $TARFILE.sha256sum + echo "$SCM_HASH $TARFILE" >$TARFILE.sha256sum + common_run sha256sum -c $TARFILE.sha256sum - if [[ -d $BUILD_SRC ]]; - then - common_run rm -rf $BUILD_SRC - fi - common_run mkdir -p $BUILD_SRC - common_run cd $BUILD_SRC - common_run tar zxf "$TARFILE" --strip 1 - common_run cd $BASE + if [[ -d $BUILD_SRC ]]; then + common_run rm -rf $BUILD_SRC + fi + common_run mkdir -p $BUILD_SRC + common_run cd $BUILD_SRC + common_run tar zxf "$TARFILE" --strip 1 + common_run cd $BASE } function common_clean { - if [ $CLEAN_BUILD_DIR -ne 1 ]; - then - return - fi + if [ $CLEAN_BUILD_DIR -ne 1 ]; then + return + fi - if [ $# -ne 1 ]; - then - echo "Invalid arguments to clean function $@" - exit 1 - fi + if [ $# -ne 1 ]; then + echo "Invalid arguments to clean function $@" + exit 1 + fi - echo "Cleaning up $1..." - common_run rm -rf $1 + echo "Cleaning up $1..." + common_run rm -rf $1 } function common_copy { - if [ $# -ne 2 ]; - then - echo "Invalid arguments to copy function $@" - exit 1 - fi - if [ ! -d $1 ] || [ ! -d $1/include ] || [ ! -d $1/libs ]; - then - echo "Invalid source $1" - exit 1 - fi - if [ -z $2 ]; - then - echo "Invalid destination $2" - exit 1 - fi + if [ $# -ne 2 ]; then + echo "Invalid arguments to copy function $@" + exit 1 + fi + if [ ! -d $1 ] || [ ! -d $1/include ] || [ ! -d $1/libs ]; then + echo "Invalid source $1" + exit 1 + fi + if [ -z $2 ]; then + echo "Invalid destination $2" + exit 1 + fi - if [ ! -d $2 ]; - then - common_run mkdir -p $2 - fi - common_run cp -L -r $1/include $2 - common_run cp -L -r $1/libs/* $2 + if [ ! -d $2 ]; then + common_run mkdir -p $2 + fi + common_run cp -L -r $1/include $2 + common_run cp -L -r $1/libs/* $2 } diff --git a/scripts/android-build-ffmpeg.sh b/scripts/android-build-ffmpeg.sh index e851696fe..e6b9a13fa 100755 --- a/scripts/android-build-ffmpeg.sh +++ b/scripts/android-build-ffmpeg.sh @@ -8,212 +8,210 @@ OLD_PATH=$PATH source $(dirname "${BASH_SOURCE[0]}")/android-build-common.sh function get_toolchain() { - HOST_OS=$(uname -s) - case ${HOST_OS} in - Darwin) HOST_OS=darwin;; - Linux) HOST_OS=linux;; - FreeBsd) HOST_OS=freebsd;; - CYGWIN*|*_NT-*) HOST_OS=cygwin;; - esac + HOST_OS=$(uname -s) + case ${HOST_OS} in + Darwin) HOST_OS=darwin ;; + Linux) HOST_OS=linux ;; + FreeBsd) HOST_OS=freebsd ;; + CYGWIN* | *_NT-*) HOST_OS=cygwin ;; + esac - HOST_ARCH=$(uname -m) - case ${HOST_ARCH} in - i?86) HOST_ARCH=x86;; - x86_64|amd64) HOST_ARCH=x86_64;; - esac + HOST_ARCH=$(uname -m) + case ${HOST_ARCH} in + i?86) HOST_ARCH=x86 ;; + x86_64 | amd64) HOST_ARCH=x86_64 ;; + esac - echo "${HOST_OS}-${HOST_ARCH}" + echo "${HOST_OS}-${HOST_ARCH}" } function get_build_host() { - case ${ARCH} in - armeabi-v7a) - echo "arm-linux-androideabi" - ;; - arm64-v8a) - echo "aarch64-linux-android" - ;; - x86) - echo "i686-linux-android" - ;; - x86_64) - echo "x86_64-linux-android" - ;; - esac + case ${ARCH} in + armeabi-v7a) + echo "arm-linux-androideabi" + ;; + arm64-v8a) + echo "aarch64-linux-android" + ;; + x86) + echo "i686-linux-android" + ;; + x86_64) + echo "x86_64-linux-android" + ;; + esac } function get_clang_target_host() { - case ${ARCH} in - armeabi-v7a) - echo "armv7a-linux-androideabi${NDK_TARGET}" - ;; - arm64-v8a) - echo "aarch64-linux-android${NDK_TARGET}" - ;; - x86) - echo "i686-linux-android${NDK_TARGET}" - ;; - x86_64) - echo "x86_64-linux-android${NDK_TARGET}" - ;; - esac + case ${ARCH} in + armeabi-v7a) + echo "armv7a-linux-androideabi${NDK_TARGET}" + ;; + arm64-v8a) + echo "aarch64-linux-android${NDK_TARGET}" + ;; + x86) + echo "i686-linux-android${NDK_TARGET}" + ;; + x86_64) + echo "x86_64-linux-android${NDK_TARGET}" + ;; + esac } function get_arch_specific_ldflags() { - case ${ARCH} in - armeabi-v7a) - echo "-march=armv7-a -mfpu=neon -mfloat-abi=softfp -Wl,--fix-cortex-a8" - ;; - arm64-v8a) - echo "-march=armv8-a" - ;; - x86) - echo "-march=i686" - ;; - x86_64) - echo "-march=x86-64" - ;; - esac + case ${ARCH} in + armeabi-v7a) + echo "-march=armv7-a -mfpu=neon -mfloat-abi=softfp -Wl,--fix-cortex-a8" + ;; + arm64-v8a) + echo "-march=armv8-a" + ;; + x86) + echo "-march=i686" + ;; + x86_64) + echo "-march=x86-64" + ;; + esac } function set_toolchain_clang_paths { - TOOLCHAIN=$(get_toolchain) + TOOLCHAIN=$(get_toolchain) - common_run export PATH=$PATH:${ANDROID_NDK}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin - AR=llvm-ar - NM=llvm-nm - RANLIB=llvm-ranlib - STRIP=llvm-strip - CC=$(get_clang_target_host)-clang - CXX=$(get_clang_target_host)-clang++ + common_run export PATH=$PATH:${ANDROID_NDK}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin + AR=llvm-ar + NM=llvm-nm + RANLIB=llvm-ranlib + STRIP=llvm-strip + CC=$(get_clang_target_host)-clang + CXX=$(get_clang_target_host)-clang++ - case ${ARCH} in - arm64-v8a) - common_run export ac_cv_c_bigendian=no - ;; - esac + case ${ARCH} in + arm64-v8a) + common_run export ac_cv_c_bigendian=no + ;; + esac } function build { - echo "Building FFmpeg architecture $1..." - BASE=$(pwd) - common_run cd $BUILD_SRC + echo "Building FFmpeg architecture $1..." + BASE=$(pwd) + common_run cd $BUILD_SRC - BUILD_HOST=$(get_build_host) - set_toolchain_clang_paths - LDFLAGS=$(get_arch_specific_ldflags) + BUILD_HOST=$(get_build_host) + set_toolchain_clang_paths + LDFLAGS=$(get_arch_specific_ldflags) - CARCH=$TARGET_ARCH - if [ "$CARCH" == "x86_64" ]; then - CARCH="x86-64" - fi - PATH=$ANDROID_NDK:$PATH - common_run ./configure \ - --cross-prefix="${BUILD_HOST}-" \ - --sysroot="${ANDROID_NDK}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \ - --arch="${CARCH}" \ - --cpu="${TARGET_CPU}" \ - --cc="${CC}" \ - --cxx="${CXX}" \ - --ar="${AR}" \ - --nm="${NM}" \ - --ranlib="${RANLIB}" \ - --strip="${STRIP}" \ - --extra-ldflags="${LDFLAGS}" \ - --prefix="${BUILD_DST}/${ARCH}" \ - --pkg-config="${HOST_PKG_CONFIG_PATH}" \ - --target-os=android \ - ${ARCH_OPTIONS} \ - --enable-cross-compile \ - --enable-pic \ - --enable-lto \ - --enable-jni \ - --enable-mediacodec \ - --enable-shared \ - --disable-vulkan \ - --disable-stripping \ - --disable-programs \ - --disable-doc \ - --disable-avdevice \ - --disable-avfilter \ - --disable-avformat \ - --disable-everything \ - --enable-encoder=aac \ - --enable-encoder=libfdk_aac \ - --enable-encoder=libgsm \ - --enable-encoder=libgsm_ms \ - --enable-encoder=libopenh264 \ - --enable-encoder=libopus \ - --enable-encoder=pcm_alaw \ - --enable-encoder=pcm_mulaw \ - --enable-encoder=pcm_s16le \ - --enable-encoder=pcm_u16le \ - --enable-encoder=h264 \ - --enable-encoder=h264_omx \ - --enable-encoder=h264_mediacodec \ - --enable-encoder=h264_vulkan \ - --enable-decoder=aac \ - --enable-decoder=aac_mediacodec \ - --enable-decoder=adpcm_g722 \ - --enable-decoder=adpcm_g726 \ - --enable-decoder=adpcm_g726le \ - --enable-decoder=gsm \ - --enable-decoder=gsm_ms \ - --enable-decoder=mp3 \ - --enable-decoder=mp3_mediacodec \ - --enable-decoder=h264 \ - --enable-decoder=h264_mediacodec \ - --enable-decoder=libopus \ - --enable-decoder=pcm_alaw \ - --enable-decoder=pcm_mulaw \ - --enable-decoder=pcm_s16le \ - --enable-decoder=pcm_u16le + CARCH=$TARGET_ARCH + if [ "$CARCH" == "x86_64" ]; then + CARCH="x86-64" + fi + PATH=$ANDROID_NDK:$PATH + common_run ./configure \ + --cross-prefix="${BUILD_HOST}-" \ + --sysroot="${ANDROID_NDK}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \ + --arch="${CARCH}" \ + --cpu="${TARGET_CPU}" \ + --cc="${CC}" \ + --cxx="${CXX}" \ + --ar="${AR}" \ + --nm="${NM}" \ + --ranlib="${RANLIB}" \ + --strip="${STRIP}" \ + --extra-ldflags="${LDFLAGS}" \ + --prefix="${BUILD_DST}/${ARCH}" \ + --pkg-config="${HOST_PKG_CONFIG_PATH}" \ + --target-os=android \ + ${ARCH_OPTIONS} \ + --enable-cross-compile \ + --enable-pic \ + --enable-lto \ + --enable-jni \ + --enable-mediacodec \ + --enable-shared \ + --disable-vulkan \ + --disable-stripping \ + --disable-programs \ + --disable-doc \ + --disable-avdevice \ + --disable-avfilter \ + --disable-avformat \ + --disable-everything \ + --enable-encoder=aac \ + --enable-encoder=libfdk_aac \ + --enable-encoder=libgsm \ + --enable-encoder=libgsm_ms \ + --enable-encoder=libopenh264 \ + --enable-encoder=libopus \ + --enable-encoder=pcm_alaw \ + --enable-encoder=pcm_mulaw \ + --enable-encoder=pcm_s16le \ + --enable-encoder=pcm_u16le \ + --enable-encoder=h264 \ + --enable-encoder=h264_omx \ + --enable-encoder=h264_mediacodec \ + --enable-encoder=h264_vulkan \ + --enable-decoder=aac \ + --enable-decoder=aac_mediacodec \ + --enable-decoder=adpcm_g722 \ + --enable-decoder=adpcm_g726 \ + --enable-decoder=adpcm_g726le \ + --enable-decoder=gsm \ + --enable-decoder=gsm_ms \ + --enable-decoder=mp3 \ + --enable-decoder=mp3_mediacodec \ + --enable-decoder=h264 \ + --enable-decoder=h264_mediacodec \ + --enable-decoder=libopus \ + --enable-decoder=pcm_alaw \ + --enable-decoder=pcm_mulaw \ + --enable-decoder=pcm_s16le \ + --enable-decoder=pcm_u16le - common_run make clean - common_run make -j - common_run make install + common_run make clean + common_run make -j + common_run make install } # Run the main program. common_parse_arguments $@ common_update $SCM_URL $SCM_TAG $BUILD_SRC $SCM_HASH -HOST_PKG_CONFIG_PATH=`command -v pkg-config` +HOST_PKG_CONFIG_PATH=$(command -v pkg-config) if [ -z ${HOST_PKG_CONFIG_PATH} ]; then - echo "(*) pkg-config command not found\n" - exit 1 + echo "(*) pkg-config command not found\n" + exit 1 fi +for ARCH in $BUILD_ARCH; do + case ${ARCH} in + armeabi-v7a) + TARGET_CPU="armv7-a" + TARGET_ARCH="armv7-a" + ARCH_OPTIONS=" --enable-neon --enable-asm --enable-inline-asm" + ;; + arm64-v8a) + TARGET_CPU="armv8-a" + TARGET_ARCH="aarch64" + ARCH_OPTIONS=" --enable-neon --enable-asm --enable-inline-asm" + ;; + x86) + TARGET_CPU="i686" + TARGET_ARCH="i686" -for ARCH in $BUILD_ARCH -do - case ${ARCH} in - armeabi-v7a) - TARGET_CPU="armv7-a" - TARGET_ARCH="armv7-a" - ARCH_OPTIONS=" --enable-neon --enable-asm --enable-inline-asm" - ;; - arm64-v8a) - TARGET_CPU="armv8-a" - TARGET_ARCH="aarch64" - ARCH_OPTIONS=" --enable-neon --enable-asm --enable-inline-asm" - ;; - x86) - TARGET_CPU="i686" - TARGET_ARCH="i686" + # asm disabled due to this ticker https://trac.ffmpeg.org/ticket/4928 + ARCH_OPTIONS=" --disable-neon --disable-asm --disable-inline-asm" + ;; + x86_64) + TARGET_CPU="x86_64" + TARGET_ARCH="x86_64" + ARCH_OPTIONS=" --disable-neon --enable-asm --enable-inline-asm" + ;; + esac - # asm disabled due to this ticker https://trac.ffmpeg.org/ticket/4928 - ARCH_OPTIONS=" --disable-neon --disable-asm --disable-inline-asm" - ;; - x86_64) - TARGET_CPU="x86_64" - TARGET_ARCH="x86_64" - ARCH_OPTIONS=" --disable-neon --enable-asm --enable-inline-asm" - ;; - esac + build + common_run cp -L $BUILD_DST/$ARCH/lib/*.so $BUILD_DST/$ARCH/ - build - common_run cp -L $BUILD_DST/$ARCH/lib/*.so $BUILD_DST/$ARCH/ - - common_run export PATH=$OLD_PATH + common_run export PATH=$OLD_PATH done diff --git a/scripts/android-build-freerdp.sh b/scripts/android-build-freerdp.sh index 18c1b992e..69874999e 100755 --- a/scripts/android-build-freerdp.sh +++ b/scripts/android-build-freerdp.sh @@ -28,74 +28,70 @@ source $SCRIPT_PATH/android-build.conf # Parse arguments. REMAINING="" -while [[ $# > 0 ]] -do - key="$1" - case $key in - --freerdp-src) - SRC_DIR="$2" - shift - ;; - --openh264) - WITH_OPENH264=1 - shift - ;; - --openh264-ndk) - shift - ANDROID_NDK_OPENH264=$1 - shift - ;; - --ffmpeg) - WITH_FFMPEG=1 - shift - ;; - --cjson) - WITH_AAD=1 - shift - ;; - --openssl) - WITH_OPENSSL=1 - shift - ;; - --debug) - CMAKE_BUILD_TYPE=Debug - shift - ;; - --release) - CMAKE_BUILD_TYPE=Release - shift - ;; - --relWithDebug) - CMAKE_BUILD_TYPE=RelWithDebug - shift - ;; - --build-deps) - BUILD_DEPS=1 - shift - ;; - *) - REMAINING="$REMAINING $key" - shift - ;; - esac +while [[ $# > 0 ]]; do + key="$1" + case $key in + --freerdp-src) + SRC_DIR="$2" + shift + ;; + --openh264) + WITH_OPENH264=1 + shift + ;; + --openh264-ndk) + shift + ANDROID_NDK_OPENH264=$1 + shift + ;; + --ffmpeg) + WITH_FFMPEG=1 + shift + ;; + --cjson) + WITH_AAD=1 + shift + ;; + --openssl) + WITH_OPENSSL=1 + shift + ;; + --debug) + CMAKE_BUILD_TYPE=Debug + shift + ;; + --release) + CMAKE_BUILD_TYPE=Release + shift + ;; + --relWithDebug) + CMAKE_BUILD_TYPE=RelWithDebug + shift + ;; + --build-deps) + BUILD_DEPS=1 + shift + ;; + *) + REMAINING="$REMAINING $key" + shift + ;; + esac done common_parse_arguments $REMAINING -if [ -z ${WITH_MEDIACODEC+x} ]; -then - common_run echo "WITH_MEDIACODEC unset, defining WITH_MEDIACODEC=1" - WITH_MEDIACODEC=1 +if [ -z ${WITH_MEDIACODEC+x} ]; then + common_run echo "WITH_MEDIACODEC unset, defining WITH_MEDIACODEC=1" + WITH_MEDIACODEC=1 fi # clean up top -if [ -d $BUILD_SRC ]; -then - common_clean $BUILD_SRC +if [ -d $BUILD_SRC ]; then + common_clean $BUILD_SRC fi -if [ -d $BUILD_DST ]; -then - common_run mkdir -p $BUILD_DST +if [ -d $BUILD_DST ]; then + common_run mkdir -p $BUILD_DST fi # Prepare the environment @@ -115,105 +111,93 @@ CMAKE_CMD_ARGS="-DANDROID_NDK=$ANDROID_NDK \ -DCMAKE_MAKE_PROGRAM=make" BASE=$(pwd) -for ARCH in $BUILD_ARCH -do - # build dependencies. - if [ $WITH_OPENH264 -ne 0 ]; - then - if [ -z "$ANDROID_NDK_OPENH264" ] - then - echo - echo "Warning: Missing openh264-ndk, using $ANDROID_NDK" >&2 - echo - ANDROID_NDK_OPENH264=$ANDROID_NDK - fi - if [ $BUILD_DEPS -ne 0 ]; - then - common_run bash $SCRIPT_PATH/android-build-openh264.sh \ - --src $BUILD_SRC/openh264 --dst $BUILD_DST \ - --sdk "$ANDROID_SDK" \ - --ndk "$ANDROID_NDK_OPENH264" \ - --arch $ARCH \ - --target $NDK_TARGET \ - --tag $OPENH264_TAG \ - --hash $OPENH264_HASH - fi - CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_OPENH264=ON" - else - CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_OPENH264=OFF" - fi +for ARCH in $BUILD_ARCH; do + # build dependencies. + if [ $WITH_OPENH264 -ne 0 ]; then + if [ -z "$ANDROID_NDK_OPENH264" ]; then + echo + echo "Warning: Missing openh264-ndk, using $ANDROID_NDK" >&2 + echo + ANDROID_NDK_OPENH264=$ANDROID_NDK + fi + if [ $BUILD_DEPS -ne 0 ]; then + common_run bash $SCRIPT_PATH/android-build-openh264.sh \ + --src $BUILD_SRC/openh264 --dst $BUILD_DST \ + --sdk "$ANDROID_SDK" \ + --ndk "$ANDROID_NDK_OPENH264" \ + --arch $ARCH \ + --target $NDK_TARGET \ + --tag $OPENH264_TAG \ + --hash $OPENH264_HASH + fi + CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_OPENH264=ON" + else + CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_OPENH264=OFF" + fi - if [ $WITH_MEDIACODEC -ne 0 ]; - then - CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_MEDIACODEC=ON" - else - CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_MEDIACODEC=OFF" - fi + if [ $WITH_MEDIACODEC -ne 0 ]; then + CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_MEDIACODEC=ON" + else + CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_MEDIACODEC=OFF" + fi - if [ $WITH_FFMPEG -ne 0 ]; - then - if [ $BUILD_DEPS -ne 0 ]; - then - common_run bash $SCRIPT_PATH/android-build-ffmpeg.sh \ - --src $BUILD_SRC/ffmpeg --dst $BUILD_DST \ - --sdk "$ANDROID_SDK" \ - --ndk "$ANDROID_NDK" \ - --arch $ARCH \ - --target $NDK_TARGET \ - --tag $FFMPEG_TAG \ - --hash $FFMPEG_HASH - fi - CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_FFMPEG=ON -DWITH_SWCALE=ON" - else - CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_FFMPEG=OFF -DWITH_SWSCALE=OFF" - fi - if [ $WITH_AAD -ne 0 ]; - then - if [ $BUILD_DEPS -ne 0 ]; - then - common_run bash $SCRIPT_PATH/android-build-cjson.sh \ - --src $BUILD_SRC/cjson --dst $BUILD_DST \ - --sdk "$ANDROID_SDK" \ - --ndk "$ANDROID_NDK" \ - --arch $ARCH \ - --target $NDK_TARGET \ - --tag $CJSON_TAG \ - --hash $CJSON_HASH - fi - fi - if [ $WITH_OPENSSL -ne 0 ]; - then - if [ $BUILD_DEPS -ne 0 ]; - then - common_run bash $SCRIPT_PATH/android-build-openssl.sh \ - --src $BUILD_SRC/openssl --dst $BUILD_DST \ - --sdk "$ANDROID_SDK" \ - --ndk $ANDROID_NDK \ - --arch $ARCH \ - --target $NDK_TARGET \ - --tag $OPENSSL_TAG \ - --hash $OPENSSL_HASH - fi - fi + if [ $WITH_FFMPEG -ne 0 ]; then + if [ $BUILD_DEPS -ne 0 ]; then + common_run bash $SCRIPT_PATH/android-build-ffmpeg.sh \ + --src $BUILD_SRC/ffmpeg --dst $BUILD_DST \ + --sdk "$ANDROID_SDK" \ + --ndk "$ANDROID_NDK" \ + --arch $ARCH \ + --target $NDK_TARGET \ + --tag $FFMPEG_TAG \ + --hash $FFMPEG_HASH + fi + CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_FFMPEG=ON -DWITH_SWCALE=ON" + else + CMAKE_CMD_ARGS="$CMAKE_CMD_ARGS -DWITH_FFMPEG=OFF -DWITH_SWSCALE=OFF" + fi + if [ $WITH_AAD -ne 0 ]; then + if [ $BUILD_DEPS -ne 0 ]; then + common_run bash $SCRIPT_PATH/android-build-cjson.sh \ + --src $BUILD_SRC/cjson --dst $BUILD_DST \ + --sdk "$ANDROID_SDK" \ + --ndk "$ANDROID_NDK" \ + --arch $ARCH \ + --target $NDK_TARGET \ + --tag $CJSON_TAG \ + --hash $CJSON_HASH + fi + fi + if [ $WITH_OPENSSL -ne 0 ]; then + if [ $BUILD_DEPS -ne 0 ]; then + common_run bash $SCRIPT_PATH/android-build-openssl.sh \ + --src $BUILD_SRC/openssl --dst $BUILD_DST \ + --sdk "$ANDROID_SDK" \ + --ndk $ANDROID_NDK \ + --arch $ARCH \ + --target $NDK_TARGET \ + --tag $OPENSSL_TAG \ + --hash $OPENSSL_HASH + fi + fi - # Build and install the library. - if [ $DEPS_ONLY -eq 0 ]; - then - common_run cd $BASE - common_run mkdir -p $BUILD_SRC/freerdp-build/$ARCH - common_run cd $BUILD_SRC/freerdp-build/$ARCH - common_run export ANDROID_NDK=$ANDROID_NDK - common_run $CMAKE_PROGRAM $CMAKE_CMD_ARGS \ - -DANDROID_ABI=$ARCH \ - -DCMAKE_INSTALL_PREFIX=$BUILD_DST/$ARCH \ - -DCMAKE_INSTALL_LIBDIR=. \ - -DCMAKE_PREFIX_PATH=$BUILD_DST/$ARCH \ - -DCMAKE_SHARED_LINKER_FLAGS="-L$BUILD_DST/$ARCH" \ - -DcJSON_DIR=$BUILD_DST/$ARCH/cmake/cJSON \ - $SRC_DIR - echo $(pwd) - common_run $CMAKE_PROGRAM --build . --target install - fi + # Build and install the library. + if [ $DEPS_ONLY -eq 0 ]; then + common_run cd $BASE + common_run mkdir -p $BUILD_SRC/freerdp-build/$ARCH + common_run cd $BUILD_SRC/freerdp-build/$ARCH + common_run export ANDROID_NDK=$ANDROID_NDK + common_run $CMAKE_PROGRAM $CMAKE_CMD_ARGS \ + -DANDROID_ABI=$ARCH \ + -DCMAKE_INSTALL_PREFIX=$BUILD_DST/$ARCH \ + -DCMAKE_INSTALL_LIBDIR=. \ + -DCMAKE_PREFIX_PATH=$BUILD_DST/$ARCH \ + -DCMAKE_SHARED_LINKER_FLAGS="-L$BUILD_DST/$ARCH" \ + -DcJSON_DIR=$BUILD_DST/$ARCH/cmake/cJSON \ + $SRC_DIR + echo $(pwd) + common_run $CMAKE_PROGRAM --build . --target install + fi done echo "Successfully build library for architectures $BUILD_ARCH" diff --git a/scripts/android-build-openh264.sh b/scripts/android-build-openh264.sh index 19f580eef..4808b52bd 100755 --- a/scripts/android-build-openh264.sh +++ b/scripts/android-build-openh264.sh @@ -6,59 +6,55 @@ SCM_HASH=94c8ca364db990047ec4ec3481b04ce0d791e62561ef5601443011bdc00825e3 source $(dirname "${BASH_SOURCE[0]}")/android-build-common.sh function build { - echo "Building architecture $1..." - BASE=$(pwd) - common_run cd $BUILD_SRC - PATH=$ANDROID_NDK:$PATH - MAKE="make LDFLAGS=-static-libstdc++ PATH=$PATH ENABLEPIC=Yes OS=android NDKROOT=$ANDROID_NDK NDK_TOOLCHAIN_VERSION=clang TARGET=android-$2 NDKLEVEL=$2 ARCH=$1 -j libraries" + echo "Building architecture $1..." + BASE=$(pwd) + common_run cd $BUILD_SRC + PATH=$ANDROID_NDK:$PATH + MAKE="make LDFLAGS=-static-libstdc++ PATH=$PATH ENABLEPIC=Yes OS=android NDKROOT=$ANDROID_NDK NDK_TOOLCHAIN_VERSION=clang TARGET=android-$2 NDKLEVEL=$2 ARCH=$1 -j libraries" - common_run export QUIET_AR="$CCACHE " - common_run export QUIET_ASM="$CCACHE " - common_run export QUIET_CC="$CCACHE " - common_run export QUIET_CCAR="$CCACHE " - common_run export QUIET_CXX="$CCACHE " + common_run export QUIET_AR="$CCACHE " + common_run export QUIET_ASM="$CCACHE " + common_run export QUIET_CC="$CCACHE " + common_run export QUIET_CCAR="$CCACHE " + common_run export QUIET_CXX="$CCACHE " - common_run $MAKE - # Install creates a non optimal directory layout, fix that - common_run $MAKE PREFIX=$BUILD_SRC/libs/$1 install - common_run cd $BASE + common_run $MAKE + # Install creates a non optimal directory layout, fix that + common_run $MAKE PREFIX=$BUILD_SRC/libs/$1 install + common_run cd $BASE } # Run the main program. common_parse_arguments $@ common_update $SCM_URL $SCM_TAG $BUILD_SRC $SCM_HASH +for ARCH in $BUILD_ARCH; do + case $ARCH in + "armeabi") + OARCH="arm" + ;; + "armeabi-v7a") + OARCH="arm" + ;; + "arm64-v8a") + OARCH="arm64" + ;; + *) + OARCH=$ARCH + ;; + esac -for ARCH in $BUILD_ARCH -do - case $ARCH in - "armeabi") - OARCH="arm" - ;; - "armeabi-v7a") - OARCH="arm" - ;; - "arm64-v8a") - OARCH="arm64" - ;; - *) - OARCH=$ARCH - ;; - esac + echo "$ARCH=$OARCH" - echo "$ARCH=$OARCH" + build $OARCH $NDK_TARGET - build $OARCH $NDK_TARGET + if [ ! -d $BUILD_DST/$ARCH/include ]; then + common_run mkdir -p $BUILD_DST/$ARCH/include + fi - if [ ! -d $BUILD_DST/$ARCH/include ]; - then - common_run mkdir -p $BUILD_DST/$ARCH/include - fi - - common_run cp -L -r $BUILD_SRC/libs/$OARCH/include/ $BUILD_DST/$ARCH/ - if [ ! -d $BUILD_DST/$ARCH ]; - then - common_run mkdir -p $BUILD_DST/$ARCH - fi - common_run cp -L $BUILD_SRC/libs/$OARCH/lib/*.so $BUILD_DST/$ARCH/ + common_run cp -L -r $BUILD_SRC/libs/$OARCH/include/ $BUILD_DST/$ARCH/ + if [ ! -d $BUILD_DST/$ARCH ]; then + common_run mkdir -p $BUILD_DST/$ARCH + fi + common_run cp -L $BUILD_SRC/libs/$OARCH/lib/*.so $BUILD_DST/$ARCH/ done diff --git a/scripts/android-build-openssl.sh b/scripts/android-build-openssl.sh index 99e163fb3..b5179b891 100755 --- a/scripts/android-build-openssl.sh +++ b/scripts/android-build-openssl.sh @@ -9,36 +9,34 @@ COMPILER=4.9 source $(dirname "${BASH_SOURCE[0]}")/android-build-common.sh function build { - if [ $# -ne 2 ]; - then - echo "Invalid arguments $@" - exit 1 - fi + if [ $# -ne 2 ]; then + echo "Invalid arguments $@" + exit 1 + fi - CONFIG=$1 - DST_PREFIX=$2 + CONFIG=$1 + DST_PREFIX=$2 - common_run export CC=clang - common_run export PATH=$(${SCRIPT_PATH}/toolchains_path.py --ndk ${ANDROID_NDK}):$ORG_PATH - common_run export ANDROID_NDK + common_run export CC=clang + common_run export PATH=$(${SCRIPT_PATH}/toolchains_path.py --ndk ${ANDROID_NDK}):$ORG_PATH + common_run export ANDROID_NDK - echo "CONFIG=$CONFIG" - echo "DST_PREFIX=$DST_PREFIX" - echo "PATH=$PATH" + echo "CONFIG=$CONFIG" + echo "DST_PREFIX=$DST_PREFIX" + echo "PATH=$PATH" - BASE=$(pwd) - DST_DIR=$BUILD_DST/$DST_PREFIX - common_run cd $BUILD_SRC - common_run ./Configure ${CONFIG} -D__ANDROID_API__=$NDK_TARGET - common_run make SHLIB_EXT=.so -j build_libs + BASE=$(pwd) + DST_DIR=$BUILD_DST/$DST_PREFIX + common_run cd $BUILD_SRC + common_run ./Configure ${CONFIG} -D__ANDROID_API__=$NDK_TARGET + common_run make SHLIB_EXT=.so -j build_libs - if [ ! -d $DST_DIR ]; - then - common_run mkdir -p $DST_DIR - fi + if [ ! -d $DST_DIR ]; then + common_run mkdir -p $DST_DIR + fi - common_run cp *.so $DST_DIR/ - common_run cd $BASE + common_run cp *.so $DST_DIR/ + common_run cd $BASE } # Run the main program. @@ -48,38 +46,36 @@ SCM_MOD_TAG=$SCM_TAG # Workaround for naming of OpenSSL releases changing with every major version case $SCM_TAG in OpenSSL_*) - SCM_MOD_TAG=${SCM_TAG//OpenSSL_/openssl-} - SCM_MOD_TAG=${SCM_MOD_TAG//_/.} + SCM_MOD_TAG=${SCM_TAG//OpenSSL_/openssl-} + SCM_MOD_TAG=${SCM_MOD_TAG//_/.} + ;; esac common_update "$SCM_URL/$SCM_TAG" $SCM_MOD_TAG $BUILD_SRC $SCM_HASH ORG_PATH=$PATH -for ARCH in $BUILD_ARCH -do +for ARCH in $BUILD_ARCH; do - case $ARCH in - "armeabi-v7a") - build "android-arm" "armeabi-v7a" - ;; - "x86") - build "android-x86" "x86" - ;; - "arm64-v8a") - build "android-arm64" "arm64-v8a" - ;; - "x86_64") - build "android-x86_64" "x86_64" - ;; - *) - echo "[WARNING] Skipping unsupported architecture $ARCH" - continue - ;; - esac + case $ARCH in + "armeabi-v7a") + build "android-arm" "armeabi-v7a" + ;; + "x86") + build "android-x86" "x86" + ;; + "arm64-v8a") + build "android-arm64" "arm64-v8a" + ;; + "x86_64") + build "android-x86_64" "x86_64" + ;; + *) + echo "[WARNING] Skipping unsupported architecture $ARCH" + continue + ;; + esac done -if [ ! -d $BUILD_DST/$ARCH/include ]; -then - common_run mkdir -p $BUILD_DST/$ARCH/include +if [ ! -d $BUILD_DST/$ARCH/include ]; then + common_run mkdir -p $BUILD_DST/$ARCH/include fi common_run cp -L -R $BUILD_SRC/include/openssl $BUILD_DST/$ARCH/include/ - diff --git a/scripts/bundle-mac-os.sh b/scripts/bundle-mac-os.sh index c4e720076..2e0722094 100755 --- a/scripts/bundle-mac-os.sh +++ b/scripts/bundle-mac-os.sh @@ -1,5 +1,5 @@ #!/bin/bash -xe -SCRIPT_PATH="$(dirname -- "${BASH_SOURCE[0]}")" # relative +SCRIPT_PATH="$(dirname -- "${BASH_SOURCE[0]}")" # relative SCRIPT_PATH="$(cd -- "$SCRIPT_PATH" && pwd)" # absolutized and normalized BASE=$(pwd) @@ -14,7 +14,7 @@ DATADIR=Resources DEPLOYMENT_ARCH='arm64 x86_64' DEPLOYMENT_TARGET=12 -usage () { +usage() { echo "${BASH_SOURCE[0]} [-a|--arch 'arch1 arch2 ...'] [-t|--target target][-h|--help]" echo "" echo "default options:" @@ -23,100 +23,90 @@ usage () { } check_tools() { - for TOOL in mkdir rm mv git dirname pwd find cut basename grep xargs cmake ninja autoconf automake aclocal autoheader glibtoolize lipo otool install_name_tool; - do - set +e - TOOL_PATH=$(which "$TOOL") - set -e - echo "$TOOL: $TOOL_PATH" + for TOOL in mkdir rm mv git dirname pwd find cut basename grep xargs cmake ninja autoconf automake aclocal autoheader glibtoolize lipo otool install_name_tool; do + set +e + TOOL_PATH=$(which "$TOOL") + set -e + echo "$TOOL: $TOOL_PATH" - if [ ! -f "$TOOL_PATH" ]; - then - echo "Missing $TOOL! please install and add to PATH." - exit 1 - fi - done + if [ ! -f "$TOOL_PATH" ]; then + echo "Missing $TOOL! please install and add to PATH." + exit 1 + fi + done } while [[ $# -gt 0 ]]; do case $1 in - -a|--arch) - DEPLOYMENT_ARCH="$2" - shift # past argument - shift # past value - ;; - -t|--target) - DEPLOYMENT_TARGET="$2" - shift # past argument - shift # past value - ;; - -t|--target) - usage - exit 0 - ;; - -*|--*) - usage - exit 1 - ;; - *) - usage - exit 1 - ;; + -a | --arch) + DEPLOYMENT_ARCH="$2" + shift # past argument + shift # past value + ;; + -t | --target) + DEPLOYMENT_TARGET="$2" + shift # past argument + shift # past value + ;; + -t | --target) + usage + exit 0 + ;; + -* | --*) + usage + exit 1 + ;; + *) + usage + exit 1 + ;; esac done check_tools fix_rpath() { - SEARCH_PATH=$1 - FIX_PATH=$1 - EXT=".dylib" - if [ "$#" -gt 1 ]; - then - FIX_PATH=$2 - fi - if [ "$#" -gt 2 ]; - then - EXT=$3 - fi + SEARCH_PATH=$1 + FIX_PATH=$1 + EXT=".dylib" + if [ "$#" -gt 1 ]; then + FIX_PATH=$2 + fi + if [ "$#" -gt 2 ]; then + EXT=$3 + fi # some build systems do not handle @rpath on mac os correctly. # do check that and fix it. DYLIB_ABS_NAMES=$(find $SEARCH_PATH -type f -name "*$EXT") - for DYLIB_ABS in $DYLIB_ABS_NAMES; - do - DYLIB_NAME=$(basename $DYLIB_ABS) - install_name_tool -id @rpath/$DYLIB_NAME $DYLIB_ABS + for DYLIB_ABS in $DYLIB_ABS_NAMES; do + DYLIB_NAME=$(basename $DYLIB_ABS) + install_name_tool -id @rpath/$DYLIB_NAME $DYLIB_ABS - for DYLIB_DEP in $(otool -L $DYLIB_ABS | grep "$FIX_PATH" | cut -d' ' -f1); - do - if [[ $DYLIB_DEP == $DYLIB_ABS ]]; - then - continue - elif [[ $DYLIB_DEP == $FIX_PATH/* ]]; - then - DEP_BASE=$(basename $DYLIB_DEP) - install_name_tool -change $DYLIB_DEP @rpath/$DEP_BASE $DYLIB_ABS - fi - done + for DYLIB_DEP in $(otool -L $DYLIB_ABS | grep "$FIX_PATH" | cut -d' ' -f1); do + if [[ $DYLIB_DEP == $DYLIB_ABS ]]; then + continue + elif [[ $DYLIB_DEP == $FIX_PATH/* ]]; then + DEP_BASE=$(basename $DYLIB_DEP) + install_name_tool -change $DYLIB_DEP @rpath/$DEP_BASE $DYLIB_ABS + fi + done done } replace_rpath() { - FILE=$1 - for PTH in $(otool -l $FILE | grep -A2 LC_RPATH | grep path | xargs -J ' ' | cut -d ' ' -f2); - do - install_name_tool -delete_rpath $PTH $FILE - done - install_name_tool -add_rpath @loader_path/../$LIBDIR $FILE + FILE=$1 + for PTH in $(otool -l $FILE | grep -A2 LC_RPATH | grep path | xargs -J ' ' | cut -d ' ' -f2); do + install_name_tool -delete_rpath $PTH $FILE + done + install_name_tool -add_rpath @loader_path/../$LIBDIR $FILE } CMAKE_ARCHS= OSSL_FLAGS="-mmacosx-version-min=$DEPLOYMENT_TARGET -I$INSTALL/include -L$INSTALL/lib" -for ARCH in $DEPLOYMENT_ARCH; -do - OSSL_FLAGS="$OSSL_FLAGS -arch $ARCH" - CMAKE_ARCHS="$ARCH;$CMAKE_ARCHS" +for ARCH in $DEPLOYMENT_ARCH; do + OSSL_FLAGS="$OSSL_FLAGS -arch $ARCH" + CMAKE_ARCHS="$ARCH;$CMAKE_ARCHS" done echo "build arch [$DEPLOYMENT_ARCH]" @@ -140,36 +130,33 @@ CMAKE_ARGS="-DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON \ -DCMAKE_IGNORE_PREFIX_PATH='/opt/local;/usr/local;/opt/homebrew;/Library;~/Library' " -if [ ! -d $SRC ]; -then - mkdir -p $SRC - cd $SRC - git clone --depth 1 -b openssl-3.3.1 https://github.com/openssl/openssl.git - git clone --depth 1 -b v1.3.1 https://github.com/madler/zlib.git - git clone --depth 1 -b uriparser-0.9.8 https://github.com/uriparser/uriparser.git - git clone --depth 1 -b v1.7.18 https://github.com/DaveGamble/cJSON.git - git clone --depth 1 -b release-2.30.4 https://github.com/libsdl-org/SDL.git - git clone --depth 1 --shallow-submodules --recurse-submodules -b release-2.22.0 https://github.com/libsdl-org/SDL_ttf.git - git clone --depth 1 --shallow-submodules --recurse-submodules -b release-2.8.2 https://github.com/libsdl-org/SDL_image.git - git clone --depth 1 --shallow-submodules --recurse-submodules -b v1.0.27-1 https://github.com/libusb/libusb-cmake.git - git clone --depth 1 -b n7.0.1 https://github.com/FFmpeg/FFmpeg.git - git clone --depth 1 -b v2.4.1 https://github.com/cisco/openh264.git - git clone --depth 1 -b v1.5.2 https://gitlab.xiph.org/xiph/opus.git - git clone --depth 1 -b 2.11.1 https://github.com/knik0/faad2.git - git clone --depth 1 -b 1.18.0 https://gitlab.freedesktop.org/cairo/cairo.git - git clone --depth 1 -b 1_30 https://github.com/knik0/faac.git - cd faac - ./bootstrap +if [ ! -d $SRC ]; then + mkdir -p $SRC + cd $SRC + git clone --depth 1 -b openssl-3.3.1 https://github.com/openssl/openssl.git + git clone --depth 1 -b v1.3.1 https://github.com/madler/zlib.git + git clone --depth 1 -b uriparser-0.9.8 https://github.com/uriparser/uriparser.git + git clone --depth 1 -b v1.7.18 https://github.com/DaveGamble/cJSON.git + git clone --depth 1 -b release-2.30.4 https://github.com/libsdl-org/SDL.git + git clone --depth 1 --shallow-submodules --recurse-submodules -b release-2.22.0 https://github.com/libsdl-org/SDL_ttf.git + git clone --depth 1 --shallow-submodules --recurse-submodules -b release-2.8.2 https://github.com/libsdl-org/SDL_image.git + git clone --depth 1 --shallow-submodules --recurse-submodules -b v1.0.27-1 https://github.com/libusb/libusb-cmake.git + git clone --depth 1 -b n7.0.1 https://github.com/FFmpeg/FFmpeg.git + git clone --depth 1 -b v2.4.1 https://github.com/cisco/openh264.git + git clone --depth 1 -b v1.5.2 https://gitlab.xiph.org/xiph/opus.git + git clone --depth 1 -b 2.11.1 https://github.com/knik0/faad2.git + git clone --depth 1 -b 1.18.0 https://gitlab.freedesktop.org/cairo/cairo.git + git clone --depth 1 -b 1_30 https://github.com/knik0/faac.git + cd faac + ./bootstrap fi -if [ -d $INSTALL ]; -then - rm -rf $INSTALL +if [ -d $INSTALL ]; then + rm -rf $INSTALL fi -if [ -d $BUILD ]; -then - rm -rf $BUILD +if [ -d $BUILD ]; then + rm -rf $BUILD fi mkdir -p $BUILD @@ -180,7 +167,7 @@ cmake --build zlib cmake --install zlib cmake -GNinja -Buriparser -S$SRC/uriparser $CMAKE_ARGS -DURIPARSER_BUILD_DOCS=OFF -DURIPARSER_BUILD_TESTS=OFF \ - -DURIPARSER_BUILD_TOOLS=OFF + -DURIPARSER_BUILD_TOOLS=OFF cmake --build uriparser cmake --install uriparser @@ -201,7 +188,7 @@ cmake --build SDL cmake --install SDL cmake -GNinja -BSDL_ttf -S$SRC/SDL_ttf $CMAKE_ARGS -DSDL2TTF_HARFBUZZ=ON -DSDL2TTF_FREETYPE=ON -DSDL2TTF_VENDORED=ON \ - -DFT_DISABLE_ZLIB=OFF -DSDL2TTF_SAMPLES=OFF + -DFT_DISABLE_ZLIB=OFF -DSDL2TTF_SAMPLES=OFF cmake --build SDL_ttf cmake --install SDL_ttf @@ -210,7 +197,7 @@ cmake --build SDL_image cmake --install SDL_image cmake -GNinja -Blibusb-cmake -S$SRC/libusb-cmake $CMAKE_ARGS -DLIBUSB_BUILD_EXAMPLES=OFF -DLIBUSB_BUILD_TESTING=OFF \ - -DLIBUSB_ENABLE_DEBUG_LOGGING=OFF -DLIBUSB_BUILD_SHARED_LIBS=ON + -DLIBUSB_ENABLE_DEBUG_LOGGING=OFF -DLIBUSB_BUILD_SHARED_LIBS=ON cmake --build libusb-cmake cmake --install libusb-cmake @@ -226,29 +213,28 @@ mkdir -p faac cd faac # undefine __SSE2__, symbol clashes with universal build CFLAGS="$OSSL_FLAGS -U__SSE2__" LDFLAGS=$OSSL_FLAGS $SRC/faac/configure --prefix=$INSTALL --libdir="$INSTALL/lib" \ - --enable-shared --disable-static + --enable-shared --disable-static CFLAGS="$OSSL_FLAGS -U__SSE2__" LDFLAGS=$OSSL_FLAGS make -j CFLAGS="$OSSL_FLAGS -U__SSE2__" LDFLAGS=$OSSL_FLAGS make -j install cd $BUILD meson setup --prefix="$INSTALL" -Doptimization=3 -Db_lto=true -Db_pie=true -Dc_args="$OSSL_FLAGS" -Dc_link_args="$OSSL_FLAGS" \ - -Dcpp_args="$OSSL_FLAGS" -Dcpp_link_args="$OSSL_FLAGS" -Dpkgconfig.relocatable=true -Dtests=disabled \ - -Dlibdir=lib openh264 $SRC/openh264 + -Dcpp_args="$OSSL_FLAGS" -Dcpp_link_args="$OSSL_FLAGS" -Dpkgconfig.relocatable=true -Dtests=disabled \ + -Dlibdir=lib openh264 $SRC/openh264 ninja -C openh264 install -for ARCH in $DEPLOYMENT_ARCH; -do - mkdir -p $BUILD/FFmpeg/$ARCH - cd $BUILD/FFmpeg/$ARCH - FFCFLAGS="-arch $ARCH -mmacosx-version-min=$DEPLOYMENT_TARGET" - FINSTPATH=$BUILD/FFmpeg/install/$ARCH - CFLAGS=$FFCFLAGS LDFLAGS=$FFCFLAGS $SRC/FFmpeg/configure --prefix=$FINSTPATH --disable-all \ - --enable-shared --disable-static --enable-swscale --disable-asm --disable-libxcb \ - --disable-securetransport --disable-xlib --enable-cross-compile - CFLAGS=$FFCFLAGS LDFLAGS=$FFCFLAGS make -j - CFLAGS=$FFCFLAGS LDFLAGS=$FFCFLAGS make -j install - fix_rpath "$FINSTPATH/lib" +for ARCH in $DEPLOYMENT_ARCH; do + mkdir -p $BUILD/FFmpeg/$ARCH + cd $BUILD/FFmpeg/$ARCH + FFCFLAGS="-arch $ARCH -mmacosx-version-min=$DEPLOYMENT_TARGET" + FINSTPATH=$BUILD/FFmpeg/install/$ARCH + CFLAGS=$FFCFLAGS LDFLAGS=$FFCFLAGS $SRC/FFmpeg/configure --prefix=$FINSTPATH --disable-all \ + --enable-shared --disable-static --enable-swscale --disable-asm --disable-libxcb \ + --disable-securetransport --disable-xlib --enable-cross-compile + CFLAGS=$FFCFLAGS LDFLAGS=$FFCFLAGS make -j + CFLAGS=$FFCFLAGS LDFLAGS=$FFCFLAGS make -j install + fix_rpath "$FINSTPATH/lib" done BASE_ARCH="${DEPLOYMENT_ARCH%% *}" @@ -259,37 +245,36 @@ find lib -type l -exec cp -P {} $INSTALL/lib/ \; BASE_LIBS=$(find lib -type f -name "*.dylib" -exec basename {} \;) cd $BUILD/FFmpeg/install -for LIB in $BASE_LIBS; -do - LIBS=$(find . -name $LIB) - lipo $LIBS -output $INSTALL/lib/$LIB -create +for LIB in $BASE_LIBS; do + LIBS=$(find . -name $LIB) + lipo $LIBS -output $INSTALL/lib/$LIB -create done cd $BUILD cmake -GNinja -Bfreerdp -S"$SCRIPT_PATH/.." \ - $CMAKE_ARGS \ - -DWITH_PLATFORM_SERVER=OFF \ - -DWITH_SIMD=ON \ - -DWITH_FFMPEG=OFF \ - -DWITH_VERBOSE_WINPR_ASSERT=OFF \ - -DWITH_OPENH264=ON \ - -DWITH_SWSCALE=ON \ - -DWITH_OPUS=ON \ - -DWITH_WEBVIEW=OFF \ - -DWITH_FAAD2=ON \ - -DWITH_FAAC=ON \ - -DWITH_INTERNAL_RC4=ON \ - -DWITH_INTERNAL_MD4=ON \ - -DWITH_INTERNAL_MD5=ON \ - -DCHANNEL_RDPEAR=OFF \ - -DWITH_CJSON_REQUIRED=ON + $CMAKE_ARGS \ + -DWITH_PLATFORM_SERVER=OFF \ + -DWITH_SIMD=ON \ + -DWITH_FFMPEG=OFF \ + -DWITH_VERBOSE_WINPR_ASSERT=OFF \ + -DWITH_OPENH264=ON \ + -DWITH_SWSCALE=ON \ + -DWITH_OPUS=ON \ + -DWITH_WEBVIEW=OFF \ + -DWITH_FAAD2=ON \ + -DWITH_FAAC=ON \ + -DWITH_INTERNAL_RC4=ON \ + -DWITH_INTERNAL_MD4=ON \ + -DWITH_INTERNAL_MD5=ON \ + -DCHANNEL_RDPEAR=OFF \ + -DWITH_CJSON_REQUIRED=ON cmake --build freerdp cmake --install freerdp # remove unused stuff from bin -find "$INSTALL" -name "*.a" -exec rm -f {} \; -find "$INSTALL" -name "*.la" -exec rm -f {} \; +find "$INSTALL" -name "*.a" -exec rm -f {} \; +find "$INSTALL" -name "*.la" -exec rm -f {} \; find "$INSTALL" -name sdl2-config -exec rm -f {} \; fix_rpath "$INSTALL/lib" @@ -301,14 +286,12 @@ mv lib $LIBDIR mv bin $BINDIR # update RPATH -for LIB in $(find $LIBDIR -type f -name "*.dylib"); -do - replace_rpath $LIB +for LIB in $(find $LIBDIR -type f -name "*.dylib"); do + replace_rpath $LIB done -for BIN in $(find $BINDIR -type f); -do - replace_rpath $BIN +for BIN in $(find $BINDIR -type f); do + replace_rpath $BIN done # clean up unused data diff --git a/scripts/cmake-format.sh b/scripts/cmake-format.sh index b6e997ea6..bec889bc8 100755 --- a/scripts/cmake-format.sh +++ b/scripts/cmake-format.sh @@ -6,38 +6,32 @@ SRC_PATH="${SCRIPT_PATH}/.." FORMAT_ARG="--check" REST_ARGS=$@ -if [ $# -ne 0 ] -then - if [ "$1" = "--help" ] || [ "$1" = "-h" ]; - then - echo "usage: $0 [options] [file, file, ...]" - echo "\t--check.-c ... run format check only, no files changed (default)" - echo "\t--format,-f ... format files in place" - echo "\t--help,-h ... print this help" +if [ $# -ne 0 ]; then + if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then + echo "usage: $0 [options] [file, file, ...]" + echo "\t--check.-c ... run format check only, no files changed (default)" + echo "\t--format,-f ... format files in place" + echo "\t--help,-h ... print this help" - exit 1 - fi + exit 1 + fi - if [ "$1" = "--check" ] || [ "$1" = "-c" ]; - then - FORMAT_ARG="--check" - REST_ARGS="${@:2}" - fi - if [ "$1" = "--format" ] || [ "$1" = "-f" ]; - then - FORMAT_ARG="-i" - REST_ARGS="${@:2}" - fi + if [ "$1" = "--check" ] || [ "$1" = "-c" ]; then + FORMAT_ARG="--check" + REST_ARGS="${@:2}" + fi + if [ "$1" = "--format" ] || [ "$1" = "-f" ]; then + FORMAT_ARG="-i" + REST_ARGS="${@:2}" + fi fi -if [ ! -n "$REST_ARGS" ]; -then - CMAKE_FILES=$(find ${SRC_PATH} -name "*.cmake" -o -name "CMakeLists.txt") - CMAKE_CI_FILES=$(find ${SRC_PATH}/ci -name "*.txt") +if [ ! -n "$REST_ARGS" ]; then + CMAKE_FILES=$(find ${SRC_PATH} -name "*.cmake" -o -name "CMakeLists.txt") + CMAKE_CI_FILES=$(find ${SRC_PATH}/ci -name "*.txt") fi -for FILE in $CMAKE_FILES $CMAKE_CI_FILES $REST_ARGS; -do - echo "processing file $FILE..." - cmake-format -c "$SCRIPT_PATH/cmake-format.yml" $FORMAT_ARG $FILE +for FILE in $CMAKE_FILES $CMAKE_CI_FILES $REST_ARGS; do + echo "processing file $FILE..." + cmake-format -c "$SCRIPT_PATH/cmake-format.yml" $FORMAT_ARG $FILE done diff --git a/scripts/codespell.sh b/scripts/codespell.sh index 0e72b96a3..3fcf78753 100755 --- a/scripts/codespell.sh +++ b/scripts/codespell.sh @@ -10,7 +10,7 @@ SCRIPT_PATH=$(realpath "$SCRIPT_PATH") # 3. Every word prefixed by e.g. '\tSome text', e.g. format string escapes codespell --version codespell \ - -I "$SCRIPT_PATH/codespell.ignore" \ - -S ".git,*.ai,*.svg,*.rtf,*/assets/de_*,*/res/values-*,*/protocols/xdg*,*/test/*" \ - --ignore-regex "\b[a-zA-Z][a-zA-Z]\b|\bp[A-Z].*|\\\\[a-z][a-zA-Z].*" \ - --count $SCRIPT_PATH/.. + -I "$SCRIPT_PATH/codespell.ignore" \ + -S ".git,*.ai,*.svg,*.rtf,*/assets/de_*,*/res/values-*,*/protocols/xdg*,*/test/*" \ + --ignore-regex "\b[a-zA-Z][a-zA-Z]\b|\bp[A-Z].*|\\\\[a-z][a-zA-Z].*" \ + --count $SCRIPT_PATH/.. diff --git a/scripts/create_release_tarball.sh b/scripts/create_release_tarball.sh index fffe954c7..13994984d 100755 --- a/scripts/create_release_tarball.sh +++ b/scripts/create_release_tarball.sh @@ -1,55 +1,56 @@ #!/bin/bash -e function run { - "$@" - RES=$? - if [[ $RES -ne 0 ]]; - then - echo "[ERROR] $@ returned $RES" >&2 - exit 1 - fi + "$@" + RES=$? + if [[ $RES -ne 0 ]]; then + echo "[ERROR] $@ returned $RES" >&2 + exit 1 + fi } -if [ -z ${TAG:-} ];then - echo "No TAG set - trying to detect" - TAG=$(git describe --tags) - echo "Is the TAG ${TAG} ok (YES|NO)?" - read answ - case "$answ" in - YES): - ;; - *) - echo 'stopping here' - exit 1 - esac +if [ -z ${TAG:-} ]; then + echo "No TAG set - trying to detect" + TAG=$(git describe --tags) + echo "Is the TAG ${TAG} ok (YES|NO)?" + read answ + case "$answ" in + YES) + : + ;; + *) + echo 'stopping here' + exit 1 + ;; + esac fi function create_hash { - NAME=$1 - run md5sum ${NAME} > ${NAME}.md5 - run sha1sum ${NAME} > ${NAME}.sha1 - run sha256sum ${NAME} > ${NAME}.sha256 - run sha512sum ${NAME} > ${NAME}.sha512 + NAME=$1 + run md5sum ${NAME} >${NAME}.md5 + run sha1sum ${NAME} >${NAME}.sha1 + run sha256sum ${NAME} >${NAME}.sha256 + run sha512sum ${NAME} >${NAME}.sha512 } function create_tar { - ARGS=$1 - EXT=$2 - TAG=$3 + ARGS=$1 + EXT=$2 + TAG=$3 - NAME=freerdp-${TAG}${EXT} - run tar $ARGS ${NAME} freerdp-${TAG} - create_hash ${NAME} + NAME=freerdp-${TAG}${EXT} + run tar $ARGS ${NAME} freerdp-${TAG} + create_hash ${NAME} } TMPDIR=$(mktemp -d -t release-${TAG}-XXXXXXXXXX) run git archive --prefix=freerdp-${TAG}/ --format=tar.gz -o ${TMPDIR}/freerdp-${TAG}.tar.gz ${TAG} run tar xzvf ${TMPDIR}/freerdp-${TAG}.tar.gz -C ${TMPDIR} -run echo ${TAG} > ${TMPDIR}/freerdp-${TAG}/.source_version +run echo ${TAG} >${TMPDIR}/freerdp-${TAG}/.source_version pushd . -cd $TMPDIR +cd $TMPDIR create_tar czf .tar.gz ${TAG} create_tar cvjSf .tar.bz2 ${TAG} create_tar cfJ .tar.xz ${TAG} @@ -60,9 +61,8 @@ create_hash ${ZIPNAME} popd # Sign the release tarballs -for EXT in tar.gz tar.bz2 tar.xz zip; -do - run gpg --local-user 0xA49454A3FC909FD5 --sign --armor --output ${TMPDIR}/freerdp-${TAG}.${EXT}.asc --detach-sig ${TMPDIR}/freerdp-${TAG}.${EXT} +for EXT in tar.gz tar.bz2 tar.xz zip; do + run gpg --local-user 0xA49454A3FC909FD5 --sign --armor --output ${TMPDIR}/freerdp-${TAG}.${EXT}.asc --detach-sig ${TMPDIR}/freerdp-${TAG}.${EXT} done run mv ${TMPDIR}/freerdp-${TAG}.tar* . @@ -70,9 +70,8 @@ run mv ${TMPDIR}/freerdp-${TAG}.zip* . run rm -rf ${TMPDIR} # Verify the release tarball signatures -for EXT in tar.gz tar.bz2 tar.xz zip; -do - run gpg --verify freerdp-${TAG}.${EXT}.asc +for EXT in tar.gz tar.bz2 tar.xz zip; do + run gpg --verify freerdp-${TAG}.${EXT}.asc done exit 0 diff --git a/scripts/xcode.sh b/scripts/xcode.sh index f86faa95a..9c94f8a31 100755 --- a/scripts/xcode.sh +++ b/scripts/xcode.sh @@ -16,59 +16,59 @@ BUILDTYPE=-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:Debug}" MANPAGES=-DWITH_MANPAGES="${WITHMANPAGES:NO}" # Run cmake for FreeRDP and MacFreeRDP -mkdir ${XCODE_PROJ_DIR} >/dev/null 2>&1 +mkdir ${XCODE_PROJ_DIR} >/dev/null 2>&1 pushd ${XCODE_PROJ_DIR} cmake ${BUILDTYPE} -G "$GEN" ${ARCH} ../ popd -mkdir ${CLIENT_MAC_DIR}/${XCODE_PROJ_DIR} >/dev/null 2>&1 +mkdir ${CLIENT_MAC_DIR}/${XCODE_PROJ_DIR} >/dev/null 2>&1 pushd ${CLIENT_MAC_DIR}/${XCODE_PROJ_DIR} cmake ${BUILDTYPE} -G "$GEN" ${ARCH} ../ popd # Check for errors; otherwise, ask for compile. if [ "$?" -ne 0 ]; then - echo "CMake failed. Please check error messages" - popd > /dev/null - exit + echo "CMake failed. Please check error messages" + popd >/dev/null + exit else - popd - while true - do - echo -n "Compile FreeRDP? (y or n) - (y recommended for MacFreeRDP compilation):" - read CONFIRM - case $CONFIRM in - y|Y|YES|yes|Yes) - pushd ./${XCODE_PROJ_DIR} - xcodebuild - popd - break ;; - n|N|no|NO|No) - echo OK - you entered $CONFIRM - break - ;; - *) echo Please enter only y or n - esac - done - - echo "SUCCESS!" - while true - do - echo -n "Open Xcode projects now? (y or n):" - read CONFIRM - case $CONFIRM in - y|Y|YES|yes|Yes) - open ${CLIENT_MAC_DIR}/${XCODE_PROJ_DIR}/MacFreeRDP.xcodeproj - open ./${XCODE_PROJ_DIR}/FreeRDP.xcodeproj - break ;; - n|N|no|NO|No) - echo OK - $CONFIRM - break - ;; - *) echo Please enter only y or n - esac - done + popd + while true; do + echo -n "Compile FreeRDP? (y or n) - (y recommended for MacFreeRDP compilation):" + read CONFIRM + case $CONFIRM in + y | Y | YES | yes | Yes) + pushd ./${XCODE_PROJ_DIR} + xcodebuild + popd + break + ;; + n | N | no | NO | No) + echo OK - you entered $CONFIRM + break + ;; + *) echo Please enter only y or n ;; + esac + done - echo -n "NOTE: Dragging FreeRDP project from finder onto the MacFreeRDP project in Xcode + echo "SUCCESS!" + while true; do + echo -n "Open Xcode projects now? (y or n):" + read CONFIRM + case $CONFIRM in + y | Y | YES | yes | Yes) + open ${CLIENT_MAC_DIR}/${XCODE_PROJ_DIR}/MacFreeRDP.xcodeproj + open ./${XCODE_PROJ_DIR}/FreeRDP.xcodeproj + break + ;; + n | N | no | NO | No) + echo OK - $CONFIRM + break + ;; + *) echo Please enter only y or n ;; + esac + done + + echo -n "NOTE: Dragging FreeRDP project from finder onto the MacFreeRDP project in Xcode will enable code stepping from MacFreeRDP into FreeRDP. " fi