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