Skip to contentSkip to conversation

Makefile: Force regeneration of env.txt

PATCH Superseded Andrew Davis 2 participants 4 messages Sep 5, 2023 – Sep 15, 2023 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Force regeneration of env.txt

If the source .env file changes to one that is also older than the generated env.txt file then it is not regenerated. This means when switching board configs we do not regenerate the env. This can be tested easily with:

$ make j721e_evm_a72_defconfig
$ make # this may fail to complete but that is okay for this test
$ make am64x_evm_a53_defconfig
$ make
$ vim include/generated/env.txt

Note this is still the J721e env not the AM64 config as expected.

There is probably a better way to detect if the dependency name changed, but that may involve extra files and hashing contents, so let's just force it for now.

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 9be24c4ec61..d195590d4b0 100644
@@ -1830,7 +1830,7 @@ quiet_cmd_envc = ENVC    $@
 		touch $@ ; \
 	fi
 
-include/generated/env.txt: $(wildcard $(ENV_FILE))
+include/generated/env.txt: $(wildcard $(ENV_FILE)) FORCE
 	$(call cmd,envc)
 
 # Write out the resulting environment, converted to a C string
Signature · 1 line
2.39.2
#1 lore raw
Quoted 11 lines · Andrew Davis

If the source .env file changes to one that is also older than the generated env.txt file then it is not regenerated. This means when switching board configs we do not regenerate the env. This can be tested easily with:

$ make j721e_evm_a72_defconfig
$ make # this may fail to complete but that is okay for this test
$ make am64x_evm_a53_defconfig
$ make
$ vim include/generated/env.txt
Quoted 8 lines

Note this is still the J721e env not the AM64 config as expected.

There is probably a better way to detect if the dependency name changed, but that may involve extra files and hashing contents, so let's just force it for now.

---

This is basically a revert of:
36fc832927eb ("Makefile: Fix incorrect FORCE deps on env rules")

But without changing the include/generated/env.in rule. The more I think about it, that should also be changed to forced as right now any changes to include/config.h or other kconfig options are not reflected in the env.in file after updates.

That rule should depend on the generated config file so that any change in kconfig variables will cause it to regenerate, that might be what we need for this target instead of FORCE.

Andrew

Quoted 16 lines
  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index 9be24c4ec61..d195590d4b0 100644
@@ -1830,7 +1830,7 @@ quiet_cmd_envc = ENVC    $@
  		touch $@ ; \
  	fi
 
-include/generated/env.txt: $(wildcard $(ENV_FILE))
+include/generated/env.txt: $(wildcard $(ENV_FILE)) FORCE
  	$(call cmd,envc)
 
  # Write out the resulting environment, converted to a C string
#2 lore raw

Hi Andrew,

Quoted 50 lines · Andrew Davis
Quoted 11 lines · Andrew Davis

If the source .env file changes to one that is also older than the generated env.txt file then it is not regenerated. This means when switching board configs we do not regenerate the env. This can be tested easily with:

$ make j721e_evm_a72_defconfig
$ make # this may fail to complete but that is okay for this test
$ make am64x_evm_a53_defconfig
$ make
$ vim include/generated/env.txt
Quoted 8 lines

Note this is still the J721e env not the AM64 config as expected.

There is probably a better way to detect if the dependency name changed, but that may involve extra files and hashing contents, so let's just force it for now.

---

This is basically a revert of:
36fc832927eb ("Makefile: Fix incorrect FORCE deps on env rules")

But without changing the include/generated/env.in rule. The more I think about it, that should also be changed to forced as right now any changes to include/config.h or other kconfig options are not reflected in the env.in file after updates.

That rule should depend on the generated config file so that any change in kconfig variables will cause it to regenerate, that might be what we need for this target instead of FORCE.

Andrew

Quoted 11 lines
  Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index 9be24c4ec61..d195590d4b0 100644
@@ -1830,7 +1830,7 @@ quiet_cmd_envc = ENVC    $@
              touch $@ ; \
      fi
 
Quoted 3 lines

Makefile quiet_cmd_envc = ENVC $@ · line 1834

Quoted 3 lines
Makefile +1 -1
-include/generated/env.txt: $(wildcard $(ENV_FILE))
+include/generated/env.txt: $(wildcard $(ENV_FILE)) FORCE
      $(call cmd,envc)

I thought that FORCE was only for if_changed - see makefiles.rst.txt

Could it depend on autoconf.h instead?

Quoted 2 lines

Makefile quiet_cmd_envc = ENVC $@ · line 1836

Quoted 2 lines
Makefile +0 -0
  # Write out the resulting environment, converted to a C string

Regards,
Simon

#3 lore raw
Quoted 53 lines · Simon Glass

Hi Andrew,

Quoted 50 lines · Andrew Davis
Quoted 11 lines · Andrew Davis

If the source .env file changes to one that is also older than the generated env.txt file then it is not regenerated. This means when switching board configs we do not regenerate the env. This can be tested easily with:

$ make j721e_evm_a72_defconfig
$ make # this may fail to complete but that is okay for this test
$ make am64x_evm_a53_defconfig
$ make
$ vim include/generated/env.txt
Quoted 8 lines

Note this is still the J721e env not the AM64 config as expected.

There is probably a better way to detect if the dependency name changed, but that may involve extra files and hashing contents, so let's just force it for now.

---

This is basically a revert of:
36fc832927eb ("Makefile: Fix incorrect FORCE deps on env rules")

But without changing the include/generated/env.in rule. The more I think about it, that should also be changed to forced as right now any changes to include/config.h or other kconfig options are not reflected in the env.in file after updates.

That rule should depend on the generated config file so that any change in kconfig variables will cause it to regenerate, that might be what we need for this target instead of FORCE.

Andrew

Quoted 11 lines
   Makefile | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index 9be24c4ec61..d195590d4b0 100644
@@ -1830,7 +1830,7 @@ quiet_cmd_envc = ENVC    $@
               touch $@ ; \
       fi
 
Quoted 8 lines
Quoted 3 lines

Makefile quiet_cmd_envc = ENVC $@ · line 1834

Quoted 3 lines
Makefile +1 -1
-include/generated/env.txt: $(wildcard $(ENV_FILE))
+include/generated/env.txt: $(wildcard $(ENV_FILE)) FORCE
       $(call cmd,envc)

I thought that FORCE was only for if_changed - see makefiles.rst.txt

Could it depend on autoconf.h instead?

That works, sending v2, thanks!

Andrew

Quoted 5 lines
Quoted 2 lines

Makefile quiet_cmd_envc = ENVC $@ · line 1836

Quoted 2 lines
Makefile +0 -0
   # Write out the resulting environment, converted to a C string

Regards,
Simon