]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
build: config-submenu: Introduce parameter to exclude libraries
authorSimon Kuenzer <simon@unikraft.io>
Thu, 14 Sep 2023 19:08:02 +0000 (21:08 +0200)
committerRazvan Deaconescu <razvand@unikraft.io>
Fri, 20 Oct 2023 16:35:55 +0000 (19:35 +0300)
This commit introduces the `-e` parameter which accepts a colon-separated
list of library paths. Such a path is compared to any library path that
would be included. If a match occurs, the affected library path is skipped.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
GitHub-Closes: #1104

support/build/config-submenu.sh

index 8df3070c6131588ed919fb9988f009d4d991e6ed..cd95f96df7a64aedfc04cd6b12e73781fae2f24a 100755 (executable)
@@ -22,16 +22,19 @@ usage()
        echo "  -t [TEXT]                  Generates a submenu with TEXT as title"
        echo "  -l [PATH]                  Library directory"
        echo "  -c [PATH:PATH:...]         Colon separated list of library directories"
+       echo "  -e [PATH:PATH:...]         Colon separated list of library paths that"
+       echo "                             shall be skipped/excluded"
        echo "  -r [PATH]                  Search for library directories in subfolders"
        echo "  -o [PATH]                  Write to output file instead of STDOUT"
 }
 
 ARG_OUT=
 ARG_PATHS=()
+ARG_EXCLUDES=()
 ARG_TITLE=
 OPT_MODE="concat"
 OPT_QUIET=1
-while getopts :hqt:l:r:c:o: OPT; do
+while getopts :hqt:l:r:c:e:o: OPT; do
        case ${OPT} in
        h)
                usage
@@ -58,7 +61,16 @@ while getopts :hqt:l:r:c:o: OPT; do
                IFS=':'
                for P in ${OPTARG}; do
                        IFS=$IFS_ORIG
-                       ARG_PATHS+=("${P}")
+                       [ ! -z "${P}" ] && ARG_PATHS+=("${P}")
+                       IFS=$IFS_NL
+               done
+               IFS=$IFS_ORIG
+               ;;
+       e)
+               IFS=':'
+               for S in ${OPTARG}; do
+                       IFS=$IFS_ORIG
+                       [ ! -z "${S}" ] && ARG_EXCLUDES+=("${S}")
                        IFS=$IFS_NL
                done
                IFS=$IFS_ORIG
@@ -98,6 +110,39 @@ else
        exec 7>&1
 fi
 
+#
+# GENERATE LIST OF FINAL LIBRARY PATHS
+#
+LIBS=()
+for ARG_PATH in "${ARG_PATHS[@]}" "$@"; do
+       # Remove trailing slashes
+       ARG_PATH="${ARG_PATH%/}"
+
+       # Does Config.uk exist?
+       CONFIG_UK="${ARG_PATH}/Config.uk"
+       if [ ! -f "${CONFIG_UK}" ]; then
+               if [ $OPT_QUIET -ne 0 ]; then
+                       echo "Could not find \"Config.uk\" under \"${ARG_PATH}\". Skipping..." 1>&2
+               fi
+               continue
+       fi
+
+       DONT_INCLUDE=1
+       for ARG_EXCLUDE in "${ARG_EXCLUDES[@]}"; do
+               if [ "${ARG_PATH}" = "${ARG_EXCLUDE}" ]; then
+                       if [ $OPT_QUIET -ne 0 ]; then
+                               echo "Skipping excluded \"${ARG_PATH}\"..." 1>&2
+                       fi
+                       echo "# Skipped excluded \"${ARG_PATH}\"" >&7
+                       DONT_INCLUDE=0
+                       break
+               fi
+       done
+       [ ${DONT_INCLUDE} -eq 0 ] && continue
+
+       LIBS+=("${ARG_PATH}")
+done
+
 #
 # HEADER
 #
@@ -112,16 +157,8 @@ esac
 #
 # BODY
 #
-for ARG_PATH in "${ARG_PATHS[@]}" "$@"; do
-       CONFIG_UK="${ARG_PATH}/Config.uk"
-
-       if [ ! -f "${CONFIG_UK}" ]; then
-               if [ $OPT_QUIET -ne 0 ]; then
-                       echo "Could not find \"Config.uk\" under \"${ARG_PATH}\". Skipping..." 1>&2
-               fi
-               continue;
-       fi
-
+for L in "${LIBS[@]}"; do
+       CONFIG_UK="${L}/Config.uk"
        printf "source \"%s\"\n" "$( "${CMD_READLINK}" -f "${CONFIG_UK}" )" >&7
 done