Aiur

zellux 的博客

为特定的项目配置 semantic

semantic是cedet的组件之一,它可以对程序做语义分析,结合company等其他插件,可以实现自动补全菜单等功能。 之前用semantic+company写MIT 6.828的lab时几乎不需要什么特殊的设置就能直接用,这次拿来改Xen的代码的时候却出现了semantic无法找到符号定义的问题,究其原因在于MIT 6.828的目录结构相对简单,头文件都在inc/目录下,而Xen的头文件在多个目录下,而且做预处理时还要加上Makefile里定义的一些预定义宏。今天参考了Alex Ott的这篇文章终于成功地让semantic支持Xen的代码分析了: 这里分享一下和项目相关的一些设置,semantic安装等问题请参考网上的其他文章。也可以参考我的配置文件http://code.google.com/p/zellux-emacs-conf/source/browse/my-cc-mode.el,cscope ecb semantic和company等配置都在这个文件里了,不过有点混乱。 ;; Danimoth-specified configurations (add-to-list 'semanticdb-project-roots "~/danimoth/xen") (setq semanticdb-project-roots (list (expand-file-name "/"))) (setq danimoth-base-dir "/home/wyx/danimoth") (add-to-list 'auto-mode-alist (cons danimoth-base-dir 'c++-mode)) (add-to-list 'auto-mode-alist (cons danimoth-base-dir 'c-mode)) (add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat danimoth-base-dir "/xen/include/config.h")) (add-to-list 'semantic-lex-c-preprocessor-symbol-file (concat danimoth-base-dir "/xen/include/asm-x86/config.h")) (ede-cpp-root-project "Danimoth" :name "Danimoth" ;; Any file at root directory of the project :file "~/danimoth/xen/Makefile" ;; Relative to the project's root directory :include-path '("/" "/include/asm-x86" "/include/xen" "/include/public" "/include/acpi" "/arch/x86/cpu/" ) ;; Pre-definds macro for preprocessing :spp-table '(("__XEN__" . 阅读全文 →