aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Corallo2020-03-18 19:52:36 +0000
committerAndrea Corallo2020-03-19 13:50:25 +0000
commitc3e640bfa6623234e6757e1ffef1b0d6a3144ff8 (patch)
tree215e34628b454933ede08586c6f0b9de45d81ff2
parentb53fc68535211a59fde7200713340d911b48ecec (diff)
downloademacs-c3e640bfa6623234e6757e1ffef1b0d6a3144ff8.tar.gz
emacs-c3e640bfa6623234e6757e1ffef1b0d6a3144ff8.zip
* comp.el: Extend `native-compile-async' for load and late-load
-rw-r--r--lisp/emacs-lisp/comp.el50
1 files changed, 34 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index d077fa59991..f1e99c5ee16 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."
433 2)) 433 2))
434 edges))) 434 edges)))
435 435
436(defun comp-output-base-filename (src)
437 "Output filename sans extention for SRC file being native compiled."
438 (let* ((expanded-filename (expand-file-name src))
439 (output-dir (file-name-as-directory
440 (concat (file-name-directory expanded-filename)
441 comp-native-path-postfix)))
442 (output-filename
443 (file-name-sans-extension
444 (file-name-nondirectory expanded-filename))))
445 (expand-file-name output-filename output-dir)))
446
447(defun comp-output-filename (src)
448 "Output filename for SRC file being native compiled."
449 (concat (comp-output-base-filename src) ".eln"))
450
436 451
437;;; spill-lap pass specific code. 452;;; spill-lap pass specific code.
438 453
@@ -2122,7 +2137,7 @@ display a message."
2122 (> (comp-async-runnings) 0)) 2137 (> (comp-async-runnings) 0))
2123 (unless (>= (comp-async-runnings) (comp-effective-async-max-jobs)) 2138 (unless (>= (comp-async-runnings) (comp-effective-async-max-jobs))
2124 (cl-loop 2139 (cl-loop
2125 for source-file = (pop comp-files-queue) 2140 for (source-file . load) = (pop comp-files-queue)
2126 while source-file 2141 while source-file
2127 do (cl-assert (string-match-p (rx ".el" eos) source-file) nil 2142 do (cl-assert (string-match-p (rx ".el" eos) source-file) nil
2128 "`comp-files-queue' should be \".el\" files: %s" 2143 "`comp-files-queue' should be \".el\" files: %s"
@@ -2136,7 +2151,9 @@ display a message."
2136 comp-verbose ,comp-verbose 2151 comp-verbose ,comp-verbose
2137 load-path ',load-path) 2152 load-path ',load-path)
2138 (message "Compiling %s..." ,source-file) 2153 (message "Compiling %s..." ,source-file)
2139 (native-compile ,source-file))) 2154 (native-compile ,source-file ,(and load t))))
2155 (source-file1 source-file) ;; Make the closure works :/
2156 (load1 load)
2140 (process (make-process 2157 (process (make-process
2141 :name (concat "Compiling: " source-file) 2158 :name (concat "Compiling: " source-file)
2142 :buffer (get-buffer-create comp-async-buffer-name) 2159 :buffer (get-buffer-create comp-async-buffer-name)
@@ -2149,6 +2166,10 @@ display a message."
2149 'comp-async-cu-done-hook 2166 'comp-async-cu-done-hook
2150 source-file) 2167 source-file)
2151 (accept-process-output process) 2168 (accept-process-output process)
2169 (when load1
2170 (native-elisp-load
2171 (comp-output-filename source-file1)
2172 load1))
2152 (comp-run-async-workers))))) 2173 (comp-run-async-workers)))))
2153 (push process comp-async-processes)) 2174 (push process comp-async-processes))
2154 when (>= (comp-async-runnings) (comp-effective-async-max-jobs)) 2175 when (>= (comp-async-runnings) (comp-effective-async-max-jobs))
@@ -2181,17 +2202,7 @@ Return the compilation unit file name."
2181 (byte-compile-debug t) 2202 (byte-compile-debug t)
2182 (comp-ctxt 2203 (comp-ctxt
2183 (make-comp-ctxt 2204 (make-comp-ctxt
2184 :output 2205 :output (comp-output-base-filename function-or-file)
2185 (if (symbolp function-or-file)
2186 (make-temp-file (concat (symbol-name function-or-file) "-"))
2187 (let* ((expanded-filename (expand-file-name function-or-file))
2188 (output-dir (file-name-as-directory
2189 (concat (file-name-directory expanded-filename)
2190 comp-native-path-postfix)))
2191 (output-filename
2192 (file-name-sans-extension
2193 (file-name-nondirectory expanded-filename))))
2194 (expand-file-name output-filename output-dir)))
2195 :with-late-load with-late-load))) 2206 :with-late-load with-late-load)))
2196 (comp-log "\n \n" 1) 2207 (comp-log "\n \n" 1)
2197 (condition-case err 2208 (condition-case err
@@ -2231,12 +2242,15 @@ Always generate elc files too and handle native compiler expected errors."
2231 (rename-file tempfile target-file t)))))) 2242 (rename-file tempfile target-file t))))))
2232 2243
2233;;;###autoload 2244;;;###autoload
2234(defun native-compile-async (paths recursively) 2245(defun native-compile-async (paths &optional recursively load)
2235 "Compile PATHS asynchronously. 2246 "Compile PATHS asynchronously.
2236PATHS is one path or a list of paths to files or directories. 2247PATHS is one path or a list of paths to files or directories.
2237`comp-async-jobs-number' specifies the number of (commands) to 2248`comp-async-jobs-number' specifies the number of (commands) to
2238run simultaneously. If RECURSIVELY, recurse into subdirectories 2249run simultaneously. If RECURSIVELY, recurse into subdirectories
2239of given directories." 2250of given directories.
2251LOAD can be nil t or 'late."
2252 (unless (member load '(nil t late))
2253 (error "LOAD must be nil t or 'late"))
2240 (unless (listp paths) 2254 (unless (listp paths)
2241 (setf paths (list paths))) 2255 (setf paths (list paths)))
2242 (let (files) 2256 (let (files)
@@ -2250,7 +2264,11 @@ of given directories."
2250 (t (signal 'native-compiler-error 2264 (t (signal 'native-compiler-error
2251 (list "Path not a file nor directory" path))))) 2265 (list "Path not a file nor directory" path)))))
2252 (dolist (file files) 2266 (dolist (file files)
2253 (add-to-list 'comp-files-queue file t)) 2267 (if-let ((entry (cl-find file comp-files-queue :key #'car :test #'string=)))
2268 (cl-assert (eq load (cdr entry))
2269 nil "Incoherent load kind in compilation queue for %s"
2270 file)
2271 (setf comp-files-queue (append comp-files-queue `((,file . ,load))))))
2254 (when (zerop (comp-async-runnings)) 2272 (when (zerop (comp-async-runnings))
2255 (comp-run-async-workers)) 2273 (comp-run-async-workers))
2256 (message "Compilation started."))) 2274 (message "Compilation started.")))