Is it normal that changing a construction environment does not trigger a build

"Arevalo Reggeti, Juan Carlos Ramon (CW)" <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <TU4PR8401MB1117CE1E0B5762A7F77E3420F5E70@TU4PR8401MB1117.NAMPRD84.PROD.OUTLOOK.COM>
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 *******************

[arevalor@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.

_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
SConstruct.py (application/octet-stream, 514 B)
#!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',[])
ExecutionLog.txt (text/plain, 526 B)
[arevalor@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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.