another code cleanup

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-10-20 03:29:55 +01:00
parent 8d9aeef3de
commit 4e54a051ef
3 changed files with 22 additions and 44 deletions

View File

@ -15,8 +15,7 @@ fetch_project_trees()
[ -z "${rev}" ] && err "fetch_project_trees $target: undefined rev" [ -z "${rev}" ] && err "fetch_project_trees $target: undefined rev"
[ -d "src/${project}/${tree}" ] && \ [ -d "src/${project}/${tree}" ] && \
printf "download/%s %s (%s): exists\n" \ printf "download/%s %s (%s): exists\n" \
"${project}" "${tree}" "${_target}" 1>&2 && \ "${project}" "${tree}" "${_target}" 1>&2 && return 0
return 1
prepare_new_tree prepare_new_tree
} }
@ -30,7 +29,7 @@ fetch_from_upstream()
fetch_config() fetch_config()
{ {
x_ rm -f "${cfgsdir}/"*/seen rm -f "${cfgsdir}/"*/seen || err "fetch_config ${cfgsdir}: !rm seen"
while true; do while true; do
eval "$(setvars "" rev tree)" eval "$(setvars "" rev tree)"
_xm="fetch_config ${project}/${_target}" _xm="fetch_config ${project}/${_target}"
@ -50,7 +49,7 @@ load_target_config()
. "${cfgsdir}/${1}/target.cfg" || \ . "${cfgsdir}/${1}/target.cfg" || \
err "load_target_config ${cfgsdir}/${1}: cannot load config" err "load_target_config ${cfgsdir}/${1}: cannot load config"
x_ touch "${cfgsdir}/${1}/seen" touch "${cfgsdir}/${1}/seen" || err "load_config $cfgsdir/$1: !mk seen"
} }
prepare_new_tree() prepare_new_tree()
@ -74,7 +73,7 @@ fetch_project_repo()
verify_config verify_config
clone_project clone_project
[ "${depend}" = "" ] || for d in ${depend} ; do [ -z "${depend}" ] || for d in ${depend} ; do
x_ ./update trees -f ${d} x_ ./update trees -f ${d}
done done
x_ rm -Rf "${tmp_git_dir}" x_ rm -Rf "${tmp_git_dir}"

View File

@ -46,7 +46,7 @@ mkvdir()
git clone . "${srcdir}" || err "mkdir: !gitclone \"${srcdir}\"" git clone . "${srcdir}" || err "mkdir: !gitclone \"${srcdir}\""
[ -z "${_nogit}" ] || x_ rm -Rf ".git" [ -z "${_nogit}" ] || x_ rm -Rf ".git"
rm -Rf "${srcdir}/.git" rm -Rf "${srcdir}/.git" || err "mkvdir: !rm -Rf ${srcdir}/.git"
insert_version_files "${srcdir}" || err "mkvdir ${srcdir}: versionfile" insert_version_files "${srcdir}" || err "mkvdir ${srcdir}: versionfile"
} }
@ -201,6 +201,8 @@ insert_copying_files()
x_ cp "src/seabios/default/COPYING" "${l}/COPYING.coreboot" x_ cp "src/seabios/default/COPYING" "${l}/COPYING.coreboot"
x_ cp "src/seabios/default/COPYING.LESSER" "${l}/COPYING.LESSER.seabios" x_ cp "src/seabios/default/COPYING.LESSER" "${l}/COPYING.LESSER.seabios"
x_ cp -R "src/u-boot/default/Licenses" "${l}/COPYING.u-boot" x_ cp -R "src/u-boot/default/Licenses" "${l}/COPYING.u-boot"
x_ printf "Multiple licenses. Check corresponding %s source archive\n" \
"${projectname}" > "${1}/COPYING"
} }
mkrom_tarball() mkrom_tarball()

View File

