Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 4dc19c3

Browse files
vontureCommit Bot
authored andcommitted
Always use commit_id.py to generate commit.h
commit_id_.py is capable of generating the default commit.h. This makes it so we always take a single path in gn. Remove the existing commit.h and generate it into the root generation folder (not the id subfolder) because Android blueprints can't handle generating into subfolders that don't exist. Make the <angle_dir> argument capable of taking a filename or directory name. This allows us to pass the .git/HEAD file which is a gn input. Android blueprints require all paths used as input or output to a script are listed as inputs or outputs in the genrule. BUG=angleproject:2344 Change-Id: Ifd9c8331f421586db6f2c6e17faf3242376e11d0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2070600 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
1 parent 74cc3a0 commit 4dc19c3

File tree

4 files changed

+40
-50
lines changed

4 files changed

+40
-50
lines changed

BUILD.gn

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,6 @@ if (ozone_platform_gbm) {
5454
}
5555
}
5656

57-
angle_git_is_present = exec_script("src/commit_id.py",
58-
[
59-
"check",
60-
rebase_path(".", root_build_dir),
61-
],
62-
"value")
63-
64-
angle_use_commit_id = angle_git_is_present == 1
65-
6657
import("src/compiler.gni")
6758
import("src/libGLESv2.gni")
6859

@@ -466,29 +457,33 @@ config("commit_id_config") {
466457
visibility = [ ":commit_id" ]
467458
}
468459

469-
commit_id_output_file = "$root_gen_dir/angle/id/commit.h"
470-
if (angle_use_commit_id) {
471-
action("commit_id") {
472-
script = "src/commit_id.py"
473-
outputs = [ commit_id_output_file ]
474-
475-
# commit id should depend on angle's HEAD revision
476-
inputs = [ ".git/HEAD" ]
460+
commit_id_output_file = "$root_gen_dir/angle/commit.h"
461+
action("commit_id") {
462+
script = "src/commit_id.py"
463+
outputs = [ commit_id_output_file ]
477464

478-
args = [
479-
"gen",
480-
rebase_path(".", root_build_dir),
481-
rebase_path(commit_id_output_file, root_build_dir),
482-
]
465+
# commit id should depend on angle's HEAD revision
466+
commit_id_git_dep = ".git/HEAD"
483467

484-
public_configs = [ ":commit_id_config" ]
485-
}
486-
} else {
487-
copy("commit_id") {
488-
sources = [ "src/commit.h" ]
489-
outputs = [ commit_id_output_file ]
490-
public_configs = [ ":commit_id_config" ]
468+
# Add git as a dependency if it is available.
469+
angle_git_is_present =
470+
exec_script("src/commit_id.py",
471+
[
472+
"check",
473+
rebase_path(commit_id_git_dep, root_build_dir),
474+
],
475+
"value") == 1
476+
if (angle_git_is_present) {
477+
inputs = [ commit_id_git_dep ]
491478
}
479+
480+
args = [
481+
"gen",
482+
rebase_path(commit_id_git_dep, root_build_dir),
483+
rebase_path(commit_id_output_file, root_build_dir),
484+
]
485+
486+
public_configs = [ ":commit_id_config" ]
492487
}
493488

494489
angle_source_set("angle_version") {

src/commit.h

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/commit_id.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ def grab_output(command, cwd):
2323
sys.exit(usage)
2424

2525
operation = sys.argv[1]
26-
cwd = sys.argv[2]
26+
if os.path.isdir(sys.argv[2]):
27+
cwd = sys.argv[2]
28+
else:
29+
cwd = os.path.dirname(sys.argv[2])
2730

2831
if operation == 'check':
29-
index_path = os.path.join(cwd, '.git', 'index')
30-
if os.path.exists(index_path):
32+
try:
33+
# Try a git command to verify the cwd is valid and we can use the 'gen command'
34+
grab_output('git status', cwd)
3135
print("1")
32-
else:
36+
except:
3337
print("0")
3438
sys.exit(0)
3539

@@ -38,18 +42,23 @@ def grab_output(command, cwd):
3842

3943
output_file = sys.argv[3]
4044
commit_id_size = 12
45+
commit_id = 'unknown hash'
46+
commit_date = 'unknown date'
4147

48+
additional_defines = []
4249
try:
4350
commit_id = grab_output('git rev-parse --short=%d HEAD' % commit_id_size, cwd)
4451
commit_date = grab_output('git show -s --format=%ci HEAD', cwd)
4552
except:
46-
commit_id = 'invalid-hash'
47-
commit_date = 'invalid-date'
53+
additional_defines.append('#define ANGLE_DISABLE_PROGRAM_BINARY_LOAD')
4854

4955
hfile = open(output_file, 'w')
5056

5157
hfile.write('#define ANGLE_COMMIT_HASH "%s"\n' % commit_id)
5258
hfile.write('#define ANGLE_COMMIT_HASH_SIZE %d\n' % commit_id_size)
5359
hfile.write('#define ANGLE_COMMIT_DATE "%s"\n' % commit_date)
5460

61+
for additional_define in additional_defines:
62+
hfile.write(additional_define + '\n')
63+
5564
hfile.close()

src/common/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#ifndef COMMON_VERSION_H_
88
#define COMMON_VERSION_H_
99

10-
#include "id/commit.h"
10+
#include "commit.h"
1111

1212
#define ANGLE_MAJOR_VERSION 2
1313
#define ANGLE_MINOR_VERSION 1

0 commit comments

Comments
 (0)