From c6a0e4952eaf005719514da37658f872c7456e3a Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 30 Dec 2023 16:52:34 +0000 Subject: 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 --- config/uefitool/target.cfg | 1 + script/update/trees | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 config/uefitool/target.cfg 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() -- cgit v1.2.1