diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2019-08-13 11:48:15 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2019-08-13 11:48:15 +0000 |
| commit | 58f03f21286cc408f8bcf03fda1e197f9b6df0fc (patch) | |
| tree | de41406f516e25a3ba661d71e9e9fe1ebdb6444b /llvm | |
| parent | 7ed816badeba39ce4e1c025482969876880f3dfc (diff) | |
| download | bcm5719-llvm-58f03f21286cc408f8bcf03fda1e197f9b6df0fc.tar.gz bcm5719-llvm-58f03f21286cc408f8bcf03fda1e197f9b6df0fc.zip | |
gn build: Extract git() and git_out() functions in sync script
llvm-svn: 368671
Diffstat (limited to 'llvm')
| -rwxr-xr-x | llvm/utils/gn/build/sync_source_lists_from_cmake.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/llvm/utils/gn/build/sync_source_lists_from_cmake.py b/llvm/utils/gn/build/sync_source_lists_from_cmake.py index d695e48d2cf..bd321d15c7f 100755 --- a/llvm/utils/gn/build/sync_source_lists_from_cmake.py +++ b/llvm/utils/gn/build/sync_source_lists_from_cmake.py @@ -52,9 +52,10 @@ def patch_gn_file(gn_file, add, remove): def sync_source_lists(write): # Use shell=True on Windows in case git is a bat file. - git_want_shell = os.name == 'nt' - gn_files = subprocess.check_output(['git', 'ls-files', '*BUILD.gn'], - shell=git_want_shell).splitlines() + def git(args): subprocess.check_call(['git'] + args, shell=os.name == 'nt') + def git_out(args): + return subprocess.check_output(['git'] + args, shell=os.name == 'nt') + gn_files = git_out(['ls-files', '*BUILD.gn']).splitlines() # Matches e.g. | "foo.cpp",|, captures |foo| in group 1. gn_cpp_re = re.compile(r'^\s*"([^"]+\.(?:cpp|c|h|S))",$', re.MULTILINE) @@ -65,9 +66,8 @@ def sync_source_lists(write): changes_by_rev = defaultdict(lambda: defaultdict(lambda: defaultdict(list))) def find_gitrev(touched_line, in_file): - return subprocess.check_output( - ['git', 'log', '--format=%h', '-1', '-S' + touched_line, in_file], - shell=git_want_shell).rstrip() + return git_out( + ['log', '--format=%h', '-1', '-S' + touched_line, in_file]).rstrip() def svnrev_from_gitrev(gitrev): git_llvm = os.path.join( os.path.dirname(__file__), '..', '..', 'git-svn', 'git-llvm') @@ -111,8 +111,7 @@ def sync_source_lists(write): remove = data.get('remove', []) if write: patch_gn_file(gn_file, add, remove) - subprocess.check_call(['git', 'add', gn_file], - shell=git_want_shell) + git(['add', gn_file]) else: print(' ' + gn_file) if add: @@ -121,9 +120,7 @@ def sync_source_lists(write): print(' remove:\n ' + '\n '.join(remove)) print() if write: - subprocess.check_call( - ['git', 'commit', '-m', 'gn build: Merge r%d' % svnrev], - shell=git_want_shell) + git(['commit', '-m', 'gn build: Merge r%d' % svnrev]) else: print() |

