Fix dawn_version_generator.py on Windows when not using depot_tools
Find git using shutil.which() so extensions are resolved according to PATHEXT. Remove the "print(e)" that is breaking the expected output. Bug: dawn:1383 Change-Id: If299b744add0797036598129e08ba7d8c64002e1 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/87481 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Loko Kung <lokokung@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Loko Kung <lokokung@google.com>
This commit is contained in:
parent
aacad7c65e
commit
4e1c65d030
|
@ -13,13 +13,17 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import os, subprocess, sys
|
import os, subprocess, sys, shutil
|
||||||
|
|
||||||
from generator_lib import Generator, run_generator, FileRender
|
from generator_lib import Generator, run_generator, FileRender
|
||||||
|
|
||||||
|
|
||||||
def get_git():
|
def get_git():
|
||||||
return "git.bat" if sys.platform == "win32" else "git"
|
# Will find git, git.exe, git.bat...
|
||||||
|
git_exec = shutil.which("git")
|
||||||
|
if not git_exec:
|
||||||
|
raise Exception("No git executable found")
|
||||||
|
|
||||||
|
return git_exec
|
||||||
|
|
||||||
|
|
||||||
def get_gitHash(dawnDir):
|
def get_gitHash(dawnDir):
|
||||||
|
@ -61,10 +65,9 @@ def get_gitResolvedHead(dawnDir):
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[get_git(), "rev-parse", "--symbolic-full-name", "HEAD"],
|
[get_git(), "rev-parse", "--symbolic-full-name", "HEAD"],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
cwd=dawnDir,
|
cwd=dawnDir)
|
||||||
)
|
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
raise Exception("Failed to execute git rev-parse to resolve git head.")
|
raise Exception("Failed to execute git rev-parse to resolve git head:", result.stdout)
|
||||||
|
|
||||||
resolved = os.path.join(dawnDir, ".git",
|
resolved = os.path.join(dawnDir, ".git",
|
||||||
result.stdout.decode("utf-8").strip())
|
result.stdout.decode("utf-8").strip())
|
||||||
|
@ -102,8 +105,7 @@ class DawnVersionGenerator(Generator):
|
||||||
if gitExists(dawnDir):
|
if gitExists(dawnDir):
|
||||||
try:
|
try:
|
||||||
return [get_gitHead(dawnDir)] + get_gitResolvedHead(dawnDir)
|
return [get_gitHead(dawnDir)] + get_gitResolvedHead(dawnDir)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
print(e)
|
|
||||||
return []
|
return []
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue