project.py 676 B

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