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

Unified Diff: third_party/class-dump/class-dump.py

Issue 1806523002: Add BUILD.gn rules to compile third_party/class-dump. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@compiler
Patch Set: Use ${host_toolchain} instead of //build/toolchain/mac:clang_x64 Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/class-dump/class-dump.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/class-dump/class-dump.py
diff --git a/third_party/class-dump/class-dump.py b/third_party/class-dump/class-dump.py
new file mode 100644
index 0000000000000000000000000000000000000000..42c13978bf8df07af693c40e1bbf91e717fa7305
--- /dev/null
+++ b/third_party/class-dump/class-dump.py
@@ -0,0 +1,55 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# Wrapper around class-dump to allow gn build to run the tool (as action
+# target can only run python scripts). Also filters the output to remove
+# all cxx_destruct lines that are not understood from class-dump output.
+
+import argparse
+import errno
+import os
+import subprocess
+import sys
+
+
+def Main(args):
+ parser = argparse.ArgumentParser('wrapper around class-dump')
+ parser.add_argument(
+ '-o', '--output', required=True,
+ help='name of the output file')
+ parser.add_argument(
+ '-t', '--class-dump-path', required=True,
+ help='path to class-dump executable')
+ parser.add_argument(
+ 'args', nargs='*',
+ help='arguments to pass to class-dump')
+ args = parser.parse_args(args)
+
+ try:
+ os.makedirs(os.path.dirname(args.output))
+ except OSError, e:
+ if e.errno != errno.EEXIST:
+ raise
+
+ process = subprocess.Popen(
+ [args.class_dump_path] + args.args,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdout, stderr = process.communicate()
+ if process.returncode != 0:
+ sys.stderr.write(stderr)
+ sys.exit(process.returncode)
+
+ with open(args.output, 'wb') as output:
+ output.write("// Treat class-dump output as a system header.\n")
+ output.write("#pragma clang system_header\n")
+ for line in stdout.splitlines():
+ if 'cxx_destruct' in line:
+ continue
+ output.write(line)
+ output.write('\n')
+
+
+if __name__ == '__main__':
+ Main(sys.argv[1:])
« no previous file with comments | « third_party/class-dump/class-dump.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698