meson/xmlconfig: win32 regex fallback

xmlconfig now uses regex fonctions even without xml support

Fixes: c83400e6
Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9261>
This commit is contained in:
Michel Zou 2021-02-24 20:28:38 +01:00 committed by Marge Bot
parent f08670b4ea
commit 5a2b930014
3 changed files with 21 additions and 1 deletions

View File

@ -1424,6 +1424,15 @@ endif
# it's not linux and wont
dep_m = cc.find_library('m', required : false)
if host_machine.system() == 'windows'
dep_regex = meson.get_compiler('c').find_library('regex', required : false)
if not dep_regex.found()
dep_regex = declare_dependency(compile_args : ['-DNO_REGEX'])
endif
else
dep_regex = null_dep
endif
if with_platform_haiku
dep_network = cc.find_library('network')
endif

View File

@ -221,6 +221,7 @@ xmlconfig_deps = []
if not (with_platform_android or with_platform_windows)
xmlconfig_deps += dep_expat
endif
xmlconfig_deps += dep_regex
_libxmlconfig = static_library(
'xmlconfig',

View File

@ -43,7 +43,17 @@
#include <dirent.h>
#include <sys/stat.h>
#endif
#ifdef NO_REGEX
typedef int regex_t;
#define REG_EXTENDED 0
#define REG_NOSUB 0
#define REG_NOMATCH 1
inline int regcomp(regex_t *r, const char *s, int f) { return 0; }
inline int regexec(regex_t *r, const char *s, int n, void *p, int f) { return REG_NOMATCH; }
inline void regfree(regex_t* r) {}
#else
#include <regex.h>
#endif
#include <fcntl.h>
#include <math.h>
#include "strndup.h"
@ -1153,7 +1163,7 @@ driParseConfigFiles(driOptionCache *cache, const driOptionCache *info,
userData.applicationVersion = applicationVersion;
userData.engineName = engineName ? engineName : "";
userData.engineVersion = engineVersion;
userData.execName = execname ?: util_get_process_name();
userData.execName = execname ? execname : util_get_process_name();
#if WITH_XMLCONFIG
char *home;