Christoffer Jansson | 4e8a773 | 2022-02-08 09:01:12 +0100 | [diff] [blame] | 1 | #!/usr/bin/env vpython3 |
| 2 | |
Mirko Bonadei | b985748 | 2020-12-14 15:28:43 +0100 | [diff] [blame] | 3 | # Copyright (c) 2020 The WebRTC project authors. All Rights Reserved. |
| 4 | # |
| 5 | # Use of this source code is governed by a BSD-style license |
| 6 | # that can be found in the LICENSE file in the root of the source |
| 7 | # tree. An additional intellectual property rights grant can be found |
| 8 | # in the file PATENTS. All contributing project authors may |
| 9 | # be found in the AUTHORS file in the root of the source tree. |
| 10 | |
| 11 | import re |
| 12 | import subprocess |
| 13 | import sys |
| 14 | |
| 15 | WEBRTC_VERSION_RE = re.compile( |
| 16 | r'WebRTC source stamp [0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}' |
| 17 | ) |
| 18 | |
| 19 | |
| 20 | if __name__ == '__main__': |
Christoffer Jansson | 4e8a773 | 2022-02-08 09:01:12 +0100 | [diff] [blame] | 21 | args = sys.argv |
| 22 | if len(args) != 2: |
| 23 | print('Usage: binary_version_test.py <FILE_NAME>') |
| 24 | sys.exit(1) |
| 25 | filename = sys.argv[1] |
| 26 | output = subprocess.check_output(['strings', filename]) |
| 27 | strings_in_binary = output.decode('utf-8').splitlines() |
| 28 | for symbol in strings_in_binary: |
| 29 | if WEBRTC_VERSION_RE.match(symbol): |
| 30 | with open('webrtc_binary_version_check', 'w') as f: |
| 31 | f.write(symbol) |
| 32 | sys.exit(0) |
| 33 | print('WebRTC source timestamp not found in "%s"' % filename) |
| 34 | print('Check why "kSourceTimestamp" from call/version.cc is not linked ' |
| 35 | '(or why it has been optimized away by the compiler/linker)') |
| 36 | sys.exit(1) |