summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-12-30 16:52:34 +0000
committerLeah Rowe <leah@libreboot.org>2023-12-30 19:03:03 +0000
commitc6a0e4952eaf005719514da37658f872c7456e3a (patch)
tree8ed3d6168e9993d792fa856b22eebd78589e5bc1
parent30337b8fa5d1ab909a158924187c3f02d1fc501c (diff)
update/trees: generic cmake handling
it is no longer hardcoded just to be handled for uefiextract. it is now defined as cmakedir in target.cfg, for a single or multi tree project. if multi tree, it is applied to the specific tree, and has to be defined per tree the way it works is: as per cmakelist, a project will define which directory is to be built, and it will then generate a makefile in the main source tree (the build tree in cmake language, where the main CMakeLists.txt file exists) when the makefile has been generated, the project is then treated like any other project. the way cmake works, if a makefile has already been generated by it, in a given directory, running it again will fail and not affect anything; if it fails but the makefile doesn't exist, then something is wrong, but if the makefile does exist, then it's all fine and nothing happens at present, this is only used for uefiextract, which is part of src/uefitool Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--config/uefitool/target.cfg1
-rwxr-xr-xscript/update/trees27
2 files changed, 17 insertions, 11 deletions
diff --git a/config/uefitool/target.cfg b/config/uefitool/target.cfg
new file mode 100644
index 00000000..98d5e03d
--- /dev/null
+++ b/config/uefitool/target.cfg
@@ -0,0 +1 @@
+cmakedir="UEFIExtract"
diff --git a/script/update/trees b/script/update/trees
index 6f4786d9..a12f3ef8 100755
--- a/script/update/trees
+++ b/script/update/trees
@@ -12,7 +12,7 @@ set -u -e
eval "$(setvars "" xarch cfgsdir codedir config config_name xlang mode \
elfdir listfile project target target_dir targets tree _f target1 \
- bootstrapargs autoconfargs)"
+ bootstrapargs autoconfargs cmakedir)"
main()
{
@@ -54,14 +54,6 @@ build_projects()
codedir="src/${project}"
[ -d "$codedir" ] || x_ ./update trees -f "$project"
- if [ "$project" = "uefitool" ]; then
- (
- x_ cd src/uefitool
- cmake UEFIExtract/ || [ -f Makefile ] || \
- err "build_projects: !cmake UEFIExtract/"
- ) || err "can't build cmake on uefiextract"
- fi
-
[ "$mode" = "distclean" ] && mode="clean"
run_make_command || return 0
}
@@ -214,6 +206,7 @@ handle_makefile()
run_make_command()
{
+ check_cmake "$codedir"
[ -z "$mode" ] && check_autoconf "$codedir"
check_makefile "$codedir" || return 1
@@ -228,15 +221,27 @@ run_make_command()
make -C "$codedir" distclean 2>/dev/null || :
}
+check_cmake()
+{
+ [ -z "${cmakedir}" ] || \
+ check_makefile "${1}" || \
+ cmake -B "${1}" "${1}/${cmakedir}" || \
+ check_makefile "${1}" || \
+ err "check_cmake ${1}: can't cmake ${cmakedir}"
+ [ -z "${cmakedir}" ] || check_makefile "${1}" || \
+ err "check_cmake ${1}: could not generate Makefile"
+ return 0
+}
+
check_autoconf()
{
(
_cfgopt=""
- cd "${codedir}" || err "!cd $codedir"
+ cd "${1}" || err "!cd $1"
[ -f "bootstrap" ] && x_ ./bootstrap $bootstrapargs
[ -f "autogen.sh" ] && x_ ./autogen.sh
[ -f "configure" ] && x_ ./configure $autoconfargs; return 0
- ) || err "can't bootstrap project: $codedir"
+ ) || err "can't bootstrap project: $1"
}
check_makefile()