diff --git a/build_tools/build_iOS.sh b/build_tools/build_iOS.sh index 9c868bcf2..da1884cab 100755 --- a/build_tools/build_iOS.sh +++ b/build_tools/build_iOS.sh @@ -61,7 +61,7 @@ function create_cmake_config(){ } #build to ffmpeg function build_shared_framework(){ - if [ -z "${LIB_NAME}" ];then + if [[ -z "${LIB_NAME}" ]];then export LIB_NAME=ffmpeg fi SRC_LIBRARIES="$(cd ./install/ffmpeg/iOS/fat/lib; ls)" @@ -84,7 +84,7 @@ function build_shared_framework(){ fi done - if [ -d "${DAV1D_EXTERNAL_DIR}/iOS/fat" ];then + if [[ -d "${DAV1D_EXTERNAL_DIR}/iOS/fat" ]];then SRC_LIBRARIES_DIR="$SRC_LIBRARIES_DIR ${DAV1D_EXTERNAL_DIR}/iOS/fat/lib" SRC_LIBRARIES="$SRC_LIBRARIES dav1d" fi @@ -98,7 +98,8 @@ function build_shared_framework(){ create_cmake_config - touch dummy.c + cp ${BUILD_TOOLS_DIR}/src/build_version.cpp ./ + sh ${BUILD_TOOLS_DIR}/gen_build_version.sh > version.h rm -rf Xcode/ mkdir -p Xcode/OS cd Xcode/OS diff --git a/build_tools/build_native.sh b/build_tools/build_native.sh index cac5d1c7f..e2ef18777 100755 --- a/build_tools/build_native.sh +++ b/build_tools/build_native.sh @@ -66,7 +66,8 @@ function build_shared_framework(){ create_cmake_config - touch dummy.c + cp ${BUILD_TOOLS_DIR}/src/build_version.cpp ./ + sh ${BUILD_TOOLS_DIR}/gen_build_version.sh > version.h rm -rf Xcode/ mkdir -p Xcode cd Xcode diff --git a/build_tools/common_build.sh b/build_tools/common_build.sh index 0c32d15e1..ab3e73ebe 100644 --- a/build_tools/common_build.sh +++ b/build_tools/common_build.sh @@ -214,8 +214,14 @@ function link_shared_lib_Android(){ ldflags="$ldflags -lx264 -L${X264_INSTALL_DIR}/lib/" fi - ${CROSS_COMPILE}-gcc -lm -lz -shared --sysroot=${SYSTEM_ROOT} -Wl,--no-undefined -Wl,-z,noexecstack ${CPU_LD_FLAGS} -landroid -llog -Wl,-soname,lib${LIB_NAME}.so \ + cp ${BUILD_TOOLS_DIR}/src/build_version.cpp ./ + sh ${BUILD_TOOLS_DIR}/gen_build_version.sh > version.h + + ${CROSS_COMPILE}-gcc build_version.cpp -lm -lz -shared --sysroot=${SYSTEM_ROOT} \ + -Wl,--no-undefined -Wl,-z,noexecstack ${CPU_LD_FLAGS} -landroid -llog -Wl,-soname,lib${LIB_NAME}.so \ ${objs} \ -o ${install_dir}/lib${LIB_NAME}.so \ -Wl,--whole-archive ${ldflags} -Wl,--no-whole-archive + + rm build_version.cpp version.h } diff --git a/build_tools/gen_build_version.sh b/build_tools/gen_build_version.sh new file mode 100755 index 000000000..94e03eba7 --- /dev/null +++ b/build_tools/gen_build_version.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +git_v=$(git describe --always) +time_v=$(date "+%Y%m%d_%H:%M:%S") + +out="#define build_version \"${time_v}_${git_v}\"" +echo "$out" diff --git a/build_tools/iOS/CMakeLists.txt b/build_tools/iOS/CMakeLists.txt index 2f46daaf8..c60bb0c8b 100644 --- a/build_tools/iOS/CMakeLists.txt +++ b/build_tools/iOS/CMakeLists.txt @@ -17,7 +17,7 @@ set(LIBRARYS ${SRC_LIBRARIES}) link_directories(${SRC_LIBRARIES_DIR}) add_library(${LIB_NAME} SHARED - dummy.c + build_version.cpp ) if (IOS) set_target_properties(${LIB_NAME} PROPERTIES diff --git a/build_tools/src/build_version.cpp b/build_tools/src/build_version.cpp new file mode 100644 index 000000000..0f7f4eb31 --- /dev/null +++ b/build_tools/src/build_version.cpp @@ -0,0 +1,23 @@ +// +// Created by moqi on 2020/3/20. +// +#include +#include "version.h" +#ifdef __ANDROID__ + #include +#endif + +static const char *get_external_build_version(); + +static const char *v = get_external_build_version(); + +static const char *get_external_build_version() +{ +#ifdef __ANDROID__ + __android_log_print(ANDROID_LOG_VERBOSE, "version", "external version is %s\n", build_version); +#else + printf("external version is %s\n", build_version); +#endif + return build_version; +} +