1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
4 # Defines the order of dependencies evaluation
8 'common/cnxk', # depends on bus.
9 'common/mlx5', # depends on bus.
10 'common/qat', # depends on bus.
11 'common/sfc_efx', # depends on bus.
12 'mempool', # depends on common and bus.
13 'net', # depends on common, bus, mempool
14 'raw', # depends on common, bus and net.
15 'crypto', # depends on common, bus and mempool (net in future).
16 'compress', # depends on common, bus, mempool.
17 'regex', # depends on common, bus, regexdev.
18 'vdpa', # depends on common, bus and mempool.
19 'event', # depends on common, bus, mempool and net.
20 'baseband', # depends on common and bus.
23 if meson.is_cross_build()
24 disable_drivers += ',' + meson.get_cross_property('disable_drivers', '')
25 enable_drivers += ',' + meson.get_cross_property('enable_drivers', '')
28 # add cmdline disabled drivers and meson disabled drivers together
29 disable_drivers += ',' + get_option('disable_drivers')
30 disable_drivers = run_command(list_dir_globs, disable_drivers, check: true).stdout().split()
32 # add cmdline enabled drivers and meson enabled drivers together
33 enable_drivers = ',' + get_option('enable_drivers')
34 enable_drivers = run_command(list_dir_globs, enable_drivers, check: true).stdout().split()
35 if enable_drivers.length() == 0
36 enable_drivers = run_command(list_dir_globs, '*/*', check: true).stdout().split()
39 # these drivers must always be enabled, otherwise the build breaks
40 always_enable = ['bus/pci', 'bus/vdev']
41 enable_drivers += always_enable
43 default_cflags = machine_args
44 default_cflags += ['-DALLOW_EXPERIMENTAL_API']
45 default_cflags += ['-DALLOW_INTERNAL_API']
47 if cc.has_argument('-Wno-format-truncation')
48 default_cflags += '-Wno-format-truncation'
51 foreach subpath:subdirs
56 # subpath can be either "class" or "class/driver"
57 if subpath.contains('/')
58 driver_path = subpath.split('/')
59 class = driver_path[0]
60 drivers += driver_path[1]
66 # save class name on first occurrence
67 if not dpdk_driver_classes.contains(class)
68 dpdk_driver_classes += class
70 # get already enabled drivers of the same class
71 enabled_drivers = get_variable(class + '_drivers', [])
73 # default log prefix can be defined per class
75 # default log name is pmd.class.driver
76 log_prefix = 'pmd.' + class
80 drv_path = join_paths(class, drv)
82 # set up empty variables used for build
83 build = true # set to false to disable, e.g. missing deps
84 reason = '<unknown reason>' # set if build == false to explain
89 cflags = default_cflags
90 includes = [include_directories(drv_path)]
91 # set up internal deps. Drivers can append/override as necessary
93 # ext_deps: Stores external library dependency got
94 # using dependency() (preferred) or find_library().
95 # For the find_library() case (but not with dependency()) we also
96 # need to specify the "-l" flags in pkgconfig_extra_libs variable
97 # too, so that it can be reflected in the pkgconfig output for
100 pkgconfig_extra_libs = []
102 if not enable_drivers.contains(drv_path)
104 reason = 'not in enabled drivers build config'
105 elif disable_drivers.contains(drv_path)
106 if always_enable.contains(drv_path)
107 message('Driver @0@ cannot be disabled, not disabling.'.format(drv_path))
110 reason = 'explicitly disabled via build config'
113 # pull in driver directory which should update all the local variables
118 # get dependency objs from strings
119 shared_deps = ext_deps
120 static_deps = ext_deps
122 if not is_variable('shared_rte_' + d)
124 reason = 'missing internal dependency, "@0@"'.format(d)
125 message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
126 .format(d, name, 'drivers/' + drv_path))
128 shared_deps += [get_variable('shared_rte_' + d)]
129 static_deps += [get_variable('static_rte_' + d)]
135 # some driver directories are placeholders which
136 # are never built, so we allow suppression of the
137 # component disable printout in those cases
139 dpdk_drvs_disabled += drv_path
140 set_variable(drv_path.underscorify() + '_disable_reason', reason)
145 enabled_drivers += name
146 lib_name = '_'.join(['rte', class, name])
147 cflags += '-DRTE_LOG_DEFAULT_LOGTYPE=' + '.'.join([log_prefix, name])
148 dpdk_conf.set(lib_name.to_upper(), 1)
150 dpdk_extra_ldflags += pkgconfig_extra_libs
152 install_headers(headers)
154 # generate pmdinfo sources by building a temporary
155 # lib and then running pmdinfogen on the contents of
156 # that lib. The final lib reuses the object files and
157 # adds in the new source file.
158 out_filename = lib_name + '.pmd.c'
159 tmp_lib = static_library('tmp_' + lib_name, sources,
160 include_directories: includes,
161 dependencies: static_deps,
163 objs += tmp_lib.extract_all_objects()
164 sources = custom_target(out_filename,
165 command: [pmdinfo, tmp_lib.full_path(), '@OUTPUT@', pmdinfogen],
166 output: out_filename,
169 # now build the static driver
170 static_lib = static_library(lib_name,
173 include_directories: includes,
174 dependencies: static_deps,
178 # now build the shared driver
179 version_map = '@0@/@1@/version.map'.format(meson.current_source_dir(), drv_path)
180 implib = 'lib' + lib_name + '.dll.a'
182 def_file = custom_target(lib_name + '_def',
183 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
185 output: '@0@_exports.def'.format(lib_name))
187 mingw_map = custom_target(lib_name + '_mingw',
188 command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
190 output: '@0@_mingw.map'.format(lib_name))
192 lk_deps = [version_map, def_file, mingw_map]
195 lk_args = ['-Wl,/def:' + def_file.full_path()]
196 if meson.version().version_compare('<0.54.0')
197 lk_args += ['-Wl,/implib:drivers\\' + implib]
200 lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
203 lk_args = ['-Wl,--version-script=' + version_map]
205 # on unix systems check the output of the
206 # check-symbols.sh script, using it as a
207 # dependency of the .so build
208 lk_deps += custom_target(lib_name + '.sym_chk',
209 command: [check_symbols, version_map, '@INPUT@'],
212 output: lib_name + '.sym_chk')
216 shared_lib = shared_library(lib_name, sources,
218 include_directories: includes,
219 dependencies: shared_deps,
222 link_depends: lk_deps,
223 version: abi_version,
224 soversion: so_version,
226 install_dir: driver_install_path)
228 # create a dependency object and add it to the global dictionary so
229 # testpmd or other built-in apps can find it if necessary
230 shared_dep = declare_dependency(link_with: shared_lib,
231 include_directories: includes,
232 dependencies: shared_deps)
233 static_dep = declare_dependency(
234 include_directories: includes,
235 dependencies: static_deps)
237 dpdk_drivers += static_lib
239 set_variable('shared_@0@'.format(lib_name), shared_dep)
240 set_variable('static_@0@'.format(lib_name), static_dep)
241 dependency_name = ''.join(lib_name.split('rte_'))
243 message('drivers/@0@: Defining dependency "@1@"'.format(
244 drv_path, dependency_name))
248 set_variable(class + '_drivers', enabled_drivers)