[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/native-comp c3e640b 4/9: * comp.el: Extend `native-compile-async
From: |
Andrea Corallo |
Subject: |
feature/native-comp c3e640b 4/9: * comp.el: Extend `native-compile-async' for load and late-load |
Date: |
Thu, 19 Mar 2020 14:41:51 -0400 (EDT) |
branch: feature/native-comp
commit c3e640bfa6623234e6757e1ffef1b0d6a3144ff8
Author: Andrea Corallo <address@hidden>
Commit: Andrea Corallo <address@hidden>
* comp.el: Extend `native-compile-async' for load and late-load
---
lisp/emacs-lisp/comp.el | 50 +++++++++++++++++++++++++++++++++----------------
1 file changed, 34 insertions(+), 16 deletions(-)
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index d077fa5..f1e99c5 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -433,6 +433,21 @@ VERBOSITY is a number between 0 and 3."
2))
edges)))
+(defun comp-output-base-filename (src)
+ "Output filename sans extention for SRC file being native compiled."
+ (let* ((expanded-filename (expand-file-name src))
+ (output-dir (file-name-as-directory
+ (concat (file-name-directory expanded-filename)
+ comp-native-path-postfix)))
+ (output-filename
+ (file-name-sans-extension
+ (file-name-nondirectory expanded-filename))))
+ (expand-file-name output-filename output-dir)))
+
+(defun comp-output-filename (src)
+ "Output filename for SRC file being native compiled."
+ (concat (comp-output-base-filename src) ".eln"))
+
;;; spill-lap pass specific code.
@@ -2122,7 +2137,7 @@ display a message."
(> (comp-async-runnings) 0))
(unless (>= (comp-async-runnings) (comp-effective-async-max-jobs))
(cl-loop
- for source-file = (pop comp-files-queue)
+ for (source-file . load) = (pop comp-files-queue)
while source-file
do (cl-assert (string-match-p (rx ".el" eos) source-file) nil
"`comp-files-queue' should be \".el\" files: %s"
@@ -2136,7 +2151,9 @@ display a message."
comp-verbose ,comp-verbose
load-path ',load-path)
(message "Compiling %s..." ,source-file)
- (native-compile ,source-file)))
+ (native-compile ,source-file ,(and load t))))
+ (source-file1 source-file) ;; Make the closure works :/
+ (load1 load)
(process (make-process
:name (concat "Compiling: " source-file)
:buffer (get-buffer-create comp-async-buffer-name)
@@ -2149,6 +2166,10 @@ display a message."
'comp-async-cu-done-hook
source-file)
(accept-process-output process)
+ (when load1
+ (native-elisp-load
+ (comp-output-filename source-file1)
+ load1))
(comp-run-async-workers)))))
(push process comp-async-processes))
when (>= (comp-async-runnings) (comp-effective-async-max-jobs))
@@ -2181,17 +2202,7 @@ Return the compilation unit file name."
(byte-compile-debug t)
(comp-ctxt
(make-comp-ctxt
- :output
- (if (symbolp function-or-file)
- (make-temp-file (concat (symbol-name function-or-file) "-"))
- (let* ((expanded-filename (expand-file-name function-or-file))
- (output-dir (file-name-as-directory
- (concat (file-name-directory
expanded-filename)
- comp-native-path-postfix)))
- (output-filename
- (file-name-sans-extension
- (file-name-nondirectory expanded-filename))))
- (expand-file-name output-filename output-dir)))
+ :output (comp-output-base-filename function-or-file)
:with-late-load with-late-load)))
(comp-log "\n\n" 1)
(condition-case err
@@ -2231,12 +2242,15 @@ Always generate elc files too and handle native
compiler expected errors."
(rename-file tempfile target-file t))))))
;;;###autoload
-(defun native-compile-async (paths recursively)
+(defun native-compile-async (paths &optional recursively load)
"Compile PATHS asynchronously.
PATHS is one path or a list of paths to files or directories.
`comp-async-jobs-number' specifies the number of (commands) to
run simultaneously. If RECURSIVELY, recurse into subdirectories
-of given directories."
+of given directories.
+LOAD can be nil t or 'late."
+ (unless (member load '(nil t late))
+ (error "LOAD must be nil t or 'late"))
(unless (listp paths)
(setf paths (list paths)))
(let (files)
@@ -2250,7 +2264,11 @@ of given directories."
(t (signal 'native-compiler-error
(list "Path not a file nor directory" path)))))
(dolist (file files)
- (add-to-list 'comp-files-queue file t))
+ (if-let ((entry (cl-find file comp-files-queue :key #'car :test
#'string=)))
+ (cl-assert (eq load (cdr entry))
+ nil "Incoherent load kind in compilation queue for %s"
+ file)
+ (setf comp-files-queue (append comp-files-queue `((,file . ,load))))))
(when (zerop (comp-async-runnings))
(comp-run-async-workers))
(message "Compilation started.")))
- feature/native-comp updated (e57d5a7 -> 64a6709), Andrea Corallo, 2020/03/19
- feature/native-comp f2c4377 1/9: * comp.el: Have the compiler generates 'late_top_level_run', Andrea Corallo, 2020/03/19
- feature/native-comp b53fc68 3/9: Extend low level code for late load, Andrea Corallo, 2020/03/19
- feature/native-comp 034d9b3 2/9: * comp.el: late-load support optional as `native-compile' parameter, Andrea Corallo, 2020/03/19
- feature/native-comp 7565a4a 5/9: Command late load when deferring compilation, Andrea Corallo, 2020/03/19
- feature/native-comp 64a6709 9/9: * comp.el (comp-async-jobs-number): Fix customize type., Andrea Corallo, 2020/03/19
- feature/native-comp 0179d95 6/9: * comp.c (native-elisp-load): Guard against misisng file., Andrea Corallo, 2020/03/19
- feature/native-comp c3e640b 4/9: * comp.el: Extend `native-compile-async' for load and late-load,
Andrea Corallo <=
- feature/native-comp b070571 7/9: * comp.el (comp-run-async-workers): Load only if compilation succeed, Andrea Corallo, 2020/03/19
- feature/native-comp 981cc15 8/9: Merge remote-tracking branch 'savannah/master' into HEAD, Andrea Corallo, 2020/03/19