Iterative visiting of all source files
Jan Goh <[email protected]> Thu, 30 Oct 2014 18:09:38 +0000
| Newsgroups | gmane.emacs.semantic |
|---|---|
| Message-ID | <[email protected]> |
Hi there,
I mentioned briefly in another response that I have to kind of work around the common semantic paradigm a bit to get things to work. I just want to check if this is a good way to do things or if there's a better way.
Keeping in mind that I have zero control of the project layout, my source files aren't arranged the way that we'd normally see in an OSS project. Files are arranged by subsystem, with headers and source files intermingled in their own directories. (EDE doesn't really seem to like that, from what I've seen, so I wasn't able to use that. I'm happy to be wrong on this, though.)
Anyway, assuming that EDE doesn't meet my needs, I've written this little snippet (with some help from the Internet). I do a save of the semanticdb every time I finish with a directory so that if my processing is interrupted partway through that I still managed to save out some partial data. I've noticed that when I get back to my machine after running an update over the whole source tree that sometimes buffers have been opened with the files that were visited, which confuses me-I was under the impression that this code wouldn't do that. I've also had emacs lock up part way through because it exceeds some imaginary memory limit (Windows claims that emacs is using less than 800MB of memory-out of the 32GB total; this is also confusing). Shouldn't this be fairly low-impact memory wise, or should I be doing something to clean up after myself after the files are visited?
(defun my-semantic-parse-dir (root regex)
"
This function is an attempt of mine to force semantic to
parse all source files under a root directory. Arguments:
-- root: The full path to the root directory
-- regex: A regular expression against which to match all files in the directory
"
(let (
;;make sure that root has a trailing slash and is a dir
(root (file-name-as-directory root))
(files (directory-files root t ))
)
;; remove current dir and parent dir from list
(setq files (delete (format "%s." root) files))
(setq files (delete (format "%s.." root) files))
(while files
(setq file (pop files))
(if (not(file-accessible-directory-p file))
;;if it's a file that matches the regex we seek
(progn (when (string-match-p regex file)
(message file)
(save-excursion
(ignore-errors (semanticdb-file-table-object file)))
))
;; When we're done parsing a directory, save the cache files out.
(semanticdb-save-all-db)
;;else if it's a directory
(my-semantic-parse-dir file regex)
)
)
)
)
Thanks,
JG
------------------------------------------------------------------------------
_______________________________________________
cedet-semantic mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cedet-semantic