mirror of
https://github.com/pestctrl/emacs-config.git
synced 2026-06-14 12:21:20 +00:00
Compare commits
3 commits
78b2de42bf
...
43b38d29a2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43b38d29a2 | ||
|
|
a9ac44b961 | ||
|
|
3197b406af |
4 changed files with 202 additions and 200 deletions
|
|
@ -23,7 +23,10 @@
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'clang-option-sets)
|
(require 'compiler-option-sets)
|
||||||
|
|
||||||
|
(defclass clang-option-config (compiler-option-config)
|
||||||
|
nil)
|
||||||
|
|
||||||
(defvar clang-subtargets
|
(defvar clang-subtargets
|
||||||
(make-hash-table :test #'equal))
|
(make-hash-table :test #'equal))
|
||||||
|
|
@ -31,23 +34,23 @@
|
||||||
(defvar clang-options-extensions
|
(defvar clang-options-extensions
|
||||||
(make-hash-table :test #'equal))
|
(make-hash-table :test #'equal))
|
||||||
|
|
||||||
(defvar cc/all-target-options
|
(defvar clang/all-target-options
|
||||||
(make-hash-table))
|
(make-hash-table))
|
||||||
|
|
||||||
(defvar cc/current-target-optionset
|
(defvar clang/current-target-optionset
|
||||||
(make-hash-table))
|
(make-hash-table))
|
||||||
|
|
||||||
(defun cc/push-new-target-option (target name option-set)
|
(defun clang/push-new-target-option (target name option-set)
|
||||||
(puthash target
|
(puthash target
|
||||||
(cons (cons name option-set)
|
(cons (cons name option-set)
|
||||||
(gethash target cc/all-target-options))
|
(gethash target clang/all-target-options))
|
||||||
cc/all-target-options))
|
clang/all-target-options))
|
||||||
|
|
||||||
(defun cc/add-and-set-target-option (target name option-set)
|
(defun clang/add-and-set-target-option (target name option-set)
|
||||||
(puthash target name cc/current-target-optionset)
|
(puthash target name clang/current-target-optionset)
|
||||||
(cc/push-new-target-option target name option-set))
|
(clang/push-new-target-option target name option-set))
|
||||||
|
|
||||||
(defvar cc/file-specific-options
|
(defvar clang/file-specific-options
|
||||||
(make-hash-table :test #'equal))
|
(make-hash-table :test #'equal))
|
||||||
|
|
||||||
(defun my/completing-read-formatter (formatter prompt list)
|
(defun my/completing-read-formatter (formatter prompt list)
|
||||||
|
|
@ -60,7 +63,7 @@
|
||||||
alist
|
alist
|
||||||
nil nil #'equal)))
|
nil nil #'equal)))
|
||||||
|
|
||||||
(defun cc/make-clang-option-set (target)
|
(defun clang/make-clang-option-set (target)
|
||||||
(let ((subtargets (hash-table-values clang-subtargets))
|
(let ((subtargets (hash-table-values clang-subtargets))
|
||||||
primary extensions)
|
primary extensions)
|
||||||
(setq primary
|
(setq primary
|
||||||
|
|
@ -73,118 +76,143 @@
|
||||||
subtargets)))
|
subtargets)))
|
||||||
(cons primary extensions)))
|
(cons primary extensions)))
|
||||||
|
|
||||||
(defun cc/get-named-target-clang-optionset (target option-name)
|
(defun clang/get-named-target-clang-optionset (target option-name)
|
||||||
(when-let ((target-options
|
(when-let ((target-options
|
||||||
(gethash target cc/all-target-options)))
|
(gethash target clang/all-target-options)))
|
||||||
(and target-options
|
(and target-options
|
||||||
(alist-get option-name target-options nil nil #'equal))))
|
(alist-get option-name target-options nil nil #'equal))))
|
||||||
|
|
||||||
(defun cc/reinitialize-clang-options (target)
|
(defun clang/reinitialize-clang-options (target)
|
||||||
(interactive (list (intern (lls/conf-get 'target))))
|
(interactive (list (intern (lls/conf-get 'target))))
|
||||||
(let ((option-name (or (gethash target cc/current-target-optionset)
|
(let ((option-name (or (gethash target clang/current-target-optionset)
|
||||||
(puthash target "default" cc/current-target-optionset))))
|
(puthash target "default" clang/current-target-optionset))))
|
||||||
(aprog1 (cc/make-clang-option-set target)
|
(aprog1 (clang/make-clang-option-set target)
|
||||||
(cc/push-new-target-option target option-name it))))
|
(clang/push-new-target-option target option-name it))))
|
||||||
|
|
||||||
;;; THE function
|
;;; THE function
|
||||||
(defun cc/get-clang-options-for-target (target &optional option-name)
|
(defun clang/get-clang-options-for-target (target &optional option-name)
|
||||||
(let ((option-name (or option-name
|
(let ((option-name (or option-name
|
||||||
(gethash target cc/current-target-optionset)
|
(gethash target clang/current-target-optionset)
|
||||||
(puthash target "default" cc/current-target-optionset))))
|
(puthash target "default" clang/current-target-optionset))))
|
||||||
(or (gethash (buffer-file-name) cc/file-specific-options)
|
(or (gethash (buffer-file-name) clang/file-specific-options)
|
||||||
(cc/get-named-target-clang-optionset target option-name)
|
(clang/get-named-target-clang-optionset target option-name)
|
||||||
(aprog1 (cc/make-clang-option-set target)
|
(aprog1 (clang/make-clang-option-set target)
|
||||||
(cc/push-new-target-option target option-name it)))))
|
(clang/push-new-target-option target option-name it)))))
|
||||||
|
|
||||||
;; (cc/get-clang-options-for-target "c29")
|
;; (clang/get-clang-options-for-target "c29")
|
||||||
|
|
||||||
(defun cc/new-clang-option-set (target name &optional optionset)
|
;; (defun clang/new-clang-option-set (target name &optional optionset)
|
||||||
|
;; (interactive
|
||||||
|
;; (list (intern (lls/conf-get 'target))
|
||||||
|
;; (read-string "Name for new optionset? ")))
|
||||||
|
;; (let ((optionset (or optionset (clang/make-clang-option-set target))))
|
||||||
|
;; (clang/add-and-set-target-option target name optionset)))
|
||||||
|
|
||||||
|
;; (defun clang/copy-clang-option-set (target name &optional optionset)
|
||||||
|
;; (interactive
|
||||||
|
;; (list (intern (lls/conf-get 'target))
|
||||||
|
;; (read-string "Name for new optionset? ")))
|
||||||
|
;; (let ((optionset (clang/get-clang-options-for-target target)))
|
||||||
|
;; (clang/add-and-set-target-option target name optionset)))
|
||||||
|
|
||||||
|
;; (defun clang/file-specific-option-set (target &optional optionset)
|
||||||
|
;; (interactive
|
||||||
|
;; (list (intern (lls/conf-get 'target))))
|
||||||
|
;; ;; TODO: might need to garbage collect these
|
||||||
|
;; (or (gethash (buffer-file-name)
|
||||||
|
;; clang/file-specific-options)
|
||||||
|
;; (let ((optionset (clang/get-clang-options-for-target target)))
|
||||||
|
;; (puthash (buffer-file-name)
|
||||||
|
;; optionset
|
||||||
|
;; clang/file-specific-options))))
|
||||||
|
|
||||||
|
;; (clang/new-clang-option-set "c29" "toyota")
|
||||||
|
|
||||||
|
(defun clang/switch-clang-option-set (target name)
|
||||||
(interactive
|
(interactive
|
||||||
(list (intern (lls/conf-get 'target))
|
(let ((target lls/conf-get 'target))
|
||||||
(read-string "Name for new optionset? ")))
|
|
||||||
(let ((optionset (or optionset (cc/make-clang-option-set target))))
|
|
||||||
(cc/add-and-set-target-option target name optionset)))
|
|
||||||
|
|
||||||
(defun cc/copy-clang-option-set (target name &optional optionset)
|
|
||||||
(interactive
|
|
||||||
(list (intern (lls/conf-get 'target))
|
|
||||||
(read-string "Name for new optionset? ")))
|
|
||||||
(let ((optionset (cc/get-clang-options-for-target target)))
|
|
||||||
(cc/add-and-set-target-option target name optionset)))
|
|
||||||
|
|
||||||
(defun cc/file-specific-option-set (target &optional optionset)
|
|
||||||
(interactive
|
|
||||||
(list (intern (lls/conf-get 'target))))
|
|
||||||
;; TODO: might need to garbage collect these
|
|
||||||
(or (gethash (buffer-file-name)
|
|
||||||
cc/file-specific-options)
|
|
||||||
(let ((optionset (cc/get-clang-options-for-target target)))
|
|
||||||
(puthash (buffer-file-name)
|
|
||||||
optionset
|
|
||||||
cc/file-specific-options))))
|
|
||||||
|
|
||||||
;; (cc/new-clang-option-set "c29" "toyota")
|
|
||||||
|
|
||||||
(defun cc/switch-clang-option-set (target name)
|
|
||||||
(interactive
|
|
||||||
(let ((target (lls/conf-get 'target)))
|
|
||||||
(list target
|
(list target
|
||||||
(--> (intern target)
|
(--> (intern target)
|
||||||
(gethash it cc/all-target-options)
|
(gethash it clang/all-target-options)
|
||||||
(mapcar #'car it)
|
(mapcar #'car it)
|
||||||
(completing-read "Optionset? " it)))))
|
(completing-read "Optionset? " it)))))
|
||||||
(remhash (buffer-file-name)
|
(remhash (buffer-file-name)
|
||||||
cc/file-specific-options)
|
clang/file-specific-options)
|
||||||
(cc/get-clang-options-for-target target name)
|
(clang/get-clang-options-for-target target name)
|
||||||
(puthash (intern target) name cc/current-target-optionset))
|
(puthash (intern target) name clang/current-target-optionset))
|
||||||
|
|
||||||
(defun cc/edit-clang-options (prefix)
|
(defun clang/edit-clang-options (prefix)
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let* ((target (intern (lls/conf-get 'target)))
|
(let* ((target (intern (lls/conf-get 'target)))
|
||||||
(options-config
|
(options-config
|
||||||
(->>
|
(->>
|
||||||
target
|
target
|
||||||
(cc/get-clang-options-for-target)
|
(clang/get-clang-options-for-target)
|
||||||
(car)))
|
(car)))
|
||||||
(current-name
|
(current-name
|
||||||
(or (and (gethash (buffer-file-name) cc/file-specific-options )
|
(or (and (gethash (buffer-file-name) clang/file-specific-options )
|
||||||
"file-specific")
|
"file-specific")
|
||||||
(gethash target cc/current-target-optionset))))
|
(gethash target clang/current-target-optionset))))
|
||||||
(dolist (slot (cddr (eieio-class-slots 'clang-option-config)))
|
(cos/edit-compiler-options options-config current-name)))
|
||||||
(let* ((slot-sym (eieio-slot-descriptor-name slot))
|
|
||||||
(slot-val (and (slot-boundp options-config slot-sym)
|
|
||||||
(slot-value options-config slot-sym))))
|
|
||||||
(when slot-val
|
|
||||||
(pcase (cl--slot-descriptor-type slot)
|
|
||||||
('list
|
|
||||||
(when (or prefix
|
|
||||||
(not (zerop (length slot-val))))
|
|
||||||
(setf (slot-value options-config slot-sym)
|
|
||||||
(read
|
|
||||||
(read-string (format "Edit '%s' for optionset '%s': "
|
|
||||||
(symbol-name slot-sym)
|
|
||||||
current-name)
|
|
||||||
(prin1-to-string slot-val))))))
|
|
||||||
('string
|
|
||||||
(when (or prefix
|
|
||||||
(not (string= slot-val "")))
|
|
||||||
(setf (slot-value options-config slot-sym)
|
|
||||||
(read-string (format "Edit '%s' for optionset '%s': "
|
|
||||||
(symbol-name slot-sym)
|
|
||||||
current-name)
|
|
||||||
slot-val))))))))))
|
|
||||||
|
|
||||||
(defvar cc/detect-extensions-function nil)
|
(defun clang/clang-options-merge (primary secondary)
|
||||||
|
(make-instance
|
||||||
|
'clang-option-config
|
||||||
|
:target-str (slot-value primary 'target-str)
|
||||||
|
:binary (or (slot-value primary 'binary-path)
|
||||||
|
(car (mapcar #'(lambda (x) (slot-value x 'binary-path))) ))
|
||||||
|
:target (slot-value primary 'target-options)
|
||||||
|
:lang (slot-value primary 'lang-options)
|
||||||
|
:optimization (slot-value primary 'optimization-level)
|
||||||
|
:other (-->
|
||||||
|
(cons primary secondary)
|
||||||
|
(mapconcat
|
||||||
|
(lambda (x)
|
||||||
|
(when (slot-boundp x 'other-options)
|
||||||
|
(slot-value x 'other-options)))
|
||||||
|
it
|
||||||
|
" "))
|
||||||
|
:include-dirs (-->
|
||||||
|
(cons primary secondary)
|
||||||
|
(apply #'append
|
||||||
|
(mapcar
|
||||||
|
(lambda (x)
|
||||||
|
(when (slot-boundp x 'include-dirs)
|
||||||
|
(slot-value x 'include-dirs)))
|
||||||
|
it)))))
|
||||||
|
|
||||||
(cl-defun cc/get-clang-options (&key filename compiler action)
|
(defun clang/clang-options->string (opts)
|
||||||
|
(with-slots
|
||||||
|
(binary-path
|
||||||
|
target-options lang-options
|
||||||
|
other-options optimization-level
|
||||||
|
include-dirs)
|
||||||
|
opts
|
||||||
|
(-->
|
||||||
|
(list
|
||||||
|
(or binary-path "")
|
||||||
|
target-options
|
||||||
|
lang-options
|
||||||
|
optimization-level
|
||||||
|
other-options
|
||||||
|
(mapconcat (lambda (x)
|
||||||
|
(format "-I\"%s\"" x))
|
||||||
|
include-dirs
|
||||||
|
" "))
|
||||||
|
(remove-if #'string-empty-p it)
|
||||||
|
(string-join it " "))))
|
||||||
|
|
||||||
|
(defvar clang/detect-extensions-function nil)
|
||||||
|
|
||||||
|
(cl-defun clang/get-clang-options (&key filename compiler action)
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((filename (or filename (buffer-file-name)))
|
(let* ((filename (or filename (buffer-file-name)))
|
||||||
(target-str (lls/conf-get 'target))
|
(target-str (lls/conf-get 'target))
|
||||||
(target (intern target-str))
|
(target (intern target-str))
|
||||||
(options-config
|
(options-config
|
||||||
(cc/get-clang-options-for-target target))
|
(clang/get-clang-options-for-target target))
|
||||||
(detected-extensions
|
(detected-extensions
|
||||||
(awhen cc/detect-extensions-function
|
(awhen clang/detect-extensions-function
|
||||||
(funcall it compiler action filename target-str))))
|
(funcall it compiler action filename target-str))))
|
||||||
(cos/clang-options->string
|
(cos/clang-options->string
|
||||||
(cos/clang-options-merge
|
(cos/clang-options-merge
|
||||||
|
|
|
||||||
|
|
@ -1,93 +0,0 @@
|
||||||
;;; clang-option-sets.el --- -*- lexical-binding: t -*-
|
|
||||||
|
|
||||||
;; Copyright (C) 2024 Benson Chu
|
|
||||||
|
|
||||||
;; Author: Benson Chu <bensonchu457@gmail.com>
|
|
||||||
;; Created: [2024-05-05 15:13]
|
|
||||||
|
|
||||||
;; This file is not part of GNU Emacs
|
|
||||||
|
|
||||||
;; This program is free software: you can redistribute it and/or modify
|
|
||||||
;; it under the terms of the GNU General Public License as published by
|
|
||||||
;; the Free Software Foundation, either version 3 of the License, or
|
|
||||||
;; (at your option) any later version.
|
|
||||||
|
|
||||||
;; This program is distributed in the hope that it will be useful,
|
|
||||||
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
;; GNU General Public License for more details.
|
|
||||||
|
|
||||||
;; You should have received a copy of the GNU General Public License
|
|
||||||
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
;;; Commentary:
|
|
||||||
|
|
||||||
;;; Code:
|
|
||||||
|
|
||||||
(defclass clang-option-config ()
|
|
||||||
((target-str :initarg :target-str :type string :initform "")
|
|
||||||
(binary-path :initarg :binary :type string :initform "")
|
|
||||||
(target-options :initarg :target :type string :initform "")
|
|
||||||
(lang-options :initarg :lang :type string :initform "")
|
|
||||||
(other-options :initarg :other :type string :initform "")
|
|
||||||
(optimization-level :initarg :optimization :type string :initform "")
|
|
||||||
(include-dirs :initarg :include-dirs :type list :initform nil)
|
|
||||||
(system-include-dirs :initarg :isystem :type list :initform nil)))
|
|
||||||
|
|
||||||
(defmacro register-prebaked-optionset (hashmap target-str key &rest options)
|
|
||||||
(declare (indent 3))
|
|
||||||
`(puthash ',key
|
|
||||||
(make-instance 'clang-option-config
|
|
||||||
:target-str ,target-str
|
|
||||||
,@options)
|
|
||||||
,hashmap))
|
|
||||||
|
|
||||||
(defun cos/clang-options-merge (primary secondary)
|
|
||||||
(make-instance
|
|
||||||
'clang-option-config
|
|
||||||
:target-str (slot-value primary 'target-str)
|
|
||||||
:binary (or (slot-value primary 'binary-path)
|
|
||||||
(car (mapcar #'(lambda (x) (slot-value x 'binary-path))) ))
|
|
||||||
:target (slot-value primary 'target-options)
|
|
||||||
:lang (slot-value primary 'lang-options)
|
|
||||||
:optimization (slot-value primary 'optimization-level)
|
|
||||||
:other (-->
|
|
||||||
(cons primary secondary)
|
|
||||||
(mapconcat
|
|
||||||
(lambda (x)
|
|
||||||
(when (slot-boundp x 'other-options)
|
|
||||||
(slot-value x 'other-options)))
|
|
||||||
it
|
|
||||||
" "))
|
|
||||||
:include-dirs (-->
|
|
||||||
(cons primary secondary)
|
|
||||||
(apply #'append
|
|
||||||
(mapcar
|
|
||||||
(lambda (x)
|
|
||||||
(when (slot-boundp x 'include-dirs)
|
|
||||||
(slot-value x 'include-dirs)))
|
|
||||||
it)))))
|
|
||||||
|
|
||||||
(defun cos/clang-options->string (opts)
|
|
||||||
(with-slots
|
|
||||||
(binary-path
|
|
||||||
target-options lang-options
|
|
||||||
other-options optimization-level
|
|
||||||
include-dirs)
|
|
||||||
opts
|
|
||||||
(-->
|
|
||||||
(list
|
|
||||||
(or binary-path "")
|
|
||||||
target-options
|
|
||||||
lang-options
|
|
||||||
optimization-level
|
|
||||||
other-options
|
|
||||||
(mapconcat (lambda (x)
|
|
||||||
(format "-I\"%s\"" x))
|
|
||||||
include-dirs
|
|
||||||
" "))
|
|
||||||
(remove-if #'string-empty-p it)
|
|
||||||
(string-join it " "))))
|
|
||||||
|
|
||||||
(provide 'clang-option-sets)
|
|
||||||
;;; clang-option-sets.el ends here
|
|
||||||
73
lisp/llvm-lib/compiler-option-sets.el
Normal file
73
lisp/llvm-lib/compiler-option-sets.el
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
;;; compiler-option-sets.el --- -*- lexical-binding: t -*-
|
||||||
|
|
||||||
|
;; Copyright (C) 2024 Benson Chu
|
||||||
|
|
||||||
|
;; Author: Benson Chu <bensonchu457@gmail.com>
|
||||||
|
;; Created: [2024-05-05 15:13]
|
||||||
|
|
||||||
|
;; This file is not part of GNU Emacs
|
||||||
|
|
||||||
|
;; This program is free software: you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
|
||||||
|
;; This program is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(defclass compiler-option-config ()
|
||||||
|
((target-str :initarg :target-str :type string :initform "")
|
||||||
|
(binary-path :initarg :binary :type string :initform "")
|
||||||
|
(target-options :initarg :target :type string :initform "")
|
||||||
|
(lang-options :initarg :lang :type string :initform "")
|
||||||
|
(other-options :initarg :other :type string :initform "")
|
||||||
|
(optimization-level :initarg :optimization :type string :initform "")
|
||||||
|
(include-dirs :initarg :include-dirs :type list :initform nil)
|
||||||
|
(system-include-dirs :initarg :isystem :type list :initform nil)))
|
||||||
|
|
||||||
|
(defmacro register-prebaked-optionset (hashmap target-str key &rest options)
|
||||||
|
(declare (indent 3))
|
||||||
|
`(puthash ',key
|
||||||
|
(make-instance 'compiler-option-config
|
||||||
|
:target-str ,target-str
|
||||||
|
,@options)
|
||||||
|
,hashmap))
|
||||||
|
|
||||||
|
(defun cos/edit-compiler-options (optionset current-name)
|
||||||
|
(dolist (slot (cddr (eieio-class-slots 'compiler-option-config)))
|
||||||
|
(let* ((slot-sym (eieio-slot-descriptor-name slot))
|
||||||
|
(slot-val (and (slot-boundp optionsset slot-sym)
|
||||||
|
(slot-value optionsset slot-sym))))
|
||||||
|
(when slot-val
|
||||||
|
(pcase (cl--slot-descriptor-type slot)
|
||||||
|
('list
|
||||||
|
(when (or prefix
|
||||||
|
(not (zerop (length slot-val))))
|
||||||
|
(setf (slot-value optionsset slot-sym)
|
||||||
|
(read
|
||||||
|
(read-string (format "Edit '%s' for optionset '%s': "
|
||||||
|
(symbol-name slot-sym)
|
||||||
|
current-name)
|
||||||
|
(prin1-to-string slot-val))))))
|
||||||
|
('string
|
||||||
|
(when (or prefix
|
||||||
|
(not (string= slot-val "")))
|
||||||
|
(setf (slot-value optionsset slot-sym)
|
||||||
|
(read-string (format "Edit '%s' for optionset '%s': "
|
||||||
|
(symbol-name slot-sym)
|
||||||
|
current-name)
|
||||||
|
slot-val)))))))))
|
||||||
|
|
||||||
|
(cl-defgeneric cos/process-c-file (optionset result file output))
|
||||||
|
|
||||||
|
(provide 'compiler-option-sets)
|
||||||
|
;;; compiler-option-sets.el ends here
|
||||||
|
|
@ -50,24 +50,17 @@
|
||||||
|
|
||||||
;; =============================== Init ==============================
|
;; =============================== Init ==============================
|
||||||
|
|
||||||
(defclass llvm-config ()
|
(defclass comp-dev-config ()
|
||||||
((root-dir :initarg :root-dir :type string)
|
((root-dir :initarg :root-dir :type string)
|
||||||
(bin-dirs-fun :initarg :bin-dirs-fun :type function)
|
|
||||||
(build-dirs-fun :initarg :build-dirs-fun :type function)
|
|
||||||
(build-release-dir :initarg :build-release-dir :type string)
|
|
||||||
(build-debug-dir :initarg :build-debug-dir :type string)
|
|
||||||
(target :initarg :target :type string)
|
(target :initarg :target :type string)
|
||||||
(compile-command-fun :initarg :cc :type function :initform (lambda ()))
|
|
||||||
(dis-command-fun :initarg :dc :type function :initform (lambda ()))
|
|
||||||
(llc-command-fun :initarg :llc :type function :initform (lambda ()))
|
|
||||||
(tramp-connection :initarg :tramp :type list :initform nil)
|
|
||||||
;; Target + CPU -> compilation command options
|
;; Target + CPU -> compilation command options
|
||||||
(target-clang-opts-fun :initarg :clang-opts-fun :type function :initform (lambda ()))
|
(target-clang-opts-fun :initarg :clang-opts-fun :type function :initform (lambda ()))
|
||||||
(aux-props :initarg :aux-props :type list :initform nil)))
|
(aux-props :initarg :aux-props :type list :initform nil)))
|
||||||
|
|
||||||
;; (defvar lls/llvm-config nil)
|
(cl-defgeneric comp-dev/get-bin-dirs (config))
|
||||||
|
(cl-defgeneric comp-dev/get-build-dirs (config))
|
||||||
|
|
||||||
(defvar lls/llvm-configs (make-hash-table :test #'equal))
|
(defvar comp-dev/configs (make-hash-table :test #'equal))
|
||||||
|
|
||||||
(defvar lls/target-init-fun nil)
|
(defvar lls/target-init-fun nil)
|
||||||
|
|
||||||
|
|
@ -83,6 +76,8 @@
|
||||||
conf
|
conf
|
||||||
lls/llvm-configs))
|
lls/llvm-configs))
|
||||||
|
|
||||||
|
;; (defvar lls/llvm-config nil)
|
||||||
|
|
||||||
(defun lls/conf-get (sym)
|
(defun lls/conf-get (sym)
|
||||||
(lls/ensure-initialized)
|
(lls/ensure-initialized)
|
||||||
(slot-value (lls/get-llvm-config) sym))
|
(slot-value (lls/get-llvm-config) sym))
|
||||||
|
|
@ -140,9 +135,12 @@
|
||||||
(load-llvm-mode (lls/conf-get 'root-dir))
|
(load-llvm-mode (lls/conf-get 'root-dir))
|
||||||
(message "llvm-lib initialize!"))
|
(message "llvm-lib initialize!"))
|
||||||
|
|
||||||
|
(defun lls/initialized? ()
|
||||||
|
(and (lls/get-llvm-config)
|
||||||
|
(llvm-config-p (lls/get-llvm-config))))
|
||||||
|
|
||||||
(defun lls/ensure-initialized ()
|
(defun lls/ensure-initialized ()
|
||||||
(when (or (not (lls/get-llvm-config))
|
(when (not (lls/initialized?))
|
||||||
(not (llvm-config-p (lls/get-llvm-config))))
|
|
||||||
(if (not (functionp lls/target-init-fun))
|
(if (not (functionp lls/target-init-fun))
|
||||||
(error "Please register an init function for llvm")
|
(error "Please register an init function for llvm")
|
||||||
(lls/initialize))))
|
(lls/initialize))))
|
||||||
|
|
@ -207,10 +205,6 @@
|
||||||
(cons dir
|
(cons dir
|
||||||
(lls/conf-get 'build-dirs))))
|
(lls/conf-get 'build-dirs))))
|
||||||
|
|
||||||
(defun lls/get-clang-options (&rest args)
|
|
||||||
(apply (lls/conf-get 'target-clang-opts-fun)
|
|
||||||
args))
|
|
||||||
|
|
||||||
;; =============================== Misc ==============================
|
;; =============================== Misc ==============================
|
||||||
|
|
||||||
(defun my/completing-read (prompt collection &optional initial-input)
|
(defun my/completing-read (prompt collection &optional initial-input)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue