Discussion:
[Scons-users] Is it normal that changing a construction environment does not trigger a build
Arevalo Reggeti, Juan Carlos Ramon (CW)
2018-10-09 09:02:47 UTC
Permalink
Hi all,

I noticed that in SCons the decider is not called on targets with no dependencies, which I can understand given that the build should entirely depend on the construction env.
However, I noticed that if you changed the environment on a target with no dependencies the build is not triggered, but it is when the builder is changed.

I put together an example below (and attached the files) where every time the SConstruct file is read the environment changes, but the target gets built only once.

My questions are: Shouldn't a change in the environment trigger a new build? If not, is there a workaround other than including a dummy target to make a custom decider that compares environments?

For example take this simple SConstruct:

******************* SCONSTRUCT**************
#!python

import random

print ("-----------NEW EXECUTION-----------")
env = Environment(DATA = str(random.randint(0,20)) + "\n")

def generate_dummy_file(target, env):
with open(str(target), 'w') as f:
f.write(env["DATA"])

def my_builder(target, source, env):
generate_dummy_file(target[0], env)

env.Append(BUILDERS = {'MyBuilder' : Builder(action=my_builder)})



print ("Environment data: " + env["DATA"])
print ("")
target = env.MyBuilder('dummy_file.txt',[])

*************** EXECUTION LOG *******************

[***@vl337 example]$ for INDEX in {1..2}; do scons; done
scons: Reading SConscript files ...
-----------NEW EXECUTION-----------
Environment data: 13


scons: done reading SConscript files.
scons: Building targets ...
my_builder(["dummy_file.txt"], [])
scons: done building targets.
scons: Reading SConscript files ...
-----------NEW EXECUTION-----------
Environment data: 7


scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
Bill Deegan
2018-10-09 12:47:14 UTC
Permalink
Per the manpage: (search for varlist= in the manpage)
Use Action()'s varlist argument like this:

# Alternatively, use a keyword argument.
a = Action(build_it, varlist=['DATA'])



On Tue, Oct 9, 2018 at 5:02 AM Arevalo Reggeti, Juan Carlos Ramon (CW) <
Post by Arevalo Reggeti, Juan Carlos Ramon (CW)
Hi all,
I noticed that in SCons the decider is not called on targets with no
dependencies, which I can understand given that the build should entirely
depend on the construction env.
However, I noticed that if you changed the environment on a target with no
dependencies the build is not triggered, but it is when the builder is
changed.
I put together an example below (and attached the files) where every time
the SConstruct file is read the environment changes, but the target gets
built only once.
My questions are: Shouldn’t a change in the environment trigger a new
build? If not, is there a workaround other than including a dummy target to
make a custom decider that compares environments?
******************* SCONSTRUCT**************
#!python
import random
print ("-----------NEW EXECUTION-----------")
env = Environment(DATA = str(random.randint(0,20)) + "\n")
f.write(env["DATA"])
generate_dummy_file(target[0], env)
env.Append(BUILDERS = {'MyBuilder' : Builder(action=my_builder)})
print ("Environment data: " + env["DATA"])
print ("")
target = env.MyBuilder('dummy_file.txt',[])
*************** EXECUTION LOG *******************
scons: Reading SConscript files ...
-----------NEW EXECUTION-----------
Environment data: 13
scons: done reading SConscript files.
scons: Building targets ...
my_builder(["dummy_file.txt"], [])
scons: done building targets.
scons: Reading SConscript files ...
-----------NEW EXECUTION-----------
Environment data: 7
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Bill Deegan
2018-10-09 12:48:11 UTC
Permalink
Also you should probably use:

target = env.MyBuilder('dummy_file.txt',Value('$DATA'))


To make it clear this is the source..
Post by Bill Deegan
Per the manpage: (search for varlist= in the manpage)
# Alternatively, use a keyword argument.
a = Action(build_it, varlist=['DATA'])
On Tue, Oct 9, 2018 at 5:02 AM Arevalo Reggeti, Juan Carlos Ramon (CW) <
Post by Arevalo Reggeti, Juan Carlos Ramon (CW)
Hi all,
I noticed that in SCons the decider is not called on targets with no
dependencies, which I can understand given that the build should entirely
depend on the construction env.
However, I noticed that if you changed the environment on a target with
no dependencies the build is not triggered, but it is when the builder is
changed.
I put together an example below (and attached the files) where every time
the SConstruct file is read the environment changes, but the target gets
built only once.
My questions are: Shouldn’t a change in the environment trigger a new
build? If not, is there a workaround other than including a dummy target to
make a custom decider that compares environments?
******************* SCONSTRUCT**************
#!python
import random
print ("-----------NEW EXECUTION-----------")
env = Environment(DATA = str(random.randint(0,20)) + "\n")
f.write(env["DATA"])
generate_dummy_file(target[0], env)
env.Append(BUILDERS = {'MyBuilder' : Builder(action=my_builder)})
print ("Environment data: " + env["DATA"])
print ("")
target = env.MyBuilder('dummy_file.txt',[])
*************** EXECUTION LOG *******************
scons: Reading SConscript files ...
-----------NEW EXECUTION-----------
Environment data: 13
scons: done reading SConscript files.
scons: Building targets ...
my_builder(["dummy_file.txt"], [])
scons: done building targets.
scons: Reading SConscript files ...
-----------NEW EXECUTION-----------
Environment data: 7
scons: done reading SConscript files.
scons: Building targets ...
scons: `.' is up to date.
scons: done building targets.
_______________________________________________
Scons-users mailing list
https://pairlist4.pair.net/mailman/listinfo/scons-users
Loading...