mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
gn build: Use "git rev-parse --git-dir" to discover the path to the .git directory.
This makes it compatible with worktrees. Differential Revision: https://reviews.llvm.org/D56422 llvm-svn: 350897
This commit is contained in:
parent
0bf824134a
commit
a112e209cc
@ -12,7 +12,6 @@ import sys
|
|||||||
|
|
||||||
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
|
THIS_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||||
LLVM_DIR = os.path.dirname(os.path.dirname(os.path.dirname(THIS_DIR)))
|
LLVM_DIR = os.path.dirname(os.path.dirname(os.path.dirname(THIS_DIR)))
|
||||||
MONO_DIR = os.path.dirname(LLVM_DIR)
|
|
||||||
|
|
||||||
|
|
||||||
def which(program):
|
def which(program):
|
||||||
@ -36,21 +35,23 @@ def main():
|
|||||||
if os.path.isdir(os.path.join(LLVM_DIR, '.svn')):
|
if os.path.isdir(os.path.join(LLVM_DIR, '.svn')):
|
||||||
print('SVN support not implemented', file=sys.stderr)
|
print('SVN support not implemented', file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
if os.path.isdir(os.path.join(LLVM_DIR, '.git')):
|
if os.path.exists(os.path.join(LLVM_DIR, '.git')):
|
||||||
print('non-mono-repo git support not implemented', file=sys.stderr)
|
print('non-mono-repo git support not implemented', file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
git_dir = os.path.join(MONO_DIR, '.git')
|
|
||||||
if not os.path.isdir(git_dir):
|
|
||||||
print('.git dir not found at "%s"' % git_dir, file=sys.stderr)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
git, use_shell = which('git'), False
|
git, use_shell = which('git'), False
|
||||||
if not git:
|
if not git:
|
||||||
git = which('git.exe')
|
git = which('git.exe')
|
||||||
if not git:
|
if not git:
|
||||||
git = which('git.bat')
|
git = which('git.bat')
|
||||||
use_shell = True
|
use_shell = True
|
||||||
|
|
||||||
|
git_dir = subprocess.check_output([git, 'rev-parse', '--git-dir'],
|
||||||
|
cwd=LLVM_DIR, shell=use_shell).strip()
|
||||||
|
if not os.path.isdir(git_dir):
|
||||||
|
print('.git dir not found at "%s"' % git_dir, file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
rev = subprocess.check_output([git, 'rev-parse', '--short', 'HEAD'],
|
rev = subprocess.check_output([git, 'rev-parse', '--short', 'HEAD'],
|
||||||
cwd=git_dir, shell=use_shell).decode().strip()
|
cwd=git_dir, shell=use_shell).decode().strip()
|
||||||
# FIXME: add pizzas such as the svn revision read off a git note?
|
# FIXME: add pizzas such as the svn revision read off a git note?
|
||||||
|
Loading…
Reference in New Issue
Block a user