eolian: Skip @beta APIs for duplicate warnings
authorJean-Philippe Andre <jp.andre@samsung.com>
Tue, 31 Oct 2017 04:58:31 +0000 (13:58 +0900)
committerJean-Philippe Andre <jp.andre@samsung.com>
Tue, 31 Oct 2017 05:52:34 +0000 (14:52 +0900)
No warnings:
export EOLIAN_WARN_FUNC_DUPLICATES=0

No beta warnings:
export EOLIAN_WARN_FUNC_DUPLICATES=1

All warnings including beta:
export EOLIAN_WARN_FUNC_DUPLICATES=2

EOLIAN_WARN_FUNC_DUPLICATES is not an API and may change in the future
as we improve the tool :)

src/lib/eolian/database_validate.c

index 28ffd5f..ed005ed 100644 (file)
@@ -290,14 +290,22 @@ _validate_function(Eolian_Function *func, Eina_Hash *nhash)
    Eolian_Function_Parameter *param;
    char buf[512];
 
+   static int _duplicates_warn = -1;
+   if (EINA_UNLIKELY(_duplicates_warn < 0))
+     {
+        const char *s = getenv("EOLIAN_WARN_FUNC_DUPLICATES");
+        if (!s) _duplicates_warn = 0;
+        else _duplicates_warn = atoi(s);
+     }
+
    const Eolian_Function *ofunc = eina_hash_find(nhash, func->name);
-   if (ofunc)
+   if (EINA_UNLIKELY(ofunc && (_duplicates_warn > 0)))
      {
         snprintf(buf, sizeof(buf),
-                 "function '%s' redefined (originally at %s:%d:%d)",
-                 func->name, ofunc->base.file,
+                 "%sfunction '%s' redefined (originally at %s:%d:%d)",
+                 func->is_beta ? "beta " : "", func->name, ofunc->base.file,
                  ofunc->base.line, ofunc->base.column);
-        if (getenv("EOLIAN_WARN_FUNC_DUPLICATES"))
+        if (!func->is_beta || (_duplicates_warn > 1))
           _obj_error(&func->base, buf);
      }