diff options
author | Vadim Bendebury <vbendeb@chromium.org> | 2018-04-30 17:10:52 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-05-02 22:20:34 -0700 |
commit | e2b45bf50888d592af5a105c2b888d69d04ef806 (patch) | |
tree | ac107a9a4044e2f5cb4a2748678f248db917fa91 /extra/usb_updater/gsctool.c | |
parent | 5b6381713b4c120e9fda7d0fb13b41225f1dc6a6 (diff) | |
download | chrome-ec-e2b45bf50888d592af5a105c2b888d69d04ef806.tar.gz |
gsctool: add version command line option
Use the same script the rest of the EC codebase uses to generate the
version string.
BRANCH=none
BUG=none
TEST=built the new image and tried:
$ ./extra/usb_updater/gsctool -v
Version: v1.1.8258+6097a64f0, built on 2018-05-01 17:04:14 by ...
Change-Id: I63d2411872bbd38188f66f51b7ca8508fc74fa8f
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1036741
Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
Diffstat (limited to 'extra/usb_updater/gsctool.c')
-rw-r--r-- | extra/usb_updater/gsctool.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/extra/usb_updater/gsctool.c b/extra/usb_updater/gsctool.c index d751cc0bc7..10f3bbefe6 100644 --- a/extra/usb_updater/gsctool.c +++ b/extra/usb_updater/gsctool.c @@ -24,6 +24,7 @@ #include "ccd_config.h" #include "compile_time_macros.h" +#include "generated_version.h" #include "gsctool.h" #include "misc_util.h" #include "signed_header.h" @@ -194,7 +195,7 @@ struct upgrade_pkt { static uint32_t protocol_version; static char *progname; -static char *short_opts = "abcd:fhIikO:oPprstUu"; +static char *short_opts = "abcd:fhIikO:oPprstUuv"; static const struct option long_opts[] = { /* name hasarg *flag val */ {"any", 0, NULL, 'a'}, @@ -214,6 +215,7 @@ static const struct option long_opts[] = { {"rma_auth", 2, NULL, 'r'}, {"systemdev", 0, NULL, 's'}, {"trunks_send", 0, NULL, 't'}, + {"version", 0, NULL, 'v'}, {"upstart", 0, NULL, 'u'}, {}, }; @@ -503,11 +505,12 @@ static void usage(int errs) "\n" " -a,--any Try any interfaces to find Cr50" " (-d, -s, -t are all ignored)\n" - " -b,--binvers Report versions of image's " + " -b,--binvers Report versions of Cr50 image's " "RW and RO headers, do not update\n" " -c,--corrupt Corrupt the inactive rw\n" " -d,--device VID:PID USB device (default %04x:%04x)\n" - " -f,--fwver Report running firmware versions\n" + " -f,--fwver " + "Report running Cr50 firmware versions\n" " -h,--help Show this message\n" " -I,--ccd_info Get information about CCD state\n" " -i,--board_id [ID[:FLAGS]]\n" @@ -533,6 +536,7 @@ static void usage(int errs) " -U,--ccd_unlock Start CCD unlock sequence\n" " -u,--upstart " "Upstart mode (strict header checks)\n" + " -v,--version Report this utility version\n" "\n", progname, VID, PID); exit(errs ? update_error : noop); @@ -1884,6 +1888,15 @@ static void process_rma(struct transfer_descriptor *td, const char *authcode) printf("RMA unlock succeeded.\n"); } +static void report_version(void) +{ + /* Get version from the generated file, ignore the underscore prefix. */ + const char *v = VERSION + 1; + + printf("Version: %s, built on %s by %s\n", v, DATE, BUILDER); + exit(0); +} + int main(int argc, char *argv[]) { struct transfer_descriptor td; @@ -2017,6 +2030,9 @@ int main(int argc, char *argv[]) case 'u': td.upstart_mode = 1; break; + case 'v': + report_version(); /* This will call exit(). */ + break; case 0: /* auto-handled option */ break; case '?': |