summaryrefslogtreecommitdiffstats
path: root/examples/winexe
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--examples/winexe/wscript21
-rw-r--r--examples/winexe/wscript_build4
2 files changed, 23 insertions, 2 deletions
diff --git a/examples/winexe/wscript b/examples/winexe/wscript
index 6b311b1..c4f13b8 100644
--- a/examples/winexe/wscript
+++ b/examples/winexe/wscript
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+import os
+
def configure(conf):
AR32 = ['i386', 'i586', 'i686']
@@ -27,5 +29,24 @@ def configure(conf):
conf.DEFINE('HAVE_WINEXE_CC_WIN64', 1);
break
+ source_date_epoch = os.environ.get('SOURCE_DATE_EPOCH')
+ if source_date_epoch is None:
+ # We use the version to make up the timestamp that will be
+ # embedded in winexe.exe, to keep the build reproducible.
+ #
+ # This is less evil than it sounds. According to Raymond Chen in
+ # https://devblogs.microsoft.com/oldnewthing/20180103-00/?p=97705
+ # since Windows 10 the timestamp has been randomised.
+ #
+ # The purpose of the timestamp in Windows PE files seems to be
+ # to make spotting ABI changes in DLLs quicker, for which a
+ # random number is just as good as a real time. The timestamp
+ # in .exe files is not used.
+ import samba_version
+ v = samba_version.load_version(env=conf.env)
+ version = (v.MAJOR << 16) | (v.MINOR << 8) | v.RELEASE
+ source_date_epoch = str(version)
+
+ conf.env.SOURCE_DATE_EPOCH = source_date_epoch
conf.DEFINE("WINEXE_LDFLAGS",
"-s -Wall -Wl,-Bstatic -Wl,-Bdynamic -luserenv")
diff --git a/examples/winexe/wscript_build b/examples/winexe/wscript_build
index 3646834..1fe019c 100644
--- a/examples/winexe/wscript_build
+++ b/examples/winexe/wscript_build
@@ -69,7 +69,7 @@ bld.SAMBA_GENERATOR(
'winexesvc32_exe',
source='winexesvc.c',
target='winexesvc32.exe',
- rule='${WINEXE_CC_WIN32} ${SRC} -o ${TGT} ${WINEXE_LDFLAGS}',
+ rule='SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} ${WINEXE_CC_WIN32} ${SRC} -o ${TGT} ${WINEXE_LDFLAGS}',
enabled=bld.env.build_winexe and bld.env.WINEXE_CC_WIN32)
vars = {"WINEXE_FN": "winexesvc32_exe_binary"}
@@ -89,7 +89,7 @@ bld.SAMBA_GENERATOR(
'winexesvc64_exe',
source='winexesvc.c',
target='winexesvc64.exe',
- rule='${WINEXE_CC_WIN64} ${SRC} -o ${TGT} ${WINEXE_LDFLAGS}',
+ rule='SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH} ${WINEXE_CC_WIN64} ${SRC} -o ${TGT} ${WINEXE_LDFLAGS}',
enabled=bld.env.build_winexe and bld.env.WINEXE_CC_WIN64)
vars = {"WINEXE_FN": "winexesvc64_exe_binary"}