Merge branch 'mcatanzaro/build-best-practices' into 'main'

Improve default value of glib_debug option

See merge request GNOME/glib!2851
This commit is contained in:
Marco Trevisan
2022-08-05 19:36:00 +00:00
2 changed files with 8 additions and 11 deletions

View File

@@ -205,15 +205,10 @@
<para> <para>
This is a standard <application>Meson</application> option which This is a standard <application>Meson</application> option which
specifies how much debugging and optimization to enable. If the build specifies how much debugging and optimization to enable. If the build
type starts with <literal>debug</literal>, type is <literal>debug</literal>,
<literal>G_ENABLE_DEBUG</literal> will be defined and GLib will be built <literal>G_ENABLE_DEBUG</literal> will be defined and GLib will be built
with additional debug code enabled. with additional debug code enabled. You can override this behavior using
</para> <option>-Dglib_debug</option>.
<para>
If the build type is <literal>plain</literal>, GLib will not enable any
optimization or debug options by default, and will leave it entirely to
the user to choose their options. To build with the options recommended
by GLib developers, choose <literal>release</literal>.
</para> </para>
</formalpara> </formalpara>

View File

@@ -294,13 +294,15 @@ elif vs_crt_opt == 'from_buildtype'
endif endif
# Use debug/optimization flags to determine whether to enable debug or disable # Use debug/optimization flags to determine whether to enable debug or disable
# cast checks # cast checks. We have a non-production (debug) build if debug is true and if
# optimization is 0 or g; otherwise, we have a production build.
glib_debug_cflags = [] glib_debug_cflags = []
glib_debug = get_option('glib_debug') glib_debug = get_option('glib_debug')
if glib_debug.enabled() or (glib_debug.auto() and get_option('debug')) optimized_build = get_option('optimization') not in [ '0', 'g' ]
if glib_debug.enabled() or (glib_debug.auto() and get_option('debug') and not optimized_build)
glib_debug_cflags += ['-DG_ENABLE_DEBUG'] glib_debug_cflags += ['-DG_ENABLE_DEBUG']
message('Enabling various debug infrastructure') message('Enabling various debug infrastructure')
elif get_option('optimization') in ['2', '3', 's'] elif optimized_build
glib_debug_cflags += ['-DG_DISABLE_CAST_CHECKS'] glib_debug_cflags += ['-DG_DISABLE_CAST_CHECKS']
message('Disabling cast checks') message('Disabling cast checks')
endif endif