Skip to contentSkip to conversation

Cleanup post-* loops

PATCH New Luca Ceresoli 4 participants 18 messages Apr 8, 2013 – May 2, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

v2 cover Cleanup post-* loops

This patch series cleans up and makes uniform the implementation of the post-build, post-image and rootfs-overlay loops. It also makes post-build and psot-image print each script name before executing it, like the rootfs-overlay does.

Luca

Changes in v2:
- use a make foreach instead of a shell for to loop over the entries (suggested by Danomi Manchego);
- rework also the post-image loop (suggested by Thomas Petazzoni).

Luca Ceresoli (3):
post-build: show each script filename before execution
post-image: show each script filename before execution
rootfs-overlay: use a make foreach instead of a shell for

 Makefile |   15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/3 post-build: show each script filename before execution

This also simplifies code by removing the ifneq/endif clauses.

---
 Makefile |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Makefile +1 -3
index c95bb1e..75f0f0c 100644
@@ -509,11 +509,9 @@ endif
 			$${dir}/ $(TARGET_DIR); \
 	done
 
-ifneq ($(BR2_ROOTFS_POST_BUILD_SCRIPT),"")
-	@$(call MESSAGE,"Executing post-build script\(s\)")
 	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
+		$(call MESSAGE,"Executing  post-build script $(s)"); \
 		$(s) $(TARGET_DIR)$(sep))
-endif
 
 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
 LOCALE_WHITELIST=$(BUILD_DIR)/locales.nopurge
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v2 1/3 post-build: show each script filename before execution

Luca, All,

Quoted 3 lines · Luca Ceresoli

This also simplifies code by removing the ifneq/endif clauses.

Very usefull, indeed.

Regards,
Yann E. MORIN

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH v2 1/3 post-build: show each script filename before execution

In reply to Luca Ceresoli
Quoted 12 lines · Luca Ceresoli

This also simplifies code by removing the ifneq/endif clauses.

---
  Makefile |    4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
Makefile +0 -0
index c95bb1e..75f0f0c 100644

Makefile endif · line 516

Quoted 9 lines
Makefile +1 -3
@@ -509,11 +509,9 @@ endif
  			$${dir}/ $(TARGET_DIR); \
  	done
 
-ifneq ($(BR2_ROOTFS_POST_BUILD_SCRIPT),"")
-	@$(call MESSAGE,"Executing post-build script\(s\)")
  	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
+		$(call MESSAGE,"Executing  post-build script $(s)"); \
  		$(s) $(TARGET_DIR)$(sep))
-endif

I wonder, if there are multiple scripts, won't the second MESSAGE be
echoed by make? I had expected that the @ would only apply to the first line when they are separated with $(sep), and that each invocation would run in a separate shell.

By the way, a very simple alternative would be to remove the @ in front
of the foreach, then each script invocation will be echoed by make.

Regards,
Arnout

Quoted 4 lines
Makefile +0 -0
  ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
  LOCALE_WHITELIST=$(BUILD_DIR)/locales.nopurge
 
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#4 lore raw

PATCH v2 1/3 post-build: show each script filename before execution

Arnout, Luca, All,

Quoted 16 lines · On Wednesday 17 April 2013 18:13:33 Arnout Vandecappelle wrote:
Quoted 15 lines · Luca Ceresoli

This also simplifies code by removing the ifneq/endif clauses.

---
  Makefile |    4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
Makefile +0 -0
index c95bb1e..75f0f0c 100644
@@ -509,11 +509,9 @@ endif
  			$${dir}/ $(TARGET_DIR); \
  	done
 
Quoted 11 lines

Makefile endif · line 516

Quoted 6 lines
Makefile +1 -3
-ifneq ($(BR2_ROOTFS_POST_BUILD_SCRIPT),"")
-	@$(call MESSAGE,"Executing post-build script\(s\)")
  	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
+		$(call MESSAGE,"Executing  post-build script $(s)"); \
  		$(s) $(TARGET_DIR)$(sep))
-endif

I wonder, if there are multiple scripts, won't the second MESSAGE be
echoed by make? I had expected that the @ would only apply to the first line when they are separated with $(sep), and that each invocation would run in a separate shell.

Well, it does work as expected: the two scripts I have are properly echoed with:

Quoted 1 line
Quoted 1 line
Quoted 1 line

Executing post-build script /blabla/script-1

[traces for script-1]

Quoted 1 line
Quoted 1 line
Quoted 1 line

Executing post-build script /blabla/script-2

[traces for script-2]

Quoted 2 lines

By the way, a very simple alternative would be to remove the @ in front
of the foreach, then each script invocation will be echoed by make.

Indeed, but I also like the highlighted trace. It makes it easier to spot the scripts traces.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |   ^                |
| --==< O_o >==-- '------------.-------:  X  AGAINST      |  /e\  There is no  |
| http://ymorin.is-a-geek.org/ | (*_*) | / \ HTML MAIL    |  """  conspiracy.  |
'------------------------------'-------'------------------'--------------------'
#5 lore raw

