-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.py
executable file
·72 lines (55 loc) · 2.12 KB
/
update.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python3
import subprocess
import tempfile
import os
from pathlib import Path
def run(*command, capture=False, **kwargs):
command = list(map(str, command))
print(f'CMD: {" ".join(command)}')
stdout = subprocess.PIPE if capture else None
result = subprocess.run(command, stdout=stdout, **kwargs)
result.check_returncode()
if capture:
return result.stdout.decode('utf-8')
return None
def git(*command, capture=False):
return run('git', '-C', GIT_DIR, *command, capture=capture)
def step(title):
print('=' * 80)
print(title)
print('-' * 80)
DESTINATION = Path(__file__).parent
GIT_DIR = DESTINATION / '.v8'
step(f'Update V8 checkout in: {GIT_DIR}')
if not GIT_DIR.exists():
run('git', 'clone', 'https://chromium.googlesource.com/v8/v8.git', GIT_DIR)
git('fetch', '--all')
step('List branches')
BRANCHES = git('branch', '--all', '--list', '*-lkgr', '--format=%(refname)', capture=True).split()
BRANCHES = list(set(map(lambda ref: ref.split('/')[-1], BRANCHES)))
# Sort branches from old to new:
BRANCHES.sort(key=lambda branch: list(map(int, branch.split('-')[0].split('.'))))
BRANCHES.append('lkgr')
# List of branches that have potential back-merges and thus need updates:
BRANCHES_FORCE_BUILDS = set(BRANCHES[-4:])
print(BRANCHES)
for branch in BRANCHES:
step(f'Generating docs for branch: {branch}')
if branch == 'lkgr':
version_name = 'head'
else:
branch_name = branch.split('-')[0]
version_name = f'v{branch_name}'
branch_dir = DESTINATION / version_name
branch_dir.mkdir(exist_ok=True)
git('switch', '--force', '--detach', f'remotes/origin/{branch}')
git('clean', '--force', '-d')
doxyfile_path = DESTINATION / 'Doxyfile'
with open(doxyfile_path) as doxyfile:
doxyfile_data = doxyfile.read()
doxyfile_data += f"\nPROJECT_NUMBER={version_name}"
run('doxygen', '-', cwd=GIT_DIR, input=doxyfile_data.encode('utf-8'))
source = GIT_DIR / 'html'
run('rsync', '--itemize-changes', '--recursive',
'--checksum', f'{source}{os.sep}', f'{branch_dir}{os.sep}')
run('git', 'add', branch_dir)