system: split long build lines

Some boards now provide very long build version strings including
version strings of multiple subcomponents.

Let the version command split those long lines printing each
subcomponent's version string in a separate line.

BRANCH=none
BUG=chrome-os-partner:55373
TEST=verified on cr50:
  > vers
  Chip:    g cr50 B2
  Board:   0
  RO_A:    0.0.1/84e2dde7
  RO_B:  * 0.0.2/13eda43f
  RW_A:  * cr50_v1.1.4980-2b9f3e1
  RW_B:    cr50_v1.1.4979-8cec36d+
  Build:   cr50_v1.1.4980-2b9f3e1
           private-cr51:v0.0.66-bd9a0fe
           tpm2:v0.0.259-2b12863
           cryptoc:v0.0.4-5319e83
           2016-07-28 20:40:55 vbendeb@kvasha

Change-Id: Ie14af3aa9febd5a3b02b273a7ab6302e74777e43
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/364491
This commit is contained in:
Vadim Bendebury
2016-07-28 20:40:55 -07:00
committed by chrome-bot
parent 78a875eadb
commit ff8c0b129e

View File

@@ -896,6 +896,62 @@ DECLARE_CONSOLE_COMMAND(hibernate, command_hibernate,
NULL);
#endif /* CONFIG_HIBERNATE */
/*
* A typical build string has the following format
*
* <version> <build_date_time> <user@buildhost>
*
* some EC board, however, are composed of multiple components, their build
* strings can include several subcomponent versions between the main version
* and the build date, for instance
*
* cr50_v1.1.4979-0061603+ private-cr51:v0.0.66-bd9a0fe tpm2:v0.0.259-2b...
*
* Each subcomponent in this case includes the ":v" substring. For these
* combined version strings this function prints each version or subcomponent
* version on a different line.
*/
static void print_build_string(void)
{
const char *full_build_string;
const char *p;
char symbol;
int seen_colonv;
ccprintf("Build: ");
full_build_string = system_get_build_info();
/* 50 characters or less, will fit into the terminal line. */
if (strlen(full_build_string) < 50) {
ccprintf("%s\n");
return;
}
/*
* Build version string needs splitting, let's split it at the first
* space (this is where the main version ends), and then on each space
* after the ":v" substring, this is where subcomponent versions are
* separated.
*/
p = full_build_string;
seen_colonv = 1;
symbol = *p++;
while (symbol) {
if ((symbol == ' ') && seen_colonv) {
seen_colonv = 0;
/* Indent each line under 'Build: ' */
ccprintf("\n ");
} else {
if ((symbol == ':') && (*p == 'v'))
seen_colonv = 1;
ccprintf("%c", symbol);
}
symbol = *p++;
}
ccprintf("\n");
}
static int command_version(int argc, char **argv)
{
ccprintf("Chip: %s %s %s\n", system_get_chip_vendor(),
@@ -931,7 +987,9 @@ static int command_version(int argc, char **argv)
#else
ccprintf("RW: %s\n", system_get_version(SYSTEM_IMAGE_RW));
#endif
ccprintf("Build: %s\n", system_get_build_info());
print_build_string();
return EC_SUCCESS;
}
DECLARE_CONSOLE_COMMAND(version, command_version,