diff options
author | Lei Zhang <antiagainst@google.com> | 2016-08-04 18:26:22 -0400 |
---|---|---|
committer | Lei Zhang <antiagainst@google.com> | 2016-08-05 10:23:41 -0400 |
commit | 0d8ddd0b759481945c87e9006f73b333158a06dd (patch) | |
tree | 7373282e8d704374e38d0a917e0aa13ec838e062 /utils | |
parent | c6465fb220f5a6a9daae84774903b64ade352b57 (diff) |
Create directory first if not existing and always refresh.
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/update_build_version.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/utils/update_build_version.py b/utils/update_build_version.py index 5e6d8964..9a3d5ac9 100755 --- a/utils/update_build_version.py +++ b/utils/update_build_version.py @@ -99,14 +99,22 @@ def main(): sys.exit(1) output_file = sys.argv[2] + output_dir = os.path.dirname(output_file) + if not os.path.isdir(output_dir): + os.makedirs(output_dir) software_version = deduce_software_version(sys.argv[1]) new_content = '"{}", "SPIRV-Tools {} {}"\n'.format( software_version, software_version, describe(sys.argv[1]).replace('"', '\\"')) - if os.path.isfile(output_file) and new_content == open(output_file, 'r').read(): - sys.exit(0) - open(output_file, 'w').write(new_content) + + if os.path.isfile(output_file): + with open(output_file, 'r') as f: + if new_content == f.read(): + return + + with open(output_file, 'w') as f: + f.write(new_content) if __name__ == '__main__': main() |