1 project('npu-engine', ['c', 'cpp'],
3 license: ['Proprietary'],
4 meson_version: '>=0.47.0',
13 cc = meson.get_compiler('c')
14 cpp = meson.get_compiler('cpp')
15 sysroot = run_command(
16 cpp.cmd_array() + ['-print-sysroot']
17 ).stdout().split('\n')[0]
20 '-Wmissing-prototypes',
21 '-Wmissing-declarations',
24 '-Wold-style-definition',
25 '-Wdeclaration-after-statement'
32 '-Wformat-nonliteral',
42 foreach extra_arg : warning_c_flags
43 if cc.has_argument (extra_arg)
44 add_project_arguments([extra_arg], language : 'c')
48 foreach extra_arg : warning_flags
49 if cc.has_argument (extra_arg)
50 add_project_arguments([extra_arg], language : 'c')
52 if cpp.has_argument (extra_arg)
53 add_project_arguments([extra_arg], language : 'cpp')
57 # Add version arguments
58 version = meson.project_version().split('.')
59 add_project_arguments('-DVER_NE_MAJOR=' + version[0], language: ['c', 'cpp'])
60 add_project_arguments('-DVER_NE_MINOR=' + version[1], language: ['c', 'cpp'])
61 add_project_arguments('-DVER_NE_EXTRA=' + version[2], language: ['c', 'cpp'])
64 ne_prefix = get_option('prefix')
65 ne_libdir = join_paths(ne_prefix, get_option('libdir'))
66 ne_bindir = join_paths(ne_prefix, get_option('bindir'))
67 ne_includedir = join_paths(ne_prefix, get_option('includedir'))
68 ne_inidir = get_option('sysconfdir')
69 ne_datadir = join_paths(ne_prefix, join_paths(get_option('datadir'), 'npu-engine'))
71 add_project_arguments('-DNE_INIDIR="' + ne_inidir + '"', language: ['c', 'cpp'])
72 add_project_arguments('-DNE_DATADIR="' + ne_datadir + '"', language: ['c', 'cpp'])
74 ne_common_inc = include_directories('include/common')
75 ne_host_inc = include_directories('include/host')
77 if not get_option('enable_npu_emul')
78 ne_kernel_hdr = get_option('kernel_hdr_dir')
79 ne_hernel_hdr_cflags = '-I' + ne_kernel_hdr
80 if cpp.has_header('misc/trinity.h', args: ne_hernel_hdr_cflags)
81 add_project_arguments(ne_hernel_hdr_cflags, language: ['c', 'cpp'])
83 if not cpp.has_header('misc/trinity.h')
84 error('Failed to find \'misc/trintiy.h\'. Try to use the -Dkernel_hdr_dir option.')
89 if sysroot.startswith('/')
90 sysroot_inc_cflags_template = '-I@0@/usr/include@1@'
91 sysroot_inc = sysroot_inc_cflags_template.format(sysroot, '')
92 add_project_arguments(sysroot_inc, language: ['c', 'cpp'])
93 sysroot_inc_cflags_iniparser = sysroot_inc_cflags_template.format(sysroot,
96 sysroot_inc_cflags_iniparser = '-I/usr/include/iniparser'
100 libdl_dep = cc.find_library('dl') # DL library
101 libm_dep = cc.find_library('m') # math library
102 thread_dep = dependency('threads') # pthread library
103 iniparser_dep = dependency('iniparser', required: false) # iniparser library
104 if not iniparser_dep.found()
105 libiniparser = cpp.find_library('iniparser')
106 if libiniparser.found() and cpp.has_header('iniparser.h',\
107 args : sysroot_inc_cflags_iniparser)
108 iniparser_dep = declare_dependency(
109 compile_args : sysroot_inc_cflags_iniparser,
110 dependencies: libiniparser,
113 error('Failed to resovle dependency on libiniparser')
116 libdrm_dep = dependency('libdrm')
118 if get_option('enable_npu_emul')
119 add_project_arguments('-I/opt/trinity/include', language: ['c', 'cpp'])
120 add_project_arguments('-DENABLE_EMUL', language: ['c', 'cpp'])
122 if get_option('enable_data_manip')
123 add_project_arguments('-DENABLE_MANIP', language: ['c', 'cpp'])
125 if get_option('enable_buffering')
126 add_project_arguments('-DENABLE_BUFFERING', language: ['c', 'cpp'])
132 # Set configuration to install .ini
133 ne_install_conf = configuration_data()
135 ne_install_conf.set('VERSION', meson.project_version())
136 ne_install_conf.set('PREFIX', ne_prefix)
137 ne_install_conf.set('EXEC_PREFIX', ne_bindir)
138 ne_install_conf.set('LIB_INSTALL_DIR', ne_libdir)
139 ne_install_conf.set('INCLUDE_INSTALL_DIR', ne_includedir)
141 ne_install_conf.set('RESV_MEM_SIZE', get_option('resv_mem_size'))
142 ne_install_conf.set('NUM_THREADS', get_option('num_threads'))
143 ne_install_conf.set('LOG_DIR', get_option('log_dir'))
144 ne_install_conf.set('LOG_VERBOSE', get_option('log_verbose'))
147 configure_file(input: 'npu-engine.ini.in', output: 'npu-engine.ini',
148 install_dir: ne_inidir,
149 configuration: ne_install_conf)
152 configure_file(input: 'npu-engine.pc.in', output: 'npu-engine.pc',
153 install_dir: join_paths(ne_libdir, 'pkgconfig'),
154 configuration: ne_install_conf)
157 ne_install_headers = [
158 'include/common/npubinfmt.h',
159 'include/common/typedef.h',
160 'include/host/libnpuhost.h',
163 install_headers(ne_install_headers, subdir: 'npu-engine')