1*a1dcee84SDoug Anderson# Copyright (c) 2012 The Chromium OS Authors. 2*a1dcee84SDoug Anderson# 3*a1dcee84SDoug Anderson# See file CREDITS for list of people who contributed to this 4*a1dcee84SDoug Anderson# project. 5*a1dcee84SDoug Anderson# 6*a1dcee84SDoug Anderson# This program is free software; you can redistribute it and/or 7*a1dcee84SDoug Anderson# modify it under the terms of the GNU General Public License as 8*a1dcee84SDoug Anderson# published by the Free Software Foundation; either version 2 of 9*a1dcee84SDoug Anderson# the License, or (at your option) any later version. 10*a1dcee84SDoug Anderson# 11*a1dcee84SDoug Anderson# This program is distributed in the hope that it will be useful, 12*a1dcee84SDoug Anderson# but WITHOUT ANY WARRANTY; without even the implied warranty of 13*a1dcee84SDoug Anderson# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14*a1dcee84SDoug Anderson# GNU General Public License for more details. 15*a1dcee84SDoug Anderson# 16*a1dcee84SDoug Anderson# You should have received a copy of the GNU General Public License 17*a1dcee84SDoug Anderson# along with this program; if not, write to the Free Software 18*a1dcee84SDoug Anderson# Foundation, Inc., 59 Temple Place, Suite 330, Boston, 19*a1dcee84SDoug Anderson# MA 02111-1307 USA 20*a1dcee84SDoug Anderson# 21*a1dcee84SDoug Anderson 22*a1dcee84SDoug Andersonimport os.path 23*a1dcee84SDoug Anderson 24*a1dcee84SDoug Andersonimport gitutil 25*a1dcee84SDoug Anderson 26*a1dcee84SDoug Andersondef DetectProject(): 27*a1dcee84SDoug Anderson """Autodetect the name of the current project. 28*a1dcee84SDoug Anderson 29*a1dcee84SDoug Anderson This looks for signature files/directories that are unlikely to exist except 30*a1dcee84SDoug Anderson in the given project. 31*a1dcee84SDoug Anderson 32*a1dcee84SDoug Anderson Returns: 33*a1dcee84SDoug Anderson The name of the project, like "linux" or "u-boot". Returns "unknown" 34*a1dcee84SDoug Anderson if we can't detect the project. 35*a1dcee84SDoug Anderson """ 36*a1dcee84SDoug Anderson top_level = gitutil.GetTopLevel() 37*a1dcee84SDoug Anderson 38*a1dcee84SDoug Anderson if os.path.exists(os.path.join(top_level, "include", "u-boot")): 39*a1dcee84SDoug Anderson return "u-boot" 40*a1dcee84SDoug Anderson elif os.path.exists(os.path.join(top_level, "kernel")): 41*a1dcee84SDoug Anderson return "linux" 42*a1dcee84SDoug Anderson 43*a1dcee84SDoug Anderson return "unknown" 44