[Scons-users] how to properly share an output folder with two subfolders?

Bill Deegan bill at baddogconsulting.com
Thu Jun 4 10:37:34 EDT 2020


+1 gary!

Basically a target dir for a variant can only have 1 source.
A Repository() can be used N times.

See:
https://scons.org/doc/production/HTML/scons-man.html#f-Repository

It's probably a bit tricky to make that work, so if you can use Gary's
suggested solution, that would be simpler.

If you can't use Gary's solution, please explain a bit more the purpose of
having a single output directory.
Is this to build a package?
Some other reason?

On Thu, Jun 4, 2020 at 7:28 AM Gary Granger <granger at ucar.edu> wrote:

> Hello Dagg,
>
> It's not clear what you mean by an 'output' directory.  Usually, variant
> builds are used to build the same source different ways, and since the
> target names may be the same, the 'output' of the variants have to go into
> different directories.  So based on your example, the code below uses
> variant_dir to build 'a' two different ways, and the variant targets will
> be put in two different subdirectories of 'output':
>
> env = Environment(O = Dir(env.subst('#/output')).abspath))
> SConscript('a/SConscript', variant_dir="#/output/a1", duplicate = 0, exports = 'env', CC='gcc')
> SConscript('a/SConscript', variant_dir="#/output/a2", duplicate = 0, exports = 'env', CC='clang')
>
> If instead you want to collect 'output' from different source directories
> into the same directory, then you'll need to define the builders that way
> in the subdirectory SConscripts, or else copy the targets explicitly.  So
> call the SConscript files without variant_dir:
>
> env = Environment(O = Dir(env.subst('#/output')).abspath))
> SConscript('a/SConscript', exports = 'env')
> SConscript('b/SConscript', exports = 'env')
>
> Then in the a or b SConscript you could use something like this to build
> directly into the shared output:
>
> Import('env')
> env.StaticObject("$O/$TARGET.file", "source.c")
>
> Or this builds the object and then copies it into the shared output:
>
> Import('env')
> o = env.StaticObject("source.c")
> env.Install("$O", o)
>
> Then it's up to you to make sure the filenames being installed into the
> output directory do not collide.  Note I haven't tested any of this code,
> I'm just working from memory.  If you really do want variant builds of the
> same source to end up in the same output, then you can use a mixture of the
> above.  I think you have to use different directories for the variant_dir
> option, but then you can use builders in the SConscript files which put the
> output into the shared output directory.
>
> Does this help, or am I misunderstanding the question?
>
> gary
>
> On 6/4/20 3:40 AM, daggs wrote:
>
> Greetings,
>
> I have this tree:
> root
> ├── output
> ├── SConstruct
> ├── a
> │   └── SCpnscript
> └── b
>     └── SCpnscript
>
> in SConstruct I do this:
> env = Environment(O = Dir(env.subst('#/output')).abspath))
> SConscript('a/SConscript', variant_dir=env['O'], duplicate = 0, exports = 'env')
> SConscript('b/SConscript', variant_dir=env['O'], duplicate = 0, exports = 'env')
>
> when I run scons, I get this error: scons: *** 'output' already has a source directory: 'a'.
> I tried duplicate = 1 for both but it didn't worked.
> if I change SConscript('b/SConscript', variant_dir=env['O'], duplicate = 0, exports = 'env')
> to SConscript('b/SConscript', exports = 'env') it works but I'm not sure that is the proper way to do it.
> so I wonder, what is the proper way to instruct both them to SConscript to one output folder?
>
> Thanks,
>
> Dagg.
>
> _______________________________________________
> Scons-users mailing listScons-users at scons.orghttps://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/20200604/d5aed5e8/attachment.html>


More information about the Scons-users mailing list