1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
8 # Defines the order in which the drivers are buit.
9 dpdk_driver_classes = ['common',
11 'mempool', # depends on common and bus.
12 'net', # depends on common, bus, mempool
13 'raw', # depends on common, bus and net.
14 'crypto', # depends on common, bus and mempool (net in future).
15 'compress', # depends on common, bus, mempool.
16 'vdpa', # depends on common, bus and mempool.
17 'event', # depends on common, bus, mempool and net.
18 'baseband'] # depends on common and bus.
20 disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'),
23 default_cflags = machine_args
24 if cc.has_argument('-Wno-format-truncation')
25 default_cflags += '-Wno-format-truncation'
28 foreach class:dpdk_driver_classes
31 config_flag_fmt = '' # format string used to set the value in dpdk_conf
32 driver_name_fmt = '' # format string for driver name, used to name
33 # the library, the dependency and to find the
34 # version file for linking
40 drv_path = join_paths(class, drv)
42 # set up empty variables used for build
43 build = true # set to false to disable, e.g. missing deps
44 reason = '<unknown reason>' # set if build == false to explain
47 allow_experimental_apis = false
50 cflags = default_cflags
51 includes = [include_directories(drv_path)]
52 # set up internal deps. Drivers can append/override as necessary
54 # ext_deps: Stores external library dependency got
55 # using dependency() (preferred) or find_library().
56 # For the find_library() case (but not with dependency()) we also
57 # need to specify the "-l" flags in pkgconfig_extra_libs variable
58 # too, so that it can be reflected in the pkgconfig output for
61 pkgconfig_extra_libs = []
63 # pull in driver directory which should assign to each of the above
66 # skip disabled drivers. For meson 0.49 change this to use
68 foreach disable_path: disabled_drivers
69 if drv_path == disable_path
71 reason = 'Explicitly disabled via build config'
75 # get dependency objs from strings
76 shared_deps = ext_deps
77 static_deps = ext_deps
79 if not is_variable('shared_rte_' + d)
81 reason = 'Missing internal dependency, "@0@"'.format(d)
82 message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
83 .format(d, name, 'drivers/' + drv_path))
85 shared_deps += [get_variable('shared_rte_' + d)]
86 static_deps += [get_variable('static_rte_' + d)]
92 # some driver directories are placeholders which
93 # are never built, so we allow suppression of the
94 # component disable printout in those cases
96 dpdk_drvs_disabled += drv_path
97 set_variable(drv_path.underscorify() +
98 '_disable_reason', reason)
101 class_drivers += name
106 dpdk_conf.set(config_flag_fmt.format(fmt_name.to_upper()),1)
107 lib_name = driver_name_fmt.format(fmt_name)
109 if allow_experimental_apis
110 cflags += '-DALLOW_EXPERIMENTAL_API'
113 dpdk_extra_ldflags += pkgconfig_extra_libs
115 # generate pmdinfo sources by building a temporary
116 # lib and then running pmdinfogen on the contents of
117 # that lib. The final lib reuses the object files and
118 # adds in the new source file.
119 out_filename = lib_name + '.pmd.c'
120 tmp_lib = static_library('tmp_' + lib_name,
122 include_directories: includes,
123 dependencies: static_deps,
125 objs += tmp_lib.extract_all_objects()
126 sources = custom_target(out_filename,
127 command: [pmdinfo, tmp_lib.full_path(),
128 '@OUTPUT@', pmdinfogen],
129 output: out_filename,
130 depends: [pmdinfogen, tmp_lib])
132 version_map = '@0@/@1@/@2@_version.map'.format(
133 meson.current_source_dir(),
136 is_experimental = run_command(is_experimental_cmd,
137 files(version_map)).returncode()
139 if is_experimental != 0
140 lib_version = experimental_abi_version
141 so_version = experimental_so_version
143 lib_version = abi_version
144 so_version = stable_so_version
147 # now build the static driver
148 static_lib = static_library(lib_name,
151 include_directories: includes,
152 dependencies: static_deps,
156 # now build the shared driver
157 version_map = '@0@/@1@/@2@_version.map'.format(
158 meson.current_source_dir(),
160 implib = dir_name + '.dll.a'
162 def_file = custom_target(lib_name + '_def',
163 command: [map_to_def_cmd, '@INPUT@', '@OUTPUT@'],
165 output: '@0@_exports.def'.format(lib_name))
166 lk_deps = [version_map, def_file]
168 lk_args = ['-Wl,/def:' + def_file.full_path(),
169 '-Wl,/implib:lib\\' + implib]
171 lk_args = ['-Wl,--version-script=' + version_map]
172 # on unix systems check the output of the
173 # experimental syms script, using it as a
174 # dependency of the .so build
175 lk_deps += custom_target(lib_name + '.exp_chk',
176 command: [check_experimental_syms,
177 version_map, '@INPUT@'],
180 output: lib_name + '.exp_chk')
183 shared_lib = shared_library(lib_name,
186 include_directories: includes,
187 dependencies: shared_deps,
190 link_depends: lk_deps,
191 version: lib_version,
192 soversion: so_version,
194 install_dir: driver_install_path)
196 # create a dependency object and add it to the global dictionary so
197 # testpmd or other built-in apps can find it if necessary
198 shared_dep = declare_dependency(link_with: shared_lib,
199 include_directories: includes,
200 dependencies: shared_deps)
201 static_dep = declare_dependency(link_with: static_lib,
202 include_directories: includes,
203 dependencies: static_deps)
205 dpdk_drivers += static_lib
207 set_variable('shared_@0@'.format(lib_name), shared_dep)
208 set_variable('static_@0@'.format(lib_name), static_dep)
209 dependency_name = ''.join(lib_name.split('rte_'))
210 message('drivers/@0@: Defining dependency "@1@"'.format(
211 drv_path, dependency_name))
215 set_variable(class + '_drivers', class_drivers)