Commit 136ec204 authored by Stephen Warren's avatar Stephen Warren Committed by Michal Marek

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.
Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent 5bb0571b
...@@ -71,6 +71,7 @@ static void __attribute__ ((noreturn)) usage(void) ...@@ -71,6 +71,7 @@ static void __attribute__ ((noreturn)) usage(void)
fprintf(stderr, "\t\t\tasm - assembler source\n"); fprintf(stderr, "\t\t\tasm - assembler source\n");
fprintf(stderr, "\t-V <output version>\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\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-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\tMake space for <number> reserve map entries (relevant for \n\t\tdtb and asm output only)\n");
fprintf(stderr, "\t-S <bytes>\n"); fprintf(stderr, "\t-S <bytes>\n");
...@@ -99,6 +100,7 @@ int main(int argc, char *argv[]) ...@@ -99,6 +100,7 @@ int main(int argc, char *argv[])
const char *inform = "dts"; const char *inform = "dts";
const char *outform = "dts"; const char *outform = "dts";
const char *outname = "-"; const char *outname = "-";
const char *depname = NULL;
int force = 0, check = 0, sort = 0; int force = 0, check = 0, sort = 0;
const char *arg; const char *arg;
int opt; int opt;
...@@ -111,7 +113,8 @@ int main(int argc, char *argv[]) ...@@ -111,7 +113,8 @@ int main(int argc, char *argv[])
minsize = 0; minsize = 0;
padsize = 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) { switch (opt) {
case 'I': case 'I':
inform = optarg; inform = optarg;
...@@ -125,6 +128,9 @@ int main(int argc, char *argv[]) ...@@ -125,6 +128,9 @@ int main(int argc, char *argv[])
case 'V': case 'V':
outversion = strtol(optarg, NULL, 0); outversion = strtol(optarg, NULL, 0);
break; break;
case 'd':
depname = optarg;
break;
case 'R': case 'R':
reservenum = strtol(optarg, NULL, 0); reservenum = strtol(optarg, NULL, 0);
break; break;
...@@ -188,6 +194,14 @@ int main(int argc, char *argv[]) ...@@ -188,6 +194,14 @@ int main(int argc, char *argv[])
fprintf(stderr, "DTC: %s->%s on file \"%s\"\n", fprintf(stderr, "DTC: %s->%s on file \"%s\"\n",
inform, outform, arg); 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")) if (streq(inform, "dts"))
bi = dt_from_source(arg); bi = dt_from_source(arg);
else if (streq(inform, "fs")) else if (streq(inform, "fs"))
...@@ -197,6 +211,11 @@ int main(int argc, char *argv[]) ...@@ -197,6 +211,11 @@ int main(int argc, char *argv[])
else else
die("Unknown input format \"%s\"\n", inform); die("Unknown input format \"%s\"\n", inform);
if (depfile) {
fputc('\n', depfile);
fclose(depfile);
}
if (cmdline_boot_cpuid != -1) if (cmdline_boot_cpuid != -1)
bi->boot_cpuid_phys = cmdline_boot_cpuid; bi->boot_cpuid_phys = cmdline_boot_cpuid;
......
...@@ -40,6 +40,7 @@ static char *dirname(const char *path) ...@@ -40,6 +40,7 @@ static char *dirname(const char *path)
return NULL; return NULL;
} }
FILE *depfile; /* = NULL */
struct srcfile_state *current_srcfile; /* = NULL */ struct srcfile_state *current_srcfile; /* = NULL */
/* Detect infinite include recursion. */ /* Detect infinite include recursion. */
...@@ -67,6 +68,9 @@ FILE *srcfile_relative_open(const char *fname, char **fullnamep) ...@@ -67,6 +68,9 @@ FILE *srcfile_relative_open(const char *fname, char **fullnamep)
strerror(errno)); strerror(errno));
} }
if (depfile)
fprintf(depfile, " %s", fullname);
if (fullnamep) if (fullnamep)
*fullnamep = fullname; *fullnamep = fullname;
else else
......
...@@ -30,6 +30,7 @@ struct srcfile_state { ...@@ -30,6 +30,7 @@ struct srcfile_state {
struct srcfile_state *prev; struct srcfile_state *prev;
}; };
extern FILE *depfile; /* = NULL */
extern struct srcfile_state *current_srcfile; /* = NULL */ extern struct srcfile_state *current_srcfile; /* = NULL */
FILE *srcfile_relative_open(const char *fname, char **fullnamep); FILE *srcfile_relative_open(const char *fname, char **fullnamep);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment