Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2017 the V8 project authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 """\ | |
| 6 Convenience script for generating arch-specific ctags file. | |
| 7 This script MUST be executed at the top directory. | |
| 8 | |
| 9 Usage: | |
| 10 $ tools/dev/gen-tags.py [<arch>...] | |
| 11 | |
| 12 The example usage is as follows: | |
| 13 $ tools/dev/gen-tags.py x64 | |
| 14 | |
| 15 If no <arch> is given, it generates tags file for all arches: | |
| 16 $ tools/dev/gen-tags.py | |
| 17 """ | |
| 18 import os | |
|
Jakob Kummerow
2017/03/21 16:14:43
nit: unused import
| |
| 19 import subprocess | |
| 20 import sys | |
| 21 | |
| 22 # All arches that this script understands. | |
| 23 ARCHES = ["ia32", "x64", "arm", "arm64", "mips", "mips64", "ppc", "s390", "x87"] | |
| 24 | |
| 25 def PrintHelpAndExit(): | |
| 26 print(__doc__) | |
| 27 sys.exit(0) | |
| 28 | |
| 29 def _Call(cmd, silent=False): | |
| 30 if not silent: print("# %s" % cmd) | |
| 31 return subprocess.call(cmd, shell=True) | |
| 32 | |
| 33 class ArgumentParser(object): | |
| 34 def __init__(self): | |
| 35 self.global_targets = set() | |
| 36 self.configs = {} | |
| 37 | |
| 38 def ParseArg(self, argstring): | |
| 39 if argstring in ("-h", "--help", "help"): | |
| 40 PrintHelpAndExit() | |
| 41 return argstring | |
| 42 | |
| 43 def ParseArguments(self, argv): | |
| 44 # if not CheckIfTopDir(argv[0]): | |
|
Jakob Kummerow
2017/03/21 16:14:43
nit: drop this
| |
| 45 if not "tools/dev" in argv[0]: | |
| 46 PrintHelpAndExit() | |
| 47 argv = argv[1:] | |
| 48 | |
| 49 # 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.
| |
| 50 if len(argv) == 0: | |
| 51 return ARCHES | |
| 52 | |
| 53 user_arches = [] | |
| 54 for argstring in argv: | |
| 55 user_arches.append(self.ParseArg(argstring)) | |
| 56 | |
| 57 return user_arches | |
| 58 | |
| 59 def Main(argv): | |
| 60 user_arches = [] | |
| 61 | |
| 62 parser = ArgumentParser() | |
| 63 user_arches = parser.ParseArguments(argv) | |
| 64 | |
| 65 exclude_arches = list(ARCHES) | |
| 66 for user_arch in user_arches: | |
| 67 exclude_arches.remove(user_arch) | |
| 68 | |
| 69 f = lambda arch : "--exclude=" + arch | |
| 70 exclude_options = ' '.join(map(f, exclude_arches)) | |
|
Jakob Kummerow
2017/03/21 16:14:43
simpler:
exclude_options = ["--exclude=%s" % arch
| |
| 71 | |
| 72 command = "ctags --fields=+l " + exclude_options + " -R include/* src/*" | |
|
Jakob Kummerow
2017/03/21 16:14:43
what about test/* ?
| |
| 73 _Call(command) | |
| 74 | |
| 75 if __name__ == "__main__": | |
| 76 sys.exit(Main(sys.argv)) | |
| OLD | NEW |