mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-14 01:50:22 -08:00
Fix 'internal--c-header-file-path'
* lisp/subr.el (internal--c-header-file-path): Fix for MS-Windows: don't prepend the (usually non-existent) "/usr/include", and run each directory through 'expand-file-name' to remove the many ".." elements and mirror any backslashes. Invoke "clang" if "gcc" is not available or is actually clang. * test/lisp/subr-tests.el (subr-tests-internal--c-header-file-path): Fix for MS-Windows: test the path by looking for stdio.h, and expand all directory names to compare to expected results.
This commit is contained in:
parent
387dcb1be8
commit
a04e8812ee
2 changed files with 33 additions and 17 deletions
31
lisp/subr.el
31
lisp/subr.el
|
|
@ -7642,14 +7642,20 @@ and return the value found in PLACE instead."
|
|||
;; cc-search-directories, semantic-c-dependency-system-include-path,
|
||||
;; semantic-gcc-setup
|
||||
(delete-dups
|
||||
(let ((base '("/usr/include" "/usr/local/include")))
|
||||
(cond ((or (internal--gcc-is-clang-p)
|
||||
(and (executable-find "clang")
|
||||
(not (executable-find "gcc"))))
|
||||
;; This is either macOS, or a system with clang only.
|
||||
;; We treat MS-Windows/MS-DOS specially, since there's no
|
||||
;; widely-accepted canonical directory for C include files.
|
||||
(let ((base (if (not (memq system-type '(windows-nt ms-dos)))
|
||||
'("/usr/include" "/usr/local/include")))
|
||||
(call-clang-p (or (internal--gcc-is-clang-p)
|
||||
(and (executable-find "clang")
|
||||
(not (executable-find "gcc"))))))
|
||||
(cond ((or call-clang-p
|
||||
(memq system-type '(windows-nt ms-dos)))
|
||||
;; This is either macOS, or MS-Windows/MS-DOS, or a system
|
||||
;; with clang only.
|
||||
(with-temp-buffer
|
||||
(ignore-errors
|
||||
(call-process (if (internal--gcc-is-clang-p) "gcc" "clang")
|
||||
(call-process (if call-clang-p "clang" "gcc")
|
||||
nil t nil
|
||||
"-v" "-E" "-"))
|
||||
(goto-char (point-min))
|
||||
|
|
@ -7663,10 +7669,15 @@ and return the value found in PLACE instead."
|
|||
(pos-bol)))
|
||||
(while (search-forward "(framework directory)" nil t)
|
||||
(delete-line))
|
||||
(append base
|
||||
(reverse
|
||||
(split-string (buffer-substring-no-properties
|
||||
(point-min) (point-max)))))))
|
||||
;; "gcc -v" reports file names with many "..", so we
|
||||
;; normalize it.
|
||||
(or (mapcar #'expand-file-name
|
||||
(append base
|
||||
(split-string (buffer-substring-no-properties
|
||||
(point-min) (point-max)))))
|
||||
;; Fallback for whedn the compiler is not available.
|
||||
(list (expand-file-name "/usr/include")
|
||||
(expand-file-name "/usr/local/include")))))
|
||||
;; Prefer GCC.
|
||||
((let ((arch (with-temp-buffer
|
||||
(when (eq 0 (ignore-errors
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue