1# SPDX-License-Identifier: GPL-2.0+ 2# Copyright (c) 2012 The Chromium OS Authors. 3# 4 5import os.path 6 7from u_boot_pylib import gitutil 8 9def detect_project(): 10 """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 """ 19 top_level = gitutil.get_top_level() 20 21 if (not top_level or 22 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" 28