Nicolas Catania | f94bca2 | 2009-10-06 10:45:44 -0700 | [diff] [blame] | 1 | ;;; |
| 2 | ;;; Copyright (C) 2009 The Android Open Source Project |
| 3 | ;;; |
| 4 | ;;; Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | ;;; you may not use this file except in compliance with the License. |
| 6 | ;;; You may obtain a copy of the License at |
| 7 | ;;; |
| 8 | ;;; http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | ;;; |
| 10 | ;;; Unless required by applicable law or agreed to in writing, software |
| 11 | ;;; distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | ;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | ;;; See the License for the specific language governing permissions and |
| 14 | ;;; limitations under the License. |
| 15 | |
| 16 | ;;; Variables to customize and common function for the android build |
| 17 | ;;; support in Emacs. |
| 18 | |
| 19 | (defgroup android nil |
| 20 | "Support for android development in Emacs." |
| 21 | :group 'tools) |
| 22 | |
| 23 | ;;;###autoload |
| 24 | (defcustom android-compilation-jobs 2 |
| 25 | "Number of jobs used to do a compilation (-j option of make)." |
| 26 | :type 'integer |
| 27 | :group 'android) |
| 28 | |
| 29 | (defun android-find-build-tree-root () |
| 30 | "Ascend the current path until the root of the android build tree is found. |
| 31 | Similarly to the shell functions in envsetup.sh, for the root both ./Makefile |
| 32 | and ./build/core/envsetup.mk are exiting files. |
| 33 | Return the root of the build tree. Signal an error if not found." |
| 34 | (let ((default-directory default-directory)) |
| 35 | (while (and (> (length default-directory) 2) |
| 36 | (not (file-exists-p (concat default-directory "Makefile"))) |
| 37 | (not (file-exists-p (concat default-directory "build/core/envsetup.mk")))) |
| 38 | (setq default-directory |
| 39 | (substring default-directory 0 |
| 40 | (string-match "[^/]+/$" default-directory)))) |
| 41 | (if (> (length default-directory) 2) |
| 42 | default-directory |
| 43 | (error "Not in a valid android tree.")))) |
| 44 | |
| 45 | (defun android-project-p () |
| 46 | "Return nil if not in an android build tree." |
| 47 | (condition-case nil |
| 48 | (android-find-build-tree-root) |
| 49 | (error nil))) |
| 50 | |
| 51 | (provide 'android-common) |