Added support for the number of jobs during a make.
Moved common functions in a new android-common.el file.
Declared a customizable variable to control the number
of jobs used during the make process.
In android-compile, call compile interactively to honor
the compile-read-command feature to give the user the opportunity
to edit the command (e.g add the snod target)
diff --git a/ide/emacs/android-common.el b/ide/emacs/android-common.el
new file mode 100644
index 0000000..a4cd1e5
--- /dev/null
+++ b/ide/emacs/android-common.el
@@ -0,0 +1,51 @@
+;;;
+;;; Copyright (C) 2009 The Android Open Source Project
+;;;
+;;; Licensed under the Apache License, Version 2.0 (the "License");
+;;; you may not use this file except in compliance with the License.
+;;; You may obtain a copy of the License at
+;;;
+;;; http://www.apache.org/licenses/LICENSE-2.0
+;;;
+;;; Unless required by applicable law or agreed to in writing, software
+;;; distributed under the License is distributed on an "AS IS" BASIS,
+;;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;;; See the License for the specific language governing permissions and
+;;; limitations under the License.
+
+;;; Variables to customize and common function for the android build
+;;; support in Emacs.
+
+(defgroup android nil
+ "Support for android development in Emacs."
+ :group 'tools)
+
+;;;###autoload
+(defcustom android-compilation-jobs 2
+ "Number of jobs used to do a compilation (-j option of make)."
+ :type 'integer
+ :group 'android)
+
+(defun android-find-build-tree-root ()
+ "Ascend the current path until the root of the android build tree is found.
+Similarly to the shell functions in envsetup.sh, for the root both ./Makefile
+and ./build/core/envsetup.mk are exiting files.
+Return the root of the build tree. Signal an error if not found."
+ (let ((default-directory default-directory))
+ (while (and (> (length default-directory) 2)
+ (not (file-exists-p (concat default-directory "Makefile")))
+ (not (file-exists-p (concat default-directory "build/core/envsetup.mk"))))
+ (setq default-directory
+ (substring default-directory 0
+ (string-match "[^/]+/$" default-directory))))
+ (if (> (length default-directory) 2)
+ default-directory
+ (error "Not in a valid android tree."))))
+
+(defun android-project-p ()
+"Return nil if not in an android build tree."
+ (condition-case nil
+ (android-find-build-tree-root)
+ (error nil)))
+
+(provide 'android-common)
diff --git a/ide/emacs/android-compile.el b/ide/emacs/android-compile.el
index f6b0a09..7abe83a 100644
--- a/ide/emacs/android-compile.el
+++ b/ide/emacs/android-compile.el
@@ -25,22 +25,7 @@
;; TODO: Maybe we could cache the result of the compile function in buffer local vars.
(require 'compile)
-
-(defun android-find-build-tree-root ()
- "Ascend the current path until the root of the android build tree is found.
-Similarly to the shell functions in envsetup.sh, for the root both ./Makefile
-and ./build/core/envsetup.mk are exiting files.
-Return the root of the build tree. Signal an error if not found."
- (let ((default-directory default-directory))
- (while (and (> (length default-directory) 2)
- (not (file-exists-p (concat default-directory "Makefile")))
- (not (file-exists-p (concat default-directory "build/core/envsetup.mk"))))
- (setq default-directory
- (substring default-directory 0
- (string-match "[^/]+/$" default-directory))))
- (if (> (length default-directory) 2)
- default-directory
- (error "Not in a valid android tree."))))
+(require 'android-common)
(defun android-find-makefile (topdir)
"Ascend the current path until an Android makefile is found.
@@ -69,30 +54,28 @@
(length topdir) nil) nil)
(error "Not in a valid android tree.")))))
-(defun android-project-p ()
-"Return nil if not in an android build tree."
- (condition-case nil
- (android-find-build-tree-root)
- (error nil)))
-
-;; TODO: Cannot pass additional flags (e.g -j4).
(defun android-compile ()
"Elisp equivalent of mm shell function.
Walk up the path until a makefile is found and build it.
-You need to have a proper buildspec.mk in your top dir."
+You need to have a proper buildspec.mk in your top dir.
+
+Use `android-compilation-jobs' to control the number of jobs used
+in a compilation."
(interactive)
(if (android-project-p)
(let* ((topdir (android-find-build-tree-root))
- (makefile (android-find-makefile topdir)))
+ (makefile (android-find-makefile topdir))
+ (options
+ (concat " -j " (number-to-string android-compilation-jobs))))
(if (not (file-exists-p (concat topdir "buildspec.mk")))
(error "buildspec.mk missing in %s." topdir))
(set (make-local-variable 'compile-command)
(if (cadr makefile)
;; The root Makefile is not invoked using ONE_SHOT_MAKEFILE.
- (concat "make -C " topdir " files ")
+ (concat "make -C " topdir options " files ")
(concat "ONE_SHOT_MAKEFILE=" (car makefile)
- " make -C " topdir " files ")))
+ " make -C " topdir options " files ")))
(if (interactive-p)
- (compile compile-command)))))
+ (call-interactively 'compile)))))
(provide 'android-compile)