Disable iniparser and fuse as default
authorJiho Chu <jiho.chu@samsung.com>
Fri, 19 Jul 2024 00:57:56 +0000 (09:57 +0900)
committerWook Song <wook16.song@samsung.com>
Tue, 18 Mar 2025 07:28:09 +0000 (16:28 +0900)
It adds an inipaser option and it's default disabled.
Also, it removes fuse dependency when cuse is disabled.

Signed-off-by: Jiho Chu <jiho.chu@samsung.com>
meson.build
meson_options.txt
packaging/npu-engine.spec
src/core/npu/NPUdrvAPI_emul.cc
src/core/utils/meson.build
src/core/utils/ne-conf.cc
src/core/utils/ne-conf.h
utils/examples/meson.build
utils/idu_load/meson.build
utils/meson.build

index 11d64483c9e0d5d00877deb0d2937bbc3c0d72d1..a82d8f79eb0f08c3487fc518e11302b0ab759093 100644 (file)
@@ -126,19 +126,23 @@ endif
 libdl_dep = cc.find_library('dl') # DL library
 libm_dep = cc.find_library('m') # math library
 thread_dep = dependency('threads') # pthread library
-iniparser_dep = dependency('iniparser', required: false) # iniparser library
-if not iniparser_dep.found()
-  libiniparser = cpp.find_library('iniparser')
-  if libiniparser.found() and cpp.has_header('iniparser.h',\
-      args : sysroot_inc_cflags_iniparser)
-    iniparser_dep = declare_dependency(
-      compile_args : sysroot_inc_cflags_iniparser,
-      dependencies: libiniparser,
-    )
-  else
-    error('Failed to resovle dependency on libiniparser')
+
+if get_option('enable_ini_parser')
+  iniparser_dep = dependency('iniparser', required: false) # iniparser library
+  if not iniparser_dep.found()
+    libiniparser = cpp.find_library('iniparser')
+    if libiniparser.found() and cpp.has_header('iniparser.h',\
+        args : sysroot_inc_cflags_iniparser)
+      iniparser_dep = declare_dependency(
+        compile_args : sysroot_inc_cflags_iniparser,
+        dependencies: libiniparser,
+      )
+    else
+      error('Failed to resovle dependency on libiniparser')
+    endif
   endif
 endif
+
 libdrm_dep = dependency('libdrm')
 npubinfmt_dep = dependency('npubin-fmt', required: true)
 
index ac18f3e10d4466edd1164042cd32b42d52e047ef..59d864aa1672a41c453aa8b226db964a19badb30 100644 (file)
@@ -9,6 +9,7 @@ option('mute_stdout', type : 'boolean', value : false)
 option('target_platform', type : 'combo', choices : ['debian', 'tizen', 'fpga'], value : 'debian')
 option('enable_npu_emul', type : 'boolean', value : false)
 option('enable_npu_cuse', type : 'boolean', value : false)
+option('enable_ini_parser', type : 'boolean', value : false)
 option('enable_data_manip', type : 'boolean', value : false)
 option('enable_buffering', type : 'boolean', value : false)
 option('enable_plugin_npumgr', type : 'boolean', value : false)
index 12c018749acb008ce062b3d87211a65d60cb4da7..38f20ee3d77d06c0fd8afa5581642d4088fb8390 100644 (file)
@@ -17,12 +17,16 @@ BuildRequires:      pkg-config
 ## TODO: add the uapi header (trinity.h) to a kernel header package
 # BuildRequires: linux-kernel-headers
 
+%if 0%{?npu_iniparser}
 # NE-CONF uses iniparser
 BuildRequires: pkgconfig(iniparser)
+%define enable_ini_parser -Denable_ini_parser=true
+%else
+%define enable_ini_parser -Denable_ini_parser=false
+%endif
 
 # utils
 BuildRequires: ncurses-devel
-BuildRequires: fuse-devel
 
 # test
 BuildRequires: gtest-devel
@@ -42,6 +46,7 @@ BuildRequires:        libmrpsim-devel >= 3.9.1
 
 %if 0%{?npu_cuse}
 BuildRequires: libmrpsim-devel >= 3.9.1
+BuildRequires: fuse-devel
 %define enable_npu_cuse -Denable_npu_cuse=true
 %else
 %define enable_npu_cuse -Denable_npu_cuse=false
@@ -83,6 +88,7 @@ meson --buildtype=plain --bindir=%{neexampledir} --prefix=%{_prefix} \
       --datadir=%{_datadir} --sysconfdir=%{_sysconfdir} \
       -Dtarget_platform=tizen -Denable_data_manip=true \
       %{enable_npu_emul} %{enable_npu_cuse} %{enable_plugin_npumgr} %{enable_plugin_nns} %{skip_idu_check} \
+      %{enable_ini_parser} \
       build
 ninja -C build %{?_smp_mflags}
 
