@@ -12,34 +12,73 @@ script_folder=${script_path/$script_name/}
1212. " ${script_folder} /common.sh"
1313cd " ${script_folder} " || exit 1
1414
15- set -x
15+ show_help () {
16+ cat << EOF
17+ Usage: $script_name [OPTIONS] [DPDK_VERSION]
1618
17- if [ -n " $1 " ]; then
18- DPDK_VER=$1
19- fi
20- dpdk_folder=" dpdk_${DPDK_VER} "
19+ Build and install DPDK with MTL patches.
20+
21+ OPTIONS:
22+ -f Force rebuild (removes existing dpdk folder if present)
23+ -h Show this help message
24+ -v VERSION Specify DPDK version to build
25+
26+ EXAMPLES:
27+ $script_name # Build default DPDK version
28+ $script_name -v # Build specific DPDK version
29+ $script_name -f -v 23.11 # Force rebuild of DPDK 23.11
30+ EOF
31+ }
32+
33+ FORCE=0
34+ while getopts " fhv:" opt; do
35+ case $opt in
36+ f)
37+ FORCE=1
38+ ;;
39+ v)
40+ DPDK_VER=" $OPTARG "
41+ ;;
42+ h)
43+ show_help
44+ exit 0
45+ ;;
46+ * )
47+ show_help
48+ exit 1
49+ ;;
50+ esac
51+ done
52+ shift $(( OPTIND - 1 ))
53+
54+ dpdk_folder=" dpdk-${DPDK_VER} "
2155
2256(return 0 2> /dev/null) && sourced=1 || sourced=0
2357
2458if [ " $sourced " -eq 0 ]; then
2559 echo " DPDK version: $DPDK_VER "
2660
61+ if [ $FORCE -eq 1 ] && [ -d " $dpdk_folder " ]; then
62+ echo " Force rebuild enabled. Removing existing '$dpdk_folder ' directory."
63+ rm -rf " $dpdk_folder "
64+ fi
65+
2766 if [ ! -d " $dpdk_folder " ]; then
28- # check out dpdk code
2967 echo " Clone DPDK source code"
30- git clone https://github.com/DPDK/dpdk.git " $dpdk_folder "
31- fi
68+ wget https://github.com/DPDK/dpdk/archive/refs/tags/v " ${DPDK_VER} " .zip
69+ unzip v " ${DPDK_VER} " .zip
3270
33- cd " $dpdk_folder " || exit 1
34- git checkout v " $DPDK_VER "
35- if git switch -c v " $DPDK_VER " _kahawai_build 2> /dev/null ; then
36- git am ../../patches/dpdk/ " $DPDK_VER " / * .patch
71+ cd " $dpdk_folder " || exit 1
72+ for patch_file in ../../patches/dpdk/ " $DPDK_VER " / * .patch ; do
73+ patch -p1 -i " $patch_file "
74+ done
3775 else
38- echo " Branch v${DPDK_VER} _kahawai_build already exists."
39- echo " Skipping patch application assuming it has been applied before."
76+ echo " DPDK source code already exists."
77+ echo " To rebuild, please remove the '$dpdk_folder ' directory and run this script again."
78+ exit 0
4079 fi
4180
42- # build and install dpdk now
81+ echo " Build and install DPDK now"
4382 meson build
4483 ninja -C build
4584 cd build
0 commit comments