Skip to content

Commit

Permalink
straight--build-compile: properly set load-path (#812)
Browse files Browse the repository at this point in the history
Previous method involved looking up each package's dependencies.
It did not account for local-repo names and transitive dependencies.
Now we just recursively add straight's build dir to the load-path
when byte-compiling. This should cover all cases.
  • Loading branch information
progfolio committed Jul 6, 2021
1 parent b45dd00 commit 01eb849
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions straight.el
Original file line number Diff line number Diff line change
Expand Up @@ -5050,27 +5050,22 @@ individual package recipe."
RECIPE should be a straight.el-style plist. Note that this
function only modifies the build folder, not the original
repository."
(let* ((package (plist-get recipe :package))
(dir (straight--build-dir package))
(program (concat invocation-directory invocation-name))
(args
`("-Q" "-L" ,dir
,@(apply #'append
(mapcar (lambda (d)
(let ((d (straight--build-dir d)))
(when (file-exists-p d) (list "-L" d))))
(straight--get-dependencies package)))
"--batch" "--eval"
,(format "(byte-recompile-directory %S 0 'force)" dir))))
(let* ((dir (straight--build-dir (or (plist-get recipe :local-repo)
(plist-get recipe :package))))
(emacs (concat invocation-directory invocation-name))
(program (format "(let ((default-directory %S))
(normal-top-level-add-subdirs-to-load-path)
(byte-recompile-directory %S 0 'force))"
(straight--build-dir) dir))
(args (list "-Q" "-L" dir "--batch" "--eval" program)))
(when straight-byte-compilation-buffer
(with-current-buffer (get-buffer-create straight-byte-compilation-buffer)
(insert "\n$ " (replace-regexp-in-string
"\\(-L [^z-a]*? \\)"
"\\1\\\\ \n "
(string-join `(,program ,@args) " "))
"\n")))
(apply #'call-process
`(,program nil ,straight-byte-compilation-buffer nil ,@args))))
(insert (format "\n$ %s %s %s \\\n %S\n" emacs
(string-join (cl-subseq args 0 3) " ")
(string-join (cl-subseq args 3 5) " ")
program)))
(apply #'call-process
`(,emacs nil ,straight-byte-compilation-buffer nil ,@args)))))

;;;;; Native compilation

Expand Down

0 comments on commit 01eb849

Please sign in to comment.