[Scons-users] Provide default Import to SConscript

Bill Deegan bill at baddogconsulting.com
Sat Feb 17 16:15:11 EST 2018


Likely you don't need a SConscript for every directory in your case?
Are you wrapping a complete linux build tree?

Is this a build tree you can share for us to look at?

-Bill

On Sat, Feb 17, 2018 at 3:30 PM, Hua Yanghao <huayanghao at gmail.com> wrote:

> I see everything passed into env.SConscript(default_import=some_obj),
> if some_obj is a string it can pass through but if some_obj is a
> function object it end up as None in Script/SConscript.py/SConscript()
> function.
>
> I could have used a string and then import the right function however
> my function to be passed is a dynamically generated partial function
> ...
>
> Could anyone please give me some hint how could this be best implemented?
>
> Best Regards,
> Yanghao
>
> On Sat, Feb 17, 2018 at 7:53 PM, Hua Yanghao <huayanghao at gmail.com> wrote:
> > @Bill, I have managed to hack the Frame class and the
> > BuildDefaultGlobals() function to have some thing imported into
> > SConscript by default.
> > However I don't quite understand when the "default_import" keyword
> > argument passed down, somewhere somehow it end up as a set.
> >
> > Any documentation to explain what is going on from Base class into
> > SConscript() calls regarding parameter handling?
> >
> > Thanks,
> > Yanghao
> >
> > On Sat, Feb 17, 2018 at 7:45 PM, Hua Yanghao <huayanghao at gmail.com>
> wrote:
> >> It varies a lot, ranging from 0 (yes, no source files at all) to a few
> >> dozen (didn't really count, see statistics below).
> >>
> >> Here is an example Linux kernel driver sub-module Makefile:
> >>
> >> linux/drivers/sn/Makefile:
> >>   1 #
> >>   2 # Makefile for the Altix device drivers.
> >>   3 #
> >>   4 #
> >>   5
> >>   6 obj-$(CONFIG_SGI_IOC3) += ioc3.o
> >>
> >> I want to replicate this kind of simplicity in scons.
> >>
> >> I actually have implemented almost the same thing in scons, but all
> >> those SConscript files have to start with Import("my_func") ... which
> >> is pretty annoying. I know I need it in every single SConscript, and I
> >> have to repeat it ... and this is so anti-pattern.
> >> I have get rid of the Return() part already, but getting rid of the
> >> Import() part seems not that straightforward.
> >>
> >> hua at huyangha-mobl:~/git/usw $ find . -iname "SConscript" | wc
> >>     121     121    5953
> >>
> >> At the moment the project supports 4 different CPU architectures, a
> >> little less than 1000 C files, 400K+ lines of code.
> >>
> >> And this is no small problem (at least for me). If I start working
> >> around it with too much python code, I might end up bypassing a
> >> significant portion of core scons and eventually might find it easier
> >> to just wrap around Makefiles.
> >>
> >> Someone thought I was criticizing scons, I actually love scons, but
> >> that doesn't stop me criticizing scons. ;-) Just don't see me as an
> >> enemy I am a serious user of scons since 10 years ago when I was still
> >> in college.
> >>
> >> Best Regards,
> >> Yanghao
> >>
> >> On Sat, Feb 17, 2018 at 4:46 PM, Bill Deegan <bill at baddogconsulting.com>
> wrote:
> >>> How many source files per SConscript?
> >>> That's a lot of sconscripts.
> >>> Is this all one project?
> >>> Are all the SConscripts identical?
> >>>
> >>> On Sat, Feb 17, 2018 at 3:05 AM, Hua Yanghao <huayanghao at gmail.com>
> wrote:
> >>>>
> >>>> Actually I have one and only one import for hundreds of SConscript :)
> >>>>
> >>>> On Sat, Feb 17, 2018 at 01:19 Jonathon Reinhart
> >>>> <jonathon.reinhart at gmail.com> wrote:
> >>>>>
> >>>>> Hua,
> >>>>>
> >>>>> If you are importing lots of variables into SConscripts, then you're
> >>>>> using SCons wrong. Most of your variables should probably be
> construction
> >>>>> variables (in the environment).
> >>>>>
> >>>>> I've written many, many SConscripts and I've never used more than 3
> or 4
> >>>>> Import() statements in a single SConscript. Before you critique a
> >>>>> long-established framework, you might want to consider if you're
> using it
> >>>>> inappropriately.
> >>>>>
> >>>>> Jonathon
> >>>>>
> >>>>>
> >>>>>
> >>>>> On Fri, Feb 16, 2018 at 6:02 PM, Hua Yanghao <huayanghao at gmail.com>
> >>>>> wrote:
> >>>>>>
> >>>>>> Will do. It is really not good if a particular framework force user
> to
> >>>>>> create repeated code. In comparison kbuild can easily create a one
> line make
> >>>>>> file for a module.
> >>>>>>
> >>>>>> I am using localized scons anyway if not accepted will just use it
> on my
> >>>>>> own.
> >>>>>>
> >>>>>> On Fri, Feb 16, 2018 at 22:46 Bill Deegan <
> bill at baddogconsulting.com>
> >>>>>> wrote:
> >>>>>>>
> >>>>>>> Feel free to make a pull request, though I can't promise that it
> will
> >>>>>>> be accepted.
> >>>>>>>
> >>>>>>> Is it really that much of an inconvenience?
> >>>>>>> -Bill
> >>>>>>>
> >>>>>>>
> >>>>>>> On Fri, Feb 16, 2018 at 3:20 PM, Hua Yanghao <huayanghao at gmail.com
> >
> >>>>>>> wrote:
> >>>>>>>>
> >>>>>>>> Hi Bill,
> >>>>>>>> Do you think if it is useful to add a new keyword for
> >>>>>>>> env.SConscript(default_imports=[xyz,abc,...])?
> >>>>>>>> For return I think I can abuse some global variables. This can
> really
> >>>>>>>> make the SConscript clean/minimal.
> >>>>>>>>
> >>>>>>>> Best Regards,
> >>>>>>>> Yanghao
> >>>>>>>>
> >>>>>>>> On Fri, Feb 16, 2018 at 9:09 PM, Bill Deegan
> >>>>>>>> <bill at baddogconsulting.com> wrote:
> >>>>>>>> > No, there is no way without hacking the core code.
> >>>>>>>> >
> >>>>>>>> > It is the way it is by design.
> >>>>>>>> >
> >>>>>>>> > -Bill
> >>>>>>>> > SCons Project Co-Manager
> >>>>>>>> >
> >>>>>>>> > On Fri, Feb 16, 2018 at 2:28 PM, Hua Yanghao <
> huayanghao at gmail.com>
> >>>>>>>> > wrote:
> >>>>>>>> >>
> >>>>>>>> >> Does anyone know in scons there are ways to implicitly make a
> >>>>>>>> >> object
> >>>>>>>> >> (e.g. xyz) available for SConscript without explicity
> Import(xyz)?
> >>>>>>>> >>
> >>>>>>>> >> Just want to eliminate the annoying repeated Import(xyz) in
> every
> >>>>>>>> >> single SConscript.
> >>>>>>>> >>
> >>>>>>>> >> And what about implicit Return()? e.g. xyz() returns a list of
> >>>>>>>> >> object,
> >>>>>>>> >> then in every SConscript if the top level SConstruct want to
> >>>>>>>> >> collect
> >>>>>>>> >> the complete list of object returned from every single
> SConscript.
> >>>>>>>> >>
> >>>>>>>> >> For example:
> >>>>>>>> >> SConscript-1:
> >>>>>>>> >> Import("xyz")
> >>>>>>>> >>
> >>>>>>>> >> ret = xyz(...)
> >>>>>>>> >>
> >>>>>>>> >> Return("ret")
> >>>>>>>> >>
> >>>>>>>> >> Would ideally become:
> >>>>>>>> >> SConscript-2:
> >>>>>>>> >> xyz(...)
> >>>>>>>> >>
> >>>>>>>> >> Thanks,
> >>>>>>>> >> 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
> >>>>>>>
> >>>>>>>
> >>>>>>> _______________________________________________
> >>>>>>> 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
> >>>
> _______________________________________________
> 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/20180217/cb03243e/attachment.html>


More information about the Scons-users mailing list