You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
srs/trunk/auto/auto_headers.sh

272 lines
8.2 KiB
Bash

10 years ago
#!/bin/bash
# output variables:
# SRS_AUTO_HEADERS_H: the auto generated header file.
SRS_AUTO_HEADERS_H="${SRS_OBJS}/srs_auto_headers.hpp"
# write user options to headers
echo "// auto generated by configure" > $SRS_AUTO_HEADERS_H
echo "#ifndef SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_AUTO_HEADER_HPP" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_PACKAGER \"${SRS_AUTO_PACKAGER}\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_BUILD_TS \"`date +%s`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_BUILD_DATE \"`date \"+%Y-%m-%d %H:%M:%S\"`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_UNAME \"`uname -a`\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_USER_CONFIGURE \"${SRS_AUTO_USER_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_CONFIGURE \"${SRS_AUTO_CONFIGURE}\"" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H
function srs_define_macro()
{
macro=$1 && file=$2
echo "#define $macro" >> $file
echo "#define ${macro}_BOOL true" >> $file
}
function srs_define_macro_value()
{
macro=$1 && value=$2 && file=$3
echo "#define $macro $value" >> $file
echo "#define ${macro}_BOOL true" >> $file
}
function srs_undefine_macro()
{
macro=$1 && file=$2
echo "#undef $macro" >> $file
echo "#define ${macro}_BOOL false" >> $file
}
10 years ago
#####################################################################################
# generate auto headers file, depends on the finished of options.sh
#####################################################################################
# auto headers in depends.
if [[ $SRS_HDS == YES ]]; then
srs_define_macro "SRS_HDS" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_HDS" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_SRT == YES ]]; then
srs_define_macro "SRS_SRT" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SRT" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_CXX11 == YES ]]; then
srs_define_macro "SRS_CXX11" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_CXX11" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_CXX14 == YES ]]; then
srs_define_macro "SRS_CXX14" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_CXX14" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_BACKTRACE == YES ]]; then
srs_define_macro "SRS_BACKTRACE" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_BACKTRACE" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_RTC == YES ]]; then
srs_define_macro "SRS_RTC" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_RTC" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_FFMPEG_FIT == YES ]]; then
srs_define_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_FFMPEG_FIT" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_FFMPEG_OPUS == YES ]]; then
srs_define_macro "SRS_FFMPEG_OPUS" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_FFMPEG_OPUS" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_H265 == YES ]]; then
srs_define_macro "SRS_H265" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_H265" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_SIMULATOR == YES ]]; then
srs_define_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SIMULATOR" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_HTTPS == YES ]]; then
srs_define_macro "SRS_HTTPS" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_HTTPS" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_GB28181 == YES ]]; then
srs_define_macro "SRS_GB28181" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_GB28181" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_APM == YES ]]; then
srs_define_macro "SRS_APM" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_APM" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_UTEST == YES ]]; then
srs_define_macro "SRS_UTEST" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_UTEST" $SRS_AUTO_HEADERS_H
fi
10 years ago
# whatever the FFMPEG tools, if transcode and ingest specified,
# srs always compile the FFMPEG tool stub which used to start the FFMPEG process.
if [[ $SRS_FFMPEG_STUB == YES ]]; then
srs_define_macro "SRS_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
10 years ago
else
srs_undefine_macro "SRS_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
10 years ago
fi
if [[ $SRS_GPERF == YES ]]; then
srs_define_macro "SRS_GPERF" $SRS_AUTO_HEADERS_H
10 years ago
else
srs_undefine_macro "SRS_GPERF" $SRS_AUTO_HEADERS_H
10 years ago
fi
if [[ $SRS_GPERF_MC == YES ]]; then
srs_define_macro "SRS_GPERF_MC" $SRS_AUTO_HEADERS_H
10 years ago
else
srs_undefine_macro "SRS_GPERF_MC" $SRS_AUTO_HEADERS_H
10 years ago
fi
if [[ $SRS_GPERF_MD == YES ]]; then
srs_define_macro "SRS_GPERF_MD" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_GPERF_MD" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_GPERF_MP == YES ]]; then
srs_define_macro "SRS_GPERF_MP" $SRS_AUTO_HEADERS_H
10 years ago
else
srs_undefine_macro "SRS_GPERF_MP" $SRS_AUTO_HEADERS_H
10 years ago
fi
if [[ $SRS_GPERF_CP == YES ]]; then
srs_define_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
10 years ago
else
srs_undefine_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
10 years ago
fi
if [ $SRS_SANITIZER == YES ]; then
srs_define_macro "SRS_SANITIZER" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SANITIZER" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_SANITIZER_LOG == YES ]; then
srs_define_macro "SRS_SANITIZER_LOG" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SANITIZER_LOG" $SRS_AUTO_HEADERS_H
fi
API: Support new HTTP API for VALGRIND. v6.0.149 v7.0.6 (#4150) New features for valgrind: 1. ST: Support /api/v1/valgrind for leaking check. 2. ST: Support /api/v1/valgrind?check=full|added|changed|new|quick To use Valgrind to detect memory leaks in SRS, even though Valgrind hooks are supported in ST, there are still many false positives. A more reasonable approach is to have Valgrind report incremental memory leaks. This way, global and static variables can be avoided, and detection can be achieved without exiting the program. Follow these steps: 1. Compile SRS with Valgrind support: `./configure --valgrind=on && make` 2. Start SRS with memory leak detection enabled: `valgrind --leak-check=full ./objs/srs -c conf/console.conf` 3. Trigger memory detection by using curl to access the API and generate calibration data. There will still be many false positives, but these can be ignored: `curl http://127.0.0.1:1985/api/v1/valgrind?check=added` 4. Perform load testing or test the suspected leaking functionality, such as RTMP streaming: `ffmpeg -re -i doc/source.flv -c copy -f flv rtmp://127.0.0.1/live/livestream` 5. Stop streaming and wait for SRS to clean up the Source memory, approximately 30 seconds. 6. Perform incremental memory leak detection. The reported leaks will be very accurate at this point: `curl http://127.0.0.1:1985/api/v1/valgrind?check=added` > Note: To avoid interference from the HTTP request itself on Valgrind, SRS uses a separate coroutine to perform periodic checks. Therefore, after accessing the API, you may need to wait a few seconds for the detection to be triggered. --------- Co-authored-by: Jacob Su <suzp1984@gmail.com>
6 months ago
if [ $SRS_VALGRIND == YES ]; then
srs_define_macro "SRS_VALGRIND" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_VALGRIND" $SRS_AUTO_HEADERS_H
fi
10 years ago
#####################################################################################
# for embeded.
#####################################################################################
# for log level compile settings
if [[ $SRS_LOG_VERBOSE == YES ]]; then
srs_define_macro "SRS_VERBOSE" $SRS_AUTO_HEADERS_H
10 years ago
else
srs_undefine_macro "SRS_VERBOSE" $SRS_AUTO_HEADERS_H
10 years ago
fi
if [[ $SRS_LOG_INFO == YES ]]; then
srs_define_macro "SRS_INFO" $SRS_AUTO_HEADERS_H
10 years ago
else
srs_undefine_macro "SRS_INFO" $SRS_AUTO_HEADERS_H
10 years ago
fi
if [[ $SRS_LOG_TRACE == YES ]]; then
srs_define_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
10 years ago
else
srs_undefine_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
10 years ago
fi
if [[ $SRS_SINGLE_THREAD == YES ]]; then
srs_define_macro "SRS_SINGLE_THREAD" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SINGLE_THREAD" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_SIGNAL_API == YES ]]; then
srs_define_macro "SRS_SIGNAL_API" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SIGNAL_API" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_LOG_LEVEL_V2 == YES ]]; then
srs_define_macro "SRS_LOG_LEVEL_V2" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_LOG_LEVEL_V2" $SRS_AUTO_HEADERS_H
fi
if [[ $SRS_CROSS_BUILD == YES ]]; then
srs_define_macro "SRS_CROSSBUILD" $SRS_AUTO_HEADERS_H
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
srs_undefine_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
fi
10 years ago
if [[ $SRS_DEBUG == YES ]]; then
srs_define_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
5 years ago
else
srs_undefine_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
5 years ago
fi
if [[ $SRS_DEBUG_STATS == YES ]]; then
srs_define_macro "SRS_DEBUG_STATS" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_DEBUG_STATS" $SRS_AUTO_HEADERS_H
fi
10 years ago
# prefix
echo "" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_PREFIX \"${SRS_PREFIX}\"" >> $SRS_AUTO_HEADERS_H
3 years ago
echo "#define SRS_DEFAULT_CONFIG \"${SRS_DEFAULT_CONFIG}\"" >> $SRS_AUTO_HEADERS_H
10 years ago
echo "" >> $SRS_AUTO_HEADERS_H
#####################################################################################
# generated the contributors from AUTHORS.txt
#####################################################################################
4 years ago
if [[ -f AUTHORS.md ]]; then
RTMP_SIG_SRS_AUTHORS=$(cat AUTHORS.md|grep "^-"|awk -F '`' '{print $2}')
echo "#define RTMP_SIG_SRS_AUTHORS \"\\" >> $SRS_AUTO_HEADERS_H
for CONTRIBUTOR in $RTMP_SIG_SRS_AUTHORS; do
6 years ago
echo "${CONTRIBUTOR} \\" >> $SRS_AUTO_HEADERS_H
done
echo "\"" >> $SRS_AUTO_HEADERS_H
else
echo "#define RTMP_SIG_SRS_AUTHORS \"ossrs\"" >> $SRS_AUTO_HEADERS_H
6 years ago
fi
10 years ago
# new empty line to auto headers file.
echo "" >> $SRS_AUTO_HEADERS_H
#####################################################################################
10 years ago
# auto header EOF.
#####################################################################################
10 years ago
echo "#endif" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H