broadcom: Disbale CLIF dumping when libexpat isn't available.

Given what a niche developer tool CLIF dumps are, no sense requiring
libexpat just for that.

Acked-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Jose Maria Casanova Crespo <jmcasanova@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9764>
This commit is contained in:
Eric Anholt 2021-03-22 13:01:52 -07:00 committed by Marge Bot
parent 6eee6769e9
commit 3cc390bf7d
3 changed files with 31 additions and 4 deletions

View File

@ -1422,7 +1422,7 @@ if host_machine.system() == 'darwin'
dep_expat = meson.get_compiler('c').find_library('expat')
elif host_machine.system() != 'windows'
dep_expat = dependency('expat', fallback : ['expat', 'expat_dep'],
required: not with_platform_android or with_any_broadcom or with_any_intel)
required: not with_platform_android or with_any_intel)
else
dep_expat = null_dep
endif

View File

@ -53,11 +53,16 @@ v3d_xml_h = custom_target(
capture : true,
)
expat_args = []
if dep_expat.found()
expat_args += '-DWITH_LIBEXPAT=1'
endif
libbroadcom_cle = static_library(
['broadcom_cle', v3d_xml_h],
'v3d_decoder.c',
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_broadcom],
c_args : [no_override_init_args],
c_args : [no_override_init_args, expat_args],
gnu_symbol_visibility : 'hidden',
dependencies : [dep_libdrm, dep_valgrind, dep_expat, dep_zlib],
build_by_default : false,

View File

@ -22,19 +22,24 @@
* IN THE SOFTWARE.
*/
#include "v3d_decoder.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdarg.h>
#include <string.h>
#ifdef WITH_LIBEXPAT
#include <expat.h>
#endif
#include <inttypes.h>
#include <zlib.h>
#include <util/macros.h>
#include <util/ralloc.h>
#include <util/u_debug.h>
#include "v3d_decoder.h"
#include "v3d_packet_helpers.h"
#include "v3d_xml.h"
#include "broadcom/clif/clif_private.h"
@ -52,6 +57,8 @@ struct v3d_spec {
struct v3d_enum *enums[256];
};
#ifdef WITH_LIBEXPAT
struct location {
const char *filename;
int line_number;
@ -75,6 +82,8 @@ struct parser_context {
int parse_skip_depth;
};
#endif /* WITH_LIBEXPAT */
const char *
v3d_group_get_name(struct v3d_group *group)
{
@ -128,6 +137,8 @@ v3d_spec_find_enum(struct v3d_spec *spec, const char *name)
return NULL;
}
#ifdef WITH_LIBEXPAT
static void __attribute__((noreturn))
fail(struct location *loc, const char *msg, ...)
{
@ -645,9 +656,16 @@ static uint32_t zlib_inflate(const void *compressed_data,
return zstream.total_out;
}
#endif /* WITH_LIBEXPAT */
struct v3d_spec *
v3d_spec_load(const struct v3d_device_info *devinfo)
{
struct v3d_spec *spec = calloc(1, sizeof(struct v3d_spec));
if (!spec)
return NULL;
#ifdef WITH_LIBEXPAT
struct parser_context ctx;
void *buf;
uint8_t *text_data = NULL;
@ -683,7 +701,7 @@ v3d_spec_load(const struct v3d_device_info *devinfo)
XML_SetElementHandler(ctx.parser, start_element, end_element);
XML_SetCharacterDataHandler(ctx.parser, character_data);
ctx.spec = xzalloc(sizeof(*ctx.spec));
ctx.spec = spec;
total_length = zlib_inflate(compress_genxmls,
sizeof(compress_genxmls),
@ -709,6 +727,10 @@ v3d_spec_load(const struct v3d_device_info *devinfo)
free(text_data);
return ctx.spec;
#else /* !WITH_LIBEXPAT */
debug_warn_once("CLIF dumping not supported due to missing libexpat");
return spec;
#endif /* !WITH_LIBEXPAT */
}
struct v3d_group *