Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0+ |
Doug Anderson | 31ffd7f | 2012-12-03 14:43:18 +0000 | [diff] [blame] | 2 | # Copyright (c) 2012 The Chromium OS Authors. |
| 3 | # |
Doug Anderson | 31ffd7f | 2012-12-03 14:43:18 +0000 | [diff] [blame] | 4 | |
| 5 | import os.path |
| 6 | |
Simon Glass | a997ea5 | 2020-04-17 18:09:04 -0600 | [diff] [blame] | 7 | from patman import gitutil |
Doug Anderson | 31ffd7f | 2012-12-03 14:43:18 +0000 | [diff] [blame] | 8 | |
Simon Glass | 1908d354 | 2022-01-29 14:14:12 -0700 | [diff] [blame] | 9 | def detect_project(): |
Doug Anderson | 31ffd7f | 2012-12-03 14:43:18 +0000 | [diff] [blame] | 10 | """Autodetect the name of the current project. |
| 11 | |
| 12 | This looks for signature files/directories that are unlikely to exist except |
| 13 | in the given project. |
| 14 | |
| 15 | Returns: |
| 16 | The name of the project, like "linux" or "u-boot". Returns "unknown" |
| 17 | if we can't detect the project. |
| 18 | """ |
Simon Glass | 761648b | 2022-01-29 14:14:11 -0700 | [diff] [blame] | 19 | top_level = gitutil.get_top_level() |
Doug Anderson | 31ffd7f | 2012-12-03 14:43:18 +0000 | [diff] [blame] | 20 | |
| 21 | if os.path.exists(os.path.join(top_level, "include", "u-boot")): |
| 22 | return "u-boot" |
| 23 | elif os.path.exists(os.path.join(top_level, "kernel")): |
| 24 | return "linux" |
| 25 | |
| 26 | return "unknown" |