From c0cd9f8b8fdc17eb4f3a9069f3b292e4d777e662 Mon Sep 17 00:00:00 2001 From: hyeonseok lee Date: Wed, 4 Aug 2021 13:07:59 +0900 Subject: [PATCH] [mesonbuild] update meson build - Make platform meson option - Check sysroot Signed-off-by: hyeonseok lee --- Applications/VGG/jni/meson.build | 2 +- api/capi/meson.build | 6 +++--- meson.build | 27 +++++++++++++++++++++------ meson_options.txt | 2 +- nntrainer/meson.build | 2 +- packaging/nntrainer.spec | 6 +++--- 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/Applications/VGG/jni/meson.build b/Applications/VGG/jni/meson.build index 6169114..ce88f1e 100644 --- a/Applications/VGG/jni/meson.build +++ b/Applications/VGG/jni/meson.build @@ -3,7 +3,7 @@ res_path = meson.current_source_dir() / '..' / 'res' mnist_sources = [ 'main.cpp' ] -if build_platform == 'tizen' +if get_option('platform') == 'tizen' if not gtest_dep.found() error('Gtest dependency not found for VGG application') endif diff --git a/api/capi/meson.build b/api/capi/meson.build index eee567e..fad69a7 100644 --- a/api/capi/meson.build +++ b/api/capi/meson.build @@ -8,7 +8,7 @@ if not nnstreamer_capi_dep.found() error('nnstreamer capi dependency not found for tizen') endif -if get_option('enable-tizen') and get_option('enable-tizen-feature-check') +if get_option('platform') == 'tizen' and get_option('enable-tizen-feature-check') capi_src += meson.current_source_dir() / 'src' / 'nntrainer-capi-tizen-feature-check.cpp' endif @@ -16,7 +16,7 @@ capi_headers = [] capi_headers += meson.current_source_dir() / 'include' / 'nntrainer.h' capi_headers += meson.current_source_dir() / '..' / 'nntrainer-api-common.h' -if get_option('enable-tizen') +if get_option('platform') == 'tizen' capi_headers += meson.current_source_dir() / 'include' / 'nntrainer-tizen-internal.h' endif @@ -25,7 +25,7 @@ capi_deps = [ nnstreamer_capi_dep, ] -if get_option('enable-tizen') +if get_option('platform') == 'tizen' message('CAPI is in Tizen mode') tizen_deps = [ diff --git a/meson.build b/meson.build index 7135aa7..d5db305 100644 --- a/meson.build +++ b/meson.build @@ -14,11 +14,9 @@ add_project_arguments('-DMIN_CPP_VERSION=201703L', language:['c','cpp']) cc = meson.get_compiler('c') cxx = meson.get_compiler('cpp') -build_platform = '' -if get_option('enable-tizen') +if get_option('platform') == 'tizen' # Pass __TIZEN__ to the compiler - build_platform = 'tizen' add_project_arguments('-D__TIZEN__=1', language:['c','cpp']) if get_option('enable-tizen-feature-check') @@ -108,7 +106,7 @@ endif if get_option('enable-blas') add_project_arguments('-DUSE_BLAS=1', language:['c','cpp']) - if build_platform == 'tizen' + if get_option('platform') == 'tizen' or get_option('platform') == 'yocto' blas_dep = dependency('openblas') else blas_dep = dependency('blas-openblas', required:false) @@ -142,14 +140,31 @@ endif libm_dep = cxx.find_library('m') # cmath library libdl_dep = cxx.find_library('dl') # DL library thread_dep = dependency('threads') # pthread for tensorflow-lite + iniparser_dep = dependency('iniparser', required : false, version : '>=4.1') # iniparser if not iniparser_dep.found() message('falling back to find libiniparser library and header files') libiniparser_dep = cxx.find_library('iniparser') + sysroot = run_command( + cxx.cmd_array() + ['-print-sysroot'] + ).stdout().split('\n')[0] + + if sysroot.startswith('/') + sysroot_inc_cflags_template = '-I@0@/usr/include@1@' + sysroot_inc = sysroot_inc_cflags_template.format(sysroot, '') + add_project_arguments(sysroot_inc, language: ['c', 'cpp']) + sysroot_inc_cflags_iniparser = sysroot_inc_cflags_template.format(sysroot, + '/iniparser') + else + sysroot_inc_cflags_iniparser = '-I/usr/include/iniparser' + endif + if libiniparser_dep.found() and cxx.has_header('iniparser.h', \ - args : '-I/usr/include/iniparser') + args : sysroot_inc_cflags_iniparser) iniparser_dep = declare_dependency (dependencies : libiniparser_dep, - compile_args : '-I/usr/include/iniparser') + compile_args : sysroot_inc_cflags_iniparser) + else + error('Failed to resolve dependency on iniparser') endif endif diff --git a/meson_options.txt b/meson_options.txt index e024f20..01674bd 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,4 @@ -option('enable-tizen', type: 'boolean', value: false) +option('platform', type: 'combo', choices: ['none', 'tizen', 'yocto'], value: 'none') option('enable-blas', type: 'boolean', value: true) option('enable-cublas', type: 'boolean', value: false) option('enable-app', type: 'boolean', value: true) diff --git a/nntrainer/meson.build b/nntrainer/meson.build index b6da47b..793c333 100644 --- a/nntrainer/meson.build +++ b/nntrainer/meson.build @@ -21,7 +21,7 @@ nntrainer_base_deps=[ thread_dep ] -if build_platform == 'tizen' +if get_option('platform') == 'tizen' nntrainer_base_deps += dependency('dlog') endif diff --git a/packaging/nntrainer.spec b/packaging/nntrainer.spec index 977709b..6d42b28 100644 --- a/packaging/nntrainer.spec +++ b/packaging/nntrainer.spec @@ -267,7 +267,7 @@ NNSteamer tensor filter static package for nntrainer to support inference. %endif #tizen ## Define build options -%define enable_tizen -Denable-tizen=false +%define platform -Dplatform=tizen %define enable_tizen_feature_check -Denable-tizen-feature-check=true %define install_app -Dinstall-app=true %define enable_ccapi -Denable-ccapi=false @@ -284,7 +284,7 @@ NNSteamer tensor filter static package for nntrainer to support inference. %endif %if %{with tizen} -%define enable_tizen -Denable-tizen=true +%define platform -Dplatform=tizen %if 0%{?support_ccapi} %define enable_ccapi -Denable-ccapi=true @@ -342,7 +342,7 @@ ln -sf %{_libdir}/pkgconfig/capi-nnstreamer.pc %{_libdir}/pkgconfig/capi-ml-comm mkdir -p build meson --buildtype=plain --prefix=%{_prefix} --sysconfdir=%{_sysconfdir} \ --libdir=%{_libdir} --bindir=%{nntrainerapplicationdir} \ - --includedir=%{_includedir} %{install_app} %{enable_tizen} \ + --includedir=%{_includedir} %{install_app} %{platform} \ %{enable_tizen_feature_check} %{enable_cblas} %{enable_ccapi} \ %{enable_gym} %{enable_nnstreamer_tensor_filter} %{enable_profile} \ %{enable_nnstreamer_backbone} %{enable_tflite_backbone} \ -- 2.7.4