dtc: Implement -d option to write out a dependency file
PATCH v2 1/1 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.
---
v2: Replaced fputs/fputc with fprintf
This is an updated patch for dtc itself. Once it's accepted, I'll repost the equivalent kernel patch.
Documentation/manual.txt | 3 +++ dtc.c | 20 +++++++++++++++++++- srcpos.c | 4 ++++ srcpos.h | 1 + tests/dependencies.cmp | 1 + tests/dependencies.dts | 6 ++++++ tests/deps_inc1.dtsi | 1 + tests/deps_inc2.dtsi | 1 + tests/run_tests.sh | 4 ++++ 9 files changed, 40 insertions(+), 1 deletions(-) create mode 100644 tests/dependencies.cmp create mode 100644 tests/dependencies.dts create mode 100644 tests/deps_inc1.dtsi create mode 100644 tests/deps_inc2.dtsi
Documentation/manual.txt +3 -0
@@ -106,6 +106,9 @@ Options: -O <output_format> The generated output format, as listed above. + -d <dependency_filename> + Generate a dependency file during compilation. + -q Quiet: -q suppress warnings, -qq errors, -qqq all
dtc.c +19 -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 , sort =0 ;const char *arg;int opt;
@@ -111,7 +113,7 @@ int main(int argc, char *argv[]) minsize =0 ; padsize =0 ; -while ((opt =getopt (argc, argv,"hI:O:o:V:R:S:p:fqb:vH:s" )) !=EOF ) { +while ((opt =getopt (argc, argv,"hI:O:o:V:d:R:S:p:fqb:vH:s" )) !=EOF ) {switch (opt) {case 'I' : inform = optarg;
@@ -125,6 +127,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 ;
@@ -185,6 +190,14 @@ 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)); +fprintf (depfile,"%s:" , outname); + } +if (streq (inform,"dts" )) bi =dt_from_source (arg);else if (streq (inform,"fs" ))
@@ -194,6 +207,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;
srcpos.c +4 -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,9 @@ FILE *srcfile_relative_open(const char *fname, char **fullnamep) strerror(errno)); } +if (depfile) +fprintf (depfile," %s" , fullname); +if (fullnamep) *fullnamep = fullname;else
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);
tests/dependencies.cmp new file +1 -0
@@ -0,0 +1 @@ +dependencies.test.dtb: dependencies.dts deps_inc1.dtsi deps_inc2.dtsi
tests/dependencies.dts new file +6 -0
@@ -0,0 +1,6 @@ +/dts-v1/; + +/include/ "deps_inc1.dtsi" + +/ { +};
tests/deps_inc1.dtsi new file +1 -0
@@ -0,0 +1 @@ +/include/ "deps_inc2.dtsi"
tests/deps_inc2.dtsi new file +1 -0
@@ -0,0 +1 @@ +/* Empty */
tests/run_tests.sh +4 -0
@@ -353,6 +353,10 @@ dtc_tests () { run_sh_test dtc-fatal.sh -I dts -O dtb nosuchfile.dts run_sh_test dtc-fatal.sh -I dtb -O dtb nosuchfile.dtb run_sh_test dtc-fatal.sh -I fs -O dtb nosuchfile + + # Dependencies + run_dtc_test -I dts -O dtb -o dependencies.test.dtb -d dependencies.test.d dependencies.dts + run_wrap_test cmp dependencies.test.d dependencies.cmp } cmp_tests () {
Signature · 1 line
1.7.0.4
David Gibson
Acked-byQuoted 4 lines · Stephen Warren
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]>
Nice.
Jon, please apply.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 11 lines · Stephen Warren
Quoted 4 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]>Nice.
Acked-by David Gibson <[email protected]>Jon, please apply.
Will do with a patch for the DTC repo.
Thanks,
jdl
Quoted 6 lines · Jon Loeliger
Quoted 6 lines · Stephen Warren
Quoted 4 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]>
Quoted 7 lines
Quoted 5 lines
Nice.
Acked-by David Gibson <[email protected]>Jon, please apply.
Will do with a patch for the DTC repo.
Uh.. this patch is for the dtc repo, he sent it in addition to the one against the kernel version.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 9 lines · Jon Loeliger
Quoted 8 lines
Quoted 8 lines · Stephen Warren
Quoted 4 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]>Nice.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Acked-by David Gibson <[email protected]>Jon, please apply.
Will do with a patch for the DTC repo.
Uh.. this patch is for the dtc repo, he sent it in addition to the one against the kernel version.
I did not receive this patch for the DTC repo. I have this patch for the kernel only on the arm list.
I'm not saying he didn't do the worl, nor am I saying he didn't post such a past. I'm saying *I* don't have it!
Request 3: Please send this patch to *me* for the DTC repo! :-)
jdl
Quoted 3 lines
I'm not saying he didn't do the worl, nor am I saying he didn't post such a past. I'm saying *I* don't have it!
Yeeesh.
s/worl/work/
s/past/patch/
jdl
Quoted 15 lines · Jon Loeliger
Quoted 15 lines · Jon Loeliger
Quoted 13 lines
Quoted 11 lines · Stephen Warren
Quoted 4 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]>Nice.
Acked-by David Gibson <[email protected]>Jon, please apply.
Will do with a patch for the DTC repo.
Quoted 8 lines
Quoted 2 lines
Uh.. this patch is for the dtc repo, he sent it in addition to the one against the kernel version.
I did not receive this patch for the DTC repo. I have this patch for the kernel only on the arm list.
I'm not saying he didn't do the worl, nor am I saying he didn't post such a past. I'm saying *I* don't have it!
Um.. so, the mail I was replying to you above, was for the dtc repo and you were on the recipient list. Given the frequency with which I need to resend my own patches, I'm beginning to wonder if your mail system is dropping things, Jon..
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 5 lines
Um.. so, the mail I was replying to you above, was for the dtc repo and you were on the recipient list. Given the frequency with which I need to resend my own patches, I'm beginning to wonder if your mail system is dropping things, Jon..
It is not. See Stephen's mail, for example.
jdl
David Gibson wrote at Thursday, January 12, 2012 4:12 PM:
Quoted 22 lines · Jon Loeliger
Quoted 21 lines
Quoted 9 lines · Jon Loeliger
Quoted 8 lines
Quoted 8 lines · Stephen Warren
Quoted 4 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]>Nice.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Acked-by David Gibson <[email protected]>Jon, please apply.
Will do with a patch for the DTC repo.
Uh.. this patch is for the dtc repo, he sent it in addition to the one against the kernel version.
I did not receive this patch for the DTC repo. I have this patch for the kernel only on the arm list.
Quoted 7 lines
Quoted 2 lines
I'm not saying he didn't do the worl, nor am I saying he didn't post such a past. I'm saying *I* don't have it!
Um.. so, the mail I was replying to you above, was for the dtc repo and you were on the recipient list. Given the frequency with which I need to resend my own patches, I'm beginning to wonder if your mail system is dropping things, Jon..
In this case, it was my fault.
Jon's email system validates SPF and doesn't accept messages where that fails. I was sending my patch through my personal email server but using NVIDIA's email address, hence this failed the SPF check. I think I wasn't notified of this because the bounce message my server would have presumably generated probably experienced some similar issue getting back to my NVIDIA email account.
I've reconfigured git to send email through NVIDIA's servers, although now that means I have to be on the VPN to send patches:-(
Signature · 1 line
nvpublic
Quoted 7 lines · Jon Loeliger
Quoted 5 lines
Um.. so, the mail I was replying to you above, was for the dtc repo and you were on the recipient list. Given the frequency with which I need to resend my own patches, I'm beginning to wonder if your mail system is dropping things, Jon..
It is not. See Stephen's mail, for example.
Ah, ok.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson