blob: e633401e9d6172cef9ed5771e5cc15e5cc2d67f0 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Doug Anderson31ffd7f2012-12-03 14:43:18 +00002# Copyright (c) 2012 The Chromium OS Authors.
3#
Doug Anderson31ffd7f2012-12-03 14:43:18 +00004
5import os.path
6
Simon Glassba1b3b92025-02-09 14:26:00 -07007from u_boot_pylib import gitutil
Doug Anderson31ffd7f2012-12-03 14:43:18 +00008
Simon Glass1908d3542022-01-29 14:14:12 -07009def detect_project():
Doug Anderson31ffd7f2012-12-03 14:43:18 +000010 """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 """
Simon Glass761648b2022-01-29 14:14:11 -070019 top_level = gitutil.get_top_level()
Doug Anderson31ffd7f2012-12-03 14:43:18 +000020
Simon Glass0e43cad2025-05-10 13:04:55 +020021 if (not top_level or
22 os.path.exists(os.path.join(top_level, "include", "u-boot"))):
Doug Anderson31ffd7f2012-12-03 14:43:18 +000023 return "u-boot"
24 elif os.path.exists(os.path.join(top_level, "kernel")):
25 return "linux"
26
27 return "unknown"