-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVersioning
More file actions
44 lines (36 loc) · 1.26 KB
/
Versioning
File metadata and controls
44 lines (36 loc) · 1.26 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
# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python:
import os, sys
import re
builder.SetBuildFolder('/')
includes = builder.AddFolder('includes')
argv = [
sys.executable,
os.path.join(builder.sourcePath, 'tools', 'buildbot', 'generate_headers.py'),
os.path.join(builder.sourcePath),
os.path.join(builder.buildPath, 'includes'),
]
outputs = [
os.path.join(builder.buildFolder, 'includes', 'nps_version_auto.inc'),
]
with open(os.path.join(builder.sourcePath, '.git', 'HEAD')) as fp:
head_contents = fp.read().strip()
if re.search('^[a-fA-F0-9]{40}$', head_contents):
git_head_path = os.path.join(builder.sourcePath, '.git', 'HEAD')
else:
git_state = head_contents.split(':')[1].strip()
git_head_path = os.path.join(builder.sourcePath, '.git', git_state)
if not os.path.exists(git_head_path):
git_head_path = os.path.join(builder.sourcePath, '.git', 'HEAD')
sources = [
os.path.join(builder.sourcePath, 'product.version'),
# This is a hack, but we need some way to only run this script when Git changes.
git_head_path,
# The script source is a dependency, of course...
argv[1]
]
cmd_node, output_nodes = builder.AddCommand(
inputs=sources,
argv=argv,
outputs=outputs
)
rvalue = output_nodes