Commit 4a9ec2ef by Robert Liao Committed by Commit Bot

Revert "Always use commit_id.py to generate commit.h"

This reverts commit 4dc19c38. Causes a git error during 'gn gen': fatal: this operation must be run in a work tree BUG=chromium:1055991,angleproject:2344 Change-Id: I74dd36d557dcaf1bd1b13264d806a1c6b09e1a56 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2073200Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent a1ceb87b
...@@ -54,6 +54,15 @@ if (ozone_platform_gbm) { ...@@ -54,6 +54,15 @@ if (ozone_platform_gbm) {
} }
} }
angle_git_is_present = exec_script("src/commit_id.py",
[
"check",
rebase_path(".", root_build_dir),
],
"value")
angle_use_commit_id = angle_git_is_present == 1
import("src/compiler.gni") import("src/compiler.gni")
import("src/libGLESv2.gni") import("src/libGLESv2.gni")
...@@ -457,33 +466,29 @@ config("commit_id_config") { ...@@ -457,33 +466,29 @@ config("commit_id_config") {
visibility = [ ":commit_id" ] visibility = [ ":commit_id" ]
} }
commit_id_output_file = "$root_gen_dir/angle/commit.h" commit_id_output_file = "$root_gen_dir/angle/id/commit.h"
action("commit_id") { if (angle_use_commit_id) {
script = "src/commit_id.py" action("commit_id") {
outputs = [ commit_id_output_file ] script = "src/commit_id.py"
outputs = [ commit_id_output_file ]
# commit id should depend on angle's HEAD revision # commit id should depend on angle's HEAD revision
commit_id_git_dep = ".git/HEAD" inputs = [ ".git/HEAD" ]
# Add git as a dependency if it is available. args = [
angle_git_is_present = "gen",
exec_script("src/commit_id.py", rebase_path(".", root_build_dir),
[ rebase_path(commit_id_output_file, root_build_dir),
"check", ]
rebase_path(commit_id_git_dep, root_build_dir),
],
"value") == 1
if (angle_git_is_present) {
inputs = [ commit_id_git_dep ]
}
args = [
"gen",
rebase_path(commit_id_git_dep, root_build_dir),
rebase_path(commit_id_output_file, root_build_dir),
]
public_configs = [ ":commit_id_config" ] public_configs = [ ":commit_id_config" ]
}
} else {
copy("commit_id") {
sources = [ "src/commit.h" ]
outputs = [ commit_id_output_file ]
public_configs = [ ":commit_id_config" ]
}
} }
angle_source_set("angle_version") { angle_source_set("angle_version") {
......
//
// Copyright 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// commit.h:
// This is a default commit hash header, when git is not available.
//
#define ANGLE_COMMIT_HASH "unknown hash"
#define ANGLE_COMMIT_HASH_SIZE 12
#define ANGLE_COMMIT_DATE "unknown date"
#define ANGLE_DISABLE_PROGRAM_BINARY_LOAD
...@@ -23,17 +23,13 @@ if len(sys.argv) < 3: ...@@ -23,17 +23,13 @@ if len(sys.argv) < 3:
sys.exit(usage) sys.exit(usage)
operation = sys.argv[1] operation = sys.argv[1]
if os.path.isdir(sys.argv[2]): cwd = sys.argv[2]
cwd = sys.argv[2]
else:
cwd = os.path.dirname(sys.argv[2])
if operation == 'check': if operation == 'check':
try: index_path = os.path.join(cwd, '.git', 'index')
# Try a git command to verify the cwd is valid and we can use the 'gen command' if os.path.exists(index_path):
grab_output('git status', cwd)
print("1") print("1")
except: else:
print("0") print("0")
sys.exit(0) sys.exit(0)
...@@ -42,15 +38,13 @@ if len(sys.argv) < 4 or operation != 'gen': ...@@ -42,15 +38,13 @@ if len(sys.argv) < 4 or operation != 'gen':
output_file = sys.argv[3] output_file = sys.argv[3]
commit_id_size = 12 commit_id_size = 12
commit_id = 'unknown hash'
commit_date = 'unknown date'
additional_defines = []
try: try:
commit_id = grab_output('git rev-parse --short=%d HEAD' % commit_id_size, cwd) commit_id = grab_output('git rev-parse --short=%d HEAD' % commit_id_size, cwd)
commit_date = grab_output('git show -s --format=%ci HEAD', cwd) commit_date = grab_output('git show -s --format=%ci HEAD', cwd)
except: except:
additional_defines.append('#define ANGLE_DISABLE_PROGRAM_BINARY_LOAD') commit_id = 'invalid-hash'
commit_date = 'invalid-date'
hfile = open(output_file, 'w') hfile = open(output_file, 'w')
...@@ -58,7 +52,4 @@ hfile.write('#define ANGLE_COMMIT_HASH "%s"\n' % commit_id) ...@@ -58,7 +52,4 @@ 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_HASH_SIZE %d\n' % commit_id_size)
hfile.write('#define ANGLE_COMMIT_DATE "%s"\n' % commit_date) hfile.write('#define ANGLE_COMMIT_DATE "%s"\n' % commit_date)
for additional_define in additional_defines:
hfile.write(additional_define + '\n')
hfile.close() hfile.close()
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#ifndef COMMON_VERSION_H_ #ifndef COMMON_VERSION_H_
#define COMMON_VERSION_H_ #define COMMON_VERSION_H_
#include "commit.h" #include "id/commit.h"
#define ANGLE_MAJOR_VERSION 2 #define ANGLE_MAJOR_VERSION 2
#define ANGLE_MINOR_VERSION 1 #define ANGLE_MINOR_VERSION 1
......
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