[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/beardbolt 0fbc3d3f09 153/323: Enable compile_commands.j
From: |
ELPA Syncer |
Subject: |
[elpa] externals/beardbolt 0fbc3d3f09 153/323: Enable compile_commands.json parsing for c/cpp |
Date: |
Thu, 9 Mar 2023 10:58:26 -0500 (EST) |
branch: externals/beardbolt
commit 0fbc3d3f09c2655b09cedb1ce4e2ce1730175d2a
Author: Jay Kamat <jaygkamat@gmail.com>
Commit: Jay Kamat <jaygkamat@gmail.com>
Enable compile_commands.json parsing for c/cpp
Closes #4
---
rmsbolt-split.el | 3 ++-
rmsbolt.el | 32 ++++++++++++++++++++++++++------
2 files changed, 28 insertions(+), 7 deletions(-)
diff --git a/rmsbolt-split.el b/rmsbolt-split.el
index 2e7e5bf1ea..1fdfc50aab 100644
--- a/rmsbolt-split.el
+++ b/rmsbolt-split.el
@@ -66,5 +66,6 @@
cmd)
" ")))
-;;; rmsbolt-split.el ends here
(provide 'rmsbolt-split)
+
+;;; rmsbolt-split.el ends here
diff --git a/rmsbolt.el b/rmsbolt.el
index 04062ee9f9..b903ff599a 100644
--- a/rmsbolt.el
+++ b/rmsbolt.el
@@ -75,6 +75,7 @@
(require 'json)
(require 'rmsbolt-java)
+(require 'rmsbolt-split)
;;; Code:
;;;; Customize:
@@ -384,9 +385,12 @@ Return value is quoted for passing to the shell."
(cl-defun rmsbolt--c-compile-cmd (&key src-buffer)
"Process a compile command for gcc/clang."
+
(rmsbolt--with-files
src-buffer
- (let* ((asm-format (buffer-local-value 'rmsbolt-asm-format src-buffer))
+ (let* ( ;; Turn off passing the source file if we find compile_commands
+ (no-src-filename (rmsbolt--handle-c-compile-cmd src-buffer))
+ (asm-format (buffer-local-value 'rmsbolt-asm-format src-buffer))
(disass (buffer-local-value 'rmsbolt-disassemble src-buffer))
(cmd (buffer-local-value 'rmsbolt-command src-buffer))
(cmd (mapconcat #'identity
@@ -395,13 +399,16 @@ Return value is quoted for passing to the shell."
(if disass
"-c"
"-S")
- src-filename
+ (if no-src-filename
+ ""
+ src-filename)
"-o" output-filename
(when (and (not (booleanp asm-format))
(not disass))
(concat "-masm=" asm-format)))
" ")))
cmd)))
+
(cl-defun rmsbolt--ocaml-compile-cmd (&key src-buffer)
"Process a compile command for ocaml.
@@ -644,9 +651,13 @@ https://github.com/derickr/vld"
(dir (alist-get 'directory entry))
(cmd (alist-get 'command entry)))
(list dir cmd)))
-(defun rmsbolt--default-c-compile-cmd (src-buffer)
- "Handle compile_commands.json for c/c++ for a given SRC-BUFFER."
- (when-let* ((ccj "compile_commands.json")
+(defun rmsbolt--handle-c-compile-cmd (src-buffer)
+ "Handle compile_commands.json for c/c++ for a given SRC-BUFFER.
+return t if successful."
+ (when-let* ((defaults (buffer-local-value 'rmsbolt--default-variables
src-buffer))
+ (default-dir (cl-find 'rmsbolt-default-directory defaults))
+ (default-cmd (cl-find 'rmsbolt-command defaults))
+ (ccj "compile_commands.json")
(compile-cmd-file
(locate-dominating-file
(buffer-file-name src-buffer)
@@ -654,7 +665,16 @@ https://github.com/derickr/vld"
(compile-cmd-file (expand-file-name ccj compile-cmd-file))
(to-ret (rmsbolt--parse-compile-commands
compile-cmd-file (buffer-file-name src-buffer))))
- to-ret))
+ (with-current-buffer src-buffer
+ (setq-local rmsbolt-default-directory (cl-first to-ret))
+ (setq-local rmsbolt-command
+ ;; Remove -c, -S, and -o <arg> if present,
+ ;; as we will add them back
+ (thread-first (cl-second to-ret)
+ (rmsbolt-split-rm-single "-c")
+ (rmsbolt-split-rm-single "-S")
+ (rmsbolt-split-rm-double "-o")))
+ t)))
;;;; Language Definitions
(defvar rmsbolt-languages)
(setq
- [elpa] externals/beardbolt 9e38f2238b 135/323: Add support for functions as arguments to :compile-cmd, (continued)
- [elpa] externals/beardbolt 9e38f2238b 135/323: Add support for functions as arguments to :compile-cmd, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 1cc069a121 132/323: Quote filenames before passing them as shell arguments, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 495d481a94 136/323: Move rmsbolt-command initialization to end, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 39055a3dc4 133/323: Fix disassembly of partial files in C/C++, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 27e7bb714f 139/323: Add suppport for PHP, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 4b6abc5ef8 129/323: Optimize rmsbolt-process-src-asm-lines, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 67238e0272 138/323: Add rmsbolt-default-directory customization, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 9b2c85397c 149/323: Add texinfo version of docs, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ec99a1aa31 146/323: Attempt to fix whitespace clearing on hot recompiles, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 5e389a88d9 152/323: Add rmsbolt splitter for splitting and mutating commands, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 0fbc3d3f09 153/323: Enable compile_commands.json parsing for c/cpp,
ELPA Syncer <=
- [elpa] externals/beardbolt 743f9a68ec 158/323: Handle non absolute .file paths, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 609f781b3a 165/323: Fix usages of when-let, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt c9f3b839e9 156/323: Add support for D, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt a4f794666d 160/323: Add D to commentary, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt b7d318dfe1 178/323: Add Swift language support, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 98e984493b 170/323: Prevent hot recompile on deleted buffers, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt c655e2af39 186/323: Add check for dead buffers in compilation finish fn, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt d51e71f894 188/323: Use special named buffer for compilation, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt 712981e16c 187/323: Remove langauges godbolt has added support for, ELPA Syncer, 2023/03/09
- [elpa] externals/beardbolt ff496660cc 205/323: Migrate irc channel to libera, ELPA Syncer, 2023/03/09