[Action] upload meson test log if test failed
[platform/adaptation/npu/trix-engine.git] / meson.build
index e3433b6..f1c17f5 100644 (file)
@@ -1,7 +1,7 @@
 project('npu-engine', ['c', 'cpp'],
-  version: '2.0.0',
-  license: ['Proprietary'],
-  meson_version: '>=0.50.0',
+  version: '2.5.0',
+  license: ['Apache-2.0'],
+  meson_version: '>=0.47.0',
   default_options: [
     'werror=true',
     'warning_level=1',
@@ -12,6 +12,9 @@ project('npu-engine', ['c', 'cpp'],
 
 cc = meson.get_compiler('c')
 cpp = meson.get_compiler('cpp')
+sysroot = run_command(
+    cpp.cmd_array() + ['-print-sysroot']
+    ).stdout().split('\n')[0]
 
 warning_c_flags = [
   '-Wmissing-prototypes',
@@ -34,6 +37,7 @@ warning_flags = [
   '-Wvla',
   '-Wpointer-arith',
   '-Wno-sign-compare',
+  '-Wno-packed-not-aligned'
 ]
 
 foreach extra_arg : warning_c_flags
@@ -63,22 +67,73 @@ ne_libdir = join_paths(ne_prefix, get_option('libdir'))
 ne_bindir = join_paths(ne_prefix, get_option('bindir'))
 ne_includedir = join_paths(ne_prefix, get_option('includedir'))
 ne_inidir = get_option('sysconfdir')
-add_project_arguments('-DNE_INIDIR="' + ne_inidir + '"', language: ['c', 'cpp'])
 ne_datadir = join_paths(ne_prefix, join_paths(get_option('datadir'), 'npu-engine'))
 
+add_project_arguments('-DNE_PREFIX="' + ne_prefix + '"', language: ['c', 'cpp'])
+add_project_arguments('-DNE_INIDIR="' + ne_inidir + '"', language: ['c', 'cpp'])
+add_project_arguments('-DNE_DATADIR="' + ne_datadir + '"', language: ['c', 'cpp'])
+
 ne_common_inc = include_directories('include/common')
 ne_host_inc = include_directories('include/host')
+ne_uapi_inc = include_directories('include/uapi')
+
+# Check build platform
+target_platform = get_option('target_platform')
+if target_platform == 'tizen'
+  add_project_arguments('-D__TIZEN__=1', language: ['c', 'cpp'])
+elif target_platform == 'fpga'
+  ne_kernel_hdr = get_option('kernel_hdr_dir')
+  ne_hernel_hdr_cflags = '-I' + ne_kernel_hdr
+  if cpp.has_header('misc/trinity.h', args: ne_hernel_hdr_cflags)
+    add_project_arguments(ne_hernel_hdr_cflags, language: ['c', 'cpp'])
+    add_project_arguments('-D__FPGA__=1', language: ['c', 'cpp'])
+  else
+    if not cpp.has_header('misc/trinity.h')
+      error('Failed to find \'misc/trintiy.h\'. Try to use the -Dkernel_hdr_dir option.')
+    endif
+  endif
+else
+  # Default: debian distro
+  add_project_arguments('-I' + ne_prefix + '/include', language: ['c', 'cpp'])
+endif
+
+if get_option('enable_npu_emul')
+  add_project_arguments('-DENABLE_EMUL', language: ['c', 'cpp'])
+endif
+
+if get_option('enable_npu_cuse')
+  add_project_arguments('-DENABLE_CUSE', language: ['c', 'cpp'])
+endif
+
+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
+
 
 libdl_dep = cc.find_library('dl') # DL library
 libm_dep = cc.find_library('m') # math library
-libdrm_dep = dependency('libdrm') # libdrm library
 thread_dep = dependency('threads') # pthread library
-iniparser_dep = dependency('iniparser') # iniparser library
-
-if get_option('enable_npu_emul')
-  add_project_arguments('-I/opt/trinity/include', language: ['c', 'cpp'])
-  add_project_arguments('-DENABLE_EMUL', language: ['c', 'cpp'])
+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
+libdrm_dep = dependency('libdrm')
+
 if get_option('enable_data_manip')
   add_project_arguments('-DENABLE_MANIP', language: ['c', 'cpp'])
 endif
@@ -87,6 +142,8 @@ if get_option('enable_buffering')
 endif
 
 subdir('src')
+subdir('utils')
+subdir('plugins')
 subdir('tests')
 
 # Set configuration to install .ini
@@ -100,7 +157,11 @@ ne_install_conf.set('INCLUDE_INSTALL_DIR', ne_includedir)
 
 ne_install_conf.set('RESV_MEM_SIZE', get_option('resv_mem_size'))
 ne_install_conf.set('NUM_THREADS', get_option('num_threads'))
+ne_install_conf.set('PREFIX_SHARE', ne_prefix + get_option('prefix_share'))
+ne_install_conf.set('PREFIX_PROFILE', get_option('prefix_profile'))
 ne_install_conf.set('LOG_DIR', get_option('log_dir'))
+ne_install_conf.set('LOG_LEVEL', get_option('log_level'))
+ne_install_conf.set('MUTE_STDOUT', get_option('mute_stdout'))
 
 # Install .ini
 configure_file(input: 'npu-engine.ini.in', output: 'npu-engine.ini',