Files
asterisk/build_tools/make_version_c

71 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/bin/sh
GREP=${GREP:-grep}
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 8d506370f511d32a9100894b03718c0b5bb2140e)
2023-09-13 14:08:02 -06:00
if test ! -f include/asterisk/buildopts.h ; then
echo "include/asterisk/buildopts.h is missing"
exit 1
fi
if test ! -f .flavor ; then
EXTRA=""
elif test ! -f .version ; then
aadkflavor=`cat .flavor`
EXTRA=" (${aadkflavor})"
else
aadkver=`cat .version`
aadkflavor=`cat .flavor`
EXTRA=" (${aadkflavor} ${aadkver})"
fi
if ${GREP} "AST_DEVMODE" makeopts | ${GREP} -q "yes"
then
BUILDOPTS="AST_DEVMODE"
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 8d506370f511d32a9100894b03718c0b5bb2140e)
2023-09-13 14:08:02 -06:00
BUILDOPTS=$(sed -n -r -e 's/#define\s+AST_BUILDOPTS\s+"([^"]+)"/\1/gp' \
include/asterisk/buildopts.h )
BUILDOPTS_ALL=$(sed -n -r -e 's/#define\s+AST_BUILDOPTS_ALL\s+"([^"]+)"/\1/gp' \
include/asterisk/buildopts.h )
cat << END
/*
* version.c
* Automatically generated
*/
#include "asterisk.h"
#include "asterisk/ast_version.h"
static const char asterisk_version[] = "${ASTERISKVERSION}${EXTRA}";
static const char asterisk_version_num[] = "${ASTERISKVERSIONNUM}";
static const char asterisk_build_opts[] = "${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 8d506370f511d32a9100894b03718c0b5bb2140e)
2023-09-13 14:08:02 -06:00
static const char asterisk_build_opts_all[] = "${BUILDOPTS_ALL}";
const char *ast_get_version(void)
{
return asterisk_version;
}
const char *ast_get_version_num(void)
{
return asterisk_version_num;
}
const char *ast_get_build_opts(void)
{
return asterisk_build_opts;
}
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 8d506370f511d32a9100894b03718c0b5bb2140e)
2023-09-13 14:08:02 -06:00
const char *ast_get_build_opts_all(void)
{
return asterisk_build_opts_all;
}
END