From 4e39d5a5a808b0d59c6fb3426e1d9bc0195d6b08 Mon Sep 17 00:00:00 2001
From: Leah Rowe <leah@libreboot.org>
Date: Fri, 6 Oct 2023 22:59:36 +0100
Subject: put all src downloads under src/

build/release/src was partly re-written to accomodate this

memtest86plus was patched to have a central Makefile, and
lbmk modified to use that, rather than mess with build32
and build64. the central Makefile just builds both targets
or cleans both targets

Signed-off-by: Leah Rowe <leah@libreboot.org>
---
 script/update/project/build | 21 ++++++++++-----------
 script/update/project/repo  |  8 +++++---
 script/update/project/trees | 23 ++++++++++++-----------
 3 files changed, 27 insertions(+), 25 deletions(-)

(limited to 'script/update/project')

diff --git a/script/update/project/build b/script/update/project/build
index 2c6eff97..69c11105 100755
--- a/script/update/project/build
+++ b/script/update/project/build
@@ -33,7 +33,7 @@ main()
 		-x) mode="crossgcc-clean" ;;
 		*) err "Invalid option" ;;
 		esac
-		shift; project="${OPTARG}"; shift
+		shift; project="${OPTARG#src/}"; shift
 	done
 	[ -z ${_f} ] && err "flag not specified (-m, -u, -b, -c or -x)"
 	[ -z ${project} ] && err "project name not specified"
