Skip to content

Commit 488ef84

Browse files
Fix: DPDK build script undefined behavior
The DPDK build script was using git to patch the DPDK repo inside the MTL repository, which was causing undefined behavior. Switch to patch to ensure this always works and add help for UX.
1 parent cd66e77 commit 488ef84

File tree

3 files changed

+57
-17
lines changed

3 files changed

+57
-17
lines changed

.github/scripts/setup_environment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
303303

304304
if [ "${SETUP_BUILD_AND_INSTALL_DPDK}" == "1" ]; then
305305
echo "$STEP DPDK build and install"
306-
bash "${root_folder}/script/build_dpdk.sh"
306+
bash "${root_folder}/script/build_dpdk.sh" -f
307307
STEP=$((STEP + 1))
308308
fi
309309

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ mtl_system_status_*
8585
*.pcm
8686
*.wav
8787
script/ice-*
88-
script/dpdk
88+
script/dpdk-*
89+
script/*.zip*
8990
script/xdp-tools
9091

9192
#Generated documentation

script/build_dpdk.sh

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,73 @@ script_folder=${script_path/$script_name/}
1212
. "${script_folder}/common.sh"
1313
cd "${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

2458
if [ "$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

Comments
 (0)