[Scons-users] Overriding the default compilation behavior / supporting new compilers

Bill Deegan bill at baddogconsulting.com
Wed Sep 27 12:10:25 EDT 2017


Generally the compiler and linker are implemented as different tools as far
as SCons is concerned.
That said migrating your more complex logic into site_scons/__init__.py and
if appropriate different tools in site_scons/site_tools is wise.

Regardless, if you care compiling C or C++, then basing your tools or
modifications to existing variables would be the simplest way to use your
cross compilers.



On Wed, Sep 27, 2017 at 11:41 AM, Hua Yanghao <huayanghao at gmail.com> wrote:

> Thanks Dan.
>
> The problem is more with a customized AR command, where the current
> implementation inserts an "rc" after ar (e.g. ar rc ....).
> I guess I can still override the ARFLAG environment variable instead
> of appending to it.
>
> However as there are some default FLAGS in other cases I do not want
> to override, so it becomes fragmented as I have to consider every and
> each cases and consider if I should append to it or replace and
> append. In the end I thought it might be cleaner if I just write an
> implementation of this special compiler with generate/exists calls but
> I am not successful so far for scons to automatically discover it in
> site_scons/site_tools/ folder. e.g. instead of a centrally located
> huge if/else I want to split the logic into separate pieces just for
> the sake of easier maintenance in the future.
>
> BR, Yanghao
>
> On Wed, Sep 27, 2017 at 5:20 PM, Dan Čermák
> <dan.cermak at cgc-instruments.com> wrote:
> > Hi Yanghao,
> >
> > you can override the environment variable 'CCCOM' to tell scons how your
> > compiler behaves (based on some condition).
> >
> > For example:
> >
> > env = Environment()
> >
> > env["CC"] = os.getenv("CC") or "gcc"
> >
> > if env["CC"] == "xyz-cc":
> >    env["CCCOM"] = '$CC -c $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES'
> >
> > You can find the documentation of all these CC-something variables here:
> > http://scons.org/doc/1.0.1/HTML/scons-user/a4754.html
> > (the example I gave here is more or less copy-pasted from my SConstruct,
> > which I use to build a arm cortex m4 firmware with arm-none-eabi-gcc &
> > TI's armcl compiler)
> >
> > Hope this is what you wanted to know.
> >
> >
> > Cheers,
> >
> > Dan
> >
> > Hua Yanghao <huayanghao at gmail.com> writes:
> >
> >> Dear Scons Friends,
> >> I looked at https://bitbucket.org/scons/scons/wiki/ToolsForFools which
> >> is a good starting point explaining how to use scons to implement
> >> tools. However I am missing one part how scons is actually connecting
> >> the CC=xyz-cc to the tools/xyz-cc.py file. For cross-compilation (e.g.
> >> CC=arm-none-eabi-gcc) it just works (I assume it is using the GCC
> >> command line options).
> >>
> >> Assume I have a customized C compiler called xyz-cc which uses
> >> completely different command line options to generate object files and
> >> a customized library archiver xyz-ar for building static libraries.
> >> Instead of making a new builder name (e.g. xyzObject(),
> >> xyzStaticLibrary), how can I change the default behaviour of the
> >> Object/StaticLibrary/Program builder to use my customized compilation
> >> tool chain?
> >>
> >> Best Regards,
> >> Yanghao
> >> _______________________________________________
> >> 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/20170927/ad04fd37/attachment-0001.html>


More information about the Scons-users mailing list