[PATCH xserver 2/3] Use #ifdef instead of #if for features to make Meson easier.

Eric Anholt eric at anholt.net
Wed Apr 26 18:21:28 UTC 2017


Aaron Plattner <aplattner at nvidia.com> writes:

> We try to do exactly the opposite in our internal driver build, because
> it's too easy to accidentally do something like
>
> #ifdef GLAMOUR_HAS_GBM
>
> And mistakes like that don't always cause obvious build failures like
> this would. So we build everything with -Wundef -Werror=undef and try to
> use #if whenever possible. It's a shame that Meson makes that hard.

Meson makes what you want easy with:

    set10(varname, boolean_value) is the same as above but the value is
    either true or false and will be written as 1 or 0, respectively

but autotools usually produces either #define 1 or #undef, unless you go
through contortions.  This seemed like the easy, consistent solution
today, given that our codebase is almost all #ifdef.  One alternative
would be to just disable -Wundef for now.  The other alternative to this
patch would be something like:

    conf_array += ['HAVE_DBM_H', cc.has_header('dbm.h')]

then finish with something like:

    foreach conf: conf_array
        if conf[1]
            conf_data.set(conf[0], '1')
        endif
    endforeach

but I think I'd rather wait and consistently swap to .set10() and #if
once we've nuked autotools.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.x.org/archives/xorg-devel/attachments/20170426/cab7bff9/attachment.sig>


More information about the xorg-devel mailing list