summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorDenis Brockus <dbrockus@google.com>2020-11-14 10:24:07 -0700
committerCommit Bot <commit-bot@chromium.org>2020-11-17 20:53:34 +0000
commit5c8f8d83d4fbff5ddf03d620089873e146360a90 (patch)
tree5d5896fb6247493994500f8c593917f0410451e9 /util
parent6b1102d0f89c7b8aed02541abad440a217734a12 (diff)
downloadchrome-ec-5c8f8d83d4fbff5ddf03d620089873e146360a90.tar.gz
genvif: add --no-config
genvif has a new option of creating an output file based solely on the overrides and not the configs. This will make comparisons from other generators a little easier. USAGE: genvif -b|--board <board name> -o|--out <out directory> [-n|--no-config] [-v|--over <override XML file>] BUG=b:173219559 BRANCH=none TEST=verify XML output Signed-off-by: Denis Brockus <dbrockus@google.com> Change-Id: I4af5662321e29ed806dea0a2420fd8f4627f8e0f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2538955 Tested-by: Denis Brockus <dbrockus@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Commit-Queue: Denis Brockus <dbrockus@chromium.org>
Diffstat (limited to 'util')
-rw-r--r--util/genvif.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/util/genvif.c b/util/genvif.c
index e9d32584bd..c42088f697 100644
--- a/util/genvif.c
+++ b/util/genvif.c
@@ -21,7 +21,6 @@
#include "usb_pd.h"
#include "usb_pd_tcpm.h"
#include "charge_manager.h"
-#include "system.h"
#include "genvif.h"
@@ -3378,9 +3377,7 @@ static void init_vif_component_product_power_fields(
"0", "Assured");
}
-static int gen_vif(const char *name,
- const char *board,
- const char *vif_producer,
+static int gen_vif(const char *board,
struct vif_t *vif)
{
int override_value;
@@ -3503,10 +3500,7 @@ static int gen_vif(const char *name,
src_max_power,
type);
- /*********************************************************************
- * Format the structure in XML and output it to file
- */
- return vif_output_xml(name, vif);
+ return 0;
}
/*
* VIF Structure Initialization from Config Functions
@@ -3518,21 +3512,20 @@ int main(int argc, char **argv)
int ret;
const char *out = NULL;
const char *board = NULL;
- const char *vif_producer;
+ bool do_config_init = true;
DIR *vifdir;
char *name;
int name_size;
- const char * const short_opt = "hb:o:";
+ const char * const short_opt = "hb:o:nv:";
const struct option long_opts[] = {
- { "help", 0, NULL, 'h' },
- { "board", 1, NULL, 'b' },
- { "out", 1, NULL, 'o' },
- { "over", 1, NULL, 'v'},
+ { "help", 0, NULL, 'h' },
+ { "board", 1, NULL, 'b' },
+ { "out", 1, NULL, 'o' },
+ { "no-config", 0, NULL, 'n' },
+ { "over", 1, NULL, 'v' },
{ NULL }
};
- vif_producer = argv[0];
-
/* Clear the VIF structure */
memset(&vif, 0, sizeof(struct vif_t));
@@ -3540,8 +3533,10 @@ int main(int argc, char **argv)
nopt = getopt_long(argc, argv, short_opt, long_opts, NULL);
switch (nopt) {
case 'h': /* -h or --help */
- printf("USAGE: %s -b <board name> -o <out directory>"
- " --over <override XML file>\n", vif_producer);
+ printf("USAGE: genvif -b|--board <board name>\n"
+ " -o|--out <out directory>\n"
+ " [-n|--no-config]\n"
+ " [-v|--over <override XML file>]\n");
return 1;
case 'b': /* -b or --board */
@@ -3552,7 +3547,11 @@ int main(int argc, char **argv)
out = optarg;
break;
- case 'v': /* --over */
+ case 'n': /* -n or --no-config */
+ do_config_init = false;
+ break;
+
+ case 'v': /* -v or --over */
/* Handle overrides */
if (override_gen_vif(optarg, &vif))
return 1;
@@ -3579,14 +3578,21 @@ int main(int argc, char **argv)
init_src_pdos();
+ /* Finish CONFIG initialization file */
+ if (do_config_init) {
+ ret = gen_vif(board, &vif);
+ if (ret)
+ return 1;
+ }
+
name_size = asprintf(&name, "%s/%s_vif.xml", out, board);
if (name_size < 0) {
fprintf(stderr, "ERROR: Out of memory.\n");
return 1;
}
- /* Finish CONFIG initialization and output the file */
- ret = gen_vif(name, board, vif_producer, &vif);
+ /* Format the structure in XML and output it to file */
+ ret = vif_output_xml(name, &vif);
free(name);
return ret;