Commit 4c859a6d authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

make/check_so_deps: Drop replace_defined_variables()



This function was recursively greping through the .mk file to map all
ref variables $(...) to values they are set to. This was including
plenty of duplicate entries which then had to be sorted|uniqed.

Instead, and to avoid recurssion, import the entire .mk file into
Bash's environment. The mapping would look like so:

 JSON_LIBS := json jsonrpc rpc
 DEPDIRS-event_vmd := event vmd conf $(JSON_LIBS) log thread
 |
 v
 JSON_LIBS="json jsonrpc rpc"
 JSON_LIBS() { echo $JSON_LIBS ; }
 event_vmd="event vmd conf $(JSON_LIBS) log thread"
 |
 v
 event_vmd="event vmd conf json jsonrpc rpc log thread"

Change-Id: Ibfcd52438403cd7638e01d2d5642c08822f85106
Signed-off-by: default avatarMichal Berger <michalx.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4629


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 7deb5625
Loading
Loading
Loading
Loading
+18 −24
Original line number Diff line number Diff line
#!/usr/bin/env bash
shopt -s extglob

if [ "$(uname -s)" = "FreeBSD" ]; then
	echo "Not testing for shared object dependencies on FreeBSD."
@@ -162,27 +163,21 @@ EOF
	echo "Processed $processed_so objects."
}

# This function is needed to properly evaluate the Make variables into actual dependencies.
function replace_defined_variables() {
	local arr=("$@")
	local bad_values=()
	local good_values=()
	local new_values
	for dep in "${arr[@]}"; do
		if [[ $dep == *'$'* ]]; then
			raw_dep=${dep/$\(/}
			raw_dep=${raw_dep/\)/ }
			bad_values+=("$raw_dep")
		else
			good_values+=("$dep")
function import_libs_deps_mk() {
	local var_mk val_mk dep_mk fun_mk
	while read -r var_mk _ val_mk; do
		if [[ $var_mk == "#"* || ! $var_mk =~ (DEPDIRS-|_DEPS|_LIBS) ]]; then
			continue
		fi
		var_mk=${var_mk#*-}
		for dep_mk in $val_mk; do
			fun_mk=${dep_mk//@('$('|')')/}
			if [[ $fun_mk != "$dep_mk" ]]; then
				eval "${fun_mk}() { echo \$$fun_mk ; }"
			fi
			eval "$var_mk=\${$var_mk:+\$$var_mk }$dep_mk"
		done
	for dep in "${bad_values[@]}"; do
		dep_def_arr=($(grep -v "#" $libdeps_file | grep "${dep}" | cut -d "=" -f 2 | xargs))
		new_values=($(replace_defined_variables "${dep_def_arr[@]}"))
		good_values=("${good_values[@]}" "${new_values[@]}")
	done
	echo ${good_values[*]}
	done < "$libdeps_file"
}

function confirm_deps() {
@@ -191,10 +186,8 @@ function confirm_deps() {
	dep_names=()
	found_symbol_lib=""

	#keep the space here to differentiate bdev and bdev_*
	lib_shortname=$(basename $lib | sed 's,libspdk_,,g' | sed 's,\.so, ,g')
	lib_make_deps=($(grep "DEPDIRS-${lib_shortname}" $libdeps_file | cut -d "=" -f 2 | xargs))
	lib_make_deps=($(replace_defined_variables "${lib_make_deps[@]}"))
	lib_shortname=$(basename "$lib" | sed 's,libspdk_,,g' | sed 's,\.so,,g')
	lib_make_deps=(${!lib_shortname})

	for ign_dep in "${IGNORED_LIBS[@]}"; do
		for i in "${!lib_make_deps[@]}"; do
@@ -278,6 +271,7 @@ if grep -q 'CONFIG_RDMA?=n' $rootdir/mk/config.mk; then
fi

(
	import_libs_deps_mk
	for lib in $SPDK_LIBS; do confirm_deps $lib & done
	wait
)