[Scons-users] More newbie questions

Bill Deegan bill at baddogconsulting.com
Tue Jul 25 15:38:01 EDT 2017


Spencer,

I looks like your understanding of how SCons works is incompleted.

You might take a look at the psuedo code here:
https://bitbucket.org/scons/scons/wiki/SconsProcessOverview

Basically there are 2 phases:
1) read SConstruct & all SConscript(s) which create Environments() and add
nodes to the DAG
2) walk the DAG and rebuild as needed

(DAG = Directed Acyclic Graph which represents all the dependencies
specified by all the SConstruct/SConscripts processed).

If you are running scons as:
scons <some flags>   some/target/to/build

The only items SCons should build are all the dependencies of
some/target/to/build and that item.
Note that you can use --debug=explain to see why items are being built, and
also --tree=prune to show the dependencies that SCons is aware of.


It may also be useful to add this to the end of your SConstruct to see what
targets have been marked as Default()

print str(DEFAULT_TARGETS[0])
if 'foo' in map(str, DEFAULT_TARGETS):
    print "Don't forget to test the `foo' program!"

-Bill



On Tue, Jul 25, 2017 at 11:26 AM, <syost at triad.rr.com> wrote:

> As you may remember, I am trying to wean my organization from a fairly
> reliable, but slow and exceedingly complicated Frankenstein build system
> developed internally.  Permission and resources to put scons head to head
> with our internal build system came, and I am putting that together demo
> now.   Its not due for a while, but trying to nail down a couple of things:
>
> I have run across an issue with dependencies I am not sure how to fix.
>  If I call scons with a target name; I would assume it looks for dependency
> names in things like the "LIBS" variable.   It would then scans the
> SConscript files it has read and then determines what needed to be built.
>
> But that is not what seems to be happening.
>
> If I have the SConstruct file load just the 4 or 5 SConscript files I
> need, it works.  If I have the SConstruct file scan the whole tree and load
> all 40-50 SConscript files, it will try to build my entire tree .  It will
> NOT just build the target.  So:
>
>  "scons-k -j 2 -site==blahblah --prefix=blahblah src/src/src/src"
>
> will NOT work unless I specifically create 4-5 SConscript() calls in the
> SConstruct file with exactly what my target needs.  If the SConstruct scans
> and loads all of them (like below), I end up with all ~50 packages targets
> being built - even if I specified only one target on the command line.
>
> Is it obvious what I am doing wrong?
>
> Thanks,
>
> Spencer
>
>
>
> SConscript for the target
>
> import os, glob
> from SConfig import *
> myEnv = Environment(PREFIX = GetOption("prefix"))
> THISINCLUDES=[
>     '#/',
>     '/opt/ibm/db2/V10.5/include/']
> myEnv.Append(CPPPATH=THISINCLUDES)
> bld = Builder(action = '/home/db2inst1/sql_udb_prep  $SOURCE
> $TARGET',suffix='.c')
> myEnv.Append(BUILDERS = {'UDBPrecompile' : bld})
> for filename in Glob('*.sc'):
>     myEnv.UDBPrecompile(filename)
>
> finalDeliverable = myEnv.SharedLibrary("com.lowes.so.goodssvcs.ardb.o.so",
> Glob("*.c*") ,
>     LIBS=[
>         'com.lowes.so.transaction.creditcarddb.so',
>         'com.lowes.so.utility.utildb.so',
>         'db2.so'],
>     LIBPATH=[
>         '$PREFIX/opt/lowes/lib',
>         '/opt/ibm/db2/V10.5/lib64/'])
> myEnv.Alias("install", myEnv.InstallPerm("$PREFIX/opt/genesis/lib",
> finalDeliverable, 0711) )
>
>
> SConstruct (just the relevant parts, there is lots more where I am setting
> cxx variables and what not)
>
> os.path.walk(COMMAND_LINE_TARGETS[0], includeAllSConscriptFiles, '')
>
> def UDBPrecompile(target, source, env):
>
>     subprocess(['system/home/db2inst1/sql_udb_prep source'])
>     return None
>
> def includeAllSConscriptFiles(ext, dirname, names):
>     ###  Just want subdirs....
>     pattern = main_source_dir + "/"
>     workingSubDir = dirname.replace(pattern,"")
>     pattern = "^" + BUILD_CONFIGURATION
>     ##  Exclude build directory....
>     if re.search(pattern, basename(dirname)) is None:
>         for name in names:
>             if name.lower() == 'sconscript':
>                 if basename(workingSubDir) == PROJECT_NAME:
>                     sconscript_path = workingSubDir + '/SConscript'
>                     source_dir = main_source_dir
>                     out_dir = BUILD_CONFIGURATION
>                 else:
>                     sconscript_path = os.path.join(workingSubDir,
> 'SConscript')
>                     source_dir = os.path.join(main_source_dir,
> workingSubDir)
>                     out_dir = os.path.join(BUILD_CONFIGURATION,
> workingSubDir)
>
>                 ## print("Adding SConscript: " + sconscript_path + " with
> source dir: " + source_dir + " and outdir: " + out_dir)
>                 o = SConscript(sconscript_path, exports=['env',
> 'source_dir', 'pic' ],
>                    variant_dir=out_dir, duplicate=1)
>
>                 if o:
>                     objs.extend(o)
>
>
> _______________________________________________
> 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/20170725/a1e7c1c1/attachment-0001.html>


More information about the Scons-users mailing list