]> git.proxmox.com Git - ceph.git/blame - ceph/src/spdk/dpdk/drivers/meson.build
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / spdk / dpdk / drivers / meson.build
CommitLineData
11fdf7f2 1# SPDX-License-Identifier: BSD-3-Clause
9f95a23c
TL
2# Copyright(c) 2017-2019 Intel Corporation
3
4if is_windows
5 subdir_done()
6endif
11fdf7f2
TL
7
8# Defines the order in which the drivers are buit.
9f95a23c 9dpdk_driver_classes = ['common',
11fdf7f2
TL
10 'bus',
11 'mempool', # depends on common and bus.
f67539c2
TL
12 'net', # depends on common, bus, mempool
13 'raw', # depends on common, bus and net.
11fdf7f2
TL
14 'crypto', # depends on common, bus and mempool (net in future).
15 'compress', # depends on common, bus, mempool.
f67539c2 16 'vdpa', # depends on common, bus and mempool.
11fdf7f2 17 'event', # depends on common, bus, mempool and net.
f67539c2
TL
18 'baseband'] # depends on common and bus.
19
20disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'),
21 ).stdout().split()
11fdf7f2
TL
22
23default_cflags = machine_args
f67539c2
TL
24default_cflags += ['-DALLOW_EXPERIMENTAL_API']
25default_cflags += ['-DALLOW_INTERNAL_API']
26
11fdf7f2
TL
27if cc.has_argument('-Wno-format-truncation')
28 default_cflags += '-Wno-format-truncation'
29endif
9f95a23c 30
9f95a23c 31foreach class:dpdk_driver_classes
11fdf7f2
TL
32 drivers = []
33 std_deps = []
34 config_flag_fmt = '' # format string used to set the value in dpdk_conf
35 driver_name_fmt = '' # format string for driver name, used to name
36 # the library, the dependency and to find the
37 # version file for linking
38
39 subdir(class)
9f95a23c 40 class_drivers = []
11fdf7f2
TL
41
42 foreach drv:drivers
43 drv_path = join_paths(class, drv)
44
45 # set up empty variables used for build
46 build = true # set to false to disable, e.g. missing deps
f67539c2 47 reason = '<unknown reason>' # set if build == false to explain
11fdf7f2 48 name = drv
f67539c2 49 fmt_name = ''
11fdf7f2
TL
50 sources = []
51 objs = []
52 cflags = default_cflags
53 includes = [include_directories(drv_path)]
54 # set up internal deps. Drivers can append/override as necessary
55 deps = std_deps
56 # ext_deps: Stores external library dependency got
9f95a23c
TL
57 # using dependency() (preferred) or find_library().
58 # For the find_library() case (but not with dependency()) we also
59 # need to specify the "-l" flags in pkgconfig_extra_libs variable
60 # too, so that it can be reflected in the pkgconfig output for
61 # static builds.
11fdf7f2
TL
62 ext_deps = []
63 pkgconfig_extra_libs = []
64
f67539c2
TL
65 if disabled_drivers.contains(drv_path)
66 build = false
67 reason = 'Explicitly disabled via build config'
68 else
69 # pull in driver directory which should update all the local variables
70 subdir(drv_path)
71 endif
11fdf7f2
TL
72
73 if build
11fdf7f2 74 # get dependency objs from strings
f67539c2
TL
75 shared_deps = ext_deps
76 static_deps = ext_deps
11fdf7f2
TL
77 foreach d:deps
78 if not is_variable('shared_rte_' + d)
f67539c2
TL
79 build = false
80 reason = 'Missing internal dependency, "@0@"'.format(d)
81 message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
82 .format(d, name, 'drivers/' + drv_path))
83 else
84 shared_deps += [get_variable('shared_rte_' + d)]
85 static_deps += [get_variable('static_rte_' + d)]
11fdf7f2 86 endif
11fdf7f2 87 endforeach
f67539c2
TL
88 endif
89
90 if not build
91 # some driver directories are placeholders which
92 # are never built, so we allow suppression of the
93 # component disable printout in those cases
94 if reason != ''
95 dpdk_drvs_disabled += drv_path
96 set_variable(drv_path.underscorify() +
97 '_disable_reason', reason)
98 endif
99 else
100 class_drivers += name
101
102 if fmt_name == ''
103 fmt_name = name
104 endif
105 dpdk_conf.set(config_flag_fmt.format(fmt_name.to_upper()),1)
106 lib_name = driver_name_fmt.format(fmt_name)
107
11fdf7f2
TL
108 dpdk_extra_ldflags += pkgconfig_extra_libs
109
110 # generate pmdinfo sources by building a temporary
111 # lib and then running pmdinfogen on the contents of
112 # that lib. The final lib reuses the object files and
113 # adds in the new source file.
114 out_filename = lib_name + '.pmd.c'
115 tmp_lib = static_library('tmp_' + lib_name,
116 sources,
117 include_directories: includes,
f67539c2 118 dependencies: static_deps,
11fdf7f2
TL
119 c_args: cflags)
120 objs += tmp_lib.extract_all_objects()
121 sources = custom_target(out_filename,
122 command: [pmdinfo, tmp_lib.full_path(),
123 '@OUTPUT@', pmdinfogen],
124 output: out_filename,
125 depends: [pmdinfogen, tmp_lib])
126
f67539c2
TL
127 version_map = '@0@/@1@/@2@_version.map'.format(
128 meson.current_source_dir(),
129 drv_path, lib_name)
130
131 is_stable = run_command(is_stable_cmd,
132 files(version_map)).returncode() == 0
133
134 if is_stable
135 lib_version = abi_version
136 so_version = stable_so_version
11fdf7f2 137 else
f67539c2
TL
138 lib_version = experimental_abi_version
139 so_version = experimental_so_version
11fdf7f2
TL
140 endif
141
142 # now build the static driver
143 static_lib = static_library(lib_name,
144 sources,
145 objects: objs,
146 include_directories: includes,
f67539c2 147 dependencies: static_deps,
11fdf7f2
TL
148 c_args: cflags,
149 install: true)
150
151 # now build the shared driver
152 version_map = '@0@/@1@/@2@_version.map'.format(
153 meson.current_source_dir(),
154 drv_path, lib_name)
f67539c2
TL
155 implib = dir_name + '.dll.a'
156
157 def_file = custom_target(lib_name + '_def',
158 command: [map_to_def_cmd, '@INPUT@', '@OUTPUT@'],
159 input: version_map,
160 output: '@0@_exports.def'.format(lib_name))
161 lk_deps = [version_map, def_file]
162 if is_windows
163 lk_args = ['-Wl,/def:' + def_file.full_path(),
164 '-Wl,/implib:lib\\' + implib]
165 else
166 lk_args = ['-Wl,--version-script=' + version_map]
167 # on unix systems check the output of the
168 # check-symbols.sh script, using it as a
169 # dependency of the .so build
170 lk_deps += custom_target(lib_name + '.sym_chk',
171 command: [check_symbols,
172 version_map, '@INPUT@'],
173 capture: true,
174 input: static_lib,
175 output: lib_name + '.sym_chk')
176 endif
177
11fdf7f2
TL
178 shared_lib = shared_library(lib_name,
179 sources,
180 objects: objs,
181 include_directories: includes,
f67539c2 182 dependencies: shared_deps,
11fdf7f2 183 c_args: cflags,
f67539c2
TL
184 link_args: lk_args,
185 link_depends: lk_deps,
11fdf7f2
TL
186 version: lib_version,
187 soversion: so_version,
188 install: true,
189 install_dir: driver_install_path)
190
191 # create a dependency object and add it to the global dictionary so
192 # testpmd or other built-in apps can find it if necessary
193 shared_dep = declare_dependency(link_with: shared_lib,
194 include_directories: includes,
f67539c2 195 dependencies: shared_deps)
11fdf7f2
TL
196 static_dep = declare_dependency(link_with: static_lib,
197 include_directories: includes,
f67539c2 198 dependencies: static_deps)
11fdf7f2
TL
199
200 dpdk_drivers += static_lib
201
202 set_variable('shared_@0@'.format(lib_name), shared_dep)
203 set_variable('static_@0@'.format(lib_name), static_dep)
f67539c2
TL
204 dependency_name = ''.join(lib_name.split('rte_'))
205 message('drivers/@0@: Defining dependency "@1@"'.format(
206 drv_path, dependency_name))
11fdf7f2
TL
207 endif # build
208 endforeach
9f95a23c
TL
209
210 set_variable(class + '_drivers', class_drivers)
11fdf7f2 211endforeach