[mesonbuild] update meson build
authorhyeonseok lee <hs89.lee@samsung.com>
Wed, 4 Aug 2021 04:07:59 +0000 (13:07 +0900)
committerJijoong Moon <jijoong.moon@samsung.com>
Thu, 5 Aug 2021 08:37:48 +0000 (17:37 +0900)
 - Make platform meson option
 - Check sysroot

Signed-off-by: hyeonseok lee <hs89.lee@samsung.com>
Applications/VGG/jni/meson.build
api/capi/meson.build
meson.build
meson_options.txt
nntrainer/meson.build
packaging/nntrainer.spec

index 6169114f604b369ffcc03cacf94d01e5272b8dc1..ce88f1ecc42dd4a7731636124d961ac92a4c66c1 100644 (file)
@@ -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
index eee567ef55ffd36c8871bb8dc5c26a209dd2d038..fad69a7ac048bb0880ed88ebe80e2afbe817d62d 100644 (file)
@@ -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 = [
index 7135aa7f2cb10d78571abe2093939a5ef157210d..d5db30538a86348ea5a36ed1e4d2bcb47f36cd2e 100644 (file)
@@ -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
 
index e024f200aa25e867ef5bc3f2c61ccd8d19a81f8d..01674bdf6a92469b79d87b5f5a3fa11be98ea2da 100644 (file)
@@ -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)
index b6da47b20be772d289bc9c676f696aba4ed630c4..793c3335ee686deda08d1f903cfc2dfa3dfccb2e 100644 (file)
@@ -21,7 +21,7 @@ nntrainer_base_deps=[
   thread_dep
 ]
 
-if build_platform == 'tizen'
+if get_option('platform') == 'tizen'
   nntrainer_base_deps += dependency('dlog')
 endif
 
index 977709bdf153de1185ffc9359b3cd4b747093b7f..6d42b2896c0f79971d3120ec487b640937d8c967 100644 (file)
@@ -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} \