[Scons-users] How to generate symbols list on GNU Arm Embedded Toolchain

Marco Pastorelli mpastorelli at gmail.com
Fri Jul 31 10:52:38 EDT 2020


Hi all!

I’m using SCons to build an Arm Cortex-M7 project based on GNU Arm Embedded
Toolchain.
Other than compiling the project, I’d like to generate the list of symbols
to import from my IDE to get an accurate code highlighting.
I wrote some code to generate the list of header files included in the
projects, then I’m trying to get the symbol form every header file.
The main issue I’m facing is that the include hierarchy is not preserved,
so for example I got errors from freertos because FreeRTOS.h must appear in
source files before include task.h.

Does anybody know how to fix this problem or a different method to generate
the symbols list?

Thanks! Below a snippet of my code
Marco


def generate_include_list(env, target, source):
    """create a file to store include paths in GNU style, to be loaded with
@"""
    paths = []
    for p in env['CPPPATH']:
        path = Path(p)
        try:
            path.is_dir()
            paths.append(str(path))
        except OSError:
            pass
    with open('include.list', 'w') as fileout:
        for path in paths:
            fileout.write(' -I ' + path.replace('\\', '/'))


def cleanup_header_list(env, target, source):
    """get rid of the toolchain comments, we only need a list of real file
paths"""
    with open('tmp_header_file.list', 'r') as filein:
        lines = []
        for line in filein:
            path = Path(line.strip())
            try:
                path.is_file()
                lines.append(str(path))
            except OSError:
                pass
    lines.reverse()
    with open('header_file.list', 'w') as fileout:
        for line in reversed(lines):
            fileout.write(line.replace('\\', '/') + '\n')


# get the list of the header files (except toolchain header files)
# in case also the toolchain header files are needed, use the option -M
env.Command(
    target='tmp_header_file.list',
    source='',
    action=[generate_include_list, '$CC -H -MM src/main.c @include.list
$CCFLAGS > $TARGET', cleanup_header_list]
)


# from all the header files get the symbols
env.Command(
    target='symbol.list',
    source='',
    action=['type header_file.list', '$CC -E -dM @include.list $CCFLAGS
@header_file.list > $TARGET']
)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20200731/7f15eb04/attachment.html>


More information about the Scons-users mailing list