Skip to content

Commit

Permalink
[util/reggen] Do not generate stamping information if not available
Browse files Browse the repository at this point in the history
If stamping is disable, version_stamp will be an empty dictionary
and the code will print something like
```
// Generated register constants for rv_plic.
// Built for <unknown>
// https://github.com/lowRISC/opentitan/tree/<unknown>
// Tree status: <unknown>
// Build date: <current date>
```
This is unhelpful and still prints the current time which is defeats
the point of not stamping. The new code will not print anything
when a piece of information is not available.

Signed-off-by: Amaury Pouly <[email protected]>
  • Loading branch information
pamaury committed Jan 22, 2024
1 parent 318e21e commit 8bb743a
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions util/reggen/gen_tock.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,6 @@ def gen_tock(block: IpBlock, outfile: TextIO, src_file: Optional[str],
fieldstr = fieldout.getvalue()
fieldout.close()

tm = int(version_stamp.get('BUILD_TIMESTAMP', 0))
dt = datetime.utcfromtimestamp(tm) if tm else datetime.utcnow()
# Opensource council has approved dual-licensing the generated files under
# both Apache and MIT licenses.
# Since these generated files are meant to be imported into the Tock
Expand All @@ -395,17 +393,20 @@ def gen_tock(block: IpBlock, outfile: TextIO, src_file: Optional[str],
"// Licensed under the Apache License, Version 2.0 or the MIT License.\n"
)
genout(outfile, "// SPDX-License-Identifier: Apache-2.0 OR MIT\n")
genout(outfile, "// Copyright lowRISC contributors {}.\n", dt.year)
genout(outfile, "// Copyright lowRISC contributors.\n")
genout(outfile, '\n')
genout(outfile, '// Generated register constants for {}.\n', block.name)

genout(outfile, '// Built for {}\n',
version_stamp.get('BUILD_GIT_VERSION', '<unknown>'))
genout(outfile, '// https://github.com/lowRISC/opentitan/tree/{}\n',
version_stamp.get('BUILD_SCM_REVISION', '<unknown>'))
genout(outfile, '// Tree status: {}\n',
version_stamp.get('BUILD_SCM_STATUS', '<unknown>'))
genout(outfile, '// Build date: {}\n\n', dt.isoformat())
if 'BUILD_GIT_VERSION' in version_stamp:
genout(outfile, '// Built for {}\n', version_stamp['BUILD_GIT_VERSION'])
if 'BUILD_SCM_REVISION' in version_stamp:
genout(outfile, '// https://github.com/lowRISC/opentitan/tree/{}\n', version_stamp['BUILD_SCM_REVISION'])
if 'BUILD_SCM_STATUS' in version_stamp:
genout(outfile, '// Tree status: {}\n', version_stamp['BUILD_SCM_STATUS'])
if 'BUILD_TIMESTAMP' in version_stamp:
tm = int(version_stamp['BUILD_TIMESTAMP'])
dt = datetime.utcfromtimestamp(tm)
genout(outfile, '// Build date: {}\n\n', dt.isoformat())

if src_file:
genout(outfile, '// Original reference file: {}\n', src_file)
Expand Down

0 comments on commit 8bb743a

Please sign in to comment.