From 67ec6d16436813172890d8aaad30b4e94b4e2493 Mon Sep 17 00:00:00 2001 From: "Scott L. Burson" Date: Fri, 12 Jun 2026 19:23:28 -0700 Subject: [PATCH] Add :system-include-type option to use GCC C++ headers --- src/util/util.lisp | 16 ++++++++++------ src/wrap/wrapper.lisp | 15 ++++++++++++--- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/util/util.lisp b/src/util/util.lisp index dfb2dc6..92a5f77 100644 --- a/src/util/util.lisp +++ b/src/util/util.lisp @@ -318,7 +318,7 @@ (setf (uiop:getenv "LC_ALL") lc-all)))))) -(defun list-system-paths (language triple features) +(defun list-system-paths (language triple features system-include-type) (flet ((%process-paths (paths) (mapcar (lambda (path) (uiop:native-namestring (uiop:truename* path))) @@ -339,8 +339,12 @@ (unwind-protect (%process-paths (cond - ((not (emptyp (dump-gcc-version clang-name))) + ((and (member system-include-type '(:default :clang)) + (not (emptyp (dump-gcc-version clang-name)))) (dump-include-paths lang clang-name triple)) + ((eq system-include-type :clang) + (error "system-include-type is :clang, but ~A is not on $PATH" + clang-name)) ((windows-target-p) (if (not (emptyp (dump-gcc-version (string+ "x86_64-w64-mingw32-" gcc-name)))) @@ -352,9 +356,9 @@ (setf (uiop:getenv "LC_ALL") lc-all))))))) -(defun list-system-include-paths (language triple features) +(defun list-system-include-paths (language triple features system-include-type) (remove-if #'%darwin-framework-path-p - (list-system-paths language triple features))) + (list-system-paths language triple features system-include-type))) (defun list-default-resource-paths () @@ -363,12 +367,12 @@ (list resource-path)))) -(defun list-framework-paths (language triple features) +(defun list-framework-paths (language triple features system-include-type) (flet ((cut-darwin-postfix (path) (subseq path 0 (- (length path) (length +stupid-darwin-framework-postfix+))))) (mapcar #'cut-darwin-postfix (remove-if (complement #'%darwin-framework-path-p) - (list-system-paths language triple features))))) + (list-system-paths language triple features system-include-type))))) (defun dump-gcc-version (&optional (executable "gcc")) (handler-case diff --git a/src/wrap/wrapper.lisp b/src/wrap/wrapper.lisp index a6358b6..64a5fca 100644 --- a/src/wrap/wrapper.lisp +++ b/src/wrap/wrapper.lisp @@ -42,6 +42,7 @@ framework-includes defines intrinsics + system-include-type system-includes) @@ -64,9 +65,13 @@ framework-includes defines intrinsics + (system-include-type '(:default)) system-includes &allow-other-keys) (alist-plist opts) + (unless (member (car system-include-type) '(:default :clang :gcc)) + (error ":system-include-type must be one of (:default :clang :gcc), not ~S" + (car system-include-type))) (with-evaluated-variables (language standard) (with-evaluated-lists (headers @@ -92,6 +97,7 @@ :headers headers :includes includes :framework-includes framework-includes + :system-include-type (car system-include-type) :system-includes system-includes :defines defines :intrinsics intrinsics @@ -263,7 +269,8 @@ (%parse-opt 'standard target-parse-opts) (%parse-opt 'standard common-parse-opts))) (features (target-options-features target-opts)) - (triple (target-options-triple target-opts))) + (triple (target-options-triple target-opts)) + (system-include-type (%parse-opt 'system-include-type common-parse-opts))) (make-parse-options :include-sources (append (%parse-opt 'include-sources common-parse-opts) @@ -312,12 +319,14 @@ (or (append (%parse-opt 'system-includes target-parse-opts) (%parse-opt 'system-includes common-parse-opts)) - (list-system-include-paths language triple features)) + (list-system-include-paths language triple features + system-include-type)) :framework-includes (or (append (%parse-opt 'framework-includes target-parse-opts) (%parse-opt 'framework-includes common-parse-opts)) - (list-framework-paths language triple features)) + (list-framework-paths language triple features + system-include-type)) :defines (append (%parse-opt 'defines common-parse-opts)