blob: e05ff1163f8fd351927af1a530cb962bbe964083 [file] [log] [blame]
Doug Andersona1dcee82012-12-03 14:43:18 +00001# Copyright (c) 2012 The Chromium OS Authors.
2#
Wolfgang Denk1a459662013-07-08 09:37:19 +02003# SPDX-License-Identifier: GPL-2.0+
Doug Andersona1dcee82012-12-03 14:43:18 +00004#
5
6import os.path
7
8import gitutil
9
10def DetectProject():
11 """Autodetect the name of the current project.
12
13 This looks for signature files/directories that are unlikely to exist except
14 in the given project.
15
16 Returns:
17 The name of the project, like "linux" or "u-boot". Returns "unknown"
18 if we can't detect the project.
19 """
20 top_level = gitutil.GetTopLevel()
21
22 if os.path.exists(os.path.join(top_level, "include", "u-boot")):
23 return "u-boot"
24 elif os.path.exists(os.path.join(top_level, "kernel")):
25 return "linux"
26
27 return "unknown"