PATCH v2 1/3 post-build: show each script filename before execution

In reply to Luca Ceresoli
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Luca" == Luca Ceresoli <[email protected]> writes:

Luca> This also simplifies code by removing the ifneq/endif clauses. Luca> Signed-off-by: Luca Ceresoli <[email protected]> Luca> ---

 Luca>  Makefile |    4 +---

Luca> 1 file changed, 1 insertion(+), 3 deletions(-)

Luca> diff --git a/Makefile b/Makefile
Luca> index c95bb1e..75f0f0c 100644
Luca> --- a/Makefile
Luca> +++ b/Makefile
Luca> @@ -509,11 +509,9 @@ endif
Luca> $${dir}/ $(TARGET_DIR); \
Luca> done

Luca> -ifneq ($(BR2_ROOTFS_POST_BUILD_SCRIPT),"")
Luca> - @$(call MESSAGE,"Executing post-build script\(s\)")
Luca> @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
Luca> + $(call MESSAGE,"Executing post-build script $(s)"); \
Luca> $(s) $(TARGET_DIR)$(sep))

Double space after 'executing'. Committed with that fixed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#6 lore raw

PATCH v2 1/3 post-build: show each script filename before execution

Quoted 21 lines · Peter Korsgaard
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Luca" == Luca Ceresoli <[email protected]> writes:

Luca> This also simplifies code by removing the ifneq/endif clauses. Luca> Signed-off-by: Luca Ceresoli <[email protected]> Luca> ---

  Luca>  Makefile |    4 +---

Luca> 1 file changed, 1 insertion(+), 3 deletions(-)

  Luca> diff --git a/Makefile b/Makefile
  Luca> index c95bb1e..75f0f0c 100644
  Luca> --- a/Makefile
  Luca> +++ b/Makefile
  Luca> @@ -509,11 +509,9 @@ endif
  Luca>  			$${dir}/ $(TARGET_DIR); \
  Luca>  	done
  
  Luca> -ifneq ($(BR2_ROOTFS_POST_BUILD_SCRIPT),"")
  Luca> -	@$(call MESSAGE,"Executing post-build script\(s\)")
  Luca>  	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
  Luca> +		$(call MESSAGE,"Executing  post-build script $(s)"); \
  Luca>  		$(s) $(TARGET_DIR)$(sep))
Quoted 1 line

Double space after 'executing'. Committed with that fixed, thanks.

Ouch, thanks.

Luca

#7 lore raw

PATCH v2 1/3 post-build: show each script filename before execution

In reply to Luca Ceresoli
Quoted 3 lines · Luca Ceresoli

This also simplifies code by removing the ifneq/endif clauses.

Quoted 22 lines
---
  Makefile |    4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
Makefile +1 -3
index c95bb1e..75f0f0c 100644
@@ -509,11 +509,9 @@ endif
  			$${dir}/ $(TARGET_DIR); \
  	done
 
-ifneq ($(BR2_ROOTFS_POST_BUILD_SCRIPT),"")
-	@$(call MESSAGE,"Executing post-build script\(s\)")
  	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
+		$(call MESSAGE,"Executing  post-build script $(s)"); \
  		$(s) $(TARGET_DIR)$(sep))
-endif
 
  ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
  LOCALE_WHITELIST=$(BUILD_DIR)/locales.nopurge
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#8 lore raw

PATCH v2 1/3 post-build: show each script filename before execution

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle <[email protected]> writes:

Quoted 3 lines · Luca Ceresoli
Quoted 3 lines

This also simplifies code by removing the ifneq/endif clauses.

Arnout> Acked-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>

FYI, I applied this and the post-image patch on the 24th.

Signature · 1 line
Bye, Peter Korsgaard
#9 lore raw

PATCH v2 2/3 post-image: show each script filename before execution

In reply to Luca Ceresoli

This also simplifies code by removing the ifneq/endif clauses.

---
 Makefile |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
Makefile +1 -3
index 75f0f0c..f475d1b 100644
@@ -555,11 +555,9 @@ target-generatelocales: host-localedef
 endif
 
 target-post-image:
-ifneq ($(BR2_ROOTFS_POST_IMAGE_SCRIPT),"")
-	@$(call MESSAGE,"Executing post-image script\(s\)")
 	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
+		$(call MESSAGE,"Executing post-image script $(s)"); \
 		$(s) $(BINARIES_DIR)$(sep))
-endif
 
 toolchain-eclipse-register:
 	./support/scripts/eclipse-register-toolchain `readlink -f $(O)` $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
Signature · 1 line
1.7.10.4
#10 lore raw

PATCH v2 2/3 post-image: show each script filename before execution

Luca, All,

Quoted 3 lines · Luca Ceresoli

This also simplifies code by removing the ifneq/endif clauses.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#11 lore raw

