Add LOCAL_ prefix to non-UMA histogram macros.
[chromium-blink-merge.git] / third_party / protobuf / protobuf_lite_java_parse_pom.py
blob675c5cf00299105b3808a6369fb45487c2662993
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium 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.
6 """Parses the Maven pom.xml file for which files to include in a lite build.
8 Usage:
9 protobuf_lite_java_parse_pom.py {path to pom.xml}
11 This is a helper file for the protobuf_lite_java target in protobuf.gyp.
13 It parses the pom.xml file, and looks for all the includes specified in the
14 'lite' profile. It does not return and test includes.
16 The result is printed as one line per entry.
17 """
19 import sys
21 from xml.etree import ElementTree
23 def main(argv):
24 if (len(argv) < 2):
25 usage()
26 return 1
28 # Setup all file and XML query paths.
29 pom_path = argv[1]
30 namespace = "{http://maven.apache.org/POM/4.0.0}"
31 profile_path = '{0}profiles/{0}profile'.format(namespace)
32 id_path = '{0}id'.format(namespace)
33 plugin_path = \
34 '{0}build/{0}plugins/{0}plugin'.format(namespace)
35 artifact_path = '{0}artifactId'.format(namespace)
36 include_path = '{0}configuration/{0}includes/{0}include'.format(namespace)
38 # Parse XML file and store result in includes list.
39 includes = []
40 for profile in ElementTree.parse(pom_path).getroot().findall(profile_path):
41 id_element = profile.find(id_path)
42 if (id_element is not None and id_element.text == 'lite'):
43 for plugin in profile.findall(plugin_path):
44 artifact_element = plugin.find(artifact_path)
45 if (artifact_element is not None and
46 artifact_element.text == 'maven-compiler-plugin'):
47 for include in plugin.findall(include_path):
48 includes.append(include.text)
50 # Print result to stdout, one item on each line.
51 print '\n'.join(includes)
53 def usage():
54 print(__doc__);
56 if __name__ == '__main__':
57 sys.exit(main(sys.argv))