[Scons-users] Provide default Import to SConscript
Bill Deegan
bill at baddogconsulting.com
Fri Feb 23 15:01:57 EST 2018
Take a look at this:
https://gist.github.com/bdbaddog/1ddedecdfd13f6193c173e511e895b1f
That should work.
Forgot that by the time you're in SConstruct it's too late for this to
work. (Or so it seems)
-Bill
On Fri, Feb 23, 2018 at 1:49 PM, Hua Yanghao <huayanghao at gmail.com> wrote:
> Hi Gary,
>
> On Fri, Feb 23, 2018 at 3:42 PM, Gary Oberbrunner <garyo at oberbrunner.com>
> wrote:
> > In case folks don't know this, here are two ways to get symbols into the
> > namespace that SConscripts start with:
> > 1. Add them to SCons.Script (which is automatically imported into all
> > SConscripts)
>
> This doesn't work for me, I assigned "usw_files" to
> SCons.Script.usw_files right before SConscript got called:
> import SCons.Script
> SCons.Script.usw_files = usw_files
> SConscript(...)
>
> and removed the import from one of the SConscript file, I got below error:
> Running : ./tools/scons -Q config=configs/qemu_arm_vexpress.py
> NameError: name 'usw_files' is not defined:
> File "/home/hua/git/usw/SConstruct", line 38:
> usw_config(config, usw_target, target_list, verbose=V)
> File "/home/hua/git/usw/configs/qemu_arm_vexpress.py", line 176:
> main = usw_target(path, "main", "elf", prepend("firmware",
> main_list), main_config, output_list, depends=bios,
> target_list=target_list, verbose=verbose)
> File "/home/hua/git/usw/site_scons/usw_tools.py", line 78:
> BuildObjList(env, scons_folder, cwd, build_dir)
> File "/home/hua/git/usw/site_scons/common.py", line 86:
> env.SConscript(true_scons_file, variant_dir=variant_dir)
> File "/home/hua/git/usw/tools/scons-3.0.1/scons-local-3.0.1/
> SCons/Script/SConscript.py",
> line 551:
> return _SConscript(self.fs, *files, **subst_kw)
> File "/home/hua/git/usw/tools/scons-3.0.1/scons-local-3.0.1/
> SCons/Script/SConscript.py",
> line 256:
> call_stack[-1].globals)
> File "/home/hua/git/usw/build/configs/qemu_arm_vexpress/
> main/firmware/common/SConscript",
> line 6:
> usw_files("elf_obj", obj_files)
>
>
> > 2. Put them in site_init/site_scons.py
> > The site init file logic (in src/engine/SCons/Script/Main.py) prepends
> > site_scons to sys.path, imports site_init.py into the SCons.Script
> > namespace, as well as prepending site_scons/site_tools to the default
> tool
> > path.
> >
> > Also note that in any Python file you can do 'import SCons.Script' and
> use
> > standard SCons functions like File, Dir, Program, etc.
>
>
> I tried but failed to use this method, as my usw_files function needs
> to be different for different configs. this is partially to
> work-around removing the "Return()" part in the SConscript file.If I
> have a way to return things implicitly from SConscript file then I can
> make usw_files() as a static API which can be put in site_init.py.
>
> I tried to put a dummy function in site_init.py and indeed my
> SConscript can see it and call it properly! thanks a lot for the tip.
> Do you have any suggestion to make it easier to implement implicit
> Return() from SConscript?
> _______________________________________________
> 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/20180223/b6a35bc7/attachment-0001.html>
More information about the Scons-users
mailing list