Skip to contentSkip to conversation

env: Avoid using a leftover text-environment file

PATCH In review Simon Glass 3 participants 4 messages Mar 12, 2022 – Apr 1, 2022 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 env: Avoid using a leftover text-environment file

If include/generated/environment.h exists (perhaps leftover from a build of another board) it is used, even if the board currently being built does not have a text environment.

This causes a build error. Fix it by emptying the file if it should not be there.

---

 Makefile | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +4 -1
index 9ef34ca4b7f..2351d6dacd2 100644
@@ -1834,7 +1834,9 @@ ENV_FILE := $(if $(ENV_SOURCE_FILE),$(ENV_FILE_CFG),$(wildcard $(ENV_FILE_BOARD)
 
 # Run the environment text file through the preprocessor, but only if it is
 # non-empty, to save time and possible build errors if something is wonky with
-# the board
+# the board.
+# If there is no ENV_FILE, produce an empty output file, to prevent a previous
+# build's file being used in the case of in-tree builds.
 quiet_cmd_gen_envp = ENVP    $@
       cmd_gen_envp = \
 	if [ -s "$(ENV_FILE)" ]; then \
@@ -1845,6 +1847,7 @@ quiet_cmd_gen_envp = ENVP    $@
 			-I$(srctree)/arch/$(ARCH)/include \
 			$< -o $@; \
 	else \
+		rm $@; \
 		touch $@ ; \
 	fi
 include/generated/env.in: include/generated/env.txt FORCE
Signature · 1 line
2.35.1.723.g4982287a31-goog
Tested-by on v1 1/1
#1 lore raw
Quoted 32 lines · Simon Glass

If include/generated/environment.h exists (perhaps leftover from a build of another board) it is used, even if the board currently being built does not have a text environment.

This causes a build error. Fix it by emptying the file if it should not be there.

---

  Makefile | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +3 -1
index 9ef34ca4b7f..2351d6dacd2 100644
@@ -1834,7 +1834,9 @@ ENV_FILE := $(if $(ENV_SOURCE_FILE),$(ENV_FILE_CFG),$(wildcard $(ENV_FILE_BOARD)
 
  # Run the environment text file through the preprocessor, but only if it is
  # non-empty, to save time and possible build errors if something is wonky with
-# the board
+# the board.
+# If there is no ENV_FILE, produce an empty output file, to prevent a previous
+# build's file being used in the case of in-tree builds.
  quiet_cmd_gen_envp = ENVP    $@
        cmd_gen_envp = \
  	if [ -s "$(ENV_FILE)" ]; then \

Makefile quiet_cmd_gen_envp = ENVP $@ · line 1853

Quoted 7 lines
Makefile +1 -0
@@ -1845,6 +1847,7 @@ quiet_cmd_gen_envp = ENVP    $@
  			-I$(srctree)/arch/$(ARCH)/include \
  			$< -o $@; \
  	else \
+		rm $@; \
  		touch $@ ; \
  	fi
  include/generated/env.in: include/generated/env.txt FORCE

Thanks!

#2 lore raw
In reply to Simon Glass

Hi Tom,

Quoted 32 lines · Simon Glass

If include/generated/environment.h exists (perhaps leftover from a build of another board) it is used, even if the board currently being built does not have a text environment.

This causes a build error. Fix it by emptying the file if it should not be there.

---

  Makefile | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
Makefile +3 -1
index 9ef34ca4b7f..2351d6dacd2 100644
@@ -1834,7 +1834,9 @@ ENV_FILE := $(if $(ENV_SOURCE_FILE),$(ENV_FILE_CFG),$(wildcard $(ENV_FILE_BOARD)
 
  # Run the environment text file through the preprocessor, but only if it is
  # non-empty, to save time and possible build errors if something is wonky with
-# the board
+# the board.
+# If there is no ENV_FILE, produce an empty output file, to prevent a previous
+# build's file being used in the case of in-tree builds.
  quiet_cmd_gen_envp = ENVP    $@
        cmd_gen_envp = \
  	if [ -s "$(ENV_FILE)" ]; then \

Makefile quiet_cmd_gen_envp = ENVP $@ · line 1853

Quoted 7 lines
Makefile +1 -0
@@ -1845,6 +1847,7 @@ quiet_cmd_gen_envp = ENVP    $@
  			-I$(srctree)/arch/$(ARCH)/include \
  			$< -o $@; \
  	else \
+		rm $@; \
  		touch $@ ; \
  	fi
  include/generated/env.in: include/generated/env.txt FORCE

Can you pick this up for the release? I find myself needing to dig it up and apply it every time I build sandbox then go back to another board.

--Sean

#3 lore raw
In reply to Simon Glass
Quoted 11 lines · Simon Glass

If include/generated/environment.h exists (perhaps leftover from a build of another board) it is used, even if the board currently being built does not have a text environment.

This causes a build error. Fix it by emptying the file if it should not be there.

Applied to u-boot/master, thanks!

Signature · 1 line
Tom