Skip to content

Commit

Permalink
Update to latest branch revision as released version is broken.
Browse files Browse the repository at this point in the history
  • Loading branch information
tzarc committed Sep 22, 2021
1 parent 1e02f56 commit 68cf31f
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 91 deletions.
2 changes: 1 addition & 1 deletion lib/chibios
Submodule chibios updated 212 files
90 changes: 0 additions & 90 deletions util/chibios_conf_updater.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ this_script="$(realpath "${BASH_SOURCE[0]}")"
script_dir="$(realpath "$(dirname "$this_script")")"
qmk_firmware_dir="$(realpath "$script_dir/../")"

declare -A file_hashes

export PATH="$PATH:$script_dir/fmpp/bin"

build_fmpp() {
Expand Down Expand Up @@ -56,67 +54,6 @@ find_chibi_files() {
done
}

revert_chibi_files() {
local search_path="$1"
shead "Reverting ChibiOS config/board files..."
for file in $(find_chibi_files "$search_path" -name chconf.h -or -name halconf.h -or -name mcuconf.h -or -name board.c -or -name board.h -or -name board.mk -or -name board.chcfg) ; do
pushd "$search_path" >/dev/null 2>&1
local relpath=$(realpath --relative-to="$search_path" "$file")
git checkout upstream/develop -- "$relpath" || git checkout origin/develop -- "$relpath" || true
popd >/dev/null 2>&1
done
}

populate_file_hashes() {
local search_path="$1"
shead "Determining duplicate config/board files..."
for file in $(find_chibi_files "$search_path" -name chconf.h -or -name halconf.h -or -name mcuconf.h -or -name board.c -or -name board.h) ; do
local key="file_$(clang-format "$file" | sha1sum | cut -d' ' -f1)"
local relpath=$(realpath --relative-to="$search_path" "$file")
file_hashes[$key]="${file_hashes[$key]:-} $relpath"
done
for file in $(find_chibi_files "$search_path" -name board.mk -or -name board.chcfg) ; do
local key="file_$(cat "$file" | sha1sum | cut -d' ' -f1)"
local relpath=$(realpath --relative-to="$search_path" "$file")
file_hashes[$key]="${file_hashes[$key]:-} $relpath"
done
}

determine_equivalent_files() {
local search_file="$1"
for K in "${!file_hashes[@]}"; do
for V in ${file_hashes[$K]}; do
if [[ "$V" == "$search_file" ]] ; then
for V in ${file_hashes[$K]}; do
echo "$V"
done
return 0
fi
done
done
return 1
}

deploy_staged_files() {
shead "Deploying staged files..."
for file in $(find "$qmk_firmware_dir/util/chibios-upgrade-staging" -type f) ; do
local relpath=$(realpath --relative-to="$qmk_firmware_dir/util/chibios-upgrade-staging" "$file")
sinfo "Deploying staged file: $relpath"
for other in $(determine_equivalent_files "$relpath") ; do
sinfo " => $other"
cp "$qmk_firmware_dir/util/chibios-upgrade-staging/$relpath" "$qmk_firmware_dir/$other"
done
done
}

swap_mcuconf_f3xx_f303() {
shead "Swapping STM32F3xx_MCUCONF -> STM32F303_MCUCONF..."
for file in $(find_chibi_files "$qmk_firmware_dir" -name mcuconf.h) ; do
sed -i 's#STM32F3xx_MCUCONF#STM32F303_MCUCONF#g' "$file"
dos2unix "$file" >/dev/null 2>&1
done
}

upgrade_conf_files_generic() {
local search_filename="$1"
local update_script="$2"
Expand Down Expand Up @@ -161,35 +98,8 @@ upgrade_mcuconf_files() {
popd >/dev/null 2>&1
}

update_staged_files() {
shead "Updating staged files with ChibiOS upgraded versions..."
for file in $(find "$qmk_firmware_dir/util/chibios-upgrade-staging" -type f) ; do
local relpath=$(realpath --relative-to="$qmk_firmware_dir/util/chibios-upgrade-staging" "$file")
sinfo "Updating staged file: $relpath"
cp "$qmk_firmware_dir/$relpath" "$qmk_firmware_dir/util/chibios-upgrade-staging/$relpath"
done
}

havecmd fmpp || build_fmpp
revert_chibi_files "$qmk_firmware_dir"
populate_file_hashes "$qmk_firmware_dir"

shead "Showing duplicate ChibiOS files..."
for K in "${!file_hashes[@]}"; do
sinfo ${K#file_}:
for V in ${file_hashes[$K]}; do
sinfo " $V"
done
done

if [ "${1:-}" == "-r" ] ; then
exit 0
fi

swap_mcuconf_f3xx_f303

deploy_staged_files
upgrade_mcuconf_files
upgrade_chconf_files
upgrade_halconf_files
update_staged_files

0 comments on commit 68cf31f

Please sign in to comment.