-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathget_version.sh
More file actions
executable file
·40 lines (33 loc) · 843 Bytes
/
get_version.sh
File metadata and controls
executable file
·40 lines (33 loc) · 843 Bytes
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
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
#
# SPDX-License-Identifier: GPL-2.0
#
# Copyright (c) 2018 Intel Corporation
#
# Authors: Fengguang Wu <fengguang.wu@intel.com>
# Yao Yuan <yuan.yao@intel.com>
#
commit=$(git rev-list -1 HEAD)
diff=$(git diff HEAD)
if [[ -n "$diff" ]]; then
diff_sum=+$(echo "$diff" | md5sum | cut -f1 -d ' ')
diff_stat=$(echo "$diff" | diffstat | sed 's/$/\\n\\/')
diff_stat="\n\\"$'\n'"${diff_stat::-3}"
else
diff_sum=
diff_stat=
fi
cat > version.h <<EOF
#ifndef _AEP_VERSION_H_
#define _AEP_VERSION_H_
// auto generated by get_version.sh
#define VERSION_TIME "$(date +'%F %T')"
#define VERSION_COMMIT "$commit"
#define VERSION_DIFFSUM "$diff_sum"
#define VERSION_DIFFSTAT "$diff_stat"
void print_version()
{
printf("%s\n", VERSION_TIME " " VERSION_COMMIT VERSION_DIFFSUM VERSION_DIFFSTAT);
}
#endif
EOF