1414# never gets added to the protocol config object by init_defaults().
1515#
1616# Solution:
17- # 1. Modify Protocol.__init__() to accept config_file parameter
18- # 2. Compute protocol path from config file location when missing
19- # 3. Use computed path directly without modifying namedtuple
17+ # 1. Compute protocol path in main() before creating Protocol object
18+ # 2. Add path to config.protocol namedtuple using _replace()
19+ # 3. Pass updated config to Protocol.__init__()
20+ # 4. Use protocol.config.protocol.path in main() for inputs
2021#
2122# Original error:
2223# AttributeError: 'X' object has no attribute 'path'
23- # At: code_generator.py:365 in Protocol.__init__
24+ # At: code_generator.py:365 in Protocol.__init__() and line 635 in main()
2425#
2526# References:
2627# - Node.js v24 gyp build system Windows argument passing
@@ -30,38 +31,25 @@ diff --git a/deps/v8/third_party/inspector_protocol/code_generator.py b/deps/v8/
3031index b1bedb58..c702516a 100755
3132--- a/deps/v8/third_party/inspector_protocol/code_generator.py
3233+++ b/deps/v8/third_party/inspector_protocol/code_generator.py
33- @@ -357,12 +357,23 @@ def wrap_array_definition(type):
34-
35- class Protocol(object):
36-
37- - def __init__(self, config):
38- + def __init__(self, config, config_file=None):
39- self.config = config
40- self.json_api = {"domains": []}
41- self.imported_domains = []
42- self.exported_domains = []
43- - self.generate_domains = self.read_protocol_file(config.protocol.path)
44- + # Windows gyp-win-tool may fail to pass --config_value correctly.
45- + # Fall back to computing the path from the config file location.
46- + if hasattr(config.protocol, 'path'):
47- + protocol_path = config.protocol.path
48- + else:
49- + # Compute path from config file: deps/v8/src/inspector -> deps/v8/include
50- + if config_file:
51- + config_dir = os.path.dirname(config_file)
52- + protocol_path = os.path.normpath(os.path.join(config_dir, '../../include/js_protocol.pdl'))
53- + else:
54- + raise Exception("config.protocol.path not set and config_file not provided")
55- + self.generate_domains = self.read_protocol_file(protocol_path)
56-
57- if config.protocol.options:
58- self.generate_domains = [rule.domain for rule in config.protocol.options]
59- @@ -604,7 +615,7 @@ class Protocol(object):
34+ @@ -604,8 +604,20 @@ class Protocol(object):
6035 def main():
6136 jinja_dir, config_file, config = read_config()
62-
37+
6338- protocol = Protocol(config)
64- + protocol = Protocol(config, config_file)
65-
39+ + # Windows gyp-win-tool may fail to pass --config_value correctly.
40+ + # Fall back to computing the path from the config file location.
41+ + if not hasattr(config.protocol, 'path'):
42+ + # Compute path from config file: deps/v8/src/inspector -> deps/v8/include
43+ + if config_file:
44+ + config_dir = os.path.dirname(config_file)
45+ + protocol_path = os.path.normpath(os.path.join(config_dir, '../../include/js_protocol.pdl'))
46+ + # Add path to config.protocol so Protocol.__init__() and later code can use it
47+ + protocol_obj = config.protocol._replace(path=protocol_path) if hasattr(config.protocol, '_replace') else config.protocol
48+ + config = config._replace(protocol=protocol_obj) if hasattr(config, '_replace') else config
49+ + else:
50+ + raise Exception("config.protocol.path not set and config_file not provided")
51+
52+ + protocol = Protocol(config)
53+ +
6654 if not config.exported and len(protocol.exported_domains):
6755 sys.stderr.write(("Domains [%s] are exported, but config is missing export "
0 commit comments