[github-actions] use cmake to build nrf in size action (#6126)

This commit is contained in:
Li Cao
2021-02-22 15:37:41 -08:00
committed by GitHub
parent 14ef4e4082
commit b7ba04f720
+83 -61
View File
@@ -48,9 +48,15 @@ setup_arm_gcc_7()
arm-none-eabi-gcc --version arm-none-eabi-gcc --version
} }
setup_ninja_build()
{
sudo apt-get --no-install-recommends install -y ninja-build
}
setup() setup()
{ {
setup_arm_gcc_7 setup_arm_gcc_7
setup_ninja_build
} }
markdown_init() markdown_init()
@@ -100,61 +106,63 @@ markdown()
size_nrf52840_version() size_nrf52840_version()
{ {
local flags=( local options=(
"BORDER_AGENT=1" "-DOT_BORDER_AGENT=ON"
"BORDER_ROUTER=1" "-DOT_BORDER_ROUTER=ON"
"CHANNEL_MANAGER=1" "-DOT_CHANNEL_MANAGER=ON"
"CHANNEL_MONITOR=1" "-DOT_CHANNEL_MONITOR=ON"
"CHILD_SUPERVISION=1" "-DOT_CHILD_SUPERVISION=ON"
"COAP=1" "-DOT_COAP=ON"
"COAPS=1" "-DOT_COAPS=ON"
"COMMISSIONER=1" "-DOT_COMMISSIONER=ON"
"DATASET_UPDATER=1" "-DOT_DATASET_UPDATER=ON"
"DHCP6_CLIENT=1" "-DOT_DHCP6_CLIENT=ON"
"DHCP6_SERVER=1" "-DOT_DHCP6_SERVER=ON"
"DIAGNOSTIC=1" "-DOT_DIAGNOSTIC=ON"
"DISABLE_DOC=1" "-DOT_DNSSD_SERVER=ON"
"DNS_CLIENT=1" "-DOT_DNS_CLIENT=ON"
"DNSSD_SERVER=1" "-DOT_ECDSA=ON"
"ECDSA=1" "-DOT_FULL_LOGS=ON"
"FULL_LOGS=1" "-DOT_JAM_DETECTION=ON"
"JAM_DETECTION=1" "-DOT_JOINER=ON"
"JOINER=1" "-DOT_LINK_RAW=ON"
"LINK_RAW=1" "-DOT_MAC_FILTER=ON"
"MAC_FILTER=1" "-DOT_MESSAGE_USE_HEAP=ON"
"MESSAGE_USE_HEAP=1" "-DOT_MTD_NETDIAG=ON"
"MTD_NETDIAG=1" "-DOT_SERVICE=ON"
"SERVICE=1" "-DOT_SLAAC=ON"
"SLAAC=1" "-DOT_SNTP_CLIENT=ON"
"SNTP_CLIENT=1" "-DOT_SRP_CLIENT=ON"
"SRP_CLIENT=1" "-DOT_SRP_SERVER=ON"
"SRP_SERVER=1" "-DOT_TIME_SYNC=ON"
"TIME_SYNC=1" "-DOT_UDP_FORWARD=ON"
"UDP_FORWARD=1"
) )
local thread_version=$1 local thread_version=$1
if [[ ${thread_version} == "1.2" ]]; then if [[ ${thread_version} == "1.2" ]]; then
flags+=( options+=(
"THREAD_VERSION=1.2" "-DOT_THREAD_VERSION=1.2"
"BACKBONE_ROUTER=1" "-DOT_BACKBONE_ROUTER=ON"
"DUA=1" "-DOT_DUA=ON"
"MLR=1" "-DOT_MLR=ON"
"CSL_RECEIVER=1" "-DOT_CSL_RECEIVER=ON"
"LINK_METRICS=1" "-DOT_LINK_METRICS=ON"
) )
fi fi
rm -rf "${OT_TMP_DIR}" rm -rf "${OT_TMP_DIR}"
local build_dir="build"
# new commit # new commit
mkdir -p "${OT_TMP_DIR}/b" mkdir -p "${OT_TMP_DIR}/b"
git archive "${OT_SHA_NEW}" | tar x -C "${OT_TMP_DIR}/b" git 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}/b" \ (cd "${OT_TMP_DIR}/b" \
&& ./bootstrap \ && OT_CMAKE_BUILD_DIR=${build_dir} script/build nrf52840 UART_trans "${options[@]}")
&& make -f examples/Makefile-nrf52840 "${flags[@]}")
# old commit # old commit
if [[ "${GITHUB_ACTIONS+x}" ]]; then if [[ "${GITHUB_ACTIONS+x}" ]]; then
@@ -162,39 +170,53 @@ size_nrf52840_version()
fi fi
mkdir -p "${OT_TMP_DIR}/a" mkdir -p "${OT_TMP_DIR}/a"
git archive "${OT_SHA_OLD}" | tar x -C "${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 "${OT_TMP_DIR}/a" \ (cd "${OT_TMP_DIR}/a" \
&& ./bootstrap \ && OT_CMAKE_BUILD_DIR=${build_dir} script/build nrf52840 UART_trans "${options[@]}")
&& make -f examples/Makefile-nrf52840 "${flags[@]}")
# rename the generated files to be ready for size-report # rename the generated files to be ready for size-report
# shellcheck disable=SC2011 # shellcheck disable=SC2011
( (
cd "${OT_TMP_DIR}"/a/output/nrf52840/bin cd "${OT_TMP_DIR}"/a/"${build_dir}"/bin
ls | xargs -I{} mv {} {}_"${thread_version}" ls | xargs -I{} mv {} {}_"${thread_version}"
cd "${OT_TMP_DIR}"/b/output/nrf52840/bin cd "${OT_TMP_DIR}"/b/"${build_dir}"/bin
ls | xargs -I{} mv {} {}_"${thread_version}" ls | xargs -I{} mv {} {}_"${thread_version}"
cd "${OT_TMP_DIR}"/a/output/nrf52840/lib/ cd "${OT_TMP_DIR}"/a/"${build_dir}"/lib
ls ./*.a | xargs -I{} mv {} {}_"${thread_version}" ls ./*.a | xargs -I{} mv {} {}_"${thread_version}"
cd "${OT_TMP_DIR}"/b/output/nrf52840/lib/ cd "${OT_TMP_DIR}"/b/"${build_dir}"/lib
ls ./*.a | xargs -I{} mv {} {}_"${thread_version}" ls ./*.a | xargs -I{} mv {} {}_"${thread_version}"
) )
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-cli-ftd_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-cli-ftd_"${thread_version}" local bins=(
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-cli-mtd_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-cli-mtd_"${thread_version}" "ot-cli-ftd"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-ncp-ftd_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-ncp-ftd_"${thread_version}" "ot-cli-mtd"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-ncp-mtd_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-ncp-mtd_"${thread_version}" "ot-ncp-ftd"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/bin/ot-rcp_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/bin/ot-rcp_"${thread_version}" "ot-ncp-mtd"
"ot-rcp"
)
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-cli-ftd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-cli-ftd.a_"${thread_version}" local libs=(
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-cli-mtd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-cli-mtd.a_"${thread_version}" "libopenthread-cli-ftd.a"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-ftd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-ftd.a_"${thread_version}" "libopenthread-cli-mtd.a"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-mtd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-mtd.a_"${thread_version}" "libopenthread-ftd.a"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-ncp-ftd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-ncp-ftd.a_"${thread_version}" "libopenthread-mtd.a"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-ncp-mtd.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-ncp-mtd.a_"${thread_version}" "libopenthread-ncp-ftd.a"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-rcp.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-rcp.a_"${thread_version}" "libopenthread-ncp-mtd.a"
"${reporter}" size "${OT_TMP_DIR}"/a/output/nrf52840/lib/libopenthread-radio.a_"${thread_version}" "${OT_TMP_DIR}"/b/output/nrf52840/lib/libopenthread-radio.a_"${thread_version}" "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}"
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}"
done
} }
size_nrf52840() size_nrf52840()