export DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
export DEB_HOST_ARCH ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
export GST_PLUGIN_PATH=${ROOT_DIR}/build/gst/nnstreamer
+export NNSTREAMER_CONF=${ROOT_DIR}/build/nnstreamer-test.ini
export NNSTREAMER_FILTERS=${ROOT_DIR}/build/ext/nnstreamer/tensor_filter
export NNSTREAMER_DECODERS=${ROOT_DIR}/build/ext/nnstreamer/tensor_decoder
typedef struct
{
gboolean loaded; /**< TRUE if loaded at least once */
+ gboolean enable_envvar; /**< TRUE to parse env variables */
gchar *conffile; /**< Location of conf file. */
memset (&conf, 0, sizeof (confdata));
}
- /* Read from Environmental Variables */
- conf.conffile = _strdup_getenv (NNSTREAMER_ENVVAR_CONF_FILE);
- if (!conf.conffile || !g_file_test (conf.conffile, G_FILE_TEST_IS_REGULAR)) {
+ /* Read from the conf file first */
+ conf.conffile = g_strdup (NNSTREAMER_CONF_FILE);
+ if (!g_file_test (conf.conffile, G_FILE_TEST_IS_REGULAR)) {
/* File not found or not configured */
- if (NULL != conf.conffile)
- g_free (conf.conffile);
- conf.conffile = g_strdup (NNSTREAMER_DEFAULT_CONF_FILE);
- }
+ g_free (conf.conffile);
- conf.pathFILTERS[0] = _strdup_getenv (NNSTREAMER_ENVVAR_FILTERS);
- conf.pathDECODERS[0] = _strdup_getenv (NNSTREAMER_ENVVAR_DECODERS);
- conf.pathCUSTOM_FILTERS[0] = _strdup_getenv (NNSTREAMER_ENVVAR_CUSTOMFILTERS);
+ /* Try to read from Environmental Variables */
+ conf.conffile = _strdup_getenv (NNSTREAMER_ENVVAR_CONF_FILE);
+ }
/* Read the conf file. It's ok even if we cannot load it. */
if (g_key_file_load_from_file (key_file, conf.conffile, G_KEY_FILE_NONE,
NULL)) {
+ gchar *value;
+
+ value = g_key_file_get_string (key_file, "common", "enable_envvar", NULL);
+ conf.enable_envvar = _parse_bool_string (value, FALSE);
+ g_free (value);
conf.pathFILTERS[1] =
g_key_file_get_string (key_file, "filter", "filters", NULL);
g_key_file_get_string (key_file, "filter", "customfilters", NULL);
}
+ /* Read from env variables. */
+ if (conf.enable_envvar) {
+ conf.pathFILTERS[0] = _strdup_getenv (NNSTREAMER_ENVVAR_FILTERS);
+ conf.pathDECODERS[0] = _strdup_getenv (NNSTREAMER_ENVVAR_DECODERS);
+ conf.pathCUSTOM_FILTERS[0] =
+ _strdup_getenv (NNSTREAMER_ENVVAR_CUSTOMFILTERS);
+ }
+
/* Strdup the hardcoded */
conf.pathFILTERS[2] = g_strdup (NNSTREAMER_FILTERS);
conf.pathDECODERS[2] = g_strdup (NNSTREAMER_DECODERS);
value = g_hash_table_lookup (custom_table, hashkey);
if (NULL == value) {
- gchar *envkey = g_strdup_printf ("NNSTREAMER_%s_%s", group, key);
-
/* 1. Read envvar */
- value = _strdup_getenv (envkey);
- g_free (envkey);
+ if (conf.enable_envvar) {
+ gchar *envkey = g_strdup_printf ("NNSTREAMER_%s_%s", group, key);
+
+ value = _strdup_getenv (envkey);
+ g_free (envkey);
+ }
/* 2. Read ini */
if (NULL == value && conf.conffile) {
/* Internal Hardcoded Values */
#define NNSTREAMER_DEFAULT_CONF_FILE "/etc/nnstreamer.ini"
+#ifndef NNSTREAMER_CONF_FILE
+#define NNSTREAMER_CONF_FILE NNSTREAMER_DEFAULT_CONF_FILE
+#endif
#define NNSTREAMER_FILTERS "/usr/lib/nnstreamer/filters/"
#define NNSTREAMER_DECODERS "/usr/lib/nnstreamer/decoders/"
#define NNSTREAMER_CUSTOM_FILTERS "/usr/lib/nnstreamer/customfilters/"
project('nnstreamer', 'c', 'cpp',
version: '0.1.3',
license: ['LGPL'],
- meson_version: '>=0.40.0',
+ meson_version: '>=0.42.0',
default_options: [
'werror=true',
'warning_level=1',
]
)
-add_project_arguments('-DVERSION="'+meson.project_version()+'"', language: ['c', 'cpp'])
+add_project_arguments('-DVERSION="' + meson.project_version() + '"', language: ['c', 'cpp'])
cc = meson.get_compiler('c')
cxx = meson.get_compiler('cpp')
gst_api_verision = '1.0'
-# Set configuration
-nnstreamer_conf = configuration_data()
-nnstreamer_conf.set('VERSION', meson.project_version())
-
# Set install path
nnstreamer_prefix = get_option('prefix')
nnstreamer_libdir = join_paths(nnstreamer_prefix, get_option('libdir'))
customfilter_install_dir = join_paths(subplugin_install_prefix, 'customfilters')
unittest_install_dir = join_paths(subplugin_install_prefix, 'unittest')
+# Set default configuration
+nnstreamer_conf = configuration_data()
+nnstreamer_conf.set('VERSION', meson.project_version())
nnstreamer_conf.set('PREFIX', nnstreamer_prefix)
nnstreamer_conf.set('EXEC_PREFIX', nnstreamer_bindir)
nnstreamer_conf.set('LIB_INSTALL_DIR', nnstreamer_libdir)
nnstreamer_conf.set('INCLUDE_INSTALL_DIR', nnstreamer_includedir)
nnstreamer_conf.set('SUBPLUGIN_INSTALL_PREFIX', subplugin_install_prefix)
+# Define default conf file
+add_project_arguments('-DNNSTREAMER_CONF_FILE="' + join_paths(nnstreamer_inidir, 'nnstreamer.ini') + '"', language: 'c')
+
# Dependencies
glib_dep = dependency('glib-2.0')
gst_dep = dependency('gstreamer-' + gst_api_verision)
else
error('Cannot find tensorflow')
endif
-
- nnstreamer_conf.set('TF_MEM_OPTMZ', get_option('enable-tensorflow-mem-optmz'))
-else
- message('Tensorflow is disabled')
- nnstreamer_conf.set('TF_MEM_OPTMZ', false)
endif
# Tensorflow-lite
# Build unittests
if get_option('enable-test')
subdir('tests')
+
+ # temporary ini file for test, enable env variables.
+ nnstreamer_test_conf = configuration_data()
+ nnstreamer_test_conf.merge_from(nnstreamer_conf)
+
+ nnstreamer_test_conf.set('ENABLE_ENV_VAR', true)
+ nnstreamer_test_conf.set('TF_MEM_OPTMZ', false)
+
+ # meson 0.50 supports install argument in configure_file()
+ if get_option('install-test')
+ configure_file(input: 'nnstreamer.ini.in', output: 'nnstreamer-test.ini',
+ install_dir: unittest_install_dir,
+ configuration: nnstreamer_test_conf
+ )
+ else
+ configure_file(input: 'nnstreamer.ini.in', output: 'nnstreamer-test.ini',
+ configuration: nnstreamer_test_conf
+ )
+ endif
endif
+# Set configuration to install .ini
+nnstreamer_install_conf = configuration_data()
+nnstreamer_install_conf.merge_from(nnstreamer_conf)
+
+nnstreamer_install_conf.set('ENABLE_ENV_VAR', get_option('enable-env-var'))
+nnstreamer_install_conf.set('TF_MEM_OPTMZ', get_option('enable-tensorflow-mem-optmz'))
+
# Install .ini
configure_file(input: 'nnstreamer.ini.in', output: 'nnstreamer.ini',
install_dir: nnstreamer_inidir,
- configuration: nnstreamer_conf
+ configuration: nnstreamer_install_conf
)
# Install .pc
configure_file(input: 'nnstreamer.pc.in', output: 'nnstreamer.pc',
install_dir: join_paths(nnstreamer_libdir, 'pkgconfig'),
- configuration: nnstreamer_conf
+ configuration: nnstreamer_install_conf
)
option('install-example', type: 'boolean', value: false)
option('disable-video-support', type: 'boolean', value: false)
option('disable-audio-support', type: 'boolean', value: false)
+option('enable-env-var', type: 'boolean', value: true)
option('enable-tizen-capi', type: 'boolean', value: false)
option('enable-python', type: 'boolean', value: true)
+# Set 1 or True if you want to set your custom sub-plugins' path with env variables.
+# Please be informed that, configured ini file should be in RO partition for the release binary.
+[common]
+enable_envvar=@ENABLE_ENV_VAR@
+
[filter]
filters=@SUBPLUGIN_INSTALL_PREFIX@/filters/
customfilters=@SUBPLUGIN_INSTALL_PREFIX@/customfilters/
enable_tf=false
%endif
-meson --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir=%{_libdir} --bindir=%{nnstexampledir} --includedir=%{_includedir} -Dinstall-example=true -Denable-tensorflow=${enable_tf} %{api} build
+meson --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} --libdir=%{_libdir} --bindir=%{nnstexampledir} --includedir=%{_includedir} -Dinstall-example=true -Denable-tensorflow=${enable_tf} %{api} -Denable-env-var=false build
ninja -C build %{?_smp_mflags}
%if 0%{?unit_test}
pushd build
export GST_PLUGIN_PATH=$(pwd)/gst/nnstreamer
+ export NNSTREAMER_CONF=$(pwd)/nnstreamer-test.ini
export NNSTREAMER_FILTERS=$(pwd)/ext/nnstreamer/tensor_filter
export NNSTREAMER_DECODERS=$(pwd)/ext/nnstreamer/tensor_decoder
./tests/unittest_common
project('capi-nnstreamer', 'c',
version: '0.1',
license: ['LGPL'],
- meson_version: '>=0.40.0',
+ meson_version: '>=0.42.0',
default_options: [
'werror=true',
'warning_level=1',
project('{fname}', 'c',
version: '1.0',
license: ['LGPL'],
- meson_version: '>=0.40.0',
+ meson_version: '>=0.42.0',
default_options: [
'warning_level=1',
]