dtc: Implement -d option to write out a dependency file
Subsystems (6)
PATCH 1/2 dtc: Implement -d option to write out a dependency file
This will allow callers to rebuild .dtb files when any of the /include/d .dtsi files are modified, not just the top-level .dts file.
---
This patch is against the Linux kernel's copy of dtc, but it applies to upstream dtc with a couple of trivial conflicts. I can post a version for upstream dtc as well if desired.
I have only tested this series for ARM.
scripts/dtc/dtc.c | 22 +++++++++++++++++++++- scripts/dtc/srcpos.c | 6 ++++++ scripts/dtc/srcpos.h | 1 + 3 files changed, 28 insertions(+), 1 deletions(-)
scripts/dtc/dtc.c +21 -1
@@ -71,6 +71,7 @@ static void __attribute__ ((noreturn)) usage(void)fprintf (stderr,"\t\t\tasm - assembler source\n" );fprintf (stderr,"\t-V <output version>\n" );fprintf (stderr,"\t\tBlob version to produce, defaults to %d (relevant for dtb\n\t\tand asm output only)\n" ,DEFAULT_FDT_VERSION ); +fprintf (stderr,"\t-d <output dependency file>\n" );fprintf (stderr,"\t-R <number>\n" );fprintf (stderr,"\t\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n" );fprintf (stderr,"\t-S <bytes>\n" );
@@ -99,6 +100,7 @@ int main(int argc, char *argv[])const char *inform ="dts" ;const char *outform ="dts" ;const char *outname ="-" ; +const char *depname =NULL ;int force =0 , check =0 , sort =0 ;const char *arg;int opt;
@@ -111,7 +113,8 @@ int main(int argc, char *argv[]) minsize =0 ; padsize =0 ; -while ((opt =getopt (argc, argv,"hI:O:o:V:R:S:p:fcqb:vH:s" )) !=EOF ) { +while ((opt =getopt (argc, argv,"hI:O:o:V:d:R:S:p:fcqb:vH:s" )) + !=EOF ) {switch (opt) {case 'I' : inform = optarg;
@@ -125,6 +128,9 @@ int main(int argc, char *argv[])case 'V' : outversion =strtol (optarg,NULL ,0 );break ; +case 'd' : + depname = optarg; +break ;case 'R' : reservenum =strtol (optarg,NULL ,0 );break ;
@@ -188,6 +194,15 @@ int main(int argc, char *argv[])fprintf (stderr,"DTC: %s->%s on file \"%s\"\n" , inform, outform, arg); +if (depname) { + depfile =fopen (depname,"w" ); +if (!depfile) +die ("Couldn't open dependency file %s: %s\n" , depname, +strerror (errno)); +fputs (outname, depfile); +fputc (':' , depfile); + } +if (streq (inform,"dts" )) bi =dt_from_source (arg);else if (streq (inform,"fs" ))
@@ -197,6 +212,11 @@ int main(int argc, char *argv[])else die ("Unknown input format \"%s\"\n" , inform); +if (depfile) { +fputc ('\n' , depfile); +fclose (depfile); + } +if (cmdline_boot_cpuid !=-1 ) bi->boot_cpuid_phys = cmdline_boot_cpuid;
scripts/dtc/srcpos.c +6 -0
@@ -40,6 +40,7 @@ static char *dirname(const char *path)return NULL ; } +FILE *depfile;/* = NULL */ struct srcfile_state *current_srcfile;/* = NULL */ /* Detect infinite include recursion. */
@@ -67,6 +68,11 @@ FILE *srcfile_relative_open(const char *fname, char **fullnamep) strerror(errno)); } +if (depfile) { +fputc (' ' , depfile); +fputs (fullname, depfile); + } +if (fullnamep) *fullnamep = fullname;else
scripts/dtc/srcpos.h +1 -0
@@ -30,6 +30,7 @@ struct srcfile_state {struct srcfile_state *prev; }; +extern FILE *depfile;/* = NULL */ extern struct srcfile_state *current_srcfile;/* = NULL */ FILE *srcfile_relative_open (const char *fname,char **fullnamep);
Signature · 1 line
1.7.0.4
PATCH 2/2 Kbuild: Use dtc's -d (dependency) option
This hooks dtc into Kbuild's dependency system.
Thus, for example, "make dtbs" will rebuild tegra-harmony.dtb if only tegra20.dtsi has changed yet tegra-harmony.dts has not. The previous lack of this feature recently caused me to have very confusing "git bisect" results.
For ARM, it's obvious what to add to $(targets). I'm not familiar enough with other architectures to know what to add there. Powerpc appears to already add various .dtb files into $(targets), but the other archs may need something added to $(targets) to work.
---
I have only tested this series for ARM.
arch/arm/boot/Makefile | 6 ++++-- arch/c6x/boot/Makefile | 2 +- arch/microblaze/boot/Makefile | 2 +- arch/openrisc/boot/Makefile | 4 ++-- arch/powerpc/boot/Makefile | 4 ++-- scripts/Makefile.lib | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-)
arch/arm/boot/Makefile +4 -2
@@ -62,9 +62,11 @@ $(obj)/zImage-dtb.%: $(obj)/%.dtb $(obj)/zImage endif +targets += $(dtb-y) + # Rule to build device tree blobs -$(obj)/%.dtb: $(src)/dts/%.dts - $(call cmd,dtc) +$(obj)/%.dtb: $(src)/dts/%.dts FORCE + $(call if_changed_dep,dtc) $(obj)/dtbs: $(addprefix $(obj)/, $(dtb-y))
arch/c6x/boot/Makefile +1 -1
@@ -13,7 +13,7 @@ obj-y += linked_dtb.o endif $(obj)/%.dtb: $(src)/dts/%.dts FORCE - $(call cmd,dtc) + $(call if_changed_dep,dtc) quiet_cmd_cp = CP $< $@$2 cmd_cp = cat $< >$@$2 || (rm -f $@ && echo false)
arch/microblaze/boot/Makefile +1 -1
@@ -53,6 +53,6 @@ $(obj)/simpleImage.%: vmlinux FORCE DTC_FLAGS := -p 1024 $(obj)/%.dtb: $(src)/dts/%.dts FORCE - $(call cmd,dtc) + $(call if_changed_dep,dtc) clean-files += *.dtb simpleImage.*.unstrip linux.bin.ub
arch/openrisc/boot/Makefile +2 -2
@@ -11,5 +11,5 @@ clean-files := *.dtb.S #DTC_FLAGS ?= -p 1024 -$(obj)/%.dtb: $(src)/dts/%.dts - $(call cmd,dtc) +$(obj)/%.dtb: $(src)/dts/%.dts FORCE + $(call if_changed_dep,dtc)
arch/powerpc/boot/Makefile +2 -2
@@ -345,8 +345,8 @@ $(obj)/treeImage.%: vmlinux $(obj)/%.dtb $(wrapperbits) $(call if_changed,wrap,treeboot-$*,,$(obj)/$*.dtb) # Rule to build device tree blobs -$(obj)/%.dtb: $(src)/dts/%.dts - $(call cmd,dtc) +$(obj)/%.dtb: $(src)/dts/%.dts FORCE + $(call if_changed_dep,dtc) # If there isn't a platform selected then just strip the vmlinux. ifeq (,$(image-y))
scripts/Makefile.lib +1 -1
@@ -264,7 +264,7 @@ $(obj)/%.dtb.S: $(obj)/%.dtb $(call cmd,dt_S_dtb) quiet_cmd_dtc = DTC $@ -cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) $< +cmd_dtc = $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 $(DTC_FLAGS) -d $(depfile) $< # Bzip2 # ---------------------------------------------------------------------------
Signature · 1 line
1.7.0.4
Re: [PATCH 2/2] Kbuild: Use dtc's -d (dependency) option
Quoted 7 lines · Stephen Warren
This hooks dtc into Kbuild's dependency system.
Thus, for example, "make dtbs" will rebuild tegra-harmony.dtb if only
tegra20.dtsihas changed yettegra-harmony.dtshas not. The previous lack of this feature recently caused me to have very confusing "git bisect" results.
Quoted 6 lines
For ARM, it's obvious what to add to $(targets). I'm not familiar enough with other architectures to know what to add there. Powerpc appears to already add various .dtb files into $(targets), but the other archs may need something added to $(targets) to work.
Signed-off-by Stephen Warren <[email protected]>
Though I did not look into the patches deeply, I know the problem very well and it annoys me a lot. It's great that we have patches to fix it, so
Signature · 2 lines
Regards, Shawn
Re: [PATCH 2/2] Kbuild: Use dtc's -d (dependency) option
In reply to Stephen WarrenQuoted 7 lines · Stephen Warren
This hooks dtc into Kbuild's dependency system.
Thus, for example, "make dtbs" will rebuild tegra-harmony.dtb if only
tegra20.dtsihas changed yettegra-harmony.dtshas not. The previous lack of this feature recently caused me to have very confusing "git bisect" results.
Quoted 7 lines
For ARM, it's obvious what to add to $(targets). I'm not familiar enough with other architectures to know what to add there. Powerpc appears to already add various .dtb files into $(targets), but the other archs may need something added to $(targets) to work.
Signed-off-by Stephen Warren <[email protected]>
For the arch/c6x bit.
Re: [PATCH 2/2] Kbuild: Use dtc's -d (dependency) option
Quoted 13 lines · Mark Salter
Quoted 12 lines · Stephen Warren
This hooks dtc into Kbuild's dependency system.
Thus, for example, "make dtbs" will rebuild tegra-harmony.dtb if only
tegra20.dtsihas changed yettegra-harmony.dtshas not. The previous lack of this feature recently caused me to have very confusing "git bisect" results.For ARM, it's obvious what to add to $(targets). I'm not familiar enough with other architectures to know what to add there. Powerpc appears to already add various .dtb files into $(targets), but the other archs may need something added to $(targets) to work.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Stephen Warren <[email protected]>Acked-by Mark Salter <[email protected]>For the
arch/c6xbit.
As the C6X port has been merged in this merge window, I can't easily apply this patch to my kbuild branch and at the same time please Linus by basing the pull request on a tagged release. So I'm going to drop the arch/c6x part to keep the kbuild branch "pretty" and let either Mark or Stephen send the patch to Linus directly, once he has merged the kbuild branch. Would that work?
Thanks,
Michal
RE: [PATCH 2/2] Kbuild: Use dtc's -d (dependency) option
Michal Marek wrote at Saturday, January 14, 2012 3:51 PM:
Quoted 19 lines · Mark Salter
Quoted 18 lines · Stephen Warren
Quoted 7 lines
This hooks dtc into Kbuild's dependency system.
Thus, for example, "make dtbs" will rebuild tegra-harmony.dtb if only
tegra20.dtsihas changed yettegra-harmony.dtshas not. The previous lack of this feature recently caused me to have very confusing "git bisect" results.Quoted 7 lines
For ARM, it's obvious what to add to $(targets). I'm not familiar enough with other architectures to know what to add there. Powerpc appears to already add various .dtb files into $(targets), but the other archs may need something added to $(targets) to work.
Signed-off-by Stephen Warren <[email protected]>Acked-by Mark Salter <[email protected]>
Quoted 8 lines
Quoted 1 line
For the
arch/c6xbit.As the C6X port has been merged in this merge window, I can't easily apply this patch to my kbuild branch and at the same time please Linus by basing the pull request on a tagged release. So I'm going to drop the
arch/c6xpart to keep the kbuild branch "pretty" and let either Mark or Stephen send the patch to Linus directly, once he has merged the kbuild branch. Would that work?
I was assuming my patches were for 3.4 rather than 3.3, since it's pretty late for new features in 3.3. In that case, there wouldn't be an issue, right?
If you do want to go ahead and push my patches into 3.3, your proposal looks fine to me. Mark, do you want me to push the patch to Linus, or do you want to pick it up?
Thanks.
Signature · 1 line
nvpublic
RE: [PATCH 2/2] Kbuild: Use dtc's -d (dependency) option
Quoted 29 lines · Stephen Warren
Michal Marek wrote at Saturday, January 14, 2012 3:51 PM:
Quoted 19 lines · Mark Salter
Quoted 18 lines · Stephen Warren
Quoted 7 lines
This hooks dtc into Kbuild's dependency system.
Thus, for example, "make dtbs" will rebuild tegra-harmony.dtb if only
tegra20.dtsihas changed yettegra-harmony.dtshas not. The previous lack of this feature recently caused me to have very confusing "git bisect" results.Quoted 7 lines
For ARM, it's obvious what to add to $(targets). I'm not familiar enough with other architectures to know what to add there. Powerpc appears to already add various .dtb files into $(targets), but the other archs may need something added to $(targets) to work.
Signed-off-by Stephen Warren <[email protected]>Acked-by Mark Salter <[email protected]>Quoted 8 lines
Quoted 1 line
For the
arch/c6xbit.As the C6X port has been merged in this merge window, I can't easily apply this patch to my kbuild branch and at the same time please Linus by basing the pull request on a tagged release. So I'm going to drop the
arch/c6xpart to keep the kbuild branch "pretty" and let either Mark or Stephen send the patch to Linus directly, once he has merged the kbuild branch. Would that work?
Quoted 7 lines
I was assuming my patches were for 3.4 rather than 3.3, since it's pretty late for new features in 3.3. In that case, there wouldn't be an issue, right?
If you do want to go ahead and push my patches into 3.3, your proposal looks fine to me. Mark, do you want me to push the patch to Linus, or do you want to pick it up?
It would probably be best to keep it all together, but if there's a need to break out c6x individually, I don't mind picking it up.
--Mark
Re: [PATCH 2/2] Kbuild: Use dtc's -d (dependency) option
In reply to Stephen WarrenQuoted 11 lines · Stephen Warren
Michal Marek wrote at Saturday, January 14, 2012 3:51 PM:
Quoted 6 lines
As the C6X port has been merged in this merge window, I can't easily apply this patch to my kbuild branch and at the same time please Linus by basing the pull request on a tagged release. So I'm going to drop the
arch/c6xpart to keep the kbuild branch "pretty" and let either Mark or Stephen send the patch to Linus directly, once he has merged the kbuild branch. Would that work?I was assuming my patches were for 3.4 rather than 3.3, since it's pretty late for new features in 3.3. In that case, there wouldn't be an issue, right?
OK, that was a misunderstanding then. I applied it to the kbuild branch for 3.3 and Linus pulled it in the meantime. It's not a terribly intrusive change, after all.
Michal
Quoted 8 lines
This will allow callers to rebuild .dtb files when any of the /include/d .dtsi files are modified, not just the top-level .dts file.
Signed-off-by Stephen Warren <[email protected]>---
This patch is against the Linux kernel's copy of dtc, but it applies to upstream dtc with a couple of trivial conflicts. I can post a version for upstream dtc as well if desired.
If it does go upstream into Linux proper, we should definitely have it in the main DTC repository.
So if you would, please send me a path that applies there.
Thanks,
jdl