1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-15 04:42:04 +00:00
srs/trunk/auto/auto_headers.sh

267 lines
8.1 KiB
Bash
Raw Normal View History

2015-03-07 08:49:21 +00:00
#!/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
2015-09-24 04:15:12 +00:00
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
}
2015-03-07 08:49:21 +00:00
#####################################################################################
# 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
2015-03-12 03:15:15 +00:00
else
srs_undefine_macro "SRS_HDS" $SRS_AUTO_HEADERS_H
2015-03-12 03:15:15 +00:00
fi
if [[ $SRS_SRT == YES ]]; then
srs_define_macro "SRS_SRT" $SRS_AUTO_HEADERS_H
2020-01-23 06:23:09 +00:00
else
srs_undefine_macro "SRS_SRT" $SRS_AUTO_HEADERS_H
2020-01-23 06:23:09 +00:00
fi
if [[ $SRS_CXX11 == YES ]]; then
2020-06-03 11:18:41 +00:00
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
2020-06-11 09:12:37 +00:00
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
2020-05-07 08:29:11 +00:00
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
2015-03-07 08:49:21 +00:00
# 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
2015-03-07 08:49:21 +00:00
else
srs_undefine_macro "SRS_FFMPEG_STUB" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
fi
if [[ $SRS_GPERF == YES ]]; then
srs_define_macro "SRS_GPERF" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
else
srs_undefine_macro "SRS_GPERF" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
fi
if [[ $SRS_GPERF_MC == YES ]]; then
srs_define_macro "SRS_GPERF_MC" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
else
srs_undefine_macro "SRS_GPERF_MC" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
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
2015-03-07 08:49:21 +00:00
else
srs_undefine_macro "SRS_GPERF_MP" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
fi
if [[ $SRS_GPERF_CP == YES ]]; then
srs_define_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
else
srs_undefine_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
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>
2024-08-21 07:39:01 +00:00
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
2015-03-07 08:49:21 +00:00
#####################################################################################
# for embeded.
#####################################################################################
# for log level compile settings
if [[ $SRS_LOG_VERBOSE == YES ]]; then
srs_define_macro "SRS_VERBOSE" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
else
srs_undefine_macro "SRS_VERBOSE" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
fi
if [[ $SRS_LOG_INFO == YES ]]; then
srs_define_macro "SRS_INFO" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
else
srs_undefine_macro "SRS_INFO" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
fi
if [[ $SRS_LOG_TRACE == YES ]]; then
srs_define_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
else
srs_undefine_macro "SRS_TRACE" $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
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_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
2020-03-28 09:20:40 +00:00
else
srs_undefine_macro "SRS_OSX" $SRS_AUTO_HEADERS_H
2020-03-28 09:20:40 +00:00
fi
2015-03-07 08:49:21 +00:00
if [[ $SRS_DEBUG == YES ]]; then
srs_define_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
2020-04-14 12:12:33 +00:00
else
srs_undefine_macro "SRS_DEBUG" $SRS_AUTO_HEADERS_H
2020-04-14 12:12:33 +00:00
fi
if [[ $SRS_DEBUG_STATS == YES ]]; then
2021-02-15 05:09:13 +00:00
srs_define_macro "SRS_DEBUG_STATS" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_DEBUG_STATS" $SRS_AUTO_HEADERS_H
fi
2015-03-07 08:49:21 +00:00
# prefix
echo "" >> $SRS_AUTO_HEADERS_H
echo "#define SRS_PREFIX \"${SRS_PREFIX}\"" >> $SRS_AUTO_HEADERS_H
2022-01-13 10:26:28 +00:00
echo "#define SRS_DEFAULT_CONFIG \"${SRS_DEFAULT_CONFIG}\"" >> $SRS_AUTO_HEADERS_H
2015-03-07 08:49:21 +00:00
echo "" >> $SRS_AUTO_HEADERS_H
#####################################################################################
# generated the contributors from AUTHORS.txt
#####################################################################################
2021-07-09 01:00:35 +00:00
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
2019-05-04 23:55:55 +00:00
echo "${CONTRIBUTOR} \\" >> $SRS_AUTO_HEADERS_H
done
echo "\"" >> $SRS_AUTO_HEADERS_H
else
echo "#define RTMP_SIG_SRS_AUTHORS \"ossrs\"" >> $SRS_AUTO_HEADERS_H
2019-05-04 23:55:55 +00:00
fi
2015-03-07 08:49:21 +00:00
# new empty line to auto headers file.
echo "" >> $SRS_AUTO_HEADERS_H
2015-09-17 03:57:17 +00:00
#####################################################################################
2015-03-07 08:49:21 +00:00
# auto header EOF.
2015-09-17 03:57:17 +00:00
#####################################################################################
2015-03-07 08:49:21 +00:00
echo "#endif" >> $SRS_AUTO_HEADERS_H
echo "" >> $SRS_AUTO_HEADERS_H