#!/bin/bash
set -euo pipefail
-PROJECT=webauthn-ble
-
# Change working directory to the directory containing the currently run script
cd -P -- "$(dirname -- "$0")"
+PROJECT="$(basename -- "${PWD}")"
+
GBS_BUILD_ROOTFS="$(ls -t --directory "$HOME/GBS-ROOT/local/BUILD-ROOTS/"* | head -n 1 || true)"
if [ -z "$GBS_BUILD_ROOTFS" ]; then
- echo "Could not find most recent GBS build root, please build the project with GBS first"
+ echo "error: could not find most recent GBS build root, please build the project with GBS first"
exit 1
fi
sed 's% -msse4.2 % %' |
sed 's% -mfpmath=sse % %'
}
+elif [ "${ARCH}" == "aarch64" ]; then
+ target="aarch64-arm-linux"
+ function extra_filters {
+ sed 's% -mtune[^ ]* % %'
+ }
+elif [ "${ARCH}" == "x86_64" ]; then
+ target="x86_64-pc-linux-gnu"
+ function extra_filters {
+ sed 's% -msse4.2 % %' |
+ sed 's% -march=nehalem % %'
+ }
else
- echo "Unexpected architecture: ${ARCH}"
+ echo "error: unexpected architecture: ${ARCH}"
exit 1
fi
ORIG_COMPILE_COMMANDS_JSON="$(ls -t "compile_commands.json" "${ORIG_COMPILE_COMMANDS_JSON}" | head -n 1)"
fi
elif [ ! -f "${ORIG_COMPILE_COMMANDS_JSON}" ]; then
- echo "Could not find compile_commands.json generated by CMake, please build the project with GBS first"
+ echo "error: could not find compile_commands.json generated by CMake, please build the project with GBS first"
exit 1
elif [ "compile_commands.json" -nt "${ORIG_COMPILE_COMMANDS_JSON}" ] && [ "compile_commands.json" -nt "$(basename "$0")" ]; then # this check fails if compile_commands.json does not exist
exit 0 # compile_commands.json seem not to need regeneration
sed 's% -fmax-errors=[^ ]*%%g' |
sed 's% -Wno-stringop-overflow % %g' |
# Add system includes from the GBS rootfs
- sed "s% -std=% -isystem $(echo "${GBS_BUILD_ROOTFS}"/usr/lib/gcc/*-tizen-linux-gnu*/*/include-fixed/) -std=%" |
- sed "s% -std=% -isystem $(echo "${GBS_BUILD_ROOTFS}"/usr/lib/gcc/*-tizen-linux-gnu*/*/include/) -std=%" |
- sed "s% -std=% -isystem $(echo "${GBS_BUILD_ROOTFS}"/usr/lib/gcc/*-tizen-linux-gnu*/*/include/c++/) -std=%" |
- sed "s% -std=% -isystem $(echo "${GBS_BUILD_ROOTFS}"/usr/lib/gcc/*-tizen-linux-gnu*/*/include/c++/*-tizen-linux-gnu*/) -std=%" |
+ sed "s% -std=% -isystem $(echo "${GBS_BUILD_ROOTFS}"/usr/lib*/gcc/*-tizen-linux-gnu*/*/include-fixed/) -std=%" |
+ sed "s% -std=% -isystem $(echo "${GBS_BUILD_ROOTFS}"/usr/lib*/gcc/*-tizen-linux-gnu*/*/include/) -std=%" |
+ sed "s% -std=% -isystem $(echo "${GBS_BUILD_ROOTFS}"/usr/lib*/gcc/*-tizen-linux-gnu*/*/include/c++/) -std=%" |
+ sed "s% -std=% -isystem $(echo "${GBS_BUILD_ROOTFS}"/usr/lib*/gcc/*-tizen-linux-gnu*/*/include/c++/*-tizen-linux-gnu*/) -std=%" |
sed "s% -std=% -isystem $(echo "${GBS_BUILD_ROOTFS}"/usr/include/) -std=%" |
extra_filters > compile_commands.json