efl runtime dynamic lib loading - make errors consistent and useful
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 2 Aug 2016 02:23:34 +0000 (11:23 +0900)
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>
Tue, 2 Aug 2016 02:23:34 +0000 (11:23 +0900)
so drop trying to appease the openbsd packages and stick to "upstream
so major versions" and let users fix their systems with symlinks. also
report what we are looking for so they have a chance to symlink to
make efl happy.

at some point we should make a single simple runtime lib linker
subsystem in efl so all these errors are reported in the same way,
input libray names are listed in a simple consistent way etc. etc.

for now we have 3 locations in efl that do this and they are roughly
similar. we can unify it later.

src/lib/ecore_audio/ecore_audio.c
src/lib/ecore_con/ecore_con_url_curl.c
src/lib/edje/edje_main.c

index d09d656..fbb5ad0 100644 (file)
@@ -99,7 +99,7 @@ ecore_audio_pulse_lib_load(void)
      {
         if (!ecore_audio_pulse_lib->mod)
           {
-             ERR("Cannot find libpulse!");
+             ERR("Cannot find libpulse at runtime!");
              return EINA_FALSE;
           }
         return EINA_TRUE;
@@ -120,19 +120,25 @@ ecore_audio_pulse_lib_load(void)
    LOAD("libpulse-0.dll");
    LOAD("libpulse.dll");
    LOAD("pulse.dll");
+   if (!ecore_audio_pulse_lib->mod)
+     ERR("Could not find libpulse-0.dll, libpulse.dll, pulse.dll");
 # elif defined(__APPLE__) && defined(__MACH__)
    LOAD("libpulse.0.dylib");
    LOAD("libpulse.0.so");
    LOAD("libpulse.so.0");
+   if (!ecore_audio_pulse_lib->mod)
+     ERR("Could not find libpulse.0.dylib, libpulse.0.so, libpulse.so.0");
 # else
    LOAD("libpulse.so.0");
+   if (!ecore_audio_pulse_lib->mod)
+     ERR("Could not find libpulse.so.0");
 # endif
 # undef LOAD
    if (!ecore_audio_pulse_lib->mod) return EINA_FALSE;
 
 #define SYM(x) \
    if (!(ecore_audio_pulse_lib->x = eina_module_symbol_get(ecore_audio_pulse_lib->mod, #x))) { \
-      ERR("libpulse - cannot find %s", #x); \
+      ERR("Cannot find symbol '%s' in'%s", #x, eina_module_file_get(ecore_audio_pulse_lib->mod)); \
       goto err; \
    }
    SYM(pa_context_new);
@@ -186,7 +192,7 @@ ecore_audio_sndfile_lib_load(void)
      {
         if (!ecore_audio_sndfile_lib->mod)
           {
-             ERR("Cannot find libsndfile!");
+             ERR("Cannot find libsndfile at runtime!");
              return EINA_FALSE;
           }
         return EINA_TRUE;
@@ -219,7 +225,7 @@ ecore_audio_sndfile_lib_load(void)
 
 #define SYM(x) \
    if (!(ecore_audio_sndfile_lib->x = eina_module_symbol_get(ecore_audio_sndfile_lib->mod, #x))) { \
-      ERR("libsndfile - cannot find %s", #x); \
+      ERR("Cannot find symbol '%s' in'%s", #x, eina_module_file_get(ecore_audio_pulse_lib->mod)); \
       goto err; \
    }
    SYM(sf_open);
index 56eb424..e241ecd 100644 (file)
@@ -32,7 +32,11 @@ _c_init(void)
    long ms = 0;
 
    if (_c) return EINA_TRUE;
-   if (_c_fail) return EINA_FALSE;
+   if (_c_fail)
+     {
+        ERR("Cannot find libcurl at runtime!");
+        return EINA_FALSE;
+     }
    _c = calloc(1, sizeof(Ecore_Con_Curl));
    if (!_c) goto error;
 
@@ -50,32 +54,28 @@ _c_init(void)
    LOAD("libcurl-4.dll"); // try correct dll first
    LOAD("libcurl.dll"); // try 1
    LOAD("curllib.dll"); // if fail try 2
+   if (!_c->mod)
+     ERR("Could not find libcurl-5.dll, libcurl-4.dll, libcurl.dll, curllib.dll");
 #elif defined(__APPLE__) && defined(__MACH__)
    LOAD("libcurl.5.dylib"); // try 1
    LOAD("libcurl.4.dylib"); // try 1
    LOAD("libcurl.so.5"); // if fail try 2
    LOAD("libcurl.so.4"); // if fail try 2
-#elif defined(__OpenBSD__)
-   {
-      char buf[64];
-      int min;
-      int maj = 25;
-
-      for (min = 0; min < 10; min++)
-        {
-           snprintf(buf, sizeof (buf), "libcurl.so.%d.%d", maj, min);
-           LOAD(buf);
-           if (_c->mod) break;
-        }
-   }
+   if (!_c->mod)
+     ERR("Could not find libcurl.5.dylib, libcurl.4.dylib, libcurl.so.5, libcurl.so.4");
 #else
    LOAD("libcurl.so.5"); // try only
    LOAD("libcurl.so.4"); // try only
+   if (!_c->mod)
+     ERR("Could not find libcurl.so.5, libcurl.so.4");
 #endif
    if (!_c->mod) goto error;
 
-#define SYM(x) if (!(_c->x = eina_module_symbol_get(_c->mod, #x))) \
-    goto error
+#define SYM(x) \
+   if (!(_c->x = eina_module_symbol_get(_c->mod, #x))) { \
+      ERR("Cannot find symbol '%s' in'%s", #x, eina_module_file_get(_c->mod)); \
+      goto error; \
+   }
    SYM(curl_global_init);
    SYM(curl_global_cleanup);
    SYM(curl_multi_init);
index ee7ecd2..7bb4774 100644 (file)
@@ -334,12 +334,11 @@ _edje_ephysics_load(void)
      {
         if (!_edje_ephysics->mod)
           {
-             ERR("Cannot find libpulse!");
+             ERR("Cannot find libephysics at runtime!");
              return EINA_FALSE;
           }
         return EINA_TRUE;
      }
-   ERR("PHYYYYYYYYYYYYYYZIKS");
    _edje_ephysics = calloc(1, sizeof(Edje_Ephysics));
    if (!_edje_ephysics) return EINA_FALSE;
 # define LOAD(x)                                        \
@@ -353,19 +352,26 @@ _edje_ephysics_load(void)
    }
 # if defined(_WIN32) || defined(__CYGWIN__)
    LOAD("libephysics-1.dll");
+   LOAD("libephysics1.dll");
    LOAD("libephysics.dll");
+   if (!_edje_ephysics->mod)
+     ERR("Could not find libephysics-1.dll, libephysics1.dll, libephysics.dll");
 # elif defined(__APPLE__) && defined(__MACH__)
    LOAD("libephysics.1.dylib");
    LOAD("libephysics.1.so");
    LOAD("libephysics.so.1");
+   if (!_edje_ephysics->mod)
+     ERR("Could not find libephysics.1.dylib, libephysics.1.so, libephysics.so.1");
 # else
    LOAD("libephysics.so.1");
+   if (!_edje_ephysics->mod)
+     ERR("Could not find libephysics.so.1");
 # endif
 # undef LOAD
    if (!_edje_ephysics->mod) return EINA_FALSE;
 # define SYM(x) \
    if (!(_edje_ephysics->x = eina_module_symbol_get(_edje_ephysics->mod, #x))) { \
-      ERR("libpulse - cannot find %s", #x); \
+      ERR("Cannot find symbol '%s' in'%s", #x, eina_module_file_get(_edje_ephysics->mod)); \
       goto err; \
    }
    SYM(ephysics_init);