@ -16,8 +16,6 @@ export LOCALVERSION="-${projectname}-${version%%-*}"
eval "$(setvars "" arch cfgsdir codedir config config_name crossgcc_ada mode \ eval "$(setvars "" arch cfgsdir codedir config config_name crossgcc_ada mode \
elfdir listfile project romtype target target_dir targets tree _f target1)" elfdir listfile project romtype target target_dir targets tree _f target1)"
tmpclean="$(mktemp -d -t makeclean.XXXXXXXXXX)"
main() main()
{ {
while getopts f:b:m:u:c:x:s:l:n: option while getopts f:b:m:u:c:x:s:l:n: option
@ -37,7 +35,7 @@ main()
esac esac
shift; project="${OPTARG#src/}"; shift shift; project="${OPTARG#src/}"; shift
done done
[ -z "${_f}" ] && err "flag not specified (-m, -u, -b, -c, -x, -f, -s, -l or -n)" [ -z "${_f}" ] && err "missing flag (-m/-u/-b/-c/-x/-f/-s/-l/-n)"
[ -z "${project}" ] && err "project name not specified" [ -z "${project}" ] && err "project name not specified"
if [ ! -f "config/${project}/build.list" ]; then if [ ! -f "config/${project}/build.list" ]; then
@ -51,10 +49,7 @@ build_projects()
{ {
[ $# -gt 0 ] && x_ ./update trees ${_f} ${@} [ $# -gt 0 ] && x_ ./update trees ${_f} ${@}
if [ "${mode}" = "fetch" ]; then [ "${mode}" = "fetch" ] && fetch_project_repo && return 0
fetch_project_repo
return 0
fi
codedir="src/${project}" codedir="src/${project}"
[ -d "${codedir}" ] || x_ ./update trees -f "${project}" [ -d "${codedir}" ] || x_ ./update trees -f "${project}"
@ -140,10 +135,7 @@ handle_src_tree()
romtype="normal" romtype="normal"
target_dir="${cfgsdir}/${target}" target_dir="${cfgsdir}/${target}"
if [ "${mode}" = "fetch" ]; then [ "${mode}" = "fetch" ] && fetch_project_trees && return 1
fetch_project_trees
return 1
fi
x_ mkdir -p "${elfdir}/${target}" x_ mkdir -p "${elfdir}/${target}"
eval "$(setvars "" arch tree)" eval "$(setvars "" arch tree)"
@ -151,10 +143,9 @@ handle_src_tree()
. "${target_dir}/target.cfg" || \ . "${target_dir}/target.cfg" || \
err "handle_src_tree ${target_dir}: cannot load target.cfg" err "handle_src_tree ${target_dir}: cannot load target.cfg"
[ -z "${tree}" ] && \ for ix in arch tree; do
err "handle_src_tree: ${target_dir}: tree undefined" eval "[ -z \"\${$ix}\" ] && err \"handle_src: $ix undefined\""
[ -z "${arch}" ] && \ done
err "handle_src_tree: ${target_dir}: undefined cpu type"
codedir="src/${project}/${tree}" codedir="src/${project}/${tree}"
@ -166,21 +157,14 @@ handle_src_tree()
return 1 return 1
fi fi
x_ ./update trees -f "${project}" "${target}" x_ ./update trees -f "${project}" "${target}"
elif [ "${mode}" = "distclean" ] || \
[ "${mode}" = "crossgcc-clean" ]; then
[ -f "${tmpclean}/${tree}" ] && return 1
touch "${tmpclean}/${tree}"
fi fi
[ "${target1}" = "utils" ] && [ "${project}" = "coreboot" ] && return 0 [ "${target1}" = "utils" ] && [ "${project}" = "coreboot" ] && return 0
[ "$project" != "coreboot" ] && [ "$project" != "u-boot" ] && return 0 [ "$project" != "coreboot" ] && [ "$project" != "u-boot" ] && return 0
# u-boot and coreboot are both compiled with coreboot's crossgcc # u-boot and coreboot are both compiled with coreboot's crossgcc
[ ! -z ${mode} ] || check_cross_compiler || \ [ -z ${mode} ] || return 0
err "handle_src_tree ${project}/${target}: crossgcc" check_cross_compiler
cbfstool="cbutils/${tree}/cbfstool"
[ -f "${cbfstool}" ] && return 0
x_ ./update trees -b coreboot utils "${tree}"
} }
# set up cross-compiler (coreboot crossgcc) for u-boot and coreboot # set up cross-compiler (coreboot crossgcc) for u-boot and coreboot
@ -189,42 +173,35 @@ check_cross_compiler()
{ {
[ "${crossgcc_ada}" = "y" ] || [ "${crossgcc_ada}" = "n" ] || \ [ "${crossgcc_ada}" = "y" ] || [ "${crossgcc_ada}" = "n" ] || \
crossgcc_ada="y" crossgcc_ada="y"
[ "${crossgcc_ada}" != "y" ] && \ [ "${crossgcc_ada}" = "y" ] || export BUILD_LANGUAGES=c
export BUILD_LANGUAGES=c
cbdir="src/coreboot/${tree}" cbdir="src/coreboot/${tree}"
[ "${project}" != "coreboot" ] && \ [ "${project}" != "coreboot" ] && cbdir="src/coreboot/default"
cbdir="src/coreboot/default"
# only true if not building coreboot: # only true if not building coreboot:
ctarget="${cbdir#src/coreboot/}" ctarget="${cbdir#src/coreboot/}"
[ -d "${cbdir}" ] || \ [ -d "${cbdir}" ] || x_ ./update trees -f coreboot ${ctarget}
x_ ./update trees -f coreboot ${ctarget}
if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then
[ -d "${cbdir}/util/crossgcc/xgcc/i386-elf/" ] || \ [ -d "${cbdir}/util/crossgcc/xgcc/i386-elf/" ] || \
make -C "${cbdir}" crossgcc-i386 CPUS=$(nproc) || \ x_ make -C "${cbdir}" crossgcc-i386 CPUS=$(nproc)
return 1
case "$(uname -m)" in case "$(uname -m)" in
x86*|i*86|amd64) : ;; x86*|i*86|amd64) : ;;
*) export CROSS_COMPILE=i386-elf- ;; *) export CROSS_COMPILE=i386-elf- ;;
esac esac
elif [ "${arch}" = "ARMv7" ]; then elif [ "${arch}" = "ARMv7" ]; then
[ -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ] || \ [ -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ] || \
make -C "${cbdir}" crossgcc-arm CPUS=$(nproc) || \ x_ make -C "${cbdir}" crossgcc-arm CPUS=$(nproc)
return 1
case "$(uname -m)" in case "$(uname -m)" in
arm|arm32|armv6*|armv7*) : ;; arm|arm32|armv6*|armv7*) : ;;
*) export CROSS_COMPILE=arm-eabi- ;; *) export CROSS_COMPILE=arm-eabi- ;;
esac esac
elif [ "${arch}" = "AArch64" ]; then elif [ "${arch}" = "AArch64" ]; then
[ -d "${cbdir}/util/crossgcc/xgcc/aarch64-elf/" ] || \ [ -d "${cbdir}/util/crossgcc/xgcc/aarch64-elf/" ] || \
make -C "${cbdir}" crossgcc-aarch64 CPUS=$(nproc) || \ x_ make -C "${cbdir}" crossgcc-aarch64 CPUS=$(nproc)
return 1
# aarch64 also needs armv7 toolchain for arm-trusted-firmware # aarch64 also needs armv7 toolchain for arm-trusted-firmware
[ -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ] || \ [ -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ] || \
make -C "${cbdir}" crossgcc-arm CPUS=$(nproc) || \ x_ make -C "${cbdir}" crossgcc-arm CPUS=$(nproc)
return 1
case "$(uname -m)" in case "$(uname -m)" in
arm64|aarch64) : ;; arm64|aarch64) : ;;
*) export CROSS_COMPILE=aarch64-elf- ;; *) export CROSS_COMPILE=aarch64-elf- ;;