-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathversion.py
More file actions
executable file
·62 lines (47 loc) · 1.63 KB
/
version.py
File metadata and controls
executable file
·62 lines (47 loc) · 1.63 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/python
import subprocess
template = """// GENERATED BY version.py
#ifndef version_hpp
#define version_hpp
#include <string>
const std::string CROWDSOUND_VERSION = "{}";
const std::string PLAYSOURCE_VERSION = "{}";
const std::string ALGORITHM_VERSION = "{}";
const std::string SKRILLEX_VERSION = "{}";
const std::string GRPC_VERSION = "{}";
#endif
"""
def get_git_revision_hash():
result = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD'])
result = str.strip(result.decode('utf-8'))
return result
def get_submodule_status():
result = subprocess.check_output(['git', 'submodule', 'status'])
result = str.strip(result.decode('utf-8')).split('\n')
statuses = {}
for l in result:
parts = str.strip(l).split(' ')
statuses[parts[1]] = parts[0][:7]
return statuses
if __name__ == "__main__":
submodules = get_submodule_status()
# Generate library version from git info
crowdsound_version = get_git_revision_hash()
algorithm_version = submodules['decisionalgorithm']
skrillex_version = submodules['skrillex']
# Playsource is hard coded, until we can hook up
# we can expose it dynamically (because it can change dynamically)
playsource_version = "48bfe14d3730c44b2b14b330d10a118eb626a258"[:7]
# gRPC version is hard coded, because determining it super
# hard, plus it rarely changes.
grpc_version = "0.11-1"
output = template.format(
crowdsound_version,
algorithm_version,
skrillex_version,
playsource_version,
grpc_version
)
f = open("src/version.hpp", "w")
f.write(output)
f.close()