sconfig: Update command line parameters

Instead of having directories and file names hardcoded, pass in the full
path and filename of both the input and output files.

In the makefile, create variables for these values, and use them in
places that previously had the names and paths written out.

Change-Id: Icb6f536547ce3193980ec5d60c786a29755c2813
Signed-off-by: Martin Roth <martinroth@google.com>
Reviewed-on: https://review.coreboot.org/16078
Tested-by: build bot (Jenkins)
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
Martin Roth 2016-08-05 15:46:56 -06:00
parent 3205170a2e
commit 25f8a4f6d4
2 changed files with 19 additions and 27 deletions

View File

@ -451,15 +451,18 @@ $(obj)/config.h: $(objutil)/kconfig/conf
####################################################################### #######################################################################
# needed objects that every mainboard uses # needed objects that every mainboard uses
# Creation of these is architecture and mainboard independent # Creation of these is architecture and mainboard independent
$(obj)/mainboard/$(MAINBOARDDIR)/static.c: $(src)/mainboard/$(MAINBOARDDIR)/$(call strip_quotes, $(CONFIG_DEVICETREE)) $(objutil)/sconfig/sconfig DEVICETREE_FILE := $(src)/mainboard/$(MAINBOARDDIR)/$(call strip_quotes, $(CONFIG_DEVICETREE))
@printf " SCONFIG $(subst $(src)/,,$(<))\n" DEVICETREE_STATIC_C := $(obj)/mainboard/$(MAINBOARDDIR)/static.c
mkdir -p $(obj)/mainboard/$(MAINBOARDDIR)
$(objutil)/sconfig/sconfig $(MAINBOARDDIR) $(obj)/mainboard/$(MAINBOARDDIR) $(call strip_quotes, $(CONFIG_DEVICETREE))
ramstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c $(DEVICETREE_STATIC_C): $(DEVICETREE_FILE) $(objutil)/sconfig/sconfig
romstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c @printf " SCONFIG $(subst $(src)/,,$(<))\n"
verstage-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c mkdir -p $(dir $(DEVICETREE_STATIC_C))
bootblock-y+=$(obj)/mainboard/$(MAINBOARDDIR)/static.c $(objutil)/sconfig/sconfig $(MAINBOARDDIR) $(DEVICETREE_FILE) $(DEVICETREE_STATIC_C)
ramstage-y+=$(DEVICETREE_STATIC_C)
romstage-y+=$(DEVICETREE_STATIC_C)
verstage-y+=$(DEVICETREE_STATIC_C)
bootblock-y+=$(DEVICETREE_STATIC_C)
$(objgenerated)/libverstage.a: $$(libverstage-objs) $(objgenerated)/libverstage.a: $$(libverstage-objs)
rm -f $@ rm -f $@

View File

@ -551,7 +551,7 @@ static void inherit_subsystem_ids(FILE *file, struct device *dev)
static void usage(void) static void usage(void)
{ {
printf("usage: sconfig vendor/mainboard outputdir devicetree [-{s|b|k} outputfile]\n"); printf("usage: sconfig vendor/mainboard devicetree_file output_file [-{s|b|k}]\n");
printf("\t-s file\tcreate ramstage static device map\n"); printf("\t-s file\tcreate ramstage static device map\n");
printf("\t-b file\tcreate bootblock init_mainboard()\n"); printf("\t-b file\tcreate bootblock init_mainboard()\n");
printf("\t-k file\tcreate Kconfig devicetree section\n"); printf("\t-k file\tcreate Kconfig devicetree section\n");
@ -560,31 +560,25 @@ static void usage(void)
} }
enum { enum {
VENDOR_MAINBOARD_ARG = 1, MAINBOARD_ARG = 1,
OUTPUTDIR_ARG,
DEVICEFILE_ARG, DEVICEFILE_ARG,
OUTPUTTYPE_ARG, OUTPUTFILE_ARG,
OUTPUTFILE_ARG OUTPUTTYPE_ARG
}; };
#define MIN_ARGS 4 #define MIN_ARGS 4
#define MAX_ARGS 6 #define MAX_ARGS 5
int main(int argc, char** argv) { int main(int argc, char** argv) {
if (argc != MIN_ARGS && argc != MAX_ARGS) if (argc != MIN_ARGS && argc != MAX_ARGS)
usage(); usage();
char *mainboard = argv[VENDOR_MAINBOARD_ARG]; char *mainboard = argv[MAINBOARD_ARG];
char *outputdir = argv[OUTPUTDIR_ARG]; char *devtree = argv[DEVICEFILE_ARG];
char *devfile = argv[DEVICEFILE_ARG]; char *outputc = argv[OUTPUTFILE_ARG];
char *devtree = malloc(strlen(mainboard) + strlen(devfile) + 30);
sprintf(devtree, "src/mainboard/%s/%s", mainboard, devfile);
char *outputc;
if (argc == MIN_ARGS) { if (argc == MIN_ARGS) {
scan_mode = STATIC_MODE; scan_mode = STATIC_MODE;
outputc=malloc(strlen(outputdir)+20);
sprintf(outputc, "%s/static.c", outputdir);
} else if (argc == MAX_ARGS) { } else if (argc == MAX_ARGS) {
if ((argv[OUTPUTTYPE_ARG][0] != '-') || if ((argv[OUTPUTTYPE_ARG][0] != '-') ||
(argv[OUTPUTTYPE_ARG][2] == 0)) { (argv[OUTPUTTYPE_ARG][2] == 0)) {
@ -605,10 +599,6 @@ int main(int argc, char** argv) {
usage(); usage();
break; break;
} }
char *outputfile = argv[OUTPUTFILE_ARG];
outputc=malloc(strlen(outputdir)+strlen(outputfile)+2);
sprintf(outputc, "%s/%s", outputdir, outputfile);
} }
headers.next = 0; headers.next = 0;
@ -623,7 +613,6 @@ int main(int argc, char** argv) {
FILE *filec = fopen(devtree, "r"); FILE *filec = fopen(devtree, "r");
if (!filec) { if (!filec) {
fprintf(stderr, "Could not open file '%s' for reading: ", devtree);
perror(NULL); perror(NULL);
exit(1); exit(1);
} }