mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-28 14:01:43 +01:00
setup_board: allow toolchain.conf to list multiple toolchains
We want to have some 64bit boards also install the 32bit toolchain, so extend the toolchain.conf file to allow specifying of multiple targets. BUG=chromium-os:25969 TEST=build_packages for x86-mario installed both i686-pc-linux-gnu and x86_64-cros-linux-gnu Change-Id: Ic2ca1aeeefa5ea2207d3c963ac856909cb40cae5 CQ-DEPEND=Iea6f682e258d59c0b3b3ca2cad7e15ae521dcc89 CQ-DEPEND=Ib71e7503c3ebc98549d09e35cb0bb9687b8fafb8 Reviewed-on: https://gerrit.chromium.org/gerrit/15902 Commit-Ready: Mike Frysinger <vapier@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
parent
bdc4fb1998
commit
9e30234e50
86
setup_board
86
setup_board
@ -25,6 +25,7 @@ find_common_sh() {
|
|||||||
|
|
||||||
find_common_sh
|
find_common_sh
|
||||||
. "${SCRIPT_ROOT}/common.sh" || ! echo "Unable to load common.sh" || exit 1
|
. "${SCRIPT_ROOT}/common.sh" || ! echo "Unable to load common.sh" || exit 1
|
||||||
|
. "${SRC_ROOT}/platform/dev/toolchain_utils.sh"
|
||||||
|
|
||||||
# Script must run inside the chroot
|
# Script must run inside the chroot
|
||||||
restart_in_chroot_if_needed "$@"
|
restart_in_chroot_if_needed "$@"
|
||||||
@ -315,7 +316,6 @@ install_toolchain_in_board() {
|
|||||||
if [[ -L "${BOARD_GCC_DIR}" ]] ; then
|
if [[ -L "${BOARD_GCC_DIR}" ]] ; then
|
||||||
sudo rm -f "${BOARD_GCC_DIR}"
|
sudo rm -f "${BOARD_GCC_DIR}"
|
||||||
fi
|
fi
|
||||||
. "${SRC_ROOT}/platform/dev/toolchain_utils.sh"
|
|
||||||
copy_gcc_libs "${BOARD_ROOT}" "cross-$FLAGS_toolchain/gcc-$gcc_ver"
|
copy_gcc_libs "${BOARD_ROOT}" "cross-$FLAGS_toolchain/gcc-$gcc_ver"
|
||||||
else
|
else
|
||||||
sudo mkdir -p ${BOARD_ROOT}/usr/lib64
|
sudo mkdir -p ${BOARD_ROOT}/usr/lib64
|
||||||
@ -452,40 +452,18 @@ fi
|
|||||||
|
|
||||||
get_board_and_variant $FLAGS_board $FLAGS_variant
|
get_board_and_variant $FLAGS_board $FLAGS_variant
|
||||||
|
|
||||||
#
|
|
||||||
# Check if there are any board overlays. There should be at least a top
|
|
||||||
# level board specific overlay.
|
|
||||||
#
|
|
||||||
PRIMARY_BOARD_OVERLAY=$(cros_overlay_list --board "$BOARD" --primary_only)
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Fetch the toolchain from the board overlay.
|
# Fetch the toolchain from the board overlay.
|
||||||
#
|
#
|
||||||
BOARD_TOOL_CHAIN="${PRIMARY_BOARD_OVERLAY}/toolchain.conf"
|
all_toolchains=( $(get_all_board_toolchains "${BOARD}") )
|
||||||
FLAGS_toolchain=${FLAGS_toolchain:-$(cat ${BOARD_TOOL_CHAIN})}
|
: ${FLAGS_toolchain:=${all_toolchains[0]}}
|
||||||
|
|
||||||
# Figure out ARCH from the given toolchain
|
|
||||||
# TODO: Move to common.sh as a function after scripts are switched over.
|
|
||||||
if [ -z "${FLAGS_toolchain}" ]; then
|
if [ -z "${FLAGS_toolchain}" ]; then
|
||||||
error "No toolchain specified in board overlay or on command line."
|
error "No toolchain specified in board overlay or on command line."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
TC_ARCH=$(echo "$FLAGS_toolchain" | awk -F'-' '{ print $1 }')
|
ARCH=$(get_board_arch "${BOARD}") || exit 1
|
||||||
case "$TC_ARCH" in
|
|
||||||
arm*)
|
|
||||||
ARCH="arm"
|
|
||||||
;;
|
|
||||||
*86)
|
|
||||||
ARCH="x86"
|
|
||||||
;;
|
|
||||||
x86_64)
|
|
||||||
ARCH="amd64"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
error "Unable to determine ARCH from toolchain: $FLAGS_toolcahin"
|
|
||||||
exit 1
|
|
||||||
esac
|
|
||||||
|
|
||||||
case "$BOARD" in
|
case "$BOARD" in
|
||||||
*-host)
|
*-host)
|
||||||
@ -516,37 +494,37 @@ BOARD_OVERLAY_LIST=$(cros_overlay_list \
|
|||||||
|
|
||||||
eval $(portageq envvar -v CHOST PKGDIR)
|
eval $(portageq envvar -v CHOST PKGDIR)
|
||||||
|
|
||||||
if [ "${CHOST}" != "$FLAGS_toolchain" ] ; then
|
# Update all the toolchains that this board wants.
|
||||||
if toolchain_needs_update $FLAGS_toolchain; then
|
for toolchain in ${all_toolchains[@]} ; do
|
||||||
warn "Toolchain needs to be updated! Updating toolchain..."
|
[[ "${CHOST}" == "${toolchain}" ]] && continue
|
||||||
uninstall_toolchain $FLAGS_toolchain
|
|
||||||
build_toolchain $FLAGS_toolchain
|
toolchain_updated=${FLAGS_FALSE}
|
||||||
# If the board root already exists, re-install the toolchain there.
|
if toolchain_needs_update ${toolchain} ; then
|
||||||
if [ -d "$BOARD_ROOT" ] && [ "$FLAGS_force" = "$FLAGS_FALSE" ]; then
|
toolchain_updated=${FLAGS_TRUE}
|
||||||
install_toolchain_in_board
|
|
||||||
fi
|
warn "Toolchain needs to be updated! Updating ${toolchain} ..."
|
||||||
if [[ "${ARCH}" = "x86" || "${ARCH}" = "amd64" ]] ; then
|
uninstall_toolchain ${toolchain}
|
||||||
echo "Switching on gold as the default linker."
|
build_toolchain ${toolchain}
|
||||||
|
|
||||||
|
if [[ "${toolchain}" != arm* ]] ; then
|
||||||
|
info "Switching on gold as the default linker."
|
||||||
BINUTILS_VERSION=$(cross_get_version binutils | sed 's/-r[0-9]\+//g')
|
BINUTILS_VERSION=$(cross_get_version binutils | sed 's/-r[0-9]\+//g')
|
||||||
sudo binutils-config "${FLAGS_toolchain}-${BINUTILS_VERSION}-gold"
|
sudo binutils-config "${FLAGS_toolchain}-${BINUTILS_VERSION}-gold"
|
||||||
fi
|
fi
|
||||||
else
|
fi
|
||||||
# Update the users libc in their board if needed.
|
|
||||||
if [ -d "$BOARD_ROOT" ] && [ "$FLAGS_force" = "$FLAGS_FALSE" ] ; then
|
if [[ "${toolchain}" == "${FLAGS_toolchain}" ]] &&
|
||||||
if board_needs_libc_update; then
|
[ -d "$BOARD_ROOT" ] && [ "$FLAGS_force" == "$FLAGS_FALSE" ] ; then
|
||||||
echo "Updating libc in the board."
|
if [[ "${toolchain_updated}" == "${FLAGS_TRUE}" ]] ; then
|
||||||
install_toolchain_in_board
|
# If the board root already exists, re-install the toolchain there.
|
||||||
fi
|
install_toolchain_in_board
|
||||||
|
elif board_needs_libc_update; then
|
||||||
|
# Update the users libc in their board if needed.
|
||||||
|
echo "Updating libc in the board."
|
||||||
|
install_toolchain_in_board
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
|
|
||||||
if [[ "${ARCH}" == "x86" ]] && toolchain_needs_update arm-none-eabi ; then
|
|
||||||
# We need a toolchain to build software for the embedded controller
|
|
||||||
# on the x86 board.
|
|
||||||
uninstall_toolchain arm-none-eabi
|
|
||||||
build_toolchain arm-none-eabi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -d "$BOARD_ROOT" ] ; then
|
if [ -d "$BOARD_ROOT" ] ; then
|
||||||
if [[ $FLAGS_force -eq $FLAGS_TRUE ]]; then
|
if [[ $FLAGS_force -eq $FLAGS_TRUE ]]; then
|
||||||
@ -698,8 +676,8 @@ if ${HOST_BOARD}; then
|
|||||||
# the latest one is correctly selected. Ignore cat errors as not
|
# the latest one is correctly selected. Ignore cat errors as not
|
||||||
# all overlays will have a toolchain.conf.
|
# all overlays will have a toolchain.conf.
|
||||||
ALL_OVERLAYS=$(cros_overlay_list --all_boards)
|
ALL_OVERLAYS=$(cros_overlay_list --all_boards)
|
||||||
TARGETS=$(cat $(printf '%s/toolchain.conf ' ${ALL_OVERLAYS}) 2>/dev/null | \
|
TARGETS=$(sed 's:#.*::' $(printf '%s/toolchain.conf ' ${ALL_OVERLAYS}) \
|
||||||
sort -u)
|
2>/dev/null | sort -u)
|
||||||
for target in ${TARGETS}; do
|
for target in ${TARGETS}; do
|
||||||
# Install needed glibc tarball.
|
# Install needed glibc tarball.
|
||||||
cross_target_path=/var/lib/portage/pkgs/cross-$target
|
cross_target_path=/var/lib/portage/pkgs/cross-$target
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user