From: Jihoon Lee Date: Mon, 20 Apr 2020 06:34:05 +0000 (+0900) Subject: Add feature object handler X-Git-Tag: submit/tizen/20200604.023022~55 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0aeb8c0089888f1f99d263b3a7f37d7b52b66101;p=platform%2Fupstream%2Fnnstreamer.git Add feature object handler 1. Feature / feature handler added 2. Add video support as feature (and wipe out disable-video-support) * 3. Add extra args support 4. Implement enable-tesnorflow, enable-tensorflow-lite ... as feature 5. Implement enable-orc, ... as feature 6. Change docs Signed-off-by: Jihoon Lee --- diff --git a/meson.build b/meson.build index 2dec2ea..7f47cb8 100644 --- a/meson.build +++ b/meson.build @@ -146,11 +146,86 @@ else add_project_arguments('-DDISABLE_ORC=1', language: ['c', 'cpp']) endif -# NO Video support -if get_option('disable-video-support') - add_project_arguments('-DNO_VIDEO=1', language: ['c', 'cpp']) - message('Disable Video Type Support') -endif + +# features registration to be controlled +# +# because dict has no ordering guarantees, list is being used instead' +# register feature as follows +# [ , { +# deps: , +# is_available: +# project_args_when_available: , +# project_args_when_not_available: , +# message_when_available: , +# defaults to be "@feature_name@ is available"> +# message_when_not_available: +# extra_args_when_available: +# extra_args_when_not_available: +# } ] + +features = [ + [ + 'video-support', { + 'is_available': get_option('video-support').enabled() or get_option('video-support').auto(), + 'project_args_when_not_available': { 'NO_VIDEO': 1 }, + } + ] +] + +project_args = {} +# This section controls the flow of feature registration. +foreach f : features + if f.length() != 2 + error('registered feature length has to be 2, [, ]') + endif + + _feature_name = f[0] + _data = f[1] + + _deps = _data.get('deps', []) + + _deps_all_found = true + + foreach dep : _deps + if not dep.found() + warning('Target dependency is @0@ not found for feature @1@'.format(dep.name(), _feature_name)) + _deps_all_found = false + endif + endforeach + + _is_available = _data.get('is_available', _deps_all_found) # falling back to _deps_all_found if is_available is not present + # todo: expose availabilty by feature name + + _variable_postfix = _is_available ? '_when_available' : '_when_not_available' + _feature_status = _is_available ? 'available' : 'unavailable' + + # handle_msg and halt with error when not_available and not_enabled at the sametime by definition + _msg = _data.get('message' + _variable_postfix, '@0@ is @1@.'.format(_feature_name, _feature_status)) + if _is_available + message(_msg) + else # not available + get_option(_feature_name).enabled() ? error(_msg) : warning(_msg) + endif + + # handle project args + project_args += _data.get('project_args' + _variable_postfix, {}) + + _extra_args = _data.get('extra_args' + _variable_postfix, {}) + + # todo: expose _extra_args + +endforeach + +message('following project_args are used') +message(project_args) +configure_file( + output: 'project_definitions.h', + configuration: project_args +) # NO Audio support if get_option('disable-audio-support') diff --git a/meson_options.txt b/meson_options.txt index 7de7e99..62a2eac 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,3 +1,8 @@ +# features +option('video-support', type: 'feature', value: 'enabled') +option('audio-support', type: 'feature', value: 'enabled') + +# booleans & other options option('enable-test', type: 'boolean', value: true) option('enable-orc', type: 'boolean', value: true) # default true, use orc when found orc library option('install-test', type: 'boolean', value: false) @@ -9,7 +14,7 @@ option('enable-pytorch-use-gpu', type: 'boolean', value: false) # default value, option('enable-movidius-ncsdk2', type: 'boolean', value: false) option('enable-mediapipe', type: 'boolean', value: false) option('install-example', type: 'boolean', value: false) -option('disable-video-support', 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-symbolic-link', type: 'boolean', value: true)