mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
1. Support cygwin by '--cygwin64=on' 2. Detect cygwin automatically. 3. Disalbe sanitizer, srt and srtp with openssl. 4. Disable multiple threads, use single threads. 5. Support utest for cygwin64. 6. Query features for windows by API. 7. Disable stat APIs for cygwin. 8. Use ST select event driver. Co-authored-by: wenjie.zhao <740936897@qq.com>
This commit is contained in:
parent
3d0dcb2a17
commit
d741f81110
15 changed files with 122 additions and 30 deletions
|
@ -178,6 +178,11 @@ if [[ $SRS_CROSS_BUILD == YES ]]; then
|
|||
else
|
||||
srs_undefine_macro "SRS_CROSSBUILD" $SRS_AUTO_HEADERS_H
|
||||
fi
|
||||
if [[ $SRS_CYGWIN64 == YES ]]; then
|
||||
srs_define_macro "SRS_CYGWIN64" $SRS_AUTO_HEADERS_H
|
||||
else
|
||||
srs_undefine_macro "SRS_CYGWIN64" $SRS_AUTO_HEADERS_H
|
||||
fi
|
||||
if [[ $SRS_OSX == YES ]]; then
|
||||
srs_define_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
|
||||
else
|
||||
|
|
|
@ -293,7 +293,7 @@ OSX_prepare; ret=$?; if [[ 0 -ne $ret ]]; then echo "OSX prepare failed, ret=$re
|
|||
#####################################################################################
|
||||
# Check OS and CPU architectures.
|
||||
#####################################################################################
|
||||
if [[ $OS_IS_UBUNTU != YES && $OS_IS_CENTOS != YES && $OS_IS_OSX != YES && $SRS_CROSS_BUILD != YES ]]; then
|
||||
if [[ $OS_IS_UBUNTU != YES && $OS_IS_CENTOS != YES && $OS_IS_OSX != YES && $SRS_CROSS_BUILD != YES && $SRS_CYGWIN64 != YES ]]; then
|
||||
echo "Your OS `uname -s` is not supported."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -347,6 +347,10 @@ fi
|
|||
if [[ $SRS_OSX == YES ]]; then
|
||||
_ST_MAKE=darwin-debug && _ST_OBJ="DARWIN_`uname -r`_DBG"
|
||||
fi
|
||||
# for windows/cygwin
|
||||
if [[ $SRS_CYGWIN64 = YES ]]; then
|
||||
_ST_MAKE=cygwin64-debug && _ST_OBJ="CYGWIN64_`uname -s`_DBG"
|
||||
fi
|
||||
# For Ubuntu, the epoll detection might be fail.
|
||||
if [[ $OS_IS_UBUNTU == YES ]]; then
|
||||
_ST_EXTRA_CFLAGS="$_ST_EXTRA_CFLAGS -DMD_HAVE_EPOLL"
|
||||
|
@ -598,8 +602,16 @@ if [[ $SRS_RTC == YES ]]; then
|
|||
rm -rf ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srtp2 \
|
||||
${SRS_OBJS}/srtp2 &&
|
||||
cp -rf ${SRS_WORKDIR}/3rdparty/libsrtp-2-fit ${SRS_OBJS}/${SRS_PLATFORM}/ &&
|
||||
patch -p0 ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/crypto/math/datatypes.c ${SRS_WORKDIR}/3rdparty/patches/srtp/gcc10-01.patch &&
|
||||
patch -p0 ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/config.guess ${SRS_WORKDIR}/3rdparty/patches/srtp/config.guess-02.patch &&
|
||||
# For cygwin64, the patch is not available, so use sed instead.
|
||||
if [[ $SRS_CYGWIN64 == YES ]]; then
|
||||
sed -i 's/char bit_string/static char bit_string/g' ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/crypto/math/datatypes.c
|
||||
else
|
||||
patch -p0 ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/crypto/math/datatypes.c ${SRS_WORKDIR}/3rdparty/patches/srtp/gcc10-01.patch
|
||||
fi &&
|
||||
# Patch the cpu arch guessing for RISCV.
|
||||
if [[ $OS_IS_RISCV == YES ]]; then
|
||||
patch -p0 ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit/config.guess ${SRS_WORKDIR}/3rdparty/patches/srtp/config.guess-02.patch
|
||||
fi &&
|
||||
(
|
||||
cd ${SRS_OBJS}/${SRS_PLATFORM}/libsrtp-2-fit &&
|
||||
$SRTP_CONFIGURE ${SRTP_OPTIONS} --prefix=${SRS_DEPENDS_LIBS}/${SRS_PLATFORM}/3rdpatry/srtp2
|
||||
|
@ -768,16 +780,16 @@ if [[ $SRS_SRT == YES ]]; then
|
|||
else
|
||||
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --enable-shared=0"
|
||||
fi
|
||||
# For windows build, over cygwin
|
||||
if [[ $SRS_CYGWIN64 == YES ]]; then
|
||||
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --cygwin-use-posix"
|
||||
fi
|
||||
# For cross-build.
|
||||
if [[ $SRS_CROSS_BUILD == YES ]]; then
|
||||
TOOL_GCC_REALPATH=$(realpath $(which $SRS_TOOL_CC))
|
||||
SRT_COMPILER_PREFIX=$(echo $TOOL_GCC_REALPATH |sed 's/-gcc.*$/-/')
|
||||
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --with-compiler-prefix=$SRT_COMPILER_PREFIX"
|
||||
fi
|
||||
# For windows build, over cygwin
|
||||
if [[ $SRS_CYGWIN64 == YES ]]; then
|
||||
LIBSRT_OPTIONS="$LIBSRT_OPTIONS --cygwin-use-posix"
|
||||
fi
|
||||
|
||||
if [[ -f ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srt/lib/libsrt.a ]]; then
|
||||
rm -rf ${SRS_OBJS}/srt && cp -rf ${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/srt ${SRS_OBJS}/ &&
|
||||
|
|
|
@ -84,6 +84,7 @@ SRS_GPROF=NO # Performance test: gprof
|
|||
################################################################
|
||||
# Preset options
|
||||
SRS_OSX= #For OSX/macOS/Darwin PC.
|
||||
SRS_CYGWIN64= # For Cygwin64 for Windows PC or servers.
|
||||
SRS_CROSS_BUILD= #For cross build, for example, on Ubuntu.
|
||||
# For cross build, the cpu, for example(FFmpeg), --cpu=24kc
|
||||
SRS_CROSS_BUILD_CPU=
|
||||
|
@ -119,6 +120,7 @@ function show_help() {
|
|||
Presets:
|
||||
--cross-build Enable cross-build, please set bellow Toolchain also. Default: $(value2switch $SRS_CROSS_BUILD)
|
||||
--osx Enable build for OSX/Darwin AppleOS. Default: $(value2switch $SRS_OSX)
|
||||
--cygwin64 Use cygwin64 to build for Windows. Default: $(value2switch $SRS_CYGWIN64)
|
||||
|
||||
Features:
|
||||
-h, --help Print this message and exit 0.
|
||||
|
@ -253,6 +255,7 @@ function parse_user_option() {
|
|||
--build-tag) SRS_BUILD_TAG=${value} ;;
|
||||
|
||||
--osx) SRS_OSX=YES ;;
|
||||
--cygwin64) SRS_CYGWIN64=YES ;;
|
||||
|
||||
--without-srtp-nasm) SRS_SRTP_ASM=NO ;;
|
||||
--with-srtp-nasm) SRS_SRTP_ASM=YES ;;
|
||||
|
@ -450,6 +453,10 @@ do
|
|||
done
|
||||
|
||||
function apply_auto_options() {
|
||||
if [[ $OS_IS_CYGWIN == YES ]]; then
|
||||
SRS_CYGWIN64=YES
|
||||
fi
|
||||
|
||||
if [[ $SRS_CROSS_BUILD == YES ]]; then
|
||||
if [[ $SRS_CROSS_BUILD_PREFIX != "" && $SRS_CROSS_BUILD_HOST == "" ]]; then
|
||||
SRS_CROSS_BUILD_HOST=$(echo $SRS_CROSS_BUILD_PREFIX| sed 's/-$//g')
|
||||
|
@ -503,6 +510,31 @@ function apply_auto_options() {
|
|||
SRS_SRTP_ASM=NO
|
||||
fi
|
||||
|
||||
# TODO: FIXME: Should build address sanitizer for cygwin64.
|
||||
# See https://github.com/ossrs/srs/issues/3252
|
||||
if [[ $SRS_CYGWIN64 == YES && $SRS_SANITIZER == YES ]]; then
|
||||
echo "Disable address sanitizer for cygwin64"
|
||||
SRS_SANITIZER=NO
|
||||
fi
|
||||
# TODO: FIXME: Should fix bug for SRT for cygwin64. Build ok, but fail in SrsSrtSocket::accept.
|
||||
# See https://github.com/ossrs/srs/issues/3251
|
||||
if [[ $SRS_CYGWIN64 == YES && $SRS_SRT == YES ]]; then
|
||||
echo "Disable SRT for cygwin64"
|
||||
SRS_SRT=NO
|
||||
fi
|
||||
# TODO: FIXME: Cygwin: ST stuck when working in multiple threads mode.
|
||||
# See https://github.com/ossrs/srs/issues/3253
|
||||
if [[ $SRS_CYGWIN64 == YES && $SRS_SINGLE_THREAD != YES ]]; then
|
||||
echo "Force single thread for cygwin64"
|
||||
SRS_SINGLE_THREAD=YES
|
||||
fi
|
||||
# TODO: FIXME: Cygwin: Build srtp with openssl fail for no srtp_aes_icm_ctx_t
|
||||
# See https://github.com/ossrs/srs/issues/3254
|
||||
if [[ $SRS_CYGWIN64 == YES && $SRS_SRTP_ASM == YES ]]; then
|
||||
echo "Disable SRTP with openssl for cygwin64"
|
||||
SRS_SRTP_ASM=NO
|
||||
fi
|
||||
|
||||
# parse the jobs for make
|
||||
if [[ ! -z SRS_JOBS ]]; then
|
||||
export SRS_JOBS="--jobs=${SRS_JOBS}"
|
||||
|
@ -589,6 +621,7 @@ function regenerate_options() {
|
|||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --debug-stats=$(value2switch $SRS_DEBUG_STATS)"
|
||||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cross-build=$(value2switch $SRS_CROSS_BUILD)"
|
||||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --sanitizer=$(value2switch $SRS_SANITIZER)"
|
||||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --cygwin64=$(value2switch $SRS_CYGWIN64)"
|
||||
SRS_AUTO_CONFIGURE="${SRS_AUTO_CONFIGURE} --single-thread=$(value2switch $SRS_SINGLE_THREAD)"
|
||||
if [[ $SRS_CROSS_BUILD_ARCH != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --arch=$SRS_CROSS_BUILD_ARCH"; fi
|
||||
if [[ $SRS_CROSS_BUILD_CPU != "" ]]; then SRS_AUTO_CONFIGURE="$SRS_AUTO_CONFIGURE --cpu=$SRS_CROSS_BUILD_CPU"; fi
|
||||
|
|
|
@ -5,6 +5,10 @@ OS_KERNEL_NAME=$(uname -s)
|
|||
OS_KERNRL_RELEASE=$(uname -r|awk -F '-' '{print $1}')
|
||||
OS_PREFIX="Platform"
|
||||
|
||||
if [[ $OSTYPE == cygwin ]]; then
|
||||
OS_KERNRL_RELEASE=$(uname -r|awk -F '(' '{print $1}')
|
||||
fi
|
||||
|
||||
# Build platform cache.
|
||||
SRS_PLATFORM="${SRS_BUILD_TAG}${OS_PREFIX}-${OS_KERNEL_NAME}-${OS_KERNRL_RELEASE}"
|
||||
# Build platform cache with gcc version.
|
||||
|
|
|
@ -17,7 +17,13 @@ mkdir -p ${SRS_OBJS}/${SRS_PLATFORM}/utest
|
|||
# trunk of srs, which contains the src dir, relative to objs/utest, it's trunk
|
||||
SRS_TRUNK_PREFIX=../../..
|
||||
# gest dir, relative to objs/utest, it's trunk/objs/{Platform}/gtest
|
||||
GTEST_DIR=${SRS_TRUNK_PREFIX}/${SRS_OBJS}/${SRS_PLATFORM}/3rdpatry/gtest/googletest
|
||||
GTEST_DIR=../3rdpatry/gtest/googletest
|
||||
|
||||
# Whether enable C++11 or higher versions.
|
||||
# For linux, always use C++11 for gtest required, see https://github.com/google/googletest
|
||||
# For cygwin64, ignore because it use -std=gnu++11 by default.
|
||||
SRS_CPP_VERSION="-std=c++11"
|
||||
if [[ $SRS_CYGWIN64 == YES ]]; then SRS_CPP_VERSION="-std=gnu++11"; fi
|
||||
|
||||
cat << END > ${FILE}
|
||||
# user must run make the ${SRS_OBJS}/utest dir
|
||||
|
@ -51,9 +57,9 @@ CXX = ${SRS_TOOL_CXX}
|
|||
CPPFLAGS += -I\$(GTEST_DIR)/include
|
||||
|
||||
# Flags passed to the C++ compiler.
|
||||
CXXFLAGS += ${CXXFLAGS} ${UTEST_EXTRA_DEFINES} -Wno-unused-private-field -Wno-unused-command-line-argument
|
||||
# Always use C++11 for gtest required, see https://github.com/google/googletest
|
||||
CXXFLAGS += -std=c++11
|
||||
CXXFLAGS += ${CXXFLAGS} ${UTEST_EXTRA_DEFINES}
|
||||
CXXFLAGS += -Wno-unused-private-field -Wno-unused-command-line-argument
|
||||
CXXFLAGS += ${SRS_CPP_VERSION}
|
||||
|
||||
# All tests produced by this Makefile. Remember to add new tests you
|
||||
# created to the list.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue