[Scons-users] Custom Builder Tool for IAR Compiler
Bill Deegan
bill at baddogconsulting.com
Wed Oct 4 18:11:10 EDT 2017
It's a default builder.
It uses LINK or SHLINK and SHLINKCOM or LINKCOM as the command lines.
Just define those appropriately.
Take a look at link.py and gnulink.py as examples..
On Wed, Oct 4, 2017 at 1:01 PM, Marco Schuler <marco.schuler at gmail.com>
wrote:
> Yes, the compiler does produce object files and only object files (not as
> gcc that can also produce executables). Linking is done by the
> linker-executable. Shared libraries are not to be considered sice I am
> working on bare metal embedded systems.
>
> In fact, I spent some time looking at cc.py and gcc.py, but I could not
> find out where builder "Program" comes from...?
>
> --
> Regards,
> Marco
>
>
>
> Am 04.10.2017 19:41 schrieb "Bill Deegan" <bill at baddogconsulting.com>:
>
>> The "-c" is part of the CCCOM and SHCCCOM values.
>> So you can do:
>> env['CCCOM'] = env['CCCOM'].replace(' -c ','')
>> env['SHCCCOM'] = env['SHCCCOM'].replace(' -c ','')
>>
>> Or you can define both those to whatever is appropriate.
>> Take a look at SCons/Tools/cc.py
>> (And then gcc.py)
>>
>> You may want copy gcc.py as an example and just modify it as you need.
>>
>> Does your compiler not generate object files?
>>
>>
>>
>> On Wed, Oct 4, 2017 at 10:20 AM, Marco Schuler <marco.schuler at gmail.com>
>> wrote:
>>
>>> Hi Bill
>>>
>>> Thanks for your answer.
>>>
>>> The problem is that if I do as you suggest, the call to the compiler
>>> adds a "-c" option (stop after compilation, aka build object file). This
>>> option is not known by my compiler. Thus I thought I'd have to implement my
>>> own builder defining my own COM string.
>>>
>>> With your proposal, how would I get rid of the "-c" option?
>>>
>>> --
>>> Regards
>>>
>>>
>>> Am 04.10.2017 19:14 schrieb "Bill Deegan" <bill at baddogconsulting.com>:
>>>
>>> Marco,
>>>
>>> You should setup the compiler using the normal compielr flags.
>>> So STM8 should be CC, etc.
>>>
>>> Then it should work like any other compiler.
>>>
>>> In fact looking at what you have above, I don't see anything notable
>>> about stm8 compiler besides come CFLAGS and the compiler name.
>>> Am I missing somthing?
>>> -Bil
>>>
>>> On Wed, Oct 4, 2017 at 8:54 AM, Marco Schuler <marco.schuler at gmail.com>
>>> wrote:
>>>
>>>> Hello
>>>>
>>>> I have a IAR compiler for STM8 microcontrollers and since it is rather
>>>> different to call compared to gcc, I implemented a custom Builder/Tool for
>>>> it. I was following https://github.com/SConsProjec
>>>> t/scons/wiki/ToolsForFools.
>>>>
>>>> Here is the directories and files that I have:
>>>>
>>>> site_scons/
>>>> site_tools/
>>>> stm8.py
>>>> site_init.py
>>>> src/
>>>> main.c
>>>> SConstruct
>>>>
>>>> site_init.py so far is an empty file.
>>>>
>>>> Contents of stm8.py is:
>>>>
>>>> import os
>>>>
>>>> import SCons.Action
>>>> import SCons.Builder
>>>> import SCons.Util
>>>>
>>>> class ToolStm8Warning(SCons.Warnings.Warning):
>>>> pass
>>>>
>>>> class Stm8CompilerNotFound(ToolStm8Warning):
>>>> pass
>>>>
>>>> SCons.Warnings.enableWarningClass(ToolStm8Warning)
>>>>
>>>>
>>>> #
>>>> # Builders
>>>> #
>>>>
>>>> _stm8_builder = SCons.Builder.Builder(action=S
>>>> Cons.Action.Action('$STM8_COM', '$STM8_COMSTR'),
>>>>
>>>> suffix='$STM8_SUFFIX',
>>>>
>>>> src_suffix='$STM8_SRC_SUFFIX')
>>>>
>>>> def generate(env):
>>>> """Add Builders and construction variables to the Environment."""
>>>>
>>>> env['STM8'] = 'iccstm8.exe'
>>>>
>>>> env['CFLAGS']=[
>>>> '-e',
>>>> '-Ol',
>>>> '--no_cse',
>>>> '--no_unroll',
>>>> '--no_inline',
>>>> '--no_code_motion',
>>>> '--no_tbaa',
>>>> '--no_cross_call',
>>>> '--debug',
>>>> '--code_model', 'small',
>>>> '--data_model', 'medium',
>>>> '--dlib_config', 'C:\Program Files (x86)\IAR Systems\Embedded
>>>> Workbench 7.3\stm8\LIB\dlstm8smn.h',
>>>> '--vregs', '16'
>>>> ]
>>>>
>>>> env.SetDefault(
>>>> # suffixes/prefixes
>>>> STM8_SUFFIX = ".o",
>>>> STM8_SRC_SUFFIX = ".c",
>>>>
>>>> # command
>>>> STM8_COM = '$STM8 $CFLAGS $SOURCES',
>>>> STM8_COMSTR = '')
>>>>
>>>> # Add stm8 builder to builders
>>>> env['BUILDERS']['Stm8'] = _stm8_builder
>>>>
>>>>
>>>> def exists(env):
>>>> """Check if the preconditions for our tool are met."""
>>>>
>>>> return env.Detect('iccstm8.exe')
>>>>
>>>>
>>>> SConstruct contains the following:
>>>>
>>>> import os
>>>>
>>>> env = Environment(tools=['stm8'],
>>>> ENV=os.environ) # take os-environment to have
>>>> compiler in path
>>>>
>>>> env.Stm8('src\main','src\main')
>>>>
>>>> When I run scons, then a main.o is created in the top level directory.
>>>>
>>>> But actually, I would like to use (instead of env.Stm8):
>>>>
>>>> env.Program(target='main', source='main')
>>>>
>>>> to build the program.
>>>>
>>>> Obviously, the ProgramBuilder is not available anymore in my
>>>> environment. How can I implement my Tool so that I can use env.Program? Did
>>>> I understand something wrong about the usage of a Tool/Builder?
>>>>
>>>> Sorry if the questions might be too basic. I am new to scons...
>>>>
>>>> --
>>>> Regards,
>>>> Marco
>>>>
>>>> _______________________________________________
>>>> 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/20171004/a0c4ed63/attachment-0001.html>
More information about the Scons-users
mailing list