index f5a42c1a5dbac7b938d00edb88d8a7971305b6bc..d54459e479dff5a8d424eebffb23159696a0b737 100644 (file)
@@ -19,6 +19,7 @@
 #include <atomic>
 #include <memory>
 #include <chrono>
+#include <unistd.h>
 
 #include <triv2profile.h>
 #include <npubinfmt.h>
index e11d3a2a84f289a7bc87f80495fdc1b67eb3c9e5..d17f91d1d0026df222afdb2eaca701da03cb3cb8 100644 (file)
@@ -4,11 +4,15 @@ ne_core_utils_src = [
   'ne-conf.cc'
 ]
 
-ne_core_utils_deps = [iniparser_dep]
+ne_core_utils_deps = []
+
+if get_option('enable_ini_parser')
+  ne_core_utils_deps += [iniparser_dep]
+endif
 
 if target_platform == 'tizen'
   dlog_dep = dependency('dlog')
-  ne_core_utils_deps += dlog_dep
+  ne_core_utils_deps += [dlog_dep]
 endif
 
 ne_core_utils_dep = declare_dependency (
index 6f3910af404c65cd2589b2a8469c71a17d46183c..d9835c008fff68a4de9f2b68047b65f72c9d953e 100644 (file)
@@ -106,10 +106,12 @@ Conf::getMuteStdout (bool is_default) const {
 /**
  * @breif error callback of iniparser, used to ignore its error message
  */
+#ifdef ENABLE_INIPARSER
 static int
 error_callback (const char *, ...) {
   return 0;
 }
+#endif
 
 /**
  * @brief Constructor of Conf class, loading default configurations.
@@ -137,6 +139,7 @@ Conf::loadConf (const char *inipath) {
 
   snprintf (default_ini_path, PATH_MAX, "%s/%s", NE_INIDIR, INI_FILE_NAME);
 
+#ifdef ENABLE_INIPARSER
   /** Ignore error messages */
   iniparser_set_error_callback (error_callback);
 
@@ -146,6 +149,7 @@ Conf::loadConf (const char *inipath) {
     loadConfIni (ini);
     iniparser_freedict (ini);
   }
+#endif
 
   /** Load up config from envvar if available */
   loadConfEnvvar ();
@@ -274,6 +278,7 @@ Conf::setNumThreads (const char *num_threads) {
  * @param[in] ini The parsed .ini file.
  * @note if a config param is nullptr, it is not set. so use default one.
 */
+#ifdef ENABLE_INIPARSER
 void
 Conf::loadConfIni (dictionary *ini) {
   const char *resv_mem_size = iniparser_getstring (ini, "main:resv_mem_size", nullptr);
@@ -293,6 +298,7 @@ Conf::loadConfIni (dictionary *ini) {
   setPrefixProfile (prefix_profile);
   setMuteStdout (mute_stdout == 1);
 }
+#endif
 
 /**
  * @brief Load configuration with env-vars
index f2833234bb67da6203b4affe36ef3fca8b3869fd..095e4d2db26598fa1bfca436d94ef023f1a36a36 100644 (file)
 #define __NE_CONF_H__
 
 #include <stdint.h>
+
+#ifdef ENABLE_INIPARSER
 #include <iniparser.h>
+#endif
 
 #include <memory>
 #include <mutex>
@@ -58,7 +61,9 @@ class Conf {
   Conf ();
 
   void loadConf (const char *inipath);
+#ifdef ENABLE_INIPARSER
   void loadConfIni (dictionary *ini);
+#endif
   void loadConfDefault ();
   void loadConfEnvvar ();
 
index d2414855bb257cd8bd36f2195893109eca16eb0a..e16e0924ef26ac8e5b5c19e6d2a160070c9f9e3d 100644 (file)
@@ -2,7 +2,7 @@
 executable ('model_share',
   'model_share.cc',
   include_directories : [ne_core_utils_inc, ne_host_inc],
-  dependencies : [npubinfmt_dep, ne_test_utils_common_dep, thread_dep],
+  dependencies : [npubinfmt_dep, ne_test_utils_common_dep, thread_dep, ne_core_utils_dep],
   link_with : ne_library_shared,
   install : true,
   install_rpath : ne_libdir,
index 177fce574b272087d3ae1e3f7639b8bd2a932116..f8603edaee6db23c35cf59659bb3f4612e296bac 100644 (file)
@@ -5,7 +5,7 @@ utils_idu_srcs = [
   'idu-load.cc',
 ]
 
-utils_trinity_cuse = executable('idu-load',
+utils_trinity_idu_load = executable('idu-load',
   [utils_idu_srcs],
   include_directories: [ne_uapi_inc],
   install : true,
index 7340e4d3c80ddef67165adfa61fbcdf9a2127824..6bb1126d723c5373f450a0c6c6d0fe62bd687538 100644 (file)
@@ -3,5 +3,4 @@ subdir('trinity_smi')
 subdir('trinity_cuse')
 subdir('trinity_test')
 subdir('trinity_trace')
-subdir('idu_load')
 subdir('examples')