Generate list of source files for BSP/PSP for etags.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Generate list of source files for BSP/PSP for etags.

Jump to solution
823 Views
billpringlemeir
Contributor V

I am using MQX 4.0.2 and the gcc makefiles.  They are very nice.  I would like to use Emacs for source code navigation and it has an etags program.  I am contemplating manually making a script with find and my BSP and PSP directories as well as the core files to get a list of active source files in my system.  Is there a supported make target or some way to automate this?  Can I limit the list to certain sub-systems or is find the best way to do this?  It seems that certain I/O, etc driver source will not be active for my BSP.  My BSP is for the vf65gs10, but I don't think that matters.  Maybe some 'make -n build' and parse the output?

Message was edited by: Bill Pringlemeir

0 Kudos
1 Solution
650 Views
billpringlemeir
Contributor V

Source Only

Running clean followed by a build with a '-n' seems to work well for me.

make -n HOSTENV=UNIX TOOL=gcc_cs TOOLCHAIN_ROOTDIR=$HOME/x-tools/arm-2012.03 CONFIG=debug build | grep "Compile c file" | cut -d\  -f 6 | xargs etags

All of the makefiles use "echo Compile c file" in their rules so this is an easy target.  I just used grep to select the lines and cut to get the file names.  This does not parse the header files, but seems to give fairly descent source code navigation.

Source and Includes

This method changes the CC_FLAGS variable to add '-MMD'.  This directs gcc to create a dependency list of non-system files and put the output in 'file.d' in the output directories.  The output is placed in 'lib/board.compiler'.  In this directory, you can run,

find . -name '*.d' -exec cat {} \; | tr -s '[[:space:]]' '\n' | sort | uniq | grep -v ':$'  > files.list 

This output needs to be checked for spurious values and then can be feed to etags with something like cat files.list | xargs etags.  This is a little more complex, but you get all of the #defines which are used in bsp.h and the like to select a BSP function inline in the main MQX source.

Use the emacs function M-x visit-tags-table to open the directory where you ran etags and this will read the TAGS file.  Type M-. (alt and period) on a function call and emacs will jump to the source definition for your BSP/PSP.

NOTE:  The method may only work for MQX 4.0.2.  If the Makefiles are improved to do incremental building, then the dependency files maybe generated in a different manner in future versions of MQX.  This will wreck the Source and Include method.  If the makefiles change the text Compile c file, then the 1st method will not work.  Use --regex='/ASM_LABEL(\([A-Z_a-z]+\))/' option to etags to get the assembler function definitions; you may have to add these files by hand.

EDIT: MQX 4.1.0 puts the '.d' files in a 'lib' directory.  The 'find' command above can be run there and a list of files generated.  It includes compiler paths (stdbool.h, etc), but these are easy to edit out.

View solution in original post

0 Kudos
1 Reply
651 Views
billpringlemeir
Contributor V

Source Only

Running clean followed by a build with a '-n' seems to work well for me.

make -n HOSTENV=UNIX TOOL=gcc_cs TOOLCHAIN_ROOTDIR=$HOME/x-tools/arm-2012.03 CONFIG=debug build | grep "Compile c file" | cut -d\  -f 6 | xargs etags

All of the makefiles use "echo Compile c file" in their rules so this is an easy target.  I just used grep to select the lines and cut to get the file names.  This does not parse the header files, but seems to give fairly descent source code navigation.

Source and Includes

This method changes the CC_FLAGS variable to add '-MMD'.  This directs gcc to create a dependency list of non-system files and put the output in 'file.d' in the output directories.  The output is placed in 'lib/board.compiler'.  In this directory, you can run,

find . -name '*.d' -exec cat {} \; | tr -s '[[:space:]]' '\n' | sort | uniq | grep -v ':$'  > files.list 

This output needs to be checked for spurious values and then can be feed to etags with something like cat files.list | xargs etags.  This is a little more complex, but you get all of the #defines which are used in bsp.h and the like to select a BSP function inline in the main MQX source.

Use the emacs function M-x visit-tags-table to open the directory where you ran etags and this will read the TAGS file.  Type M-. (alt and period) on a function call and emacs will jump to the source definition for your BSP/PSP.

NOTE:  The method may only work for MQX 4.0.2.  If the Makefiles are improved to do incremental building, then the dependency files maybe generated in a different manner in future versions of MQX.  This will wreck the Source and Include method.  If the makefiles change the text Compile c file, then the 1st method will not work.  Use --regex='/ASM_LABEL(\([A-Z_a-z]+\))/' option to etags to get the assembler function definitions; you may have to add these files by hand.

EDIT: MQX 4.1.0 puts the '.d' files in a 'lib' directory.  The 'find' command above can be run there and a list of files generated.  It includes compiler paths (stdbool.h, etc), but these are easy to edit out.

0 Kudos