2021-04-05 04:55:34 +02:00
|
|
|
#!/usr/bin/env bash
|
2024-02-08 17:33:44 +01:00
|
|
|
############################################################################
|
|
|
|
# tools/ci/cibuild.sh
|
|
|
|
#
|
2024-09-10 14:15:58 +02:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
2024-02-08 17:33:44 +01:00
|
|
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
# contributor license agreements. See the NOTICE file distributed with
|
|
|
|
# this work for additional information regarding copyright ownership. The
|
|
|
|
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
# "License"); you may not use this file except in compliance with the
|
|
|
|
# License. You may obtain a copy of the License at
|
2021-04-05 04:55:34 +02:00
|
|
|
#
|
2024-02-08 17:33:44 +01:00
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
2021-04-05 04:55:34 +02:00
|
|
|
#
|
2024-02-08 17:33:44 +01:00
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
# License for the specific language governing permissions and limitations
|
2021-04-05 04:55:34 +02:00
|
|
|
# under the License.
|
2024-02-08 17:33:44 +01:00
|
|
|
#
|
|
|
|
############################################################################
|
2021-04-05 04:55:34 +02:00
|
|
|
set -e
|
|
|
|
set -o xtrace
|
|
|
|
|
2022-10-21 07:27:32 +02:00
|
|
|
|
2024-02-08 17:33:44 +01:00
|
|
|
CID=$(cd "$(dirname "$0")" && pwd)
|
|
|
|
CIWORKSPACE=$(cd "${CID}"/../../../ && pwd -P)
|
|
|
|
CIPLAT=${CIWORKSPACE}/nuttx/tools/ci/platforms
|
|
|
|
nuttx=${CIWORKSPACE}/nuttx
|
|
|
|
apps=${CIWORKSPACE}/apps
|
2022-10-21 07:27:32 +02:00
|
|
|
|
2024-02-08 17:33:44 +01:00
|
|
|
os=$(uname -s)
|
|
|
|
if [ -f /etc/os-release ]; then
|
|
|
|
osname=$(grep "^ID=" /etc/os-release | cut -d'=' -f2 | tr -d '"')
|
|
|
|
else
|
|
|
|
osname=${os}
|
|
|
|
fi
|
2021-04-05 04:55:34 +02:00
|
|
|
|
2024-02-08 17:33:44 +01:00
|
|
|
function to_do {
|
|
|
|
echo ""
|
|
|
|
echo "NuttX TODO: $1"
|
|
|
|
echo "The $1 platform does not appear to have been added to this project."
|
|
|
|
echo ""
|
|
|
|
exit 1
|
2021-04-05 04:55:34 +02:00
|
|
|
}
|
|
|
|
|
2024-02-08 17:33:44 +01:00
|
|
|
function install_tools {
|
|
|
|
export NUTTXTOOLS=${CIWORKSPACE}/tools
|
|
|
|
mkdir -p "${NUTTXTOOLS}"
|
2022-12-10 15:34:20 +01:00
|
|
|
|
2024-02-08 17:33:44 +01:00
|
|
|
case ${osname} in
|
|
|
|
alpine)
|
|
|
|
to_do "alpine"
|
|
|
|
;;
|
|
|
|
arch)
|
|
|
|
to_do "arch"
|
|
|
|
;;
|
|
|
|
CYGWIN*)
|
|
|
|
to_do "CYGWIN"
|
|
|
|
;;
|
|
|
|
debian)
|
|
|
|
to_do "debian"
|
|
|
|
;;
|
|
|
|
fedora)
|
|
|
|
to_do "fedora"
|
|
|
|
;;
|
|
|
|
freebsd)
|
|
|
|
to_do "freebsd"
|
|
|
|
;;
|
2022-12-10 15:34:20 +01:00
|
|
|
Darwin)
|
2024-02-08 17:33:44 +01:00
|
|
|
"${CIPLAT}"/darwin.sh
|
2022-12-10 15:34:20 +01:00
|
|
|
;;
|
|
|
|
Linux)
|
2024-02-08 17:33:44 +01:00
|
|
|
"${CIPLAT}"/linux.sh
|
|
|
|
;;
|
|
|
|
manjaro)
|
|
|
|
to_do "manjaro"
|
|
|
|
;;
|
|
|
|
msys2)
|
|
|
|
"${CIPLAT}"/msys2.sh
|
|
|
|
;;
|
|
|
|
ubuntu)
|
|
|
|
"${CIPLAT}"/ubuntu.sh
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
to_do "unknown"
|
2022-12-10 15:34:20 +01:00
|
|
|
;;
|
|
|
|
esac
|
2023-03-03 08:24:16 +01:00
|
|
|
|
2024-02-08 17:33:44 +01:00
|
|
|
source "${CIWORKSPACE}"/tools/env.sh
|
2023-03-03 08:24:16 +01:00
|
|
|
}
|
|
|
|
|
2021-04-05 04:55:34 +02:00
|
|
|
function usage {
|
|
|
|
echo ""
|
|
|
|
echo "USAGE: $0 [-i] [-s] [-c] [-*] <testlist>"
|
|
|
|
echo " $0 -h"
|
|
|
|
echo ""
|
|
|
|
echo "Where:"
|
|
|
|
echo " -i install tools"
|
|
|
|
echo " -s setup repos"
|
|
|
|
echo " -c enable ccache"
|
|
|
|
echo " -* support all options in testbuild.sh"
|
2024-02-08 17:33:44 +01:00
|
|
|
echo " -h will show this help text and terminate"
|
2021-04-05 04:55:34 +02:00
|
|
|
echo " <testlist> select testlist file"
|
|
|
|
echo ""
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function enable_ccache {
|
2024-02-08 17:33:44 +01:00
|
|
|
export CCACHE_DIR="${CIWORKSPACE}"/tools/ccache
|
2022-10-21 07:27:32 +02:00
|
|
|
}
|
|
|
|
|
2021-04-05 04:55:34 +02:00
|
|
|
function setup_repos {
|
|
|
|
pushd .
|
2021-09-01 20:34:29 +02:00
|
|
|
if [ -d "${nuttx}" ]; then
|
|
|
|
cd "${nuttx}"; git pull
|
2021-04-05 04:55:34 +02:00
|
|
|
else
|
2022-11-22 19:59:48 +01:00
|
|
|
git clone https://github.com/apache/nuttx.git "${nuttx}"
|
2021-09-01 20:34:29 +02:00
|
|
|
cd "${nuttx}"
|
2021-04-05 04:55:34 +02:00
|
|
|
fi
|
|
|
|
git log -1
|
|
|
|
|
2021-09-01 20:34:29 +02:00
|
|
|
if [ -d "${apps}" ]; then
|
|
|
|
cd "${apps}"; git pull
|
2021-04-05 04:55:34 +02:00
|
|
|
else
|
2022-11-22 19:59:48 +01:00
|
|
|
git clone https://github.com/apache/nuttx-apps.git "${apps}"
|
2021-09-01 20:34:29 +02:00
|
|
|
cd "${apps}"
|
2021-04-05 04:55:34 +02:00
|
|
|
fi
|
|
|
|
git log -1
|
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
|
|
|
function run_builds {
|
|
|
|
local ncpus
|
2024-02-08 17:33:44 +01:00
|
|
|
if [ "X$osname" == "XDarwin" ]; then
|
|
|
|
ncpus=$(sysctl -n hw.ncpu)
|
|
|
|
else
|
|
|
|
ncpus=$(grep -c ^processor /proc/cpuinfo)
|
|
|
|
fi
|
2021-04-05 04:55:34 +02:00
|
|
|
|
2021-09-01 20:34:29 +02:00
|
|
|
options+="-j ${ncpus}"
|
2021-04-05 04:55:34 +02:00
|
|
|
|
2021-09-01 20:34:29 +02:00
|
|
|
for build in "${builds[@]}"; do
|
|
|
|
"${nuttx}"/tools/testbuild.sh ${options} -e "-Wno-cpp -Werror" "${build}"
|
2021-04-05 04:55:34 +02:00
|
|
|
done
|
2022-12-10 11:29:47 +01:00
|
|
|
|
|
|
|
if [ -d "${CCACHE_DIR}" ]; then
|
2024-02-08 17:33:44 +01:00
|
|
|
# Print a summary of configuration and statistics counters
|
2022-12-10 11:29:47 +01:00
|
|
|
ccache -s
|
|
|
|
fi
|
2021-04-05 04:55:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2021-09-01 20:34:29 +02:00
|
|
|
while [ -n "$1" ]; do
|
2021-04-05 04:55:34 +02:00
|
|
|
case "$1" in
|
|
|
|
-h )
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
-i )
|
|
|
|
install_tools
|
|
|
|
;;
|
|
|
|
-c )
|
|
|
|
enable_ccache
|
|
|
|
;;
|
|
|
|
-s )
|
|
|
|
setup_repos
|
|
|
|
;;
|
|
|
|
-* )
|
|
|
|
options+="$1 "
|
|
|
|
;;
|
|
|
|
* )
|
2021-09-01 20:34:29 +02:00
|
|
|
builds=( "$@" )
|
2021-04-05 04:55:34 +02:00
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
run_builds
|