Exemple #1
0
void
ecore_imf_module_init(void)
{
   char buf[PATH_MAX] = "";

   pfx = eina_prefix_new(NULL, ecore_imf_init,
                         "ECORE_IMF", "ecore_imf", "checkme",
                         PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
                         PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
   if (getuid() == geteuid())
#endif
     {
        if (getenv("EFL_RUN_IN_TREE"))
          {
             struct stat st;
             snprintf(buf, sizeof(buf), "%s/src/modules/ecore_imf",
                      PACKAGE_BUILD_DIR);
             if (stat(buf, &st) == 0)
               {
                  const char *built_modules[] = {
#ifdef ENABLE_XIM
                     "xim",
#endif
#ifdef BUILD_ECORE_IMF_IBUS
                     "ibus",
#endif
#ifdef BUILD_ECORE_IMF_SCIM
                     "scim",
#endif
#ifdef BUILD_ECORE_IMF_WAYLAND
                     "wayland",
#endif
                     NULL
                  };
                  const char **itr;
                  for (itr = built_modules; *itr != NULL; itr++)
                    {
                       snprintf(buf, sizeof(buf),
                                "%s/src/modules/ecore_imf/%s/.libs",
                                PACKAGE_BUILD_DIR, *itr);
                       module_list = eina_module_list_get(module_list, buf,
                                                          EINA_FALSE, NULL, NULL);
                    }

                  if (module_list)
                    eina_module_list_load(module_list);
                  return;
               }
          }
     }

   snprintf(buf, sizeof(buf), "%s/ecore_imf/modules", eina_prefix_lib_get(pfx));
   module_list = eina_module_arch_list_get(module_list, buf, MODULE_ARCH);

   // XXX: MODFIX: do not list ALL modules and load them ALL! this is
   // is wrong - we end up loading BOTH xim ANd scim (and maybe uim too)
   // etc. etc. when we need only 1!
   eina_module_list_load(module_list);
}
Exemple #2
0
static void
_emotion_modules_load(void)
{
   char buf[PATH_MAX];

   if (_emotion_modules_loaded) return;
   _emotion_modules_loaded = EINA_TRUE;

#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
   if (getuid() == geteuid())
#endif
     {
        if (getenv("EFL_RUN_IN_TREE"))
          {
             struct stat st;
             snprintf(buf, sizeof(buf), "%s/src/modules/emotion",
                      PACKAGE_BUILD_DIR);
             if (stat(buf, &st) == 0)
               {
                  const char *built_modules[] = {
#ifdef EMOTION_BUILD_GSTREAMER
                     "gstreamer",
#endif
#ifdef EMOTION_BUILD_GSTREAMER1
                     "gstreamer1",
#endif
#ifdef EMOTION_BUILD_XINE
                     "xine",
#endif
                     NULL
                  };
                  const char **itr;
                  for (itr = built_modules; *itr != NULL; itr++)
                    {
                       snprintf(buf, sizeof(buf),
                                "%s/src/modules/emotion/%s/.libs",
                                PACKAGE_BUILD_DIR, *itr);
                       _emotion_modules = eina_module_list_get(_emotion_modules, buf,
                                                               EINA_FALSE, NULL, NULL);
                    }
                  return;
               }
          }
     }

   snprintf(buf, sizeof(buf), "%s/emotion/modules", eina_prefix_lib_get(_emotion_pfx));
   _emotion_modules = eina_module_arch_list_get(_emotion_modules, buf, MODULE_ARCH);
// no - this is dumb. load ALL modules we find - force ALL the code pages of
// every lib a module MAY depend on and need to execute some init code into
// memory even if we never use it? not a good idea! the point of modules was
// to avoid such cost until a module is EXPLICITLY asked for.
//load:
//   if (_emotion_modules)
//     eina_module_list_load(_emotion_modules);
//
//   if (!_emotion_engine_registry)
//     ERR("Couldn't find any emotion engine.");
}
int
main(int argc, char **argv)
{
   int i, do_precache = 0, valgrind_mode = 0;
   int valgrind_tool = 0;
   char buf[16384], **args, *p;
   char valgrind_path[PATH_MAX] = "";
   const char *valgrind_log = NULL;

   eina_init();
   prefix_determine(argv[0]);

   env_set("E_START", argv[0]);

   p = getenv("PATH");
   if (p) snprintf(buf, sizeof(buf), "%s:%s", eina_prefix_bin_get(pfx), p);
   else snprintf(buf, sizeof(buf), "%s", eina_prefix_bin_get(pfx));
   env_set("PATH", buf);

   p = getenv("LD_LIBRARY_PATH");
   if (p) snprintf(buf, sizeof(buf), "%s:%s", eina_prefix_lib_get(pfx), p);
   else snprintf(buf, sizeof(buf), "%s", eina_prefix_lib_get(pfx));
   env_set("LD_LIBRARY_PATH", buf);

   for (i = 1; i < argc; i++)
     {
	if (!strcmp(argv[i], "-no-precache")) do_precache = 0;
	else if (!strncmp(argv[i], "-valgrind", sizeof("-valgrind") - 1))
	  {
	     const char *val = argv[i] + sizeof("-valgrind") - 1;

	     if (*val == '\0') valgrind_mode = 1;
	     else if (*val == '-')
	       {
		  val++;
		  if (!strncmp(val, "log-file=", sizeof("log-file=") - 1))
		    {
		       valgrind_log = val + sizeof("log-file=") - 1;
		       if (*valgrind_log == '\0') valgrind_log = NULL;
		    }
	       }
	     else if (*val == '=')
	       {
		  val++;
		  if (!strcmp(val, "all")) valgrind_mode = VALGRIND_MODE_ALL;
		  else valgrind_mode = atoi(val);
	       }
	     else
                printf("Unknown valgrind option: %s\n", argv[i]);
	  }
	else if (!strcmp(argv[i], "-massif")) valgrind_tool = 1;
	else if (!strcmp(argv[i], "-callgrind")) valgrind_tool = 2;
        else if ((!strcmp(argv[i], "-h")) ||
		 (!strcmp(argv[i], "-help")) ||
		 (!strcmp(argv[i], "--help")))
	  {
	     printf
                (
                    "Options:\n"
                    "\t-no-precache\n"
                    "\t\tDisable pre-caching of files\n"
                    "\t-valgrind[=MODE]\n"
                    "\t\tRun enlightenment from inside valgrind, mode is OR of:\n"
                    "\t\t   1 = plain valgrind to catch crashes (default)\n"
                    "\t\t   2 = trace children (thumbnailer, efm slaves, ...)\n"
                    "\t\t   4 = check leak\n"
                    "\t\t   8 = show reachable after processes finish.\n"
                    "\t\t all = all of above\n"
                    "\t-massif\n"
                    "\t\tRun enlightenment from inside massif valgrind tool.\n"
                    "\t-callgrind\n"
                    "\t\tRun enlightenment from inside callgrind valgrind tool.\n"
                    "\t-valgrind-log-file=<FILENAME>\n"
                    "\t\tSave valgrind log to file, see valgrind's --log-file for details.\n"
                    "\n"
                    "Please run:\n"
                    "\tenlightenment %s\n"
                    "for more options.\n",
                    argv[i]);
	     exit(0);
	  }
     }

   if (valgrind_mode || valgrind_tool)
     {
	if (!find_valgrind(valgrind_path, sizeof(valgrind_path)))
	  {
	     printf("E - valgrind required but no binary found! Ignoring request.\n");
	     valgrind_mode = 0;
	  }
     }
   
   printf("E - PID=%i, do_precache=%i, valgrind=%d", getpid(), do_precache, valgrind_mode);
   if (valgrind_mode)
     {
	printf(" valgrind-command='%s'", valgrind_path);
	if (valgrind_log) printf(" valgrind-log-file='%s'", valgrind_log);
     }
   putchar('\n');
   
   if (do_precache)
     {
	void *lib, *func;
        
	/* sanity checks - if precache might fail - check here first */
	lib = dlopen("libeina.so", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) dlopen("libeina.so.1", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) goto done;
	func = dlsym(lib, "eina_init");
	if (!func) goto done;

	lib = dlopen("libecore.so", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) dlopen("libecore.so.1", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) goto done;
	func = dlsym(lib, "ecore_init");
	if (!func) goto done;

	lib = dlopen("libecore_file.so", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) dlopen("libecore_file.so.1", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) goto done;
	func = dlsym(lib, "ecore_file_init");
	if (!func) goto done;

	lib = dlopen("libecore_x.so", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) dlopen("libecore_x.so.1", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) goto done;
	func = dlsym(lib, "ecore_x_init");
	if (!func) goto done;

	lib = dlopen("libevas.so", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) dlopen("libevas.so.1", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) goto done;
	func = dlsym(lib, "evas_init");
	if (!func) goto done;

	lib = dlopen("libedje.so", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) dlopen("libedje.so.1", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) goto done;
	func = dlsym(lib, "edje_init");
	if (!func) goto done;

	lib = dlopen("libeet.so", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) dlopen("libeet.so.0", RTLD_GLOBAL | RTLD_LAZY);
	if (!lib) goto done;
	func = dlsym(lib, "eet_init");
	if (!func) goto done;

	/* precache SHOULD work */
	snprintf(buf, sizeof(buf), "%s/enlightenment/preload/e_precache.so",
                 eina_prefix_lib_get(pfx));
	env_set("LD_PRELOAD", buf);
	printf("E - PRECACHE GOING NOW...\n");
	fflush(stdout);
	precache();
     }
done:
   
   /* mtrack memory tracker support */
   p = getenv("HOME");
   if (p)
     {
        FILE *f;

        /* if you have ~/.e-mtrack, then the tracker will be enabled
         * using the content of this file as the path to the mtrack.so
         * shared object that is the mtrack preload */
        snprintf(buf, sizeof(buf), "%s/.e-mtrack", p);
        f = fopen(buf, "r");
        if (f)
          {
             if (fgets(buf, sizeof(buf), f))
               {
                  int len = strlen(buf);
                  if ((len > 1) && (buf[len - 1] == '\n'))
                    {
                       buf[len - 1] = 0;
                       len--;
                    }
                  env_set("LD_PRELOAD", buf);
                  env_set("MTRACK", "track");
                  env_set("E_START_MTRACK", "track");
                  snprintf(buf, sizeof(buf), "%s/.e-mtrack.log", p);
                  env_set("MTRACK_TRACE_FILE", buf);
               }
             fclose(f);
          }
     }
   
   /* try dbus-launch */
   snprintf(buf, sizeof(buf), "%s/enlightenment", eina_prefix_bin_get(pfx));

   args = alloca((argc + 2 + VALGRIND_MAX_ARGS) * sizeof(char *));
   if ((!getenv("DBUS_SESSION_BUS_ADDRESS")) &&
       (!getenv("DBUS_LAUNCHD_SESSION_BUS_SOCKET")))
     {
	args[0] = "dbus-launch";
	args[1] = "--exit-with-session";
        
	i = 2 + valgrind_append(args + 2, valgrind_mode, valgrind_tool, valgrind_path, valgrind_log);
	args[i++] = buf;
	copy_args(args + i, argv + 1, argc - 1);
	args[i + argc - 1] = NULL;
	execvp("dbus-launch", args);
     }
   
   /* dbus-launch failed - run e direct */
   i = valgrind_append(args, valgrind_mode, valgrind_tool, valgrind_path, valgrind_log);
   args[i++] = buf;
   copy_args(args + i, argv + 1, argc - 1);
   args[i + argc - 1] = NULL;
   execv(args[0], args);

   printf("FAILED TO RUN:\n");
   printf("  %s\n", buf);
   perror("execv");
   return -1;
}
Exemple #4
0
static Eina_Bool
_etui_modules_load(void)
{
    char buf[PATH_MAX];
    char *path;
    Eina_Prefix *prefix;

    if (_etui_modules_loaded)
        return EINA_TRUE;

    _etui_modules_loaded = EINA_TRUE;

    path = eina_module_environment_path_get("HOME", "/.etui/modules");
    if (path)
    {
        _etui_modules = eina_module_arch_list_get(_etui_modules, path, MODULE_ARCH);
        free(path);
    }

    path = eina_module_environment_path_get("ETUI_MODULES_DIR", "/etui/modules");
    if (path)
    {
        _etui_modules = eina_module_arch_list_get(_etui_modules, path, MODULE_ARCH);
        free(path);
    }

    prefix = eina_prefix_new(NULL, etui_init,
                             "ETUI", "etui", "checkme",
                             PACKAGE_BIN_DIR, PACKAGE_LIB_DIR,
                             PACKAGE_DATA_DIR, PACKAGE_DATA_DIR);
    if (prefix)
    {
        snprintf(buf, sizeof(buf),
                 "%s/etui/modules", eina_prefix_lib_get(prefix));
        _etui_modules = eina_module_arch_list_get(_etui_modules, buf, MODULE_ARCH);
        eina_prefix_free(prefix);
    }
    else
    {
        INF("Could not create prefix, use library path directly.");
        _etui_modules = eina_module_arch_list_get(_etui_modules, PACKAGE_LIB_DIR"/etui/modules", MODULE_ARCH);
    }

    path = eina_module_symbol_path_get(etui_object_add, "/etui/modules");
    if (path)
    {
        _etui_modules = eina_module_list_get(_etui_modules, path, 0, NULL, NULL);
        free(path);
    }

    if (!_etui_modules)
    {
        ERR("Could not find modules.");
        return EINA_FALSE;
    }

    eina_module_list_load(_etui_modules);

    /* TODO: registry */

    return EINA_TRUE;
}