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