blob: 2dfc303729bec8f764cac6a487bd0fd2a1e377c3 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Doug Andersona1dcee82012-12-03 14:43:18 +00002# Copyright (c) 2012 The Chromium OS Authors.
3#
Doug Andersona1dcee82012-12-03 14:43:18 +00004
5import os.path
6
Simon Glassbf776672020-04-17 18:09:04 -06007from patman import gitutil
Doug Andersona1dcee82012-12-03 14:43:18 +00008
9def DetectProject():
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 """
19 top_level = gitutil.GetTopLevel()
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"