Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(481)

Side by Side Diff: third_party/WebKit/Source/build/scripts/make_instrumenting_probes.py

Issue 2329463004: ABANDONED CL: Changes needed to make things compile after running rewrite_to_chrome_style tool. (Closed)
Patch Set: More fixes - things build fine at this point. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2017 The Chromium Authors. All rights reserved. 1 # Copyright 2017 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import ast 5 import ast
6 import optparse 6 import optparse
7 import os.path 7 import os.path
8 import re 8 import re
9 import sys 9 import sys
10 10
11 # Path handling for libraries and templates 11 # Path handling for libraries and templates
12 # Paths have to be normalized because Jinja uses the exact template path to 12 # Paths have to be normalized because Jinja uses the exact template path to
13 # determine the hash used in the cache filename, and we need a pre-caching step 13 # determine the hash used in the cache filename, and we need a pre-caching step
14 # to be concurrency-safe. Use absolute path because __file__ is absolute if 14 # to be concurrency-safe. Use absolute path because __file__ is absolute if
15 # module is imported, and relative if executed directly. 15 # module is imported, and relative if executed directly.
16 # If paths differ between pre-caching and individual file compilation, the cache 16 # If paths differ between pre-caching and individual file compilation, the cache
17 # is regenerated, which causes a race condition and breaks concurrent build, 17 # is regenerated, which causes a race condition and breaks concurrent build,
18 # since some compile processes will try to read the partially written cache. 18 # since some compile processes will try to read the partially written cache.
19 module_path, module_filename = os.path.split(os.path.realpath(__file__)) 19 module_path, module_filename = os.path.split(os.path.realpath(__file__))
20 third_party_dir = os.path.normpath(os.path.join(module_path, os.pardir, os.pardi r, os.pardir, os.pardir)) 20 third_party_dir = os.path.normpath(os.path.join(module_path, os.pardir, os.pardi r, os.pardir, os.pardir))
21 # jinja2 is in chromium's third_party directory. 21 # jinja2 is in chromium's third_party directory.
22 # Insert at 1 so at front to override system libraries, and 22 # Insert at 1 so at front to override system libraries, and
23 # after path[0] == invoking script dir 23 # after path[0] == invoking script dir
24 sys.path.insert(1, third_party_dir) 24 sys.path.insert(1, third_party_dir)
25 import jinja2 25 import jinja2
26 26
27 from name_utilities import method_name
27 28
28 def _json5_loads(lines): 29 def _json5_loads(lines):
29 # Use json5.loads when json5 is available. Currently we use simple 30 # Use json5.loads when json5 is available. Currently we use simple
30 # regexs to convert well-formed JSON5 to PYL format. 31 # regexs to convert well-formed JSON5 to PYL format.
31 # Strip away comments and quote unquoted keys. 32 # Strip away comments and quote unquoted keys.
32 re_comment = re.compile(r"^\s*//.*$|//+ .*$", re.MULTILINE) 33 re_comment = re.compile(r"^\s*//.*$|//+ .*$", re.MULTILINE)
33 re_map_keys = re.compile(r"^\s*([$A-Za-z_][\w]*)\s*:", re.MULTILINE) 34 re_map_keys = re.compile(r"^\s*([$A-Za-z_][\w]*)\s*:", re.MULTILINE)
34 pyl = re.sub(re_map_keys, r"'\1':", re.sub(re_comment, "", lines)) 35 pyl = re.sub(re_map_keys, r"'\1':", re.sub(re_comment, "", lines))
35 # Convert map values of true/false to Python version True/False. 36 # Convert map values of true/false to Python version True/False.
36 re_true = re.compile(r":\s*true\b") 37 re_true = re.compile(r":\s*true\b")
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 base_name = os.path.splitext(os.path.basename(input_path))[0] 239 base_name = os.path.splitext(os.path.basename(input_path))[0]
239 240
240 fin = open(input_path, "r") 241 fin = open(input_path, "r")
241 files = load_model_from_idl(fin.read()) 242 files = load_model_from_idl(fin.read())
242 fin.close() 243 fin.close()
243 244
244 template_context = { 245 template_context = {
245 "files": files, 246 "files": files,
246 "agents": build_observers(), 247 "agents": build_observers(),
247 "config": config, 248 "config": config,
249 "method_name": method_name,
248 "name": base_name, 250 "name": base_name,
249 "input_file": os.path.basename(input_path) 251 "input_file": os.path.basename(input_path)
250 } 252 }
251 cpp_template = jinja_env.get_template("/InstrumentingProbesImpl.cpp.tmpl") 253 cpp_template = jinja_env.get_template("/InstrumentingProbesImpl.cpp.tmpl")
252 cpp_file = open(output_dirpath + "/" + base_name + "Impl.cpp", "w") 254 cpp_file = open(output_dirpath + "/" + base_name + "Impl.cpp", "w")
253 cpp_file.write(cpp_template.render(template_context)) 255 cpp_file.write(cpp_template.render(template_context))
254 cpp_file.close() 256 cpp_file.close()
255 257
256 sink_h_template = jinja_env.get_template("/ProbeSink.h.tmpl") 258 sink_h_template = jinja_env.get_template("/ProbeSink.h.tmpl")
257 sink_h_file = open(output_dirpath + "/" + to_singular(base_name) + "Sink.h", "w" ) 259 sink_h_file = open(output_dirpath + "/" + to_singular(base_name) + "Sink.h", "w" )
258 sink_h_file.write(sink_h_template.render(template_context)) 260 sink_h_file.write(sink_h_template.render(template_context))
259 sink_h_file.close() 261 sink_h_file.close()
260 262
261 for f in files: 263 for f in files:
262 template_context["file"] = f 264 template_context["file"] = f
263 h_template = jinja_env.get_template("/InstrumentingProbesInl.h.tmpl") 265 h_template = jinja_env.get_template("/InstrumentingProbesInl.h.tmpl")
264 h_file = open(output_dirpath + "/" + f.header_name + ".h", "w") 266 h_file = open(output_dirpath + "/" + f.header_name + ".h", "w")
265 h_file.write(h_template.render(template_context)) 267 h_file.write(h_template.render(template_context))
266 h_file.close() 268 h_file.close()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698