mirror of https://github.com/thesofproject/sof.git
xtensa-build-zephyr: do not clone a second version of sof.git
This script lives in a sof.git/ clone yet it was systematically cloning a second sof.git/. Besides the obvious confusion and risk of editing the wrong files, this meant it was not possible to build code that has not been merged yet! This was a problem for both CI and developers. Fixed by using symbolic links to ourselves instead. Note it is _still_ possible to build from another sof.git clone if desired, however this script will never git re-clone a second sof.git itself, that second clone has to be created (e.g.: by west) before this script runs. When cloning a brand new zephyrproject, use a shallow zephyr clone and download only the two zephyr modules we actually use. This speeds up automation considerably and makes it much faster for non-Zephyr developers to reproduce Zephyr issues. Developers can always git unshallow and west update once if they want to. Rename the default west top to "zephyrproject" to not just match the zephyr documentation but to also avoid creating a double zephyr/zephyr/ directory. See the new print_usage() for a few more implementation details. Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is contained in:
parent
831bb3755b
commit
33c5f5d38e
|
@ -5,9 +5,11 @@
|
|||
# stop on most errors
|
||||
set -e
|
||||
|
||||
SOF_TOP=$(cd "$(dirname "$0")" && cd .. && pwd)
|
||||
|
||||
SUPPORTED_PLATFORMS=(apl cnl icl tgl-h)
|
||||
# By default use "zephyr" in the current directory
|
||||
ZEPHYR_ROOT=zephyr
|
||||
# Default value, can be overridden on the command line
|
||||
WEST_TOP="${SOF_TOP}"/zephyrproject
|
||||
BUILD_JOBS=$(nproc --all)
|
||||
RIMAGE_KEY=modules/audio/sof/keys/otc_private_key.pem
|
||||
PLATFORMS=()
|
||||
|
@ -31,41 +33,43 @@ platform's _defconfig file.
|
|||
usage: $0 [options] platform(s)
|
||||
|
||||
-a Build all platforms.
|
||||
-c Clone the complete Zephyr and SOF trees before building.
|
||||
-j n Set number of make build jobs. Jobs=#cores by default.
|
||||
Infinite when not specified.
|
||||
-k Path to a non-default rimage signing key.
|
||||
-p Zephyr root directory.
|
||||
-c recursively clones Zephyr inside sof before building.
|
||||
Incompatible with -p.
|
||||
-p Existing Zephyr project directory. Incompatible with -c.
|
||||
If modules/audio/sof is missing there then a symbolic
|
||||
link pointing to ${SOF_TOP} will be added.
|
||||
|
||||
Supported platforms ${SUPPORTED_PLATFORMS[*]}
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
# Downloads zephyrproject inside sof/ and create a ../../.. symbolic
|
||||
# link back to sof/
|
||||
clone()
|
||||
{
|
||||
# Check out Zephyr + SOF
|
||||
|
||||
type -p west || die "Install west and a west toolchain following https://docs.zephyrproject.org/latest/getting_started/index.html"
|
||||
type -p git || die "Install git"
|
||||
|
||||
[ -e "$ZEPHYR_ROOT" ] && die "$ZEPHYR_ROOT already exists"
|
||||
mkdir -p "$ZEPHYR_ROOT"
|
||||
cd "$ZEPHYR_ROOT"
|
||||
west init
|
||||
west update
|
||||
cd modules/audio/sof
|
||||
git remote add sof https://github.com/thesofproject/sof.git
|
||||
git remote update sof
|
||||
git checkout sof/main
|
||||
git clone --recurse-submodules https://github.com/thesofproject/rimage.git
|
||||
cd -
|
||||
[ -e "$WEST_TOP" ] && die "$WEST_TOP already exists"
|
||||
mkdir -p "$WEST_TOP"
|
||||
git clone --depth=5 https://github.com/zephyrproject-rtos/zephyr \
|
||||
"$WEST_TOP"/zephyr
|
||||
west init -l "${WEST_TOP}"/zephyr
|
||||
( cd "${WEST_TOP}"
|
||||
mkdir -p modules/audio
|
||||
ln -s ../../.. modules/audio/sof
|
||||
# Do NOT "west update sof"!!
|
||||
west update zephyr hal_xtensa
|
||||
)
|
||||
}
|
||||
|
||||
build()
|
||||
{
|
||||
[ -d "$ZEPHYR_ROOT" ] || die "$ZEPHYR_ROOT doesn't exists"
|
||||
cd "$ZEPHYR_ROOT"
|
||||
cd "$WEST_TOP"
|
||||
|
||||
# Build rimage
|
||||
RIMAGE_DIR=build-rimage
|
||||
|
@ -107,6 +111,8 @@ build()
|
|||
|
||||
main()
|
||||
{
|
||||
local zeproj
|
||||
|
||||
# parse the args
|
||||
while getopts "acj:k:p:" OPTION; do
|
||||
case "$OPTION" in
|
||||
|
@ -114,12 +120,28 @@ main()
|
|||
c) DO_CLONE=yes ;;
|
||||
j) BUILD_JOBS="$OPTARG" ;;
|
||||
k) RIMAGE_KEY="$OPTARG" ;;
|
||||
p) ZEPHYR_ROOT="$OPTARG" ;;
|
||||
p) zeproj="$OPTARG" ;;
|
||||
*) print_usage; exit 1 ;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
if [ -n "$zeproj" ] && [ x"$DO_CLONE" = xyes ]; then
|
||||
die 'Cannot use -p with -c, -c supports %s only' "${WEST_TOP}"
|
||||
fi
|
||||
|
||||
if [ -n "$zeproj" ]; then
|
||||
|
||||
[ -d "$zeproj" ] ||
|
||||
die "$zeproj is not a directory, try -c instead of -p?"
|
||||
|
||||
( cd "$zeproj"
|
||||
test "$(realpath "$(west topdir)")" = "$(/bin/pwd)"
|
||||
) || die '%s is not a zephyrproject' "$WEST_TOP"
|
||||
|
||||
WEST_TOP="$zeproj"
|
||||
fi
|
||||
|
||||
# parse platform args
|
||||
for arg in "$@"; do
|
||||
platform=none
|
||||
|
@ -148,6 +170,17 @@ main()
|
|||
|
||||
if [ "x$DO_CLONE" == "xyes" ]; then
|
||||
clone
|
||||
else
|
||||
# Link to ourselves if no sof module yet
|
||||
test -e "${WEST_TOP}"/modules/audio/sof ||
|
||||
ln -s "$SOF_TOP" "${WEST_TOP}"/modules/audio/sof
|
||||
|
||||
# Support for submodules in west is too recent, cannot
|
||||
# rely on it
|
||||
test -d "${WEST_TOP}"/modules/audio/sof/rimage/CMakeLists.txt || (
|
||||
cd "${WEST_TOP}"/modules/audio/sof
|
||||
git submodule update --init --recursive
|
||||
)
|
||||
fi
|
||||
|
||||
build
|
||||
|
|
Loading…
Reference in New Issue