Commit 4df02c1e by Jamie Madill

Fix commit header generation on non-Windows platforms.

Previously we relied on a batch file, which for obvious reasons isn't cross-platform. BUG=angle:529 Change-Id: Ia1e3944f8ed2096773e68c39d48ae2dd7370897b Reviewed-on: https://chromium-review.googlesource.com/186974Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 16af1e41
...@@ -85,6 +85,28 @@ ...@@ -85,6 +85,28 @@
} }
] # targets ] # targets
} }
] ],
[
'OS!="win"',
{
'targets':
[
{
'target_name': 'commit_id',
'type': 'none',
'actions':
[
{
'action_name': 'Generate Commit ID Header',
'message': 'Generating commit ID header...',
'inputs': [ 'commit_id.py' ],
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/commit.h'],
'action': ['python', '<(angle_relative_src_path)commit_id.py', '<(SHARED_INTERMEDIATE_DIR)/commit.h'],
}
] #actions
},
]
}
],
] # conditions ] # conditions
} }
import subprocess as sp
import sys
def grab_output(*command):
return sp.Popen(command, stdout=sp.PIPE).communicate()[0].strip()
commit_id_size = 12
try:
commit_id = grab_output('gat', 'rev-parse', '--short=%d' % commit_id_size, 'HEAD')
commit_date = grab_output('git', 'show', '-s', '--format=%ci', 'HEAD')
except:
commit_id = 'invalid-hash'
commit_date = 'invalid-date'
hfile = open(sys.argv[1], 'w')
hfile.write('#define ANGLE_COMMIT_HASH "%s"\n' % commit_id)
hfile.write('#define ANGLE_COMMIT_HASH_SIZE %d\n' % commit_id_size)
hfile.write('#define ANGLE_COMMIT_DATE "%s"\n' % commit_date)
hfile.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment