blob: 563fe36186764ef0da0d29d4a76d5097d77db85c [file] [log] [blame]
Christoffer Jansson4e8a7732022-02-08 09:01:12 +01001#!/usr/bin/env vpython3
2
Mirko Bonadeib9857482020-12-14 15:28:43 +01003# 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
11import re
12import subprocess
13import sys
14
15WEBRTC_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
20if __name__ == '__main__':
Christoffer Jansson4e8a7732022-02-08 09:01:12 +010021 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)