asterisk/build_tools/make_buildopts_h

97 lines
3.1 KiB
Plaintext
Raw Normal View History

#!/bin/sh
GREP=${GREP:-grep}
MD5=${MD5:-md5sum}
cat << END
/*
* buildopts.h
* Automatically generated
*/
END
if ${GREP} "AST_DEVMODE" makeopts | ${GREP} -q "yes"
then
echo "#define AST_DEVMODE 1"
# AST_DEVMODE is no longer an API/ABI affecting option so it no longer
# gets added to BUILDOPTS.
fi
make_buildopts_h, et. al. Allow adding all cflags to buildopts.h The previous behavior of make_buildopts_h was to not add the non-ABI-breaking MENUSELECT_CFLAGS like DETECT_DEADLOCKS, REF_DEBUG, etc. to the buildopts.h file because "it caused ccache to invalidate files and extended compile times". They're only defined by passing them on the gcc command line with '-D' options. In practice, including them in the include file rarely causes any impact because the only time ccache cares is if you actually change an option so the hit occurrs only once after you change it. OK so why would we want to include them? Many IDEs follow the include files to resolve defines and if the options aren't in an include file, it can cause the IDE to mark blocks of "ifdeffed" code as unused when they're really not. So... * Added a new menuselect compile option ADD_CFLAGS_TO_BUILDOPTS_H which tells make_buildopts_h to include the non-ABI-breaking flags in buildopts.h as well as the ABI-breaking ones. The default is disabled to preserve current behavior. As before though, only the ABI-breaking flags appear in AST_BUILDOPTS and only those are used to calculate AST_BUILDOPT_SUM. A new AST_BUILDOPT_ALL define was created to capture all of the flags. * make_version_c was streamlined to use buildopts.h and also to create asterisk_build_opts_all[] and ast_get_build_opts_all(void) * "core show settings" now shows both AST_BUILDOPTS and AST_BUILDOPTS_ALL. UserNote: The "Build Options" entry in the "core show settings" CLI command has been renamed to "ABI related Build Options" and a new entry named "All Build Options" has been added that shows both breaking and non-breaking options. (cherry picked from commit 06da7b342e7d362813d3390daea8a320ec31a633)
2023-09-13 20:08:02 +00:00
ADD_CFLAGS_TO_BUILDOPTS=false
MENUSELECT_CFLAGS=$(${GREP} -e "^MENUSELECT_CFLAGS" menuselect.makeopts)
echo "$MENUSELECT_CFLAGS" | grep -q -e "ADD_CFLAGS_TO_BUILDOPTS_H" && ADD_CFLAGS_TO_BUILDOPTS=true
make_buildopts_h, et. al. Allow adding all cflags to buildopts.h The previous behavior of make_buildopts_h was to not add the non-ABI-breaking MENUSELECT_CFLAGS like DETECT_DEADLOCKS, REF_DEBUG, etc. to the buildopts.h file because "it caused ccache to invalidate files and extended compile times". They're only defined by passing them on the gcc command line with '-D' options. In practice, including them in the include file rarely causes any impact because the only time ccache cares is if you actually change an option so the hit occurrs only once after you change it. OK so why would we want to include them? Many IDEs follow the include files to resolve defines and if the options aren't in an include file, it can cause the IDE to mark blocks of "ifdeffed" code as unused when they're really not. So... * Added a new menuselect compile option ADD_CFLAGS_TO_BUILDOPTS_H which tells make_buildopts_h to include the non-ABI-breaking flags in buildopts.h as well as the ABI-breaking ones. The default is disabled to preserve current behavior. As before though, only the ABI-breaking flags appear in AST_BUILDOPTS and only those are used to calculate AST_BUILDOPT_SUM. A new AST_BUILDOPT_ALL define was created to capture all of the flags. * make_version_c was streamlined to use buildopts.h and also to create asterisk_build_opts_all[] and ast_get_build_opts_all(void) * "core show settings" now shows both AST_BUILDOPTS and AST_BUILDOPTS_ALL. UserNote: The "Build Options" entry in the "core show settings" CLI command has been renamed to "ABI related Build Options" and a new entry named "All Build Options" has been added that shows both breaking and non-breaking options. (cherry picked from commit 06da7b342e7d362813d3390daea8a320ec31a633)
2023-09-13 20:08:02 +00:00
# Clean up MENUSELECT_CFLAGS by removing the "MENUSELECT_CFLAGS="
# at the front, the "ADD_CFLAGS_TO_BUILDOPTS_H" flag, and any "-D"
# entries.
MENUSELECT_CFLAGS=$( echo "$MENUSELECT_CFLAGS" | \
sed -r -e "s/(MENUSELECT_CFLAGS=|ADD_CFLAGS_TO_BUILDOPTS_H|-D)//g")
# This is a list of flags that don't affect the ABI.
# "ADD_CFLAGS_TO_BUILDOPTS_H" is NOT set, we'll filter these
# out of the buildopts.h file.
#
# These used to always be filtered out but if they're not in
# buildopts.h, many IDEs will show them as undefined and mark
# any code blocks enabled by them as disabled.
#
# The original reasoning for removing them was that trivial
# changes to the buildopts.h file will cause ccache to
# invalidate any source files that use it and increase the
# compile time. It's not such a huge deal these days but
# to preserve backwards behavior the default is still to
# remove them.
#
# The ABI-breaking flags are always included in buildopts.h.
# This variable is used by sed so it needs to be a valid
# regex which will be surrounded by parens.]
FILTER_OUT="\
AO2_DEBUG|BETTER_BACKTRACES|BUILD_NATIVE|\
COMPILE_DOUBLE|DEBUG_CHAOS|DEBUG_SCHEDULER|\
DETECT_DEADLOCKS|DONT_OPTIMIZE|DUMP_SCHEDULER|\
LOTS_OF_SPANS|MALLOC_DEBUG|RADIO_RELAX|\
REBUILD_PARSERS|REF_DEBUG|USE_HOARD_ALLOCATOR"
# Create buildopts.h
INCLUDE_CFLAGS="$MENUSELECT_CFLAGS"
# Do the filter-out if needed.
if ! $ADD_CFLAGS_TO_BUILDOPTS ; then
INCLUDE_CFLAGS=$( echo "$MENUSELECT_CFLAGS" | \
sed -r -e "s/(${FILTER_OUT})//g")
fi
# Output the defines.
for x in ${INCLUDE_CFLAGS}; do
echo "#define ${x} 1"
done
make_buildopts_h, et. al. Allow adding all cflags to buildopts.h The previous behavior of make_buildopts_h was to not add the non-ABI-breaking MENUSELECT_CFLAGS like DETECT_DEADLOCKS, REF_DEBUG, etc. to the buildopts.h file because "it caused ccache to invalidate files and extended compile times". They're only defined by passing them on the gcc command line with '-D' options. In practice, including them in the include file rarely causes any impact because the only time ccache cares is if you actually change an option so the hit occurrs only once after you change it. OK so why would we want to include them? Many IDEs follow the include files to resolve defines and if the options aren't in an include file, it can cause the IDE to mark blocks of "ifdeffed" code as unused when they're really not. So... * Added a new menuselect compile option ADD_CFLAGS_TO_BUILDOPTS_H which tells make_buildopts_h to include the non-ABI-breaking flags in buildopts.h as well as the ABI-breaking ones. The default is disabled to preserve current behavior. As before though, only the ABI-breaking flags appear in AST_BUILDOPTS and only those are used to calculate AST_BUILDOPT_SUM. A new AST_BUILDOPT_ALL define was created to capture all of the flags. * make_version_c was streamlined to use buildopts.h and also to create asterisk_build_opts_all[] and ast_get_build_opts_all(void) * "core show settings" now shows both AST_BUILDOPTS and AST_BUILDOPTS_ALL. UserNote: The "Build Options" entry in the "core show settings" CLI command has been renamed to "ABI related Build Options" and a new entry named "All Build Options" has been added that shows both breaking and non-breaking options. (cherry picked from commit 06da7b342e7d362813d3390daea8a320ec31a633)
2023-09-13 20:08:02 +00:00
# We NEVER include the non-ABI-breaking flags in the
# BUILDOPTS or use them to calculate the checksum so
# we always filter out any that may exist.
# After the filter-out, we also need to convert the
# possibly-multi-spaced MENUSELECT_CFLAGS to a nice
# comma-separated list.
# I.E.
# Remove leading spaces.
# Convert consecutive interior spaces to a single space.
# Remove trailing spaces.
# Convert the now-single-spaces in the interior to ", ".
BUILDOPTS=$( echo "$MENUSELECT_CFLAGS" | \
sed -r -e "s/(${FILTER_OUT}|LOW_MEMORY)//g" -e "s/^\s+//g;s/\s+/ /g;s/\s+$//g;s/\s/, /g" )
# Calculate the checksum on only the ABI-breaking flags.
BUILDSUM=$(echo "${BUILDOPTS}" | ${MD5} | cut -c1-32)
echo "#define AST_BUILDOPT_SUM \"${BUILDSUM}\""
echo "#define AST_BUILDOPTS \"${BUILDOPTS}\""
make_buildopts_h, et. al. Allow adding all cflags to buildopts.h The previous behavior of make_buildopts_h was to not add the non-ABI-breaking MENUSELECT_CFLAGS like DETECT_DEADLOCKS, REF_DEBUG, etc. to the buildopts.h file because "it caused ccache to invalidate files and extended compile times". They're only defined by passing them on the gcc command line with '-D' options. In practice, including them in the include file rarely causes any impact because the only time ccache cares is if you actually change an option so the hit occurrs only once after you change it. OK so why would we want to include them? Many IDEs follow the include files to resolve defines and if the options aren't in an include file, it can cause the IDE to mark blocks of "ifdeffed" code as unused when they're really not. So... * Added a new menuselect compile option ADD_CFLAGS_TO_BUILDOPTS_H which tells make_buildopts_h to include the non-ABI-breaking flags in buildopts.h as well as the ABI-breaking ones. The default is disabled to preserve current behavior. As before though, only the ABI-breaking flags appear in AST_BUILDOPTS and only those are used to calculate AST_BUILDOPT_SUM. A new AST_BUILDOPT_ALL define was created to capture all of the flags. * make_version_c was streamlined to use buildopts.h and also to create asterisk_build_opts_all[] and ast_get_build_opts_all(void) * "core show settings" now shows both AST_BUILDOPTS and AST_BUILDOPTS_ALL. UserNote: The "Build Options" entry in the "core show settings" CLI command has been renamed to "ABI related Build Options" and a new entry named "All Build Options" has been added that shows both breaking and non-breaking options. (cherry picked from commit 06da7b342e7d362813d3390daea8a320ec31a633)
2023-09-13 20:08:02 +00:00
# However, it'd be nice to see the non-ABI-breaking flags
# when you do a "core show settings" so we create a separate
# define for them.
BUILDOPTS_ALL=$( echo "$MENUSELECT_CFLAGS" | \
sed -r -e "s/^\s+//g;s/\s+/ /g;s/\s+$//g;s/\s/, /g" )
echo "#define AST_BUILDOPTS_ALL \"${BUILDOPTS_ALL}\""