mirror of
https://github.com/espressif/openthread.git
synced 2026-08-10 04:37:47 +00:00
[script] update the check-size report (#9368)
This commit updates the `check-size` script and how the OpenThread size report is generated and reported. The size report now includes four device types: - FTD (not acting as a BR) - MTD (including SED) - Border Router (BR) - RCP Each type uses its own example config header file (e.g., BR uses `examples/config/ot-core-config-check-size-br.h`). These header files specify all the OT configs and enable/disable the set of features that make sense for the given type. This replaces the previous model where the same set of configs were used for all types. This change allows us to track the code size of a typical BR build, as well as the code size of other device types. In order to build and generate a size report for the BR configuration example with BR-specific features enabled (such as Border Routing Manager or NAT64), we need an implementation of the related platform APIs that are used by these features (e.g. `otPlatInfraIf` APIs). This commit adds mock empty implementations of these APIs, which are only included in the size-report builds.
This commit is contained in:
@@ -91,7 +91,7 @@ build_nrf52840()
|
||||
|
||||
main()
|
||||
{
|
||||
export CPPFLAGS="${CPPFLAGS:-} -DNDEBUG"
|
||||
export CPPFLAGS="${CPPFLAGS-} -DNDEBUG"
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
build_nrf52840
|
||||
|
||||
+136
-106
@@ -118,137 +118,166 @@ nm_size()
|
||||
diff -Nuar nmsize_old nmsize_new || true
|
||||
}
|
||||
|
||||
size_nrf52840_version()
|
||||
build_nrf52840()
|
||||
{
|
||||
local options=(
|
||||
"-DOT_ANYCAST_LOCATOR=ON"
|
||||
"-DOT_BORDER_AGENT=ON"
|
||||
"-DOT_BORDER_ROUTER=ON"
|
||||
"-DOT_CHANNEL_MANAGER=ON"
|
||||
"-DOT_CHANNEL_MONITOR=ON"
|
||||
"-DOT_COAP=ON"
|
||||
"-DOT_COAPS=ON"
|
||||
"-DOT_COMMISSIONER=ON"
|
||||
"-DOT_DATASET_UPDATER=ON"
|
||||
"-DOT_DHCP6_CLIENT=ON"
|
||||
"-DOT_DHCP6_SERVER=ON"
|
||||
"-DOT_DIAGNOSTIC=ON"
|
||||
"-DOT_DNSSD_SERVER=ON"
|
||||
"-DOT_DNS_CLIENT=ON"
|
||||
"-DOT_ECDSA=ON"
|
||||
"-DOT_FULL_LOGS=ON"
|
||||
"-DOT_JAM_DETECTION=ON"
|
||||
"-DOT_JOINER=ON"
|
||||
"-DOT_LINK_RAW=ON"
|
||||
"-DOT_MAC_FILTER=ON"
|
||||
"-DOT_MESSAGE_USE_HEAP=ON"
|
||||
"-DOT_NETDATA_PUBLISHER=ON"
|
||||
"-DOT_PING_SENDER=ON"
|
||||
"-DOT_SERVICE=ON"
|
||||
"-DOT_SLAAC=ON"
|
||||
"-DOT_SNTP_CLIENT=ON"
|
||||
"-DOT_SRP_CLIENT=ON"
|
||||
"-DOT_SRP_SERVER=ON"
|
||||
"-DOT_TIME_SYNC=ON"
|
||||
"-DOT_UDP_FORWARD=ON"
|
||||
"-DOT_UPTIME=ON"
|
||||
)
|
||||
case "$1" in
|
||||
ftd)
|
||||
local ot_ftd=ON
|
||||
local ot_mtd=OFF
|
||||
local ot_rcp=ON
|
||||
;;
|
||||
mtd)
|
||||
local ot_ftd=OFF
|
||||
local ot_mtd=ON
|
||||
local ot_rcp=ON
|
||||
;;
|
||||
br)
|
||||
local ot_ftd=ON
|
||||
local ot_mtd=OFF
|
||||
local ot_rcp=OFF
|
||||
;;
|
||||
*)
|
||||
exit 128
|
||||
;;
|
||||
esac
|
||||
|
||||
local thread_version=$1
|
||||
case "$2" in
|
||||
new)
|
||||
local sha=${OT_SHA_NEW}
|
||||
;;
|
||||
old)
|
||||
local sha=${OT_SHA_OLD}
|
||||
;;
|
||||
*)
|
||||
exit 128
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ${thread_version} != "1.1" ]]; then
|
||||
options+=(
|
||||
"-DOT_THREAD_VERSION=1.3"
|
||||
"-DOT_BACKBONE_ROUTER=ON"
|
||||
"-DOT_DUA=ON"
|
||||
"-DOT_MLR=ON"
|
||||
"-DOT_CSL_RECEIVER=ON"
|
||||
"-DOT_LINK_METRICS_INITIATOR=ON"
|
||||
"-DOT_LINK_METRICS_SUBJECT=ON"
|
||||
)
|
||||
local folder="$1_$2"
|
||||
local config_name="ot-core-config-check-size-$1.h"
|
||||
local config_file="../examples/config/${config_name}"
|
||||
|
||||
mkdir -p "${OT_TMP_DIR}/${folder}"
|
||||
script/git-tool clone https://github.com/openthread/ot-nrf528xx.git "${OT_TMP_DIR}/${folder}"
|
||||
rm -rf "${OT_TMP_DIR}/${folder}/openthread/*" # replace openthread submodule with latest commit
|
||||
git archive "${sha}" | tar x -C "${OT_TMP_DIR}/${folder}/openthread"
|
||||
|
||||
if [ ! -e "${OT_TMP_DIR}/${folder}/openthread/examples/config/${config_name}" ]; then
|
||||
# Check if the the config headers are not present, copy from
|
||||
# the main sha.
|
||||
case "$1" in
|
||||
br)
|
||||
rm -rf "${OT_TMP_DIR}/${folder}/openthread/*"
|
||||
git archive "${OT_SHA_NEW}" | tar x -C "${OT_TMP_DIR}/${folder}/openthread"
|
||||
;;
|
||||
*)
|
||||
mkdir -p "${OT_TMP_DIR}/${folder}/openthread/examples/config"
|
||||
cp "./examples/config/${config_name}" "${OT_TMP_DIR}/${folder}/openthread/examples/config"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
rm -rf "${OT_TMP_DIR}"
|
||||
local cur_dir
|
||||
|
||||
local build_dir="build"
|
||||
cur_dir=$(pwd)
|
||||
|
||||
# new commit
|
||||
mkdir -p "${OT_TMP_DIR}/b"
|
||||
script/git-tool clone https://github.com/openthread/ot-nrf528xx.git "${OT_TMP_DIR}/b"
|
||||
rm -rf "${OT_TMP_DIR}/b/openthread/*" # replace openthread submodule with latest commit
|
||||
git archive "${OT_SHA_NEW}" | tar x -C "${OT_TMP_DIR}/b/openthread"
|
||||
cd "${OT_TMP_DIR}/${folder}"
|
||||
OT_CMAKE_BUILD_DIR=build script/build nrf52840 UART_trans \
|
||||
-DOT_APP_CLI=ON -DOT_APP_NCP=ON -DOT_APP_RCP=${ot_rcp} \
|
||||
-DOT_FTD=${ot_ftd} -DOT_MTD=${ot_mtd} -DOT_RCP=${ot_rcp} \
|
||||
-DBUILD_TESTING=OFF \
|
||||
-DOT_PROJECT_CONFIG="${config_file}"
|
||||
|
||||
(cd "${OT_TMP_DIR}/b" \
|
||||
&& OT_CMAKE_BUILD_DIR=${build_dir} script/build nrf52840 UART_trans "${options[@]}")
|
||||
|
||||
# old commit
|
||||
if [[ "${GITHUB_ACTIONS+x}" ]]; then
|
||||
git fetch --depth 1 --no-recurse-submodules origin "${OT_SHA_OLD}"
|
||||
if [[ $1 == "br" ]]; then
|
||||
mv ./build/bin/ot-cli-ftd ./build/bin/ot-cli-ftd-br
|
||||
mv ./build/lib/libopenthread-ftd.a ./build/lib/libopenthread-ftd-br.a
|
||||
mv ./build/lib/libopenthread-cli-ftd.a ./build/lib/libopenthread-cli-ftd-br.a
|
||||
fi
|
||||
|
||||
mkdir -p "${OT_TMP_DIR}/a"
|
||||
git clone https://github.com/openthread/ot-nrf528xx.git "${OT_TMP_DIR}/a"
|
||||
rm -rf "${OT_TMP_DIR}/a/openthread/*" # replace openthread submodule with last commit
|
||||
git archive "${OT_SHA_OLD}" | tar x -C "${OT_TMP_DIR}/a/openthread"
|
||||
cd "${cur_dir}"
|
||||
}
|
||||
|
||||
(cd "${OT_TMP_DIR}/a" \
|
||||
&& OT_CMAKE_BUILD_DIR=${build_dir} script/build nrf52840 UART_trans "${options[@]}")
|
||||
generate_report()
|
||||
{
|
||||
local type="${1}"
|
||||
shift
|
||||
|
||||
# rename the generated files to be ready for size-report
|
||||
# shellcheck disable=SC2011
|
||||
(
|
||||
cd "${OT_TMP_DIR}"/a/"${build_dir}"/bin
|
||||
ls | xargs -I{} mv {} {}_"${thread_version}"
|
||||
cd "${OT_TMP_DIR}"/b/"${build_dir}"/bin
|
||||
ls | xargs -I{} mv {} {}_"${thread_version}"
|
||||
local old_file
|
||||
local new_file
|
||||
|
||||
cd "${OT_TMP_DIR}"/a/"${build_dir}"/lib
|
||||
ls ./*.a | xargs -I{} mv {} {}_"${thread_version}"
|
||||
cd "${OT_TMP_DIR}"/b/"${build_dir}"/lib
|
||||
ls ./*.a | xargs -I{} mv {} {}_"${thread_version}"
|
||||
)
|
||||
for file in "$@"; do
|
||||
case "${file}" in
|
||||
lib*)
|
||||
old_file="${OT_TMP_DIR}"/${type}_old/build/lib/"${file}"
|
||||
new_file="${OT_TMP_DIR}"/${type}_new/build/lib/"${file}"
|
||||
;;
|
||||
*)
|
||||
old_file="${OT_TMP_DIR}"/${type}_old/build/bin/"${file}"
|
||||
new_file="${OT_TMP_DIR}"/${type}_new/build/bin/"${file}"
|
||||
;;
|
||||
esac
|
||||
|
||||
local bins=(
|
||||
"ot-cli-ftd"
|
||||
"ot-cli-mtd"
|
||||
"ot-ncp-ftd"
|
||||
"ot-ncp-mtd"
|
||||
"ot-rcp"
|
||||
)
|
||||
|
||||
local libs=(
|
||||
"libopenthread-cli-ftd.a"
|
||||
"libopenthread-cli-mtd.a"
|
||||
"libopenthread-ftd.a"
|
||||
"libopenthread-mtd.a"
|
||||
"libopenthread-ncp-ftd.a"
|
||||
"libopenthread-ncp-mtd.a"
|
||||
"libopenthread-rcp.a"
|
||||
"libopenthread-radio.a"
|
||||
)
|
||||
|
||||
for file in "${bins[@]}"; do
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/"${build_dir}"/bin/"${file}"_"${thread_version}" "${OT_TMP_DIR}"/b/"${build_dir}"/bin/"${file}"_"${thread_version}"
|
||||
echo nm_size "${OT_TMP_DIR}"/a/"${build_dir}"/bin/"${file}"_"${thread_version}" "${OT_TMP_DIR}"/b/"${build_dir}"/bin/"${file}"_"${thread_version}"
|
||||
nm_size "${OT_TMP_DIR}"/a/"${build_dir}"/bin/"${file}"_"${thread_version}" "${OT_TMP_DIR}"/b/"${build_dir}"/bin/"${file}"_"${thread_version}"
|
||||
"${reporter}" size "${old_file}" "${new_file}"
|
||||
echo "nm_size ${old_file} ${new_file}"
|
||||
nm_size "${old_file}" "${new_file}"
|
||||
done
|
||||
|
||||
for file in "${libs[@]}"; do
|
||||
"${reporter}" size "${OT_TMP_DIR}"/a/"${build_dir}"/lib/"${file}"_"${thread_version}" "${OT_TMP_DIR}"/b/"${build_dir}"/lib/"${file}"_"${thread_version}"
|
||||
echo nm_size "${OT_TMP_DIR}"/a/"${build_dir}"/lib/"${file}"_"${thread_version}" "${OT_TMP_DIR}"/b/"${build_dir}"/lib/"${file}"_"${thread_version}"
|
||||
nm_size "${OT_TMP_DIR}"/a/"${build_dir}"/lib/"${file}"_"${thread_version}" "${OT_TMP_DIR}"/b/"${build_dir}"/lib/"${file}"_"${thread_version}"
|
||||
done
|
||||
}
|
||||
|
||||
size_nrf52840()
|
||||
{
|
||||
export OT_SHA_NEW OT_SHA_OLD
|
||||
|
||||
rm -rf "${OT_TMP_DIR}"
|
||||
|
||||
if [[ "${GITHUB_ACTIONS+x}" ]]; then
|
||||
git fetch --depth 1 --no-recurse-submodules origin "${OT_SHA_OLD}"
|
||||
fi
|
||||
|
||||
local reporter="${OT_SIZE_REPORTER:-markdown}"
|
||||
"${reporter}" init OpenThread
|
||||
|
||||
size_nrf52840_version 1.1
|
||||
size_nrf52840_version 1.3
|
||||
build_nrf52840 ftd new
|
||||
build_nrf52840 mtd new
|
||||
build_nrf52840 br new
|
||||
|
||||
build_nrf52840 ftd old
|
||||
build_nrf52840 mtd old
|
||||
build_nrf52840 br old
|
||||
|
||||
local ftd_files=(
|
||||
"ot-cli-ftd"
|
||||
"ot-ncp-ftd"
|
||||
"libopenthread-ftd.a"
|
||||
"libopenthread-cli-ftd.a"
|
||||
"libopenthread-ncp-ftd.a"
|
||||
)
|
||||
|
||||
local mtd_files=(
|
||||
"ot-cli-mtd"
|
||||
"ot-ncp-mtd"
|
||||
"libopenthread-mtd.a"
|
||||
"libopenthread-cli-mtd.a"
|
||||
"libopenthread-ncp-mtd.a"
|
||||
)
|
||||
|
||||
local br_files=(
|
||||
"ot-cli-ftd-br"
|
||||
"libopenthread-ftd-br.a"
|
||||
"libopenthread-cli-ftd-br.a"
|
||||
)
|
||||
|
||||
# `rcp`` is using same config as `ftd`.
|
||||
local rcp_files=(
|
||||
"ot-rcp"
|
||||
"libopenthread-rcp.a"
|
||||
"libopenthread-radio.a"
|
||||
)
|
||||
|
||||
generate_report ftd "${ftd_files[@]}"
|
||||
generate_report mtd "${mtd_files[@]}"
|
||||
generate_report br "${br_files[@]}"
|
||||
generate_report ftd "${rcp_files[@]}"
|
||||
|
||||
"${reporter}" post
|
||||
}
|
||||
@@ -258,6 +287,7 @@ main()
|
||||
if [[ $# == 0 ]]; then
|
||||
setup
|
||||
size_nrf52840
|
||||
cd
|
||||
elif [[ $1 == setup ]]; then
|
||||
setup
|
||||
elif [[ $1 == nrf52840 ]]; then
|
||||
|
||||
+1
-1
@@ -656,7 +656,7 @@ main()
|
||||
{
|
||||
envsetup "$@"
|
||||
|
||||
if [[ -z ${1:-} ]]; then
|
||||
if [[ -z ${1-} ]]; then
|
||||
print_usage 1
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user