xref: /OK3568_Linux_fs/u-boot/tools/patman/project.py (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# Copyright (c) 2012 The Chromium OS Authors.
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# SPDX-License-Identifier:	GPL-2.0+
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun
6*4882a593Smuzhiyunimport os.path
7*4882a593Smuzhiyun
8*4882a593Smuzhiyunimport gitutil
9*4882a593Smuzhiyun
10*4882a593Smuzhiyundef DetectProject():
11*4882a593Smuzhiyun    """Autodetect the name of the current project.
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun    This looks for signature files/directories that are unlikely to exist except
14*4882a593Smuzhiyun    in the given project.
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun    Returns:
17*4882a593Smuzhiyun        The name of the project, like "linux" or "u-boot".  Returns "unknown"
18*4882a593Smuzhiyun        if we can't detect the project.
19*4882a593Smuzhiyun    """
20*4882a593Smuzhiyun    top_level = gitutil.GetTopLevel()
21*4882a593Smuzhiyun
22*4882a593Smuzhiyun    if os.path.exists(os.path.join(top_level, "include", "u-boot")):
23*4882a593Smuzhiyun        return "u-boot"
24*4882a593Smuzhiyun    elif os.path.exists(os.path.join(top_level, "kernel")):
25*4882a593Smuzhiyun        return "linux"
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun    return "unknown"
28