[Scons-users] How to generate symbols list on GNU Arm Embedded Toolchain
Bill Deegan
bill at baddogconsulting.com
Tue Aug 4 12:34:00 EDT 2020
Can it read a compilation database (ala clang/cmake/ninja/etc)?
On Tue, Aug 4, 2020 at 5:32 AM Marco Pastorelli <mpastorelli at gmail.com>
wrote:
> Hi Hans,
>
> Yes, I spent some time with “CDT build output parser” trying also the
> various options like “heuristics” but when I check the parser log file I
> always find some unresolved name or include.
> So quite often on medium/large projects I get files with a wrong code
> highlight.
>
> I guess an effective solution can be the generation of symbols directly
> from the compiler, this way there’s no need to rely on IDE features.
>
> I feel I’m not far, but I need some help to preserve the include
> hierarchy… any suggestions?
>
> Thanks!
> Marco
>
> On Sat, 1 Aug 2020 at 15:15, Hans-Christian Wild <hchr.wild at gmail.com>
> wrote:
>
>> Have you tried using the CDT build output parser? I would assume it's in
>> there by default. SCons is verbose by default (echos all build commands),
>> so this should be enough for the parser to pick up all includes, defines
>> etc. automatically.
>>
>> -Hans
>>
>> On Sat, Aug 1, 2020 at 10:36 AM Marco Pastorelli <mpastorelli at gmail.com>
>> wrote:
>>
>>> Hi Bill,
>>>
>>> I'm using MCUXpresso, it's an Eclipse-based IDE provided by NXP
>>>
>>> Thanks!
>>> Marco
>>>
>>> On Fri, 31 Jul 2020 at 18:35, Bill Deegan <bill at baddogconsulting.com>
>>> wrote:
>>>
>>>> Which IDE are you using?
>>>>
>>>> On Fri, Jul 31, 2020 at 7:52 AM Marco Pastorelli <mpastorelli at gmail.com>
>>>> wrote:
>>>>
>>>>> 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']
>>>>> )
>>>>> _______________________________________________
>>>>> Scons-users mailing list
>>>>> Scons-users at scons.org
>>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>>
>>>> _______________________________________________
>>>> Scons-users mailing list
>>>> Scons-users at scons.org
>>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>>
>>> _______________________________________________
>>> Scons-users mailing list
>>> Scons-users at scons.org
>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20200804/9b02a0ae/attachment-0001.html>
More information about the Scons-users
mailing list