generate_location_tags.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/env python
  2. # Copyright (c) 2021 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.
  5. """Generates the directory->tags mapping used by ResultDB."""
  6. # pylint: disable=line-too-long
  7. #
  8. # For more on the tags, see
  9. # https://source.chromium.org/chromium/infra/infra/+/main:go/src/go.chromium.org/luci/resultdb/sink/proto/v1/location_tag.proto
  10. #
  11. # pylint: enable=line-too-long
  12. import argparse
  13. import os
  14. import subprocess
  15. import sys
  16. THIS_DIR = os.path.dirname(__file__)
  17. SRC_DIR = os.path.dirname(THIS_DIR)
  18. BUILD_DIR = os.path.join(SRC_DIR, 'build')
  19. sys.path.insert(0, BUILD_DIR)
  20. import find_depot_tools
  21. def main():
  22. parser = argparse.ArgumentParser()
  23. parser.add_argument('-o', '--out', required=True,
  24. help='path to write location tag metadata to')
  25. args = parser.parse_args()
  26. exe = os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, 'dirmd')
  27. if sys.platform == 'win32':
  28. exe = exe + '.bat'
  29. return subprocess.call([
  30. exe,
  31. 'location-tags',
  32. '-out', args.out,
  33. '-root', SRC_DIR,
  34. '-repo', 'https://chromium.googlesource.com/chromium/src',
  35. ])
  36. if __name__ == '__main__':
  37. sys.exit(main())