-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathSDKPatchCreate
More file actions
executable file
·71 lines (61 loc) · 2.03 KB
/
SDKPatchCreate
File metadata and controls
executable file
·71 lines (61 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -euo pipefail
realpath() {
OURPWD=$PWD
cd "$(dirname "$1")"
LINK=$(readlink "$(basename "$1")" || true)
while [ "$LINK" ]; do
cd "$(dirname "$LINK")"
LINK=$(readlink "$(basename "$1")" || true)
done
REALPATH="$PWD/$(basename "$1")"
cd "$OURPWD"
echo "$REALPATH"
}
root="$( realpath $(dirname "${BASH_SOURCE[0]}") )"
. "$root/versions.sh"
cd "$root/../toolchains/nRF5"
# Create Mesh SDK patch
mesh_dir="nrf5SDKforMeshv${NRF5_MESH_SDK_VERSION}src"
diff -Naur \
-x *.DS_Store -x *.elf -x *.hex -x *.map -x *.o -x *.bin -x _build -x Output -x *.emSession \
"${mesh_dir}.orig" "${mesh_dir}" > "$root/sdk/${mesh_dir}.patch" || true
# Create main SDK patch for files managed by the submodule
sdk_version="$NRF5_SDK_VERSION"
if [[ -n "${sdk_version:-}" ]]; then
sdk_dir="${sdk_version}"
sdk_dir_orig="${sdk_version}_vanilla"
out_patch="$root/sdk/${sdk_version}.patch"
sdk_files=(
"components/toolchain/gcc/Makefile.common"
"modules/nrfx/mdk/nrf_common.ld"
)
> "$out_patch"
for target_rel in "${sdk_files[@]}"; do
if [[ -f "$sdk_dir/$target_rel" && -f "$sdk_dir_orig/$target_rel" ]]; then
tmp_patch="$(mktemp)"
diff -u "$sdk_dir_orig/$target_rel" "$sdk_dir/$target_rel" > "$tmp_patch" || true
if [[ -s "$tmp_patch" ]]; then
# Rewrite headers to a/ b/ paths so git apply works from SDK root
sed -E \
-e "s|^--- .*${target_rel//./\\.}\$|--- a/${target_rel}|" \
-e "s|^\+\+\+ .*${target_rel//./\\.}\$|+++ b/${target_rel}|" \
"$tmp_patch" >> "$out_patch"
echo " Added $target_rel"
else
echo " No changes detected for $target_rel; skipping."
fi
rm -f "$tmp_patch"
else
echo " Skipping $target_rel: not found in $sdk_dir_orig or $sdk_dir" >&2
fi
done
if [[ -s "$out_patch" ]]; then
echo "Wrote main SDK patch: $out_patch"
else
echo "No changes detected; main SDK patch is empty."
fi
else
echo "Could not determine nRF5 SDK version; skipping main SDK patch" >&2
fi
echo "Done!"