Mesa (main): driconf: add executable_regexp application attribute

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 2 02:58:21 UTC 2021


Module: Mesa
Branch: main
Commit: 9a24de9aa743808c6c7cc2670f1e8d9753b9430e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9a24de9aa743808c6c7cc2670f1e8d9753b9430e

Author: Qiang Yu <yuq825 at gmail.com>
Date:   Tue Oct 12 15:23:27 2021 +0800

driconf: add executable_regexp application attribute

For matching executable with variable names like Mari which
append version string to its executable like: Mari4.5v2, Mari4.7v4.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Signed-off-by: Qiang Yu <yuq825 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13304>

---

 src/util/00-mesa-defaults.conf |  1 +
 src/util/xmlconfig.c           | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf
index 688a6e1067a..004b904e2f7 100644
--- a/src/util/00-mesa-defaults.conf
+++ b/src/util/00-mesa-defaults.conf
@@ -36,6 +36,7 @@ TODO: document the other workarounds.
    <!ELEMENT application  (option+)>
    <!ATTLIST application  name CDATA #REQUIRED
                           executable CDATA #IMPLIED
+                          executable_regexp CDATA #IMPLIED
                           sha1 CDATA #IMPLIED
                           application_name_match CDATA #IMPLIED
                           application_versions CDATA #IMPLIED>
diff --git a/src/util/xmlconfig.c b/src/util/xmlconfig.c
index 8766bb01f0a..60908158660 100644
--- a/src/util/xmlconfig.c
+++ b/src/util/xmlconfig.c
@@ -681,6 +681,7 @@ parseAppAttr(struct OptConfData *data, const char **attr)
    uint32_t i;
    const char *exec = NULL;
    const char *sha1 = NULL;
+   const char *exec_regexp = NULL;
    const char *application_name_match = NULL;
    const char *application_versions = NULL;
    driOptionInfo version_range = {
@@ -690,6 +691,7 @@ parseAppAttr(struct OptConfData *data, const char **attr)
    for (i = 0; attr[i]; i += 2) {
       if (!strcmp(attr[i], "name")) /* not needed here */;
       else if (!strcmp(attr[i], "executable")) exec = attr[i+1];
+      else if (!strcmp(attr[i], "executable_regexp")) exec_regexp = attr[i+1];
       else if (!strcmp(attr[i], "sha1")) sha1 = attr[i+1];
       else if (!strcmp(attr[i], "application_name_match"))
          application_name_match = attr[i+1];
@@ -699,6 +701,15 @@ parseAppAttr(struct OptConfData *data, const char **attr)
    }
    if (exec && strcmp(exec, data->execName)) {
       data->ignoringApp = data->inApp;
+   } else if (exec_regexp) {
+      regex_t re;
+
+      if (regcomp(&re, exec_regexp, REG_EXTENDED|REG_NOSUB) == 0) {
+         if (regexec(&re, data->execName, 0, NULL, 0) == REG_NOMATCH)
+            data->ignoringApp = data->inApp;
+         regfree(&re);
+      } else
+         XML_WARNING("Invalid executable_regexp=\"%s\".", exec_regexp);
    } else if (sha1) {
       /* SHA1_DIGEST_STRING_LENGTH includes terminating null byte */
       if (strlen(sha1) != (SHA1_DIGEST_STRING_LENGTH - 1)) {



More information about the mesa-commit mailing list