1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
(require 'irony-cdb)
(require 'irony-cdb-json)
(require 'cl-lib)
(defun irony-cdb-libclang (command &rest args)
(cl-case command
(get-compile-options (irony-cdb-libclang--get-compile-options))))
(defun irony-cdb-libclang--get-compile-options ()
(irony--awhen (irony-cdb-json--locate-db)
(irony-cdb-libclang--server-exact-flags it)))
(defun irony-cdb-libclang--server-exact-flags (db-file)
"Get compilation options from irony-server.
The parameter DB-FILE is the database file."
(when buffer-file-name
(let* ((build-dir (file-name-directory db-file))
(file buffer-file-name)
(task (irony--get-compile-options-task build-dir file))
(compile-options (irony--run-task task)))
(irony-cdb-libclang--adjust-options-and-remove-compiler
file compile-options))))
(defun irony-cdb-libclang--adjust-options-and-remove-compiler (file cmds)
"Remove compiler, target file FILE and output file from CMDS.
The parameter CMDS is a list of conses. In each cons, the car holds the options
and the cdr holds the working directory where the compile command was issued."
(mapcar (lambda (cmd)
(let ((opt (irony-cdb--remove-compiler-from-flags (car cmd)))
(wdir (cdr cmd)))
(cons
(irony-cdb-json--adjust-compile-options opt file wdir)
wdir)))
cmds))
(provide 'irony-cdb-libclang)
|