Reproducible builds can be achieved by utilizing the timestamp defined by the SOURCE_DATE_EPOCH environment variable.
The following patch enables the propgation of the SOURCE_DATE_EPOCH environment variable and consequently reproducible builds.
Index: SConstruct =================================================================== --- a/SConstruct (revision 7102) +++ b/SConstruct (working copy) @@ -63,20 +63,28 @@ ####### Build Environment ### ###################################################################### +import os path = ARGUMENTS.get('PATH', '') toolset = ARGUMENTS.get('TOOLSET', '') -arch = ARGUMENTS.get('TARGET_ARCH', 'x86') +defenv = { + 'TARGET_ARCH': ARGUMENTS.get('TARGET_ARCH', 'x86'), + 'ENV': {} +} -if toolset and path: - defenv = Environment(TARGET_ARCH = arch, ENV = {'PATH' : path}, TOOLS = toolset.split(',') + ['zip']) +if 'SOURCE_DATE_EPOCH' in os.environ: + defenv['ENV']['SOURCE_DATE_EPOCH'] = os.environ['SOURCE_DATE_EPOCH'] +if path: + defenv['ENV']['PATH'] = path +elif len(defenv['ENV']) == 0: + del defenv['ENV'] else: - if path: - defenv = Environment(TARGET_ARCH = arch, ENV = {'PATH' : path}) - if toolset: - defenv = Environment(TARGET_ARCH = arch, TOOLS = toolset.split(',') + ['zip']) -if not toolset and not path: - defenv = Environment(TARGET_ARCH = arch) + # Propgate PATH if at least one environment variable is set + defenv['ENV']['PATH'] = os.environ['PATH'] +if toolset: + defenv['TOOLS'] = toolset.split(',') + ['zip'] + +defenv = Environment(**defenv) Export('defenv') ###################################################################### @@ -89,7 +97,6 @@ ####### Options ### ###################################################################### -import os default_doctype = 'html' if defenv.WhereIs('hhc', os.environ['PATH']): default_doctype = 'chm'
Why should the presence of SOURCE_DATE_EPOCH trigger the usage of os.environ['PATH']?
As far as I recall setting just the SOURCE_DATE_EPOCH in the ENV directory is not the same for the PATH environment if no ENV directory at all is provided to the Environment object creation.
I don't know the details of how that ENV is handled in SCons. We don't really need to set so early anyway, we just need it set before we start calling external tools. We also have to manually patch the timestamp in PE files for older compiler versions.
I found an issue on Fedora 32:
I think this is new in Python 3.8, thanks.