2014-02-09 04:37:33 +00:00
|
|
|
# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python:
|
|
|
|
import os, sys
|
2014-06-05 17:45:03 +00:00
|
|
|
import re
|
2014-02-09 04:37:33 +00:00
|
|
|
|
|
|
|
builder.SetBuildFolder('/')
|
|
|
|
|
|
|
|
includes = builder.AddFolder('includes')
|
|
|
|
|
|
|
|
argv = [
|
|
|
|
sys.executable,
|
|
|
|
os.path.join(builder.sourcePath, 'support', 'generate_headers.py'),
|
|
|
|
os.path.join(builder.sourcePath),
|
|
|
|
os.path.join(builder.buildPath, 'includes'),
|
|
|
|
]
|
|
|
|
outputs = [
|
2014-12-08 00:39:10 +00:00
|
|
|
os.path.join(builder.buildFolder, 'includes', 'amxmodx_version_auto.h'),
|
2014-02-09 04:37:33 +00:00
|
|
|
os.path.join(builder.buildFolder, 'includes', 'amxmodx_version.inc'),
|
|
|
|
]
|
|
|
|
|
|
|
|
with open(os.path.join(builder.sourcePath, '.git', 'HEAD')) as fp:
|
2014-06-05 17:45:03 +00:00
|
|
|
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')
|
2014-02-09 04:37:33 +00:00
|
|
|
|
|
|
|
sources = [
|
|
|
|
os.path.join(builder.sourcePath, 'product.version'),
|
|
|
|
|
2014-06-05 17:45:03 +00:00
|
|
|
# This is a hack, but we need some way to only run this script when Git changes.
|
2014-02-09 04:37:33 +00:00
|
|
|
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
|