PATCH v2 2/3 post-image: show each script filename before execution

In reply to Luca Ceresoli
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Luca" == Luca Ceresoli <[email protected]> writes:

Luca> This also simplifies code by removing the ifneq/endif clauses.

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#12 lore raw

PATCH v2 2/3 post-image: show each script filename before execution

In reply to Luca Ceresoli
Quoted 3 lines · Luca Ceresoli

This also simplifies code by removing the ifneq/endif clauses.

Quoted 22 lines
---
  Makefile |    4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
Makefile +1 -3
index 75f0f0c..f475d1b 100644
@@ -555,11 +555,9 @@ target-generatelocales: host-localedef
  endif
 
  target-post-image:
-ifneq ($(BR2_ROOTFS_POST_IMAGE_SCRIPT),"")
-	@$(call MESSAGE,"Executing post-image script\(s\)")
  	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
+		$(call MESSAGE,"Executing post-image script $(s)"); \
  		$(s) $(BINARIES_DIR)$(sep))
-endif
 
  toolchain-eclipse-register:
  	./support/scripts/eclipse-register-toolchain `readlink -f $(O)` $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#13 lore raw

PATCH v2 3/3 rootfs-overlay: use a make foreach instead of a shell for

In reply to Luca Ceresoli

Makes the code uniform with the post-build and post-image implementation (which is slightly simpler and, presumably, more efficient).

---
 Makefile |    7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
Makefile +3 -4
index f475d1b..a3b98f3 100644
@@ -501,13 +501,12 @@ endif
 		echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
 	) >  $(TARGET_DIR)/etc/os-release
 
-	@for dir in $(call qstrip,$(BR2_ROOTFS_OVERLAY)); do \
-		$(call MESSAGE,"Copying overlay $${dir}"); \
+	@$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
+		$(call MESSAGE,"Copying overlay $(d)"); \
 		rsync -a \
 			--exclude .empty --exclude .svn --exclude .git \
 			--exclude .hg --exclude '*~' \
-			$${dir}/ $(TARGET_DIR); \
-	done
+			$(d)/ $(TARGET_DIR)$(sep))
 
 	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
 		$(call MESSAGE,"Executing  post-build script $(s)"); \
Signature · 1 line
1.7.10.4
#14 lore raw

PATCH v2 3/3 rootfs-overlay: use a make foreach instead of a shell for

Luca, All,

Quoted 4 lines · Luca Ceresoli

Makes the code uniform with the post-build and post-image implementation (which is slightly simpler and, presumably, more efficient).

(not tested, I don't have rootfs overlays).

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#15 lore raw

PATCH v2 3/3 rootfs-overlay: use a make foreach instead of a shell for

In reply to Luca Ceresoli
Quoted 4 lines · Luca Ceresoli

Makes the code uniform with the post-build and post-image implementation (which is slightly simpler and, presumably, more efficient).

I thought about the possibility to refactor these three use cases into
a single make function, but it would actually just complicate things.

Regards,
Arnout

Quoted 26 lines
---
  Makefile |    7 +++----
  1 file changed, 3 insertions(+), 4 deletions(-)
Makefile +3 -4
index f475d1b..a3b98f3 100644
@@ -501,13 +501,12 @@ endif
  		echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
  	) >  $(TARGET_DIR)/etc/os-release
 
-	@for dir in $(call qstrip,$(BR2_ROOTFS_OVERLAY)); do \
-		$(call MESSAGE,"Copying overlay $${dir}"); \
+	@$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
+		$(call MESSAGE,"Copying overlay $(d)"); \
  		rsync -a \
  			--exclude .empty --exclude .svn --exclude .git \
  			--exclude .hg --exclude '*~' \
-			$${dir}/ $(TARGET_DIR); \
-	done
+			$(d)/ $(TARGET_DIR)$(sep))
 
  	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
  		$(call MESSAGE,"Executing  post-build script $(s)"); \
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
#16 lore raw

PATCH v2 3/3 rootfs-overlay: use a make foreach instead of a shell for

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Arnout" == Arnout Vandecappelle <[email protected]> writes:

Quoted 4 lines · Luca Ceresoli
Quoted 4 lines

Makes the code uniform with the post-build and post-image implementation (which is slightly simpler and, presumably, more efficient).

Arnout> Acked-by: Arnout Vandecappelle (Essensium/Mind) <[email protected]>

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#17 lore raw

PATCH v2 3/3 rootfs-overlay: use a make foreach instead of a shell for

In reply to Arnout Vandecappelle
Quoted 11 lines · Arnout Vandecappelle
Quoted 4 lines · Luca Ceresoli

Makes the code uniform with the post-build and post-image implementation (which is slightly simpler and, presumably, more efficient).

I thought about the possibility to refactor these three use cases
into a single make function, but it would actually just complicate things.

I considered this as well, but for so few lines it would be overkill.

Thanks for your review,
Luca