|
18 | 18 | 'code_generator.py', |
19 | 19 | 'concatenate_protocols.py', |
20 | 20 | 'convert_protocol_to_json.py', |
21 | | - 'encoding/encoding.h', |
22 | | - 'encoding/encoding.cc', |
23 | | - 'encoding/encoding_test.cc', |
| 21 | + 'crdtp/*', |
24 | 22 | 'inspector_protocol.gni', |
25 | 23 | 'inspector_protocol.gypi', |
26 | 24 | 'lib/*', |
27 | 25 | 'pdl.py', |
28 | 26 | 'templates/*', |
29 | 27 | ] |
30 | 28 |
|
| 29 | +REVISION_LINE_PREFIX = 'Revision: ' |
31 | 30 |
|
32 | 31 | def RunCmd(cmd): |
33 | 32 | p = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
34 | 33 | (stdoutdata, stderrdata) = p.communicate() |
35 | 34 | if p.returncode != 0: |
36 | 35 | raise Exception('%s: exit status %d', str(cmd), p.returncode) |
37 | | - return stdoutdata |
| 36 | + return stdoutdata.decode('utf-8') |
38 | 37 |
|
39 | 38 |
|
40 | 39 | def CheckRepoIsClean(path, suffix): |
@@ -48,25 +47,18 @@ def CheckRepoIsClean(path, suffix): |
48 | 47 | raise Exception('%s does not end with /%s' % (path, suffix)) |
49 | 48 |
|
50 | 49 |
|
51 | | -def CheckRepoIsNotAtMasterBranch(path): |
| 50 | +def CheckRepoIsNotAtMainBranch(path): |
52 | 51 | os.chdir(path) |
53 | 52 | stdout = RunCmd(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip() |
54 | | - if stdout == 'master': |
55 | | - raise Exception('%s is at master branch - refusing to copy there.' % path) |
56 | | - |
57 | | - |
58 | | -def CheckRepoIsV8Checkout(path): |
59 | | - os.chdir(path) |
60 | | - if (RunCmd(['git', 'config', '--get', 'remote.origin.url']).strip() != |
61 | | - 'https://chromium.googlesource.com/v8/v8.git'): |
62 | | - raise Exception('%s is not a proper V8 checkout.' % path) |
| 53 | + if stdout == 'main': |
| 54 | + raise Exception('%s is at main branch - refusing to copy there.' % path) |
63 | 55 |
|
64 | 56 |
|
65 | 57 | def CheckRepoIsInspectorProtocolCheckout(path): |
66 | 58 | os.chdir(path) |
67 | | - if (RunCmd(['git', 'config', '--get', 'remote.origin.url']).strip() != |
68 | | - 'https://chromium.googlesource.com/deps/inspector_protocol.git'): |
69 | | - raise Exception('%s is not a proper inspector_protocol checkout.' % path) |
| 59 | + revision = RunCmd(['git', 'config', '--get', 'remote.origin.url']).strip() |
| 60 | + if (revision != 'https://chromium.googlesource.com/deps/inspector_protocol.git'): |
| 61 | + raise Exception('%s is not a proper inspector_protocol checkout: %s' % (path, revision)) |
70 | 62 |
|
71 | 63 |
|
72 | 64 | def FindFilesToSyncIn(path): |
@@ -83,21 +75,34 @@ def FilesAreEqual(path1, path2): |
83 | 75 | open(path1).read() == open(path2).read()) |
84 | 76 |
|
85 | 77 |
|
| 78 | +def ReadV8IPRevision(node_src_path): |
| 79 | + lines = open(os.path.join(node_src_path, 'deps/v8/third_party/inspector_protocol/README.v8')).readlines() |
| 80 | + for line in lines: |
| 81 | + line = line.strip() |
| 82 | + if line.startswith(REVISION_LINE_PREFIX): |
| 83 | + return line[len(REVISION_LINE_PREFIX):] |
| 84 | + raise Exception('No V8 inspector protocol revision found') |
| 85 | + |
| 86 | +def CheckoutRevision(path, revision): |
| 87 | + os.chdir(path) |
| 88 | + return RunCmd(['git', 'checkout', revision]) |
| 89 | + |
| 90 | + |
86 | 91 | def GetHeadRevision(path): |
87 | 92 | os.chdir(path) |
88 | 93 | return RunCmd(['git', 'rev-parse', 'HEAD']) |
89 | 94 |
|
90 | 95 |
|
91 | 96 | def main(argv): |
92 | 97 | parser = argparse.ArgumentParser(description=( |
93 | | - "Rolls the inspector_protocol project (upstream) into V8's " |
94 | | - "third_party (downstream).")) |
| 98 | + "Rolls the inspector_protocol project (upstream) into node's " |
| 99 | + "tools/inspector_protocol (downstream).")) |
95 | 100 | parser.add_argument("--ip_src_upstream", |
96 | 101 | help="The inspector_protocol (upstream) tree.", |
97 | 102 | default="~/ip/src") |
98 | | - parser.add_argument("--v8_src_downstream", |
99 | | - help="The V8 src tree.", |
100 | | - default="~/v8/v8") |
| 103 | + parser.add_argument("--node_src_downstream", |
| 104 | + help="The nodejs/node src tree.", |
| 105 | + default="~/nodejs/node") |
101 | 106 | parser.add_argument('--force', dest='force', action='store_true', |
102 | 107 | help=("Whether to carry out the modifications " |
103 | 108 | "in the destination tree.")) |
@@ -106,17 +111,22 @@ def main(argv): |
106 | 111 | args = parser.parse_args(argv) |
107 | 112 | upstream = os.path.normpath(os.path.expanduser(args.ip_src_upstream)) |
108 | 113 | downstream = os.path.normpath(os.path.expanduser( |
109 | | - args.v8_src_downstream)) |
| 114 | + args.node_src_downstream)) |
110 | 115 | CheckRepoIsClean(upstream, '/src') |
111 | | - CheckRepoIsClean(downstream, '/v8') |
| 116 | + CheckRepoIsClean(downstream, '/node') |
112 | 117 | CheckRepoIsInspectorProtocolCheckout(upstream) |
113 | | - CheckRepoIsV8Checkout(downstream) |
114 | | - # Check that the destination Git repo isn't at the master branch - it's |
115 | | - # generally a bad idea to check into the master branch, so we catch this |
| 118 | + # Check that the destination Git repo isn't at the main branch - it's |
| 119 | + # generally a bad idea to check into the main branch, so we catch this |
116 | 120 | # common pilot error here early. |
117 | | - CheckRepoIsNotAtMasterBranch(downstream) |
| 121 | + CheckRepoIsNotAtMainBranch(downstream) |
| 122 | + |
| 123 | + # Read V8's inspector_protocol revision |
| 124 | + v8_ip_revision = ReadV8IPRevision(downstream) |
| 125 | + print('Checking out %s into %s ...' % (upstream, v8_ip_revision)) |
| 126 | + CheckoutRevision(upstream, v8_ip_revision) |
| 127 | + |
118 | 128 | src_dir = upstream |
119 | | - dest_dir = os.path.join(downstream, 'third_party/inspector_protocol') |
| 129 | + dest_dir = os.path.join(downstream, 'tools/inspector_protocol') |
120 | 130 | print('Rolling %s into %s ...' % (src_dir, dest_dir)) |
121 | 131 | src_files = set(FindFilesToSyncIn(src_dir)) |
122 | 132 | dest_files = set(FindFilesToSyncIn(dest_dir)) |
@@ -137,22 +147,16 @@ def main(argv): |
137 | 147 | print('You said --force ... as you wish, modifying the destination.') |
138 | 148 | for f in to_add + to_copy: |
139 | 149 | contents = open(os.path.join(src_dir, f)).read() |
140 | | - contents = contents.replace( |
141 | | - 'INSPECTOR_PROTOCOL_ENCODING_ENCODING_H_', |
142 | | - 'V8_INSPECTOR_PROTOCOL_ENCODING_ENCODING_H_') |
143 | | - contents = contents.replace( |
144 | | - 'namespace inspector_protocol_encoding', |
145 | | - 'namespace v8_inspector_protocol_encoding') |
146 | 150 | open(os.path.join(dest_dir, f), 'w').write(contents) |
147 | 151 | shutil.copymode(os.path.join(src_dir, f), os.path.join(dest_dir, f)) |
148 | 152 | for f in to_delete: |
149 | 153 | os.unlink(os.path.join(dest_dir, f)) |
150 | 154 | head_revision = GetHeadRevision(upstream) |
151 | | - lines = open(os.path.join(dest_dir, 'README.v8')).readlines() |
152 | | - f = open(os.path.join(dest_dir, 'README.v8'), 'w') |
| 155 | + lines = open(os.path.join(dest_dir, 'README.node')).readlines() |
| 156 | + f = open(os.path.join(dest_dir, 'README.node'), 'w') |
153 | 157 | for line in lines: |
154 | | - if line.startswith('Revision: '): |
155 | | - f.write('Revision: %s' % head_revision) |
| 158 | + if line.startswith(REVISION_LINE_PREFIX): |
| 159 | + f.write(f'{REVISION_LINE_PREFIX}{head_revision}') |
156 | 160 | else: |
157 | 161 | f.write(line) |
158 | 162 | f.close() |
|