mirror of
https://github.com/chromium/crashpad.git
synced 2024-12-31 01:43:03 +08:00
a5a1c3b07f
% yapf --in-place $(git ls-files **/*.py)
% yapf --version
yapf 0.30.0
Note that this is not using the “chromium” yapf style because Chromium
is moving to PEP-8.
https://groups.google.com/a/chromium.org/d/topic/chromium-dev/RcJgJdkNIdg
yapf 0.30.0 no longer recognizes “chromium” as a style option.
22ef70f3c4
Since this is a mass reformatting, it might as well move things all the
way into the future all at once.
This uses the “google” style, which is a superset of “pep8”.
Change-Id: Ifa37371079ea1859e4afe8e31d2eef2cfd7af384
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2165637
Commit-Queue: Mark Mentovai <mark@chromium.org>
Reviewed-by: Scott Graham <scottmg@chromium.org>
92 lines
2.9 KiB
Python
Executable File
92 lines
2.9 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
# Copyright 2019 The Crashpad Authors. All rights reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import argparse
|
|
import collections
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
MigInterface = collections.namedtuple(
|
|
'MigInterface', ['user_c', 'server_c', 'user_h', 'server_h'])
|
|
|
|
|
|
def generate_interface(defs,
|
|
interface,
|
|
includes=[],
|
|
sdk=None,
|
|
clang_path=None,
|
|
mig_path=None,
|
|
migcom_path=None,
|
|
arch=None):
|
|
if mig_path is None:
|
|
mig_path = 'mig'
|
|
|
|
# yapf: disable
|
|
command = [
|
|
mig_path,
|
|
'-user', interface.user_c,
|
|
'-server', interface.server_c,
|
|
'-header', interface.user_h,
|
|
'-sheader', interface.server_h,
|
|
]
|
|
# yapf: enable
|
|
|
|
if clang_path is not None:
|
|
os.environ['MIGCC'] = clang_path
|
|
if migcom_path is not None:
|
|
os.environ['MIGCOM'] = migcom_path
|
|
if arch is not None:
|
|
command.extend(['-arch', arch])
|
|
if sdk is not None:
|
|
command.extend(['-isysroot', sdk])
|
|
for include in includes:
|
|
command.extend(['-I' + include])
|
|
command.append(defs)
|
|
subprocess.check_call(command)
|
|
|
|
|
|
def parse_args(args):
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument('--clang-path', help='Path to Clang')
|
|
parser.add_argument('--mig-path', help='Path to mig')
|
|
parser.add_argument('--migcom-path', help='Path to migcom')
|
|
parser.add_argument('--arch', help='Target architecture')
|
|
parser.add_argument('--sdk', help='Path to SDK')
|
|
parser.add_argument('--include',
|
|
default=[],
|
|
action='append',
|
|
help='Additional include directory')
|
|
parser.add_argument('defs')
|
|
parser.add_argument('user_c')
|
|
parser.add_argument('server_c')
|
|
parser.add_argument('user_h')
|
|
parser.add_argument('server_h')
|
|
return parser.parse_args(args)
|
|
|
|
|
|
def main(args):
|
|
parsed = parse_args(args)
|
|
interface = MigInterface(parsed.user_c, parsed.server_c, parsed.user_h,
|
|
parsed.server_h)
|
|
generate_interface(parsed.defs, interface, parsed.include, parsed.sdk,
|
|
parsed.clang_path, parsed.mig_path, parsed.migcom_path,
|
|
parsed.arch)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
sys.exit(main(sys.argv[1:]))
|