diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-02-11 19:30:22 +0530 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2020-02-11 10:00:40 -0500 |
commit | 1e4eeccb0f23f245ff8b65a51de03cda38632df4 (patch) | |
tree | 3a41d29d456d7fbd60f95e6bcb8e960fb018acc4 | |
parent | 36a0797e1c987cd08d1b3b993f52b17fa9a15542 (diff) | |
download | meson-1e4eeccb0f23f245ff8b65a51de03cda38632df4.zip meson-1e4eeccb0f23f245ff8b65a51de03cda38632df4.tar.gz meson-1e4eeccb0f23f245ff8b65a51de03cda38632df4.tar.bz2 |
configure_file: Also copy timestamps to avoid useless rebuilds
If we always copy files over without timestamps, we're forcing
a (probably unnecessary) rebuild. Also include a test for this.
-rw-r--r-- | mesonbuild/interpreter.py | 2 | ||||
-rw-r--r-- | test cases/common/14 configure file/check_file.py | 12 |
2 files changed, 10 insertions, 4 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index d824e3c..09f7ff5 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -4006,7 +4006,7 @@ This will become a hard error in the future.''' % kwargs['input'], location=self raise InterpreterException('Exactly one input file must be given in copy mode') os.makedirs(os.path.join(self.environment.build_dir, self.subdir), exist_ok=True) shutil.copyfile(inputs_abs[0], ofile_abs) - shutil.copymode(inputs_abs[0], ofile_abs) + shutil.copystat(inputs_abs[0], ofile_abs) else: # Not reachable raise AssertionError diff --git a/test cases/common/14 configure file/check_file.py b/test cases/common/14 configure file/check_file.py index 6aa73e0..707995e 100644 --- a/test cases/common/14 configure file/check_file.py +++ b/test cases/common/14 configure file/check_file.py @@ -6,9 +6,15 @@ import sys if len(sys.argv) == 2: assert(os.path.exists(sys.argv[1])) elif len(sys.argv) == 3: - f1 = open(sys.argv[1], 'rb').read() - f2 = open(sys.argv[2], 'rb').read() - if f1 != f2: + f1 = sys.argv[1] + f2 = sys.argv[2] + m1 = os.stat(f1).st_mtime_ns + m2 = os.stat(f2).st_mtime_ns + # Compare only os.stat() + if m1 != m2: + raise RuntimeError('mtime of {!r} () != mtime of {!r} ()'.format(f1, m1, f2, m2)) + import filecmp + if not filecmp.cmp(f1, f2): raise RuntimeError('{!r} != {!r}'.format(f1, f2)) else: raise AssertionError |