Skip to content

Commit

Permalink
[misc] Avoid unnecessary linking when git commit hash not changed (#871)
Browse files Browse the repository at this point in the history
* [misc] Avoid unnecessary linking when git commit hash not changed

* fix ci

* apply review
  • Loading branch information
yuanming-hu authored Apr 26, 2020
1 parent 9489a10 commit f3184a2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion misc/generate_commit_hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,16 @@
print(f"Building commit {commit_hash}")

output_fn = os.path.join(repo_dir, 'taichi/common/commit_hash.h')
content = f"#define TI_COMMIT_HASH \"{commit_hash}\"\n"

# First read the file to see if an update is needed
# This reduces unnecessary file changes/linkings
if os.path.exists(output_fn):
with open(output_fn, 'r') as f:
old_content = f.read()
if old_content == content:
# No update needed
exit(0)

with open(output_fn, 'w') as f:
f.write(f"#define TI_COMMIT_HASH \"{commit_hash}\"\n")
f.write(content)

0 comments on commit f3184a2

Please sign in to comment.