blob: ca43ecee99ae35628569439158e2675ac2e30b62 [file] [log] [blame]
The Android Open Source Project6ffae012009-03-18 17:39:43 -07001#!/usr/bin/python2.4
2#
3#
4# Copyright 2008, The Android Open Source Project
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17
18"""Contains utility functions for interacting with the Android build system."""
19
20# Python imports
21import os
22
23# local imports
24import errors
25import logger
26
27
28def GetTop():
29 """Returns the full pathname of the "top" of the Android development tree.
30
31 Assumes build environment has been properly configured by envsetup &
32 lunch/choosecombo.
33
34 Returns:
35 the absolute file path of the Android build root.
36
37 Raises:
38 AbortError: if Android build root could not be found.
39 """
40 # TODO: does this need to be reimplemented to be like gettop() in envsetup.sh
41 root_path = os.getenv('ANDROID_BUILD_TOP')
42 if root_path is None:
43 logger.Log('Error: ANDROID_BUILD_TOP not defined. Please run envsetup.sh')
44 raise errors.AbortError
45 return root_path