build: Fix additional python2/3 issues

The generate_version_string script was only producing correct results
in python 2, not python 3.  The gyp file that references it explicitly
runs it in python3.  The shebang line of the script has been updated
to match.  The script itself has been updated such that it now works
correctly in both python2 and python3.

Scripts that are only used as modules (not executed directly) have had
their shebang lines removed.

This fixes CI failures on GitHub Actions.

Change-Id: I309bafd2fb05e8fb33f5e092ead179c8c42ea5d3
This commit is contained in:
Joey Parrish 2021-08-26 09:44:02 -07:00
parent cd018a71c3
commit 249c83f14b
3 changed files with 4 additions and 8 deletions

View File

@ -1,5 +1,3 @@
#!/usr/bin/python
#
# Copyright 2014 Google Inc. All Rights Reserved. # Copyright 2014 Google Inc. All Rights Reserved.
# #
# Use of this source code is governed by a BSD-style # Use of this source code is governed by a BSD-style

View File

@ -1,5 +1,3 @@
#!/usr/bin/python
#
# Copyright 2014 Google Inc. All Rights Reserved. # Copyright 2014 Google Inc. All Rights Reserved.
# #
# Use of this source code is governed by a BSD-style # Use of this source code is governed by a BSD-style

View File

@ -1,4 +1,4 @@
#!/usr/bin/python #!/usr/bin/python3
# #
# Copyright 2015 Google Inc. All rights reserved. # Copyright 2015 Google Inc. All rights reserved.
# #
@ -12,7 +12,7 @@ import subprocess
if __name__ == '__main__': if __name__ == '__main__':
try: try:
version_tag = subprocess.check_output('git tag --points-at HEAD', version_tag = subprocess.check_output('git tag --points-at HEAD',
stderr=subprocess.STDOUT, shell=True).rstrip() stderr=subprocess.STDOUT, shell=True).decode().rstrip()
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
# git tag --points-at is not supported in old versions of git. Just ignore # git tag --points-at is not supported in old versions of git. Just ignore
# version_tag in this case. # version_tag in this case.
@ -20,11 +20,11 @@ if __name__ == '__main__':
try: try:
version_hash = subprocess.check_output('git rev-parse --short HEAD', version_hash = subprocess.check_output('git rev-parse --short HEAD',
stderr=subprocess.STDOUT, shell=True).rstrip() stderr=subprocess.STDOUT, shell=True).decode().rstrip()
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
version_hash = 'unknown-version' version_hash = 'unknown-version'
if version_tag: if version_tag:
print('{0}-{1}'.format(version_tag, version_hash)) print('{0}-{1}'.format(version_tag, version_hash))
else: else:
print(version_hash.decode('utf8')) print(version_hash)