project.py 686 B

1234567891011121314151617181920212223242526
  1. # SPDX-License-Identifier: GPL-2.0+
  2. # Copyright (c) 2012 The Chromium OS Authors.
  3. #
  4. import os.path
  5. from patman import gitutil
  6. def DetectProject():
  7. """Autodetect the name of the current project.
  8. This looks for signature files/directories that are unlikely to exist except
  9. in the given project.
  10. Returns:
  11. The name of the project, like "linux" or "u-boot". Returns "unknown"
  12. if we can't detect the project.
  13. """
  14. top_level = gitutil.GetTopLevel()
  15. if os.path.exists(os.path.join(top_level, "include", "u-boot")):
  16. return "u-boot"
  17. elif os.path.exists(os.path.join(top_level, "kernel")):
  18. return "linux"
  19. return "unknown"