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