v8/gni/protoc.py
Sami Kyostila c65456bfa4 tracing: Initialize track events conditionally
If V8 is running in a context where Perfetto hasn't been initialized
(e.g., as part of mksnapshot), don't try to initialize track events
either.

Since perfetto::Tracing::IsInitialized() was only added recently, we
also roll Perfetto to the latest revision. This also requires updating
the proto_library GN template together with the underlying libprotobuf
dependency.

Bug: chromium:1006541
Change-Id: Icec626b7ed78264a81f1a80d73d60be3bde0d908
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2632590
Commit-Queue: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Hannes Payer <hpayer@chromium.org>
Reviewed-by: Peter Marshall <petermarshall@chromium.org>
Auto-Submit: Sami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72130}
2021-01-18 12:39:03 +00:00

52 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python
# Copyright 2021 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Script to wrap protoc execution.
This script exists to work-around the bad depfile generation by protoc when
generating descriptors."""
from __future__ import print_function
import argparse
import os
import sys
import subprocess
import tempfile
import uuid
from codecs import open
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--descriptor_set_out', default=None)
parser.add_argument('--dependency_out', default=None)
parser.add_argument('protoc')
args, remaining = parser.parse_known_args()
if args.dependency_out and args.descriptor_set_out:
tmp_path = os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))
custom = [
'--descriptor_set_out', args.descriptor_set_out, '--dependency_out',
tmp_path
]
try:
cmd = [args.protoc] + custom + remaining
subprocess.check_call(cmd)
with open(tmp_path, 'rb') as tmp_rd:
dependency_data = tmp_rd.read().decode('utf-8')
finally:
if os.path.exists(tmp_path):
os.unlink(tmp_path)
with open(args.dependency_out, 'w', encoding='utf-8') as f:
f.write(args.descriptor_set_out + ":")
f.write(dependency_data)
else:
subprocess.check_call(sys.argv[1:])
if __name__ == '__main__':
sys.exit(main())