mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
We have been using the time of compilation to determine the
version string. This CL will keep doing that if the git repo has
uncommitted changes, but if the repo is clean we'll just use the
author date of the last commit. This ensures that the same source
will produce bitwise-identical builds (assuming no toolchain
changes, of course).
BUG=chrome-os-partner:45616
BRANCH=none
TEST=manual
cd src/platform/ec
make buildall
mv build build.one
make buildall
md5sum build{,.one}/*/ec.bin | sort
Observe that successive builds produce identical binaries.
Change-Id: Ie2ef44b216586097589c9c15f12e05c87a53f991
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/302140
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Shawn N <shawnn@chromium.org>
53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* Embed firmware version number in the binary */
|
|
|
|
#include <stdint.h>
|
|
#include "common.h"
|
|
#include "ec_version.h"
|
|
#include "version.h"
|
|
|
|
const struct version_struct __keep version_data
|
|
__attribute__((section(".rodata.ver"))) = {
|
|
CROS_EC_VERSION_COOKIE1,
|
|
CROS_EC_VERSION32,
|
|
CROS_EC_VERSION_COOKIE2
|
|
};
|
|
|
|
const char build_info[] __keep __attribute__((section(".rodata.buildinfo"))) =
|
|
CROS_EC_VERSION " " DATE " " BUILDER;
|
|
|
|
uint32_t ver_get_numcommits(void)
|
|
{
|
|
int i;
|
|
int numperiods = 0;
|
|
uint32_t ret = 0;
|
|
|
|
/*
|
|
* Version string is formatted like:
|
|
* name_major.branch.numcommits-hash[dirty]
|
|
* we want to return the numcommits as an int.
|
|
*/
|
|
for (i = 0; i < 32; i++) {
|
|
if (version_data.version[i] == '.') {
|
|
numperiods++;
|
|
if (numperiods == 2)
|
|
break;
|
|
}
|
|
}
|
|
|
|
i++;
|
|
for (; i < 32; i++) {
|
|
if (version_data.version[i] == '-')
|
|
break;
|
|
ret *= 10;
|
|
ret += version_data.version[i] - '0';
|
|
}
|
|
|
|
return (i == 32 ? 0 : ret);
|
|
}
|
|
|