[macOS/Conf] Support .dylib as a file extension of sub-plugins
authorWook Song <wook16.song@samsung.com>
Tue, 27 Aug 2019 03:52:16 +0000 (12:52 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Thu, 29 Aug 2019 01:19:51 +0000 (10:19 +0900)
This patch adds .dylib as a file extension of sub-plugins to support.

Signed-off-by: Wook Song <wook16.song@samsung.com>
gst/nnstreamer/nnstreamer_conf.c
gst/nnstreamer/nnstreamer_conf.h

index a70f717..09e8260 100644 (file)
@@ -125,14 +125,14 @@ _validate_file (nnsconf_type_path type, const gchar * fullpath)
 }
 
 /**
- * @brief Private function to fill in ".so list" with fullpath-filenames in a directory.
+ * @brief Private function to fill in ".so/.dylib list" with fullpath-filenames in a directory.
  * @param[in] type conf type to scan.
  * @param[in] dir Directory to be searched.
  * @param[in/out] listF The fullpath list to be updated.
  * @param[in/out] listB The basename list to be updated.
  * @param[in/out] counter increased by the number of appended elements.
  * @return True if successfully updated.
- * @todo This assumes .so for all sub plugins. Support Windows/Mac/iOS!
+ * @todo This assumes .so/.dylib for all sub plugins. Support Windows!
  */
 static gboolean
 _get_filenames (nnsconf_type_path type, const gchar * dir, GSList ** listF,
@@ -146,9 +146,9 @@ _get_filenames (nnsconf_type_path type, const gchar * dir, GSList ** listF,
     return FALSE;
 
   while (NULL != (name = g_dir_read_name (gdir))) {
-    /* check file prefix for given type, handle .so only. */
+    /* check file prefix for given type, currently handle .so and .dylib. */
     if (g_str_has_prefix (name, subplugin_prefixes[type]) &&
-        g_str_has_suffix (name, ".so")) {
+        g_str_has_suffix (name, NNSTREAMER_SO_FILE_EXTENSION)) {
       fullpath = g_build_filename (dir, name, NULL);
 
       if (_validate_file (type, fullpath)) {
@@ -381,7 +381,8 @@ nnsconf_get_fullpath (const gchar * subpluginname, nnsconf_type_path type)
 
   nnsconf_loadconf (FALSE);
 
-  filename = g_strconcat (subplugin_prefixes[type], subpluginname, ".so", NULL);
+  filename = g_strconcat (subplugin_prefixes[type], subpluginname,
+      NNSTREAMER_SO_FILE_EXTENSION, NULL);
   ret = nnsconf_get_fullpath_from_file (filename, type);
 
   g_free (filename);
index 8cf6352..0239808 100644 (file)
@@ -43,6 +43,16 @@ G_BEGIN_DECLS
 #define NNSTREAMER_SYS_ROOT_PATH_PREFIX "/"
 #endif /* G_OS_WIN32 */
 
+/**
+ * Hard-coded system-dependent file extension string of shared
+ * (dynamic loadable) object
+ */
+#ifdef __MACOS__
+#define NNSTREAMER_SO_FILE_EXTENSION   ".dylib"
+#else
+#define NNSTREAMER_SO_FILE_EXTENSION   ".so"
+#endif
+
 /* Env-var names */
 #define NNSTREAMER_ENVVAR_CONF_FILE     "NNSTREAMER_CONF"
 #define NNSTREAMER_ENVVAR_FILTERS       "NNSTREAMER_FILTERS"