sleep in control plane thread
[dpdk.git] / drivers / meson.build
1 # SPDX-License-Identifier: BSD-3-Clause
2 # Copyright(c) 2017-2019 Intel Corporation
3
4 if is_windows
5         subdir_done()
6 endif
7
8 # Defines the order in which the drivers are buit.
9 dpdk_driver_classes = ['common',
10                'bus',
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.
19
20 disabled_drivers = run_command(list_dir_globs, get_option('disable_drivers'),
21                 ).stdout().split()
22
23 default_cflags = machine_args
24 if cc.has_argument('-Wno-format-truncation')
25         default_cflags += '-Wno-format-truncation'
26 endif
27
28 foreach class:dpdk_driver_classes
29         drivers = []
30         std_deps = []
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
35
36         subdir(class)
37         class_drivers = []
38
39         foreach drv:drivers
40                 drv_path = join_paths(class, drv)
41
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
45                 name = drv
46                 fmt_name = ''
47                 allow_experimental_apis = false
48                 sources = []
49                 objs = []
50                 cflags = default_cflags
51                 includes = [include_directories(drv_path)]
52                 # set up internal deps. Drivers can append/override as necessary
53                 deps = std_deps
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
59                 # static builds.
60                 ext_deps = []
61                 pkgconfig_extra_libs = []
62
63                 # pull in driver directory which should assign to each of the above
64                 subdir(drv_path)
65
66                 # skip disabled drivers. For meson 0.49 change this to use
67                 # "in" keyword
68                 foreach disable_path: disabled_drivers
69                         if drv_path == disable_path
70                                 build = false
71                                 reason = 'Explicitly disabled via build config'
72                         endif
73                 endforeach
74                 if build
75                         # get dependency objs from strings
76                         shared_deps = ext_deps
77                         static_deps = ext_deps
78                         foreach d:deps
79                                 if not is_variable('shared_rte_' + d)
80                                         build = false
81                                         reason = 'Missing internal dependency, "@0@"'.format(d)
82                                         message('Disabling @1@ [@2@]: missing internal dependency "@0@"'
83                                                         .format(d, name, 'drivers/' + drv_path))
84                                 else
85                                         shared_deps += [get_variable('shared_rte_' + d)]
86                                         static_deps += [get_variable('static_rte_' + d)]
87                                 endif
88                         endforeach
89                 endif
90
91                 if not build
92                         # some driver directories are placeholders which
93                         # are never built, so we allow suppression of the
94                         # component disable printout in those cases
95                         if reason != ''
96                                 dpdk_drvs_disabled += drv_path
97                                 set_variable(drv_path.underscorify() +
98                                                 '_disable_reason', reason)
99                         endif
100                 else
101                         class_drivers += name
102
103                         if fmt_name == ''
104                                 fmt_name = name
105                         endif
106                         dpdk_conf.set(config_flag_fmt.format(fmt_name.to_upper()),1)
107                         lib_name = driver_name_fmt.format(fmt_name)
108
109                         if allow_experimental_apis
110                                 cflags += '-DALLOW_EXPERIMENTAL_API'
111                         endif
112
113                         dpdk_extra_ldflags += pkgconfig_extra_libs
114
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,
121                                         sources,
122                                         include_directories: includes,
123                                         dependencies: static_deps,
124                                         c_args: cflags)
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])
131
132                         version_map = '@0@/@1@/@2@_version.map'.format(
133                                         meson.current_source_dir(),
134                                         drv_path, lib_name)
135
136                         is_experimental = run_command(is_experimental_cmd,
137                                 files(version_map)).returncode()
138
139                         if is_experimental != 0
140                                 lib_version = experimental_abi_version
141                                 so_version = experimental_so_version
142                         else
143                                 lib_version = abi_version
144                                 so_version = stable_so_version
145                         endif
146
147                         # now build the static driver
148                         static_lib = static_library(lib_name,
149                                 sources,
150                                 objects: objs,
151                                 include_directories: includes,
152                                 dependencies: static_deps,
153                                 c_args: cflags,
154                                 install: true)
155
156                         # now build the shared driver
157                         version_map = '@0@/@1@/@2@_version.map'.format(
158                                         meson.current_source_dir(),
159                                         drv_path, lib_name)
160                         implib = dir_name + '.dll.a'
161
162                         def_file = custom_target(lib_name + '_def',
163                                 command: [map_to_def_cmd, '@INPUT@', '@OUTPUT@'],
164                                 input: version_map,
165                                 output: '@0@_exports.def'.format(lib_name))
166                         lk_deps = [version_map, def_file]
167                         if is_windows
168                                 lk_args = ['-Wl,/def:' + def_file.full_path(),
169                                         '-Wl,/implib:lib\\' + implib]
170                         else
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@'],
178                                         capture: true,
179                                         input: static_lib,
180                                         output: lib_name + '.exp_chk')
181                         endif
182
183                         shared_lib = shared_library(lib_name,
184                                 sources,
185                                 objects: objs,
186                                 include_directories: includes,
187                                 dependencies: shared_deps,
188                                 c_args: cflags,
189                                 link_args: lk_args,
190                                 link_depends: lk_deps,
191                                 version: lib_version,
192                                 soversion: so_version,
193                                 install: true,
194                                 install_dir: driver_install_path)
195
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)
204
205                         dpdk_drivers += static_lib
206
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))
212                 endif # build
213         endforeach
214
215         set_variable(class + '_drivers', class_drivers)
216 endforeach