[Scons-users] Creating SConscripts on the fly

Jason Kenny dragon512 at live.com
Thu Feb 22 09:46:47 EST 2018


I agree. There are some cases that might be a little trick to get right if you have sources that are not under the sconstruct/sconscript that refers to the files. Also one tip that I have is to make sure your root path to the variantdir starts with a ‘#’ this will help prevent issues as your call down the tree into different build files.

I have seen other people use SCons more as an API. Since you seem to be saying that they are not going to call SCons to do the build and you don’t seem to be doing a automake(scons) like generator that makes sconstructs that you can call. You might want to think of SCons more as an API. I new on team that for some reason thought XML was the future of everything and they made a build system that read xml files and called scons to define what was to be built. Scons here was just an API. My system Parts tries to extent scons, but I tend to do stuff to scons at an API level to make this happen. I also track a component tree ( vs a node tree) help me tell if a component needs to be built or not and if not is don’t load the build files to help speed up the builds. I have plans to allow a “part” to load other type of files and parse those files and define to SCons what to do. It look you are wanting to do something similar. I have not done the builder generator way you talk about as this was tricky in how to handle the emitted file ( ie what it should build) to Scons. I personally wanted to make sure that rebuild are fast and correct. Doing what you suggest it not hard for a first pass build, but defining everything so a second pass only build what is needed correctly is the tricky piece here, I am 100% sure you need to define some scanner to make this work right.. I believe Scons supports the idea of new node tree added during build time, however I do not have a good example of how to do this correctly. I think this is what you need to make this work 100% correctly.

Bill do we have an example of such as thing? Ie I think two cases could useful here:


  1.  A builder/scanner example that allows one to add a whole new build tree? Ie the scanner reads you file and emits these files as a depends ( maybe also call some builders to define how to build some of the files)
  2.  A builder that does some work and at the end can scan and add to the node tree what it did. ( This is useful for cases when all we know if that this file will make some stuff. But we don’t know what it is until it is done and we scan a directory for certain types of files) I am not sure if this case is even possible, but knowing that if the other “build” file did not change means we know we should call it if one the nodes changed, and if the other build file did change we want to call it anyways as it probably changed what it will output and the node tree needs to be updated.

I think if we had example of these cases ( if it is possible) would make what is he would like to do much easier and would help in defining other builders ( such as a builders that call other build systems or creating documentation builder a lot easier to define and be correct on rebuilding when it should)

Jason

From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of Bill Deegan
Sent: Thursday, February 22, 2018 7:46 AM
To: SCons users mailing list <scons-users at scons.org>
Subject: Re: [Scons-users] Creating SConscripts on the fly

variant_dir is just a short cut for VariantDir and SConscript.
You don't loose anything.
-Bill

On Thu, Feb 22, 2018 at 4:28 AM, Hua Yanghao <huayanghao at gmail.com<mailto:huayanghao at gmail.com>> wrote:
One slight drawback of this approach I see is: you lost the out of box
variant_dir parameter support.

Bill did show a way in another threads how this can be done also
directly using VariantDir(), so I think this slight drawback is
solvable.

I am thinking this is really a way to solve my SConscript
"default_import" issue, however this means also SConscript will be
hiding from module developers. But I think this is not a problem for
me.

On Thu, Feb 22, 2018 at 7:08 AM, Gary Granger <granger at ucar.edu<mailto:granger at ucar.edu>> wrote:
> Hi Spencer,
>
> If you already have the information to generate the SConscript file from
> within a scons builder, then why not just call the builders directly and let
> scons build the software normally, without requiring an intermediate
> SConscript file?  What purpose does generating the SConscript file serve?
>
> In normal operation, SCons first reads all the SConscript files to build up
> the graph of nodes and dependencies, and then it builds whatever nodes are
> outdated or missing.  So I don't think you can specify that a SConscript
> file is a node that needs to be built, then read that SConscript file to
> modify the graph of nodes and build again, not without running SCons twice.
>
> So in your code which determines whether a module needs to be built, rather
> than generating a SConscript file, just call the builders that the
> SConscript file would have called.  If a module does not need to be built,
> then it is ok to skip calling those builders.  Once all the builders for all
> the modules have been called, SCons will build all the modules in one run.
>
> I hope I understood your situation and this makes sense...
> Gary
>
>
> On 02/21/2018 10:35 PM, Spencer Yost wrote:
>
> I know this has been covered before, and I apologize for plowing old ground.
> I did search around but came up empty handed.  I have a question:
>
> I create my SConscript files on the fly. I have my own system for
> determining whether or not it needs to be built for a particular module in
> the tree, then I build it if needed and then make the SConscript() call.
> this works great.  So I decided I want to create a builder for this
> SConscript creation  - just because that seemed to be the "right" way to do
> it.  But if I use a custom builder it will not build the software if it
> determines the SConscript file needs to be built.  It just creates the
> SConscript file. If it doesn't have to create/recreate, it will build the
> software.
>
> I have become experienced enough with Scons now to realize why it is doing
> this. But there has to be a way to get it to build the SConscript file using
> a builder and build the software without running a second time.  Does anyone
> have a slick way of combining the creation of the SConscript while also
> building?  I do not have a "root"(at the SConstruct level) SConscript file -
> which may the be the answer - but thought  I would ask smarter people than
> me before I spent the time.
>
> Thanks in advance!
>
> Spencer Yost
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org<mailto:Scons-users at scons.org>
> https://pairlist4.pair.net/mailman/listinfo/scons-users<https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpairlist4.pair.net%2Fmailman%2Flistinfo%2Fscons-users&data=02%7C01%7C%7C21e37316701e4614b1d108d579fa962f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636549039519315262&sdata=sHHWGkb7CuXVIfIYnRbyTFsuEfT%2FkNGwh50OZPMEVfE%3D&reserved=0>
>
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org<mailto:Scons-users at scons.org>
> https://pairlist4.pair.net/mailman/listinfo/scons-users<https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpairlist4.pair.net%2Fmailman%2Flistinfo%2Fscons-users&data=02%7C01%7C%7C21e37316701e4614b1d108d579fa962f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636549039519315262&sdata=sHHWGkb7CuXVIfIYnRbyTFsuEfT%2FkNGwh50OZPMEVfE%3D&reserved=0>
>
_______________________________________________
Scons-users mailing list
Scons-users at scons.org<mailto:Scons-users at scons.org>
https://pairlist4.pair.net/mailman/listinfo/scons-users<https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpairlist4.pair.net%2Fmailman%2Flistinfo%2Fscons-users&data=02%7C01%7C%7C21e37316701e4614b1d108d579fa962f%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636549039519315262&sdata=sHHWGkb7CuXVIfIYnRbyTFsuEfT%2FkNGwh50OZPMEVfE%3D&reserved=0>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180222/4520f9e0/attachment-0001.html>


More information about the Scons-users mailing list