@@ -48,15 +48,13 @@ main()
 build_projects()
 {
 	[ $# -gt 0 ] && x_ ./update project build ${_f} ${@}
-	codedir="${project}"
+	codedir="src/${project}"
 
-	[ -d "${codedir}" ] || x_ ./update project repo "${codedir%/*}"
-	[ -d "${codedir}" ] || \
-		err "build_targets: ${codedir%/*} not downloaded"
+	[ -d "${codedir}" ] || x_ ./update project repo "${project}"
 
 	if [ "${project}" = "uefitool" ]; then
 	(
-		x_ cd uefitool
+		x_ cd src/uefitool
 		cmake UEFIExtract/ || [ -f Makefile ] || \
 		    err "build_targets: !cmake UEFIExtract/"
 	)
@@ -138,7 +136,7 @@ handle_src_tree()
 	[ -z ${arch} ] && \
 		err "handle_src_tree: ${target_dir}: undefined cpu type"
 
-	codedir="${project}/${tree}"
+	codedir="src/${project}/${tree}"
 	if [ ! -d "${codedir}" ]; then
 		if [ "${mode}" = "distclean" ] || \
 		    [ "${mode}" = "crossgcc-clean" ]; then
@@ -171,13 +169,14 @@ check_cross_compiler()
 	[ "${crossgcc_ada}" != "y" ] && \
 		export BUILD_LANGUAGES=c
 
-	cbdir="coreboot/${tree}"
+	cbdir="src/coreboot/${tree}"
 	[ "${project}" != "coreboot" ] && \
-		cbdir="coreboot/default" # not u-boot (e.g. linux will use it)
+		cbdir="src/coreboot/default" # not u-boot (e.g. linux)
 	[ "${project}" = "u-boot" ] && \
-		cbdir="coreboot/cros" # u-boot only used on coreboot/cros
+		cbdir="src/coreboot/cros" # u-boot only used on coreboot/cros
+
 	# only true if not building coreboot:
-	ctarget="${cbdir#coreboot/}"
+	ctarget="${cbdir#src/coreboot/}"
 	[ -d "${cbdir}" ] || \
 		x_ ./update project trees coreboot ${ctarget}
 
diff --git a/script/update/project/repo b/script/update/project/repo
index 71c3940c..df522edc 100755
--- a/script/update/project/repo
+++ b/script/update/project/repo
@@ -16,7 +16,7 @@ main()
 	[ $# -gt 0 ] || fail "no argument given"
 
 	[ -z "${1+x}" ] && fail 'main(): name not set'
-	name=${1}
+	name=${1#src/}
 
 	scan_config "${name}" "config/git" "fail"
 	verify_config
@@ -40,6 +40,9 @@ clone_project()
 	xx_ rm -Rf "${tmp_dir}"
 	xx_ mkdir -p "${tmp_dir%/*}"
 
+	loc="${loc#src/}"
+	loc="src/${loc}"
+
 	git clone ${url} "${tmp_dir}" || git clone ${bkup_url} "${tmp_dir}" || \
 	    fail "clone_project: could not download ${name}"
 	git_reset_rev "${tmp_dir}" "${rev}" "fail" || \
@@ -47,8 +50,7 @@ clone_project()
 	git_am_patches "${tmp_dir}" "${PWD}/config/${name}/patches" "fail" || \
 	    fail "clone_project ${loc}/: cannot apply patches"
 
-	[ ! -d "${loc}" ] || \
-		xx_ rm -Rf "${loc}"
+	xx_ rm -Rf "${loc}"
 	[ "${loc}" = "${loc%/*}" ] || xx_ mkdir -p ${loc%/*}
 	xx_ mv "${tmp_dir}" "${loc}"
 }
diff --git a/script/update/project/trees b/script/update/project/trees
index 29004760..4b25d5b9 100755
--- a/script/update/project/trees
+++ b/script/update/project/trees
@@ -15,13 +15,13 @@ eval "$(setvars "" _target tree rev project cfgsdir _xm)"
 
 main()
 {
-	printf "Downloading %s and applying patches\n" ${project}
-
 	[ -z "${1}" ] && err "project name not specified"
-	project="${1}" && shift 1
+	project="${1#src/}" && shift 1
 
 	configure_targets $@
 
+	printf "Downloading %s and applying patches\n" ${project}
+
 	for x in ${targets}; do
 		x_ rm -f "${cfgsdir}/"*/seen
 		download_for_target "${x}"
@@ -45,8 +45,9 @@ download_for_target()
 	_target="${1}"
 
 	fetch_config
-	[ -d "${project}/${tree}" ] && printf "download/%s %s (%s): exists\n" \
-	    "${project}" "${tree}" "${_target}" 1>&2 && return 0
+	[ -d "src/${project}/${tree}" ] && \
+		printf "download/%s %s (%s): exists\n" \
+		    "${project}" "${tree}" "${_target}" 1>&2 && return 0
 
 	fetch_from_upstream
 	prepare_new_tree
@@ -83,9 +84,9 @@ check_config_for_target()
 
 fetch_from_upstream()
 {
-	[ -d "${project}" ] || x_ mkdir -p "${project}"
-	[ -d "${project}/${project}" ] && return 0
+	[ -d "src/${project}/${project}" ] && return 0
 
+	x_ mkdir -p "src/${project}"
 	x_ ./update project repo "${project}"
 }
 
@@ -93,14 +94,14 @@ prepare_new_tree()
 {
 	printf "Creating %s tree %s (%s)\n" "${project}" "${tree}" "${_target}"
 
-	x_ cp -R "${project}/${project}" "${project}/${tree}"
-	x_ git_reset_rev "${project}/${tree}" "${rev}" "err"
+	x_ cp -R "src/${project}/${project}" "src/${project}/${tree}"
+	x_ git_reset_rev "src/${project}/${tree}" "${rev}" "err"
 	(
-	x_ cd "${project}/${tree}"
+	x_ cd "src/${project}/${tree}"
 	git submodule update --init --checkout || \
 	    err "prepare_new_tree ${project}/${tree}: can't update git modules"
 	)
-	git_am_patches "${PWD}/${project}/${tree}" \
+	git_am_patches "${PWD}/src/${project}/${tree}" \
 	    "${PWD}/${cfgsdir}/${tree}/patches" "err"
 }
 
-- 
cgit v1.2.1