aboutsummaryrefslogtreecommitdiff
path: root/tools/build_string.py
blob: 7c5c32301b38c260a30698317589dd44e6dc8eab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env python3
#
# Arm SCP/MCP Software
# Copyright (c) 2015-2020, Arm Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#

import subprocess
from datetime import datetime


def main():
    # Check if git is available and that the source is within a git repository
    try:
        cmd = 'git describe --tags --dirty --always'
        output = subprocess.check_output(cmd.split())
        git_string = output.decode('utf-8').strip()
    except BaseException:
        git_string = 'Unknown'

    print("{}-{}".format(datetime.now().strftime('%Y-%m-%d_%H-%M-%S'),
          git_string))


if __name__ == '__main__':
    main()