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

Unified Diff: tools/dev/gen-tags.py

Issue 2762903002: tools: Add a script to generate arch-specific ctags (Closed)
Patch Set: tools: Add a script to generate arch-specific ctags Created 3 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dev/gen-tags.py
diff --git a/tools/dev/gen-tags.py b/tools/dev/gen-tags.py
new file mode 100755
index 0000000000000000000000000000000000000000..5097287d6c02c2a6dade9375e879cd03446d10d1
--- /dev/null
+++ b/tools/dev/gen-tags.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+# Copyright 2017 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.
+"""\
+Convenience script for generating arch-specific ctags file.
+This script MUST be executed at the top directory.
+
+Usage:
+ $ tools/dev/gen-tags.py [<arch>...]
+
+The example usage is as follows:
+ $ tools/dev/gen-tags.py x64
+
+If no <arch> is given, it generates tags file for all arches:
+ $ tools/dev/gen-tags.py
+"""
+import os
Jakob Kummerow 2017/03/21 16:14:43 nit: unused import
+import subprocess
+import sys
+
+# All arches that this script understands.
+ARCHES = ["ia32", "x64", "arm", "arm64", "mips", "mips64", "ppc", "s390", "x87"]
+
+def PrintHelpAndExit():
+ print(__doc__)
+ sys.exit(0)
+
+def _Call(cmd, silent=False):
+ if not silent: print("# %s" % cmd)
+ return subprocess.call(cmd, shell=True)
+
+class ArgumentParser(object):
+ def __init__(self):
+ self.global_targets = set()
+ self.configs = {}
+
+ def ParseArg(self, argstring):
+ if argstring in ("-h", "--help", "help"):
+ PrintHelpAndExit()
+ return argstring
+
+ def ParseArguments(self, argv):
+# if not CheckIfTopDir(argv[0]):
Jakob Kummerow 2017/03/21 16:14:43 nit: drop this
+ if not "tools/dev" in argv[0]:
+ PrintHelpAndExit()
+ argv = argv[1:]
+
+ # if no argument is given, then generate ctags for all arches
Jakob Kummerow 2017/03/21 16:14:43 nit: Proper capitalization and punctuation please.
+ if len(argv) == 0:
+ return ARCHES
+
+ user_arches = []
+ for argstring in argv:
+ user_arches.append(self.ParseArg(argstring))
+
+ return user_arches
+
+def Main(argv):
+ user_arches = []
+
+ parser = ArgumentParser()
+ user_arches = parser.ParseArguments(argv)
+
+ exclude_arches = list(ARCHES)
+ for user_arch in user_arches:
+ exclude_arches.remove(user_arch)
+
+ f = lambda arch : "--exclude=" + arch
+ exclude_options = ' '.join(map(f, exclude_arches))
Jakob Kummerow 2017/03/21 16:14:43 simpler: exclude_options = ["--exclude=%s" % arch
+
+ command = "ctags --fields=+l " + exclude_options + " -R include/* src/*"
Jakob Kummerow 2017/03/21 16:14:43 what about test/* ?
+ _Call(command)
+
+if __name__ == "__main__":
+ sys.exit(Main(sys.argv))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698