mailarchive of the ptxdist mailing list
 help / color / mirror / Atom feed
From: Alexander Dahl <ada@thorsis.com>
To: ptxdist@pengutronix.de
Cc: Michael Riesch <michael.riesch@wolfvision.net>
Subject: [ptxdist] [PATCH v2 4/4] ptxd_make_world_inject: Introduce new variable <PKG>_INJECT_OOT
Date: Mon,  6 May 2024 12:50:51 +0200	[thread overview]
Message-ID: <20240506105051.323546-5-ada@thorsis.com> (raw)
In-Reply-To: <20240506105051.323546-1-ada@thorsis.com>

Setting the new variable to 'YES' allows to inject into <PKG>_BUILD_DIR
instead of <PKG>_DIR as before.

When building out-of-tree some bootloaders like U-Boot expect injected
files in the build dir, not in the source dir.  Backwards compatibility
is ensured, the source dir is still the default, the new inject dest is
optional and in case set it overwrites the default.

For using this in u-boot package, on top of the things already done to
use the old inject mechanism in general, add this line to
'rules/u-boot.make' for example:

    U_BOOT_INJECT_OOT     := YES

Signed-off-by: Alexander Dahl <ada@thorsis.com>
---

Notes:
    v2:
    - dropped the previous approach with the more flexible <PKG>_INJECT_DEST
    - reworked the whole logic to use new <PKG>_INJECT_OOT variable
    
    v1:
    - implicit

 rules/post/ptxd_make_world_inject.make |  3 ++-
 scripts/lib/ptxd_make_world_inject.sh  | 23 ++++++++++++++++++++---
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/rules/post/ptxd_make_world_inject.make b/rules/post/ptxd_make_world_inject.make
index eabcdd052..1e3979a2f 100644
--- a/rules/post/ptxd_make_world_inject.make
+++ b/rules/post/ptxd_make_world_inject.make
@@ -9,7 +9,8 @@
 world/inject/env = \
 	$(call world/env, $(1)) \
 	pkg_inject_path="$(call ptx/escape,$($(1)_INJECT_PATH))" \
-	pkg_inject_files="$(call ptx/escape,$($(1)_INJECT_FILES))"
+	pkg_inject_files="$(call ptx/escape,$($(1)_INJECT_FILES))" \
+	pkg_inject_oot="$(call ptx/escape,$($(1)_INJECT_OOT))"
 
 world/inject = \
 	$(call world/inject/env,$(strip $(1))) \
diff --git a/scripts/lib/ptxd_make_world_inject.sh b/scripts/lib/ptxd_make_world_inject.sh
index b74e464c6..e8e94fbe6 100644
--- a/scripts/lib/ptxd_make_world_inject.sh
+++ b/scripts/lib/ptxd_make_world_inject.sh
@@ -10,7 +10,7 @@ ptxd_make_inject() {
     local source target
 
     source="$(echo ${inject_file} | cut -d ":" -f 1)"
-    target="${pkg_dir}/$(echo ${inject_file} | cut -d ":" -f 2)"
+    target="${inject_dest}/$(echo ${inject_file} | cut -d ":" -f 2)"
 
     if [[ "${source}" =~ ^/.* ]]; then
 	ptxd_bailout "'${source}' must not be an absolute path!" \
@@ -32,8 +32,25 @@ export -f ptxd_make_inject
 ptxd_make_world_inject() {
     ptxd_make_world_init || return
 
-    if [ -z "${pkg_dir}" ]; then
-	ptxd_bailout "<PKG>_DIR empty, no destination to inject to."
+    if [ -z "${pkg_inject_oot}" ]; then
+	pkg_inject_oot=NO
+    fi
+
+    case "${pkg_inject_oot}" in
+	"YES") inject_dest="${pkg_build_dir}" ;;
+	"NO")  inject_dest="${pkg_dir}" ;;
+	*)     ptxd_bailout "<PKG>_INJECT_OOT: please set to YES or NO" ;;
+    esac
+
+    if [ "${pkg_build_oot:-NO}" = 'NO' ] && [ "${pkg_inject_oot}" != 'NO' ]; then
+	ptxd_warning "<PKG>_BUILD_OOT and <PKG>_INJECT_OOT contradict each other." \
+	    "Using $(ptxd_print_path ${inject_dest}) as inject destination anyways."
+    fi
+
+    if [ ! -d "${inject_dest}" ]; then
+	ptxd_bailout "<PKG> inject destination dir missing." \
+	    "Correct placement of world/inject depends on <PKG>_BUILD_OOT and <PKG>_INJECT_OOT." \
+	    "Check order of calls in prepare stage!"
     fi
 
     for inject_file in ${pkg_inject_files}; do
-- 
2.39.2




  parent reply	other threads:[~2024-05-06 10:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06 10:50 [ptxdist] [PATCH v2 0/4] ptxd_make_world_inject: Spring cleanup and optional dest dir Alexander Dahl
2024-05-06 10:50 ` [ptxdist] [PATCH v2 1/4] ptxd_make_world_inject: Remove useless test Alexander Dahl
2024-05-12 13:16   ` [ptxdist] [APPLIED] " Michael Olbrich
2024-05-06 10:50 ` [ptxdist] [PATCH v2 2/4] ptxd_make_world_inject: Use <PKG>_DIR directly Alexander Dahl
2024-05-12 13:16   ` [ptxdist] [APPLIED] " Michael Olbrich
2024-05-06 10:50 ` [ptxdist] [PATCH v2 3/4] ptxd_make_world_inject: Escape inject path and files Alexander Dahl
2024-05-12 13:16   ` [ptxdist] [APPLIED] " Michael Olbrich
2024-05-06 10:50 ` Alexander Dahl [this message]
2024-05-12 13:16   ` [ptxdist] [APPLIED] ptxd_make_world_inject: Introduce new variable <PKG>_INJECT_OOT Michael Olbrich
2024-05-06 14:11 ` [ptxdist] [PATCH v2 0/4] ptxd_make_world_inject: Spring cleanup and optional dest dir Michael Riesch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240506105051.323546-5-ada@thorsis.com \
    --to=ada@thorsis.com \
    --cc=michael.riesch@wolfvision.net \
    --cc=ptxdist@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox