Re: [CEDET-devel] ede-linux and .config
Brought to you by:
zappo
From: Eric M. L. <er...@si...> - 2014-03-15 18:37:03
|
On 03/12/2014 03:43 AM, Darren Hoo wrote: > "Eric M. Ludlam"<er...@si...> writes: > > Hi Eric, > > Sorry to bring up this years-old thread again. I full-quoted the mail > for keeping the context. Thanks for the reminder. > 1. How to enable Makefile mode on the config file? The ways I think of are I will answer this question inline with the patch. > 2. How can I turn the config file into a Include tag like what #inlclude ... > does so that semantic can search in it during parsing? If the config file is full of macros that are #defined while parsing code, then there are two possibilities. 1) EDE can add the config.h file to the list of preprocessor symbol files for the project. I'm assuming configure creates a config.h ? To do this, just load it in, parse it, and extract the semantic-lex-spp-macros for you preprocessor symbols. If not... 2) EDE can derive all the preprocessor symbols, and return them via the ede-preprocessor-map method you were patching below. If there is some other reason to treat the .config file as C code then it just needs to be associated with C, probably via auto-mode-alist. >>> >>> === modified file 'ede/ede-linux.el' >>> --- ede/ede-linux.el 2010-05-18 00:42:27 +0000 >>> +++ ede/ede-linux.el 2011-03-20 12:57:45 +0000 >>> @@ -201,6 +201,8 @@ >>> (let* ((proj (ede-target-parent this)) >>> (root (ede-project-root proj)) >>> (versionfile (ede-expand-filename root "include/linux/version.h")) >>> + (configfile (expand-file-name ".config" (oref proj :directory ))) >>> + (version (oref proj :version)) In this part, I recommend the whole "parse the config file" be moved into a separate function. That way if it exists, it will be used, and if not there will be no errors. >>> + ;; in case kernel is not configured, try to figure .config out >>> + (unless (file-exists-p configfile) >>> + (let* ((uname-r (condition-case nil >>> + (with-temp-buffer >>> + (call-process "uname" nil t nil "-r") >>> + (buffer-substring (point-min) (1- (point-max)))) >>> + (error nil))) >>> + (pc "/proc/config.gz") >>> + (bc (format "/boot/config-%s" uname-r))) >>> + (and uname-r (string-match version uname-r) >>> + (or (and (file-exists-p pc) (setq configfile pc)) >>> + (and (file-exists-p bc) (setq configfile bc)))))) >>> + >>> + (and (file-exists-p configfile) >>> + (let (configs) >>> + (with-temp-buffer >>> + (insert-file-contents configfile) Once you have inserted the contents into a temp buffer, call (makefile-mode) to force it to use that tag parser. >>> + (goto-char (point-min)) >>> + (while (re-search-forward "\\(CONFIG_.*?\\)=\\([my]\\)" nil t) >>> + (push (cons (match-string-no-properties 1) >>> + (match-string-no-properties 2)) >>> + configs))) Once here, you can use semantic-fetch-tags, then semantic-find-tags-by-name-regexp, and have all the data you need. Not that I know what the file format is. I'm guessing from the email that it is compatible with Makefile mode. If it is common for the .config to change frequently, you may need to add a new EDE command to the linux project to flush all the semanticdb databases associated with the project. That is the only way to account for changes to the macro values. I hope this helps